⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sampledocking.cs

📁 Magic Library 1.7,有说明文档
💻 CS
📖 第 1 页 / 共 3 页
字号:
    protected void OnUpdatePlainTabBorder(object sender, EventArgs e)
    {
        MenuCommand updateCommand = sender as MenuCommand;
        updateCommand.Checked = _manager.PlainTabBorder;
    }

    protected void OnColorDefault(object sender, EventArgs e)
    {
        // Remember the new color scheme selected
        _colorIndex = 0;

        // Define main Form back color
        _filler.TextColor = SystemColors.MenuText;
        _filler.BackColor = SystemColors.Control;
        this.BackColor = SystemColors.Control;
        
        // Define the menu/status bars
        _topMenu.ResetColors();
        _topMenu.Font = SystemInformation.MenuFont;
        _filler.Font = SystemInformation.MenuFont;

        _manager.ResetColors();
        _manager.CaptionFont = SystemInformation.MenuFont;
        _manager.TabControlFont = SystemInformation.MenuFont;

        // Need to manually update the colors of created Panels/Forms
        foreach(Content c in _manager.Contents)
            DefineControlColors(c);
    }

    protected void OnUpdateDefault(object sender, EventArgs e)
    {
        MenuCommand updateCommand = sender as MenuCommand;
        updateCommand.Checked = (_colorIndex == 0);
    }

    protected void OnColorSlateBlue(object sender, EventArgs e)
    {
        // Remember the new color scheme selected
        _colorIndex = 1;

        // Define main Form back color
        this.BackColor = Color.DarkSlateBlue;

        // Define the menu/status bars
        _topMenu.TextColor = Color.White;
        _topMenu.BackColor = Color.DarkSlateBlue;
        _topMenu.SelectedTextColor = Color.White;
		_topMenu.SelectedBackColor = Color.SteelBlue;
        _topMenu.Font = new Font("Garamond", 10f);

        // Define the TabControl appearance
        _filler.TextColor = Color.White;
        _filler.BackColor = Color.DarkSlateBlue;
        _filler.Font = new Font("Garamond", 10f);

		if (_style == VisualStyle.IDE)
		{
			_topMenu.HighlightTextColor = Color.Black;
			_topMenu.HighlightBackColor = Color.SlateGray;
		}
		else
		{
			_topMenu.HighlightTextColor = Color.White;
			_topMenu.HighlightBackColor = Color.DarkSlateBlue;
		}

        // Define docking window colors
        _manager.BackColor = Color.DarkSlateBlue;
        _manager.InactiveTextColor = Color.White;
        _manager.ActiveColor = Color.SteelBlue;
        _manager.ActiveTextColor = Color.White;
        _manager.ResizeBarColor = Color.DarkSlateBlue;
        _manager.CaptionFont = new Font("Garamond", 10f);
        _manager.TabControlFont = new Font("Garamond", 10f);

        // Need to manually update the colors of created Panels/Forms
        foreach(Content c in _manager.Contents)
            DefineControlColors(c);
    }

    protected void OnUpdateSlateBlue(object sender, EventArgs e)
    {
        MenuCommand updateCommand = sender as MenuCommand;
        updateCommand.Checked = (_colorIndex == 1);
    }

    protected void OnColorFirebrick(object sender, EventArgs e)
    {
        // Remember the new color scheme selected
        _colorIndex = 2;

        this.BackColor = Color.Firebrick;

        // Define the menu/status bars
        _topMenu.TextColor = Color.White;
        _topMenu.BackColor = Color.Firebrick;
	    _topMenu.HighlightTextColor = Color.White;
	    _topMenu.HighlightBackColor = Color.Firebrick;
        _topMenu.SelectedBackColor = Color.Orange;
        _topMenu.Font = new Font("Sans Serif", 12f);

        // Define the TabControl appearance
        _filler.TextColor = Color.White;
        _filler.BackColor = Color.Firebrick;
        _filler.Font = new Font("Sans Serif", 12f);

		if (_style == VisualStyle.IDE)
	        _topMenu.SelectedTextColor = Color.Black;
		else
	        _topMenu.SelectedTextColor = Color.White;

        // Define docking window colors
        _manager.BackColor = Color.Firebrick;
        _manager.InactiveTextColor = Color.White;
        _manager.ActiveColor = Color.Orange;
        _manager.ActiveTextColor = Color.Black;
        _manager.ResizeBarColor = Color.Firebrick;
        _manager.CaptionFont = new Font("Sans Serif", 12f);
        _manager.TabControlFont = new Font("Sans Serif", 10f);
        
        // Need to manually update the colors of created Panels/Forms
        foreach(Content c in _manager.Contents)
            DefineControlColors(c);
    }

    protected void OnUpdateFirebrick(object sender, EventArgs e)
    {
        MenuCommand updateCommand = sender as MenuCommand;
        updateCommand.Checked = (_colorIndex == 2);
    }
    
    protected void OnColorGreen(object sender, EventArgs e)
    {
        // Remember the new color scheme selected
        _colorIndex = 3;

        // Define main Form back color
        this.BackColor = Color.PaleGreen;

        // Define the menu/status bars
        _topMenu.TextColor = Color.Black;
        _topMenu.BackColor = Color.PaleGreen;
        _topMenu.SelectedBackColor = Color.DarkSlateGray;
        _topMenu.Font = new Font("Arial", 9f);

        // Define the TabControl appearance
        _filler.TextColor = Color.Black;
        _filler.BackColor = Color.PaleGreen;
        _filler.Font = new Font("Arial", 9f);
        
        if (_style == VisualStyle.IDE)
		{
			_topMenu.HighlightTextColor = Color.Black;
		    _topMenu.HighlightBackColor = Color.PaleGreen;
	        _topMenu.SelectedTextColor = Color.White;
		}
		else
		{
		    _topMenu.HighlightTextColor = Color.White;
		    _topMenu.HighlightBackColor = Color.DarkSlateGray;
		    _topMenu.SelectedBackColor = Color.PaleGreen;
		}

        // Define docking window colors
        _manager.BackColor = Color.PaleGreen;
        _manager.InactiveTextColor = Color.Black;
        _manager.ActiveColor = Color.DarkSlateGray;
        _manager.ActiveTextColor = Color.White;
        _manager.ResizeBarColor = Color.DarkSeaGreen;
        _manager.CaptionFont = new Font("Arial", 9f);
        _manager.TabControlFont = new Font("Arial", 9f);

        // Need to manually update the colors of created Panels/Forms
        foreach(Content c in _manager.Contents)
            DefineControlColors(c);
    }

    protected void OnUpdateGreen(object sender, EventArgs e)
    {
        MenuCommand updateCommand = sender as MenuCommand;
        updateCommand.Checked = (_colorIndex == 3);
    }

    protected void OnTabsMultiBox(object sender, EventArgs e)
    {
		_tabAppearance = Crownwood.Magic.Controls.TabControl.VisualAppearance.MultiBox;
		UpdateAllTabControls();
    }

    protected void OnUpdateTabsBox(object sender, EventArgs e)
    {
        MenuCommand updateCommand = sender as MenuCommand;
        updateCommand.Checked = (_tabAppearance == Crownwood.Magic.Controls.TabControl.VisualAppearance.MultiBox);
    }

    protected void OnTabsMultiForm(object sender, EventArgs e)
    {
		_tabAppearance = Crownwood.Magic.Controls.TabControl.VisualAppearance.MultiForm;
		UpdateAllTabControls();
    }

    protected void OnUpdateTabsForm(object sender, EventArgs e)
    {
        MenuCommand updateCommand = sender as MenuCommand;
        updateCommand.Checked = (_tabAppearance == Crownwood.Magic.Controls.TabControl.VisualAppearance.MultiForm);
    }

    protected void OnTabsMultiDocument(object sender, EventArgs e)
    {
		_tabAppearance = Crownwood.Magic.Controls.TabControl.VisualAppearance.MultiDocument;
		UpdateAllTabControls();
    }

    protected void OnUpdateTabsDocument(object sender, EventArgs e)
    {
        MenuCommand updateCommand = sender as MenuCommand;
        updateCommand.Checked = (_tabAppearance == Crownwood.Magic.Controls.TabControl.VisualAppearance.MultiDocument);
    }

    protected void OnTabsTop(object sender, EventArgs e)
    {
		_tabsBottom = false;
		UpdateAllTabControls();
    }

    protected void OnUpdateTabsTop(object sender, EventArgs e)
    {
        MenuCommand updateCommand = sender as MenuCommand;
        updateCommand.Checked = !_tabsBottom;
    }

    protected void OnTabsBottom(object sender, EventArgs e)
    {
		_tabsBottom = true;
		UpdateAllTabControls();
    }

	protected void UpdateAllTabControls()
	{
		foreach(Content c in _manager.Contents)
		{
			if (c.ParentWindowContent != null)
			{
				WindowContentTabbed wct = c.ParentWindowContent as WindowContentTabbed;

				if (wct != null)
				{
					wct.TabControl.Appearance = _tabAppearance;
					wct.TabControl.PositionTop = !_tabsBottom;
				}
			}
		}
	}

    protected void OnUpdateTabsBottom(object sender, EventArgs e)
    {
        MenuCommand updateCommand = sender as MenuCommand;
        updateCommand.Checked = _tabsBottom;
    }

    protected void OnRTBDisposed(object sender, EventArgs e)
    {   
        Console.WriteLine("OnRTBDisposed");
    }
    
    protected void OnSaveConfig(XmlTextWriter xmlOut)
    {
        // Add an extra node into the config to store some useless information
        xmlOut.WriteStartElement("MyCustomElement");
        xmlOut.WriteAttributeString("UselessData1", "Hello");
        xmlOut.WriteAttributeString("UselessData2", "World!");
        xmlOut.WriteEndElement();
    }

    protected void OnLoadConfig(XmlTextReader xmlIn)
    {
        // We are expecting our custom element to be the current one
        if (xmlIn.Name == "MyCustomElement")
        {
            // Read in both the expected attributes
            string attr1 = xmlIn.GetAttribute(0);
            string attr2 = xmlIn.GetAttribute(1);
            
            // Must move past our element
            xmlIn.Read();
        }
    }

    private void InitializeComponent()
    {
        this.BackColor = Color.SlateGray;
        this.ClientSize = new System.Drawing.Size(500, 500);
        this.Text = "SampleDocking";
		this.MinimumSize = new Size(250,250);
    }
}

public class DummyForm : Form
{
    private Button _dummy1 = new Button();
    private Button _dummy2 = new Button();
    private GroupBox _dummyBox = new GroupBox();
    private RadioButton _dummy3 = new RadioButton();
    private RadioButton _dummy4 = new RadioButton();

    public DummyForm()
    {
        _dummy1.Text = "Button 1";
        _dummy1.Size = new Size(90,25);
        _dummy1.Location = new Point(10,10);

        _dummy2.Text = "Button 2";
        _dummy2.Size = new Size(90,25);
        _dummy2.Location = new Point(110,10);

        _dummyBox.Text = "Form GroupBox";
        _dummyBox.Size = new Size(125, 67);
        _dummyBox.Location = new Point(10, 45);

        _dummy3.Text = "RadioButton 3";
        _dummy3.Size = new Size(110,22);
        _dummy3.Location = new Point(10, 20);

        _dummy4.Text = "RadioButton 4";
        _dummy4.Size = new Size(110,22);
        _dummy4.Location = new Point(10, 42);
        _dummy4.Checked = true;

        _dummyBox.Controls.AddRange(new Control[]{_dummy3, _dummy4});

        Controls.AddRange(new Control[]{_dummy1, _dummy2, _dummyBox});

        this.Disposed += new EventHandler(OnFormDisposed);

        // Define then control to be selected when activated for first time
        this.ActiveControl = _dummy4;
    }

    protected void OnFormDisposed(object sender, EventArgs e)
    {   
        Console.WriteLine("OnFormDisposed");
    }
}

public class DummyPanel : Panel
{
    private GroupBox _dummyBox = new GroupBox();
    private RadioButton _dummy3 = new RadioButton();
    private RadioButton _dummy4 = new RadioButton();

    public DummyPanel()
    {
        _dummyBox.Text = "Panel GroupBox";
        _dummyBox.Size = new Size(125, 67);
        _dummyBox.Location = new Point(10, 10);

        _dummy3.Text = "RadioButton 3";
        _dummy3.Size = new Size(110,22);
        _dummy3.Location = new Point(10, 20);

        _dummy4.Text = "RadioButton 4";
        _dummy4.Size = new Size(110,22);
        _dummy4.Location = new Point(10, 42);
        _dummy4.Checked = true;

        _dummyBox.Controls.AddRange(new Control[]{_dummy3, _dummy4});

        this.Disposed += new EventHandler(OnPanelDisposed);

        Controls.AddRange(new Control[]{_dummyBox});
    }
    
    protected void OnPanelDisposed(object sender, EventArgs e)
    {   
        Console.WriteLine("OnPanelDisposed");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -