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

📄 sampleform.cs

📁 Magic Library 1.7,有说明文档
💻 CS
📖 第 1 页 / 共 3 页
字号:
            this.tabPage2.ImageIndex = 1;
            this.tabPage2.Name = "tabPage2";
            this.tabPage2.Selected = false;
            this.tabPage2.Size = new System.Drawing.Size(384, 301);
            this.tabPage2.TabIndex = 1;
            this.tabPage2.Title = "Group2";
            // 
            // tabbedGroups2
            // 
            this.tabbedGroups2.ActiveLeaf = null;
            this.tabbedGroups2.AllowDrop = true;
            this.tabbedGroups2.AtLeastOneLeaf = true;
            this.tabbedGroups2.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tabbedGroups2.ImageList = this.groupTabs;
            this.tabbedGroups2.Name = "tabbedGroups2";
            this.tabbedGroups2.ProminentLeaf = null;
            this.tabbedGroups2.ResizeBarColor = System.Drawing.SystemColors.Control;
            this.tabbedGroups2.Size = new System.Drawing.Size(384, 301);
            this.tabbedGroups2.TabIndex = 0;
            this.tabbedGroups2.TabControlCreated += new Crownwood.Magic.Controls.TabbedGroups.TabControlCreatedHandler(this.TabControlCreated);
            this.tabbedGroups2.PageSaving += new Crownwood.Magic.Controls.TabbedGroups.PageSavingHandler(this.PageSaving);
            this.tabbedGroups2.ExternalDrop += new Crownwood.Magic.Controls.TabbedGroups.ExternalDropHandler(this.ExternalDrop);
            this.tabbedGroups2.PageLoading += new Crownwood.Magic.Controls.TabbedGroups.PageLoadingHandler(this.PageLoading);
            this.tabbedGroups2.GlobalLoading += new Crownwood.Magic.Controls.TabbedGroups.GlobalLoadingHandler(this.GlobalLoading);
            this.tabbedGroups2.GlobalSaving += new Crownwood.Magic.Controls.TabbedGroups.GlobalSavingHandler(this.GlobalSaving);
            // 
            // groupTabs
            // 
            this.groupTabs.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
            this.groupTabs.ImageSize = new System.Drawing.Size(16, 16);
            this.groupTabs.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("groupTabs.ImageStream")));
            this.groupTabs.TransparentColor = System.Drawing.Color.Transparent;
            // 
            // tabPage1
            // 
            this.tabPage1.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                                   this.tabbedGroups1});
            this.tabPage1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tabPage1.ImageIndex = 0;
            this.tabPage1.Name = "tabPage1";
            this.tabPage1.Size = new System.Drawing.Size(512, 405);
            this.tabPage1.TabIndex = 0;
            this.tabPage1.Title = "Group1";
            // 
            // tabbedGroups1
            // 
            this.tabbedGroups1.ActiveLeaf = null;
            this.tabbedGroups1.AllowDrop = true;
            this.tabbedGroups1.AtLeastOneLeaf = true;
            this.tabbedGroups1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tabbedGroups1.ImageList = this.groupTabs;
            this.tabbedGroups1.Name = "tabbedGroups1";
            this.tabbedGroups1.ProminentLeaf = null;
            this.tabbedGroups1.ResizeBarColor = System.Drawing.SystemColors.Control;
            this.tabbedGroups1.Size = new System.Drawing.Size(512, 405);
            this.tabbedGroups1.TabIndex = 0;
            this.tabbedGroups1.TabControlCreated += new Crownwood.Magic.Controls.TabbedGroups.TabControlCreatedHandler(this.TabControlCreated);
            this.tabbedGroups1.PageSaving += new Crownwood.Magic.Controls.TabbedGroups.PageSavingHandler(this.PageSaving);
            this.tabbedGroups1.ExternalDrop += new Crownwood.Magic.Controls.TabbedGroups.ExternalDropHandler(this.ExternalDrop);
            this.tabbedGroups1.PageLoading += new Crownwood.Magic.Controls.TabbedGroups.PageLoadingHandler(this.PageLoading);
            this.tabbedGroups1.GlobalLoading += new Crownwood.Magic.Controls.TabbedGroups.GlobalLoadingHandler(this.GlobalLoading);
            this.tabbedGroups1.GlobalSaving += new Crownwood.Magic.Controls.TabbedGroups.GlobalSavingHandler(this.GlobalSaving);
            // 
            // tabPage3
            // 
            this.tabPage3.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                                   this.tabbedGroups3});
            this.tabPage3.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tabPage3.ImageIndex = 2;
            this.tabPage3.Name = "tabPage3";
            this.tabPage3.Selected = false;
            this.tabPage3.Size = new System.Drawing.Size(384, 301);
            this.tabPage3.TabIndex = 2;
            this.tabPage3.Title = "Group3";
            // 
            // tabbedGroups3
            // 
            this.tabbedGroups3.ActiveLeaf = null;
            this.tabbedGroups3.AllowDrop = true;
            this.tabbedGroups3.AtLeastOneLeaf = true;
            this.tabbedGroups3.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tabbedGroups3.ImageList = this.groupTabs;
            this.tabbedGroups3.Name = "tabbedGroups3";
            this.tabbedGroups3.ProminentLeaf = null;
            this.tabbedGroups3.ResizeBarColor = System.Drawing.SystemColors.Control;
            this.tabbedGroups3.Size = new System.Drawing.Size(384, 301);
            this.tabbedGroups3.TabIndex = 0;
            this.tabbedGroups3.PageSaving += new Crownwood.Magic.Controls.TabbedGroups.PageSavingHandler(this.PageSaving);
            this.tabbedGroups3.ExternalDrop += new Crownwood.Magic.Controls.TabbedGroups.ExternalDropHandler(this.ExternalDrop);
            this.tabbedGroups3.PageLoading += new Crownwood.Magic.Controls.TabbedGroups.PageLoadingHandler(this.PageLoading);
            this.tabbedGroups3.GlobalLoading += new Crownwood.Magic.Controls.TabbedGroups.GlobalLoadingHandler(this.GlobalLoading);
            this.tabbedGroups3.GlobalSaving += new Crownwood.Magic.Controls.TabbedGroups.GlobalSavingHandler(this.GlobalSaving);
            // 
            // SampleForm
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(512, 477);
            this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                          this.tabControl1,
                                                                          this.menuControl1,
                                                                          this.statusBar1});
            this.Name = "SampleForm";
            this.Text = "Form1";
            this.tabPage2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.tabbedGroups2)).EndInit();
            this.tabPage1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.tabbedGroups1)).EndInit();
            this.tabPage3.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.tabbedGroups3)).EndInit();
            this.ResumeLayout(false);

        }
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new SampleForm());
		}

        private void PageSaving(Crownwood.Magic.Controls.TabbedGroups tg, Crownwood.Magic.Controls.TGPageSavingEventArgs e)
        {
            // Persist the text box contents
            e.XmlOut.WriteCData((e.TabPage.Control as RichTextBox).Text);
        }

        private void PageLoading(Crownwood.Magic.Controls.TabbedGroups tg, Crownwood.Magic.Controls.TGPageLoadingEventArgs e)
        {
            // Read back the text box contents
            (e.TabPage.Control as RichTextBox).Text = e.XmlIn.ReadString();        
        }

        private void GlobalSaving(Crownwood.Magic.Controls.TabbedGroups tg, System.Xml.XmlTextWriter xmlOut)
        {
            // Persist the global text box contents
            xmlOut.WriteCData(_global.Text);
        }

        private void GlobalLoading(Crownwood.Magic.Controls.TabbedGroups tg, System.Xml.XmlTextReader xmlIn)
        {
            // Read back the global text box contents
            _global.Text = xmlIn.ReadString();        
        }

        private void TabControlCreated(Crownwood.Magic.Controls.TabbedGroups tg, Crownwood.Magic.Controls.TabControl tc)
        {
            // This is where you change the tab control defaults when a new tab control is created
        }
        
        private void ExternalDrop(Crownwood.Magic.Controls.TabbedGroups tg, 
                                  Crownwood.Magic.Controls.TabGroupLeaf tgl,
                                  Crownwood.Magic.Controls.TabControl tc,
                                  Crownwood.Magic.Controls.TabbedGroups.DragProvider dp)
        {
            // Create a new tab page
            Crownwood.Magic.Controls.TabPage tp = NewTabPage();
            
            // Define the text in this control
            (tp.Control as RichTextBox).Text = "Dragged from node '" + (string)dp.Tag + "'";
            
            // We want the new page to become selected
            tp.Selected = true;
            
            // Add new page into the destination tab control
            tgl.TabPages.Add(tp);
        }
	}

    public class DragTree : TreeView
    {
        protected bool _leftDown;
        protected Point _leftPoint;
        protected TreeNode _leftNode;
    
        public DragTree()
            : base()
        {
            _leftDown = false;
        }
        
        protected override void OnMouseDown(MouseEventArgs e)
        {
            // Only interested in the left button
            if (e.Button == MouseButtons.Left)
            {
                TreeNode n = this.GetNodeAt(new Point(e.X, e.Y));
                
                // Are we selecting a valid node?
                if (n != null)
                {
                    // Might be start of a drag, so remember details
                    _leftNode = n;
                    _leftDown = true;
                    _leftPoint = new Point(e.X, e.Y);
                    
                    // Must capture the mouse
                    this.Capture = true;
                    this.Focus();
                }
            }

            base.OnMouseDown(e);
        }
            
        protected override void OnMouseMove(MouseEventArgs e)
        {
            // Are we monitoring for a drag operation?
            if (_leftDown)
            {
                Rectangle dragRect = new Rectangle(_leftPoint, new Size(0,0));
                
                // Create rectangle for drag start
                dragRect.Inflate(SystemInformation.DoubleClickSize);
                
                // Has mouse been dragged outside of rectangle?
                if (!dragRect.Contains(new Point(e.X, e.Y)))
                {
                    // Create an object the TabbedGroups control understands
                    TabbedGroups.DragProvider dp = new TabbedGroups.DragProvider();
                    
                    // Box the node name as the parameter for passing across
                    dp.Tag = (object)_leftNode.Text;
                
                    // Must start a drag operation
                    DoDragDrop(dp, DragDropEffects.Copy);
                    
                    // Cancel any further drag events until mouse is pressed again
                    _leftDown = false;
                    _leftNode = null;
                }
            }
        
            base.OnMouseMove(e);
        }
        
        protected override void WndProc(ref Message m)
        {
            switch(m.Msg)
            {
                case (int)Crownwood.Magic.Win32.Msgs.WM_LBUTTONUP:
                    // Remembering drag info?
                    if (_leftDown)
                    {
                        // Cancel any drag attempt
                        _leftDown = false;
                        _leftNode = null;
                    }   
                    break;
            }
        
            base.WndProc(ref m);
        }
    }
}

⌨️ 快捷键说明

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