コード例 #1
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     AdvancedDataGridView.TreeGridNode treeGridNode1          = new AdvancedDataGridView.TreeGridNode();
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ArpForm));
     this.toolStrip1          = new System.Windows.Forms.ToolStrip();
     this.toolStripButton1    = new System.Windows.Forms.ToolStripButton();
     this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
     this.toolStripButton2    = new System.Windows.Forms.ToolStripButton();
     this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
     this.toolStripButton3    = new System.Windows.Forms.ToolStripButton();
     this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
     this.treeGridView1       = new AdvancedDataGridView.TreeGridView();
     this.ColPCName           = new AdvancedDataGridView.TreeGridColumn();
     this.ColPCIP             = new System.Windows.Forms.DataGridViewTextBoxColumn();
     this.ColPCMac            = new System.Windows.Forms.DataGridViewTextBoxColumn();
     this.ColDownload         = new System.Windows.Forms.DataGridViewTextBoxColumn();
     this.ColUpload           = new System.Windows.Forms.DataGridViewTextBoxColumn();
     this.ColDownCap          = new DataGridViewNumericUpDownElements.DataGridViewNumericUpDownColumn();
     this.ColUploadCap        = new DataGridViewNumericUpDownElements.DataGridViewNumericUpDownColumn();
     this.ColBlock            = new System.Windows.Forms.DataGridViewCheckBoxColumn();
     this.ColSpoof            = new System.Windows.Forms.DataGridViewCheckBoxColumn();
     this.ContextMenuViews    = new System.Windows.Forms.ContextMenuStrip(this.components);
     this.ViewMenuIP          = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuMAC         = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuDownload    = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuUpload      = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuDownloadCap = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuUploadCap   = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuBlock       = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuSpoof       = new System.Windows.Forms.ToolStripMenuItem();
     this.imageList1          = new System.Windows.Forms.ImageList(this.components);
     this.timer1                = new System.Windows.Forms.Timer(this.components);
     this.timer2                = new System.Windows.Forms.Timer(this.components);
     this.timerSpoof            = new System.Windows.Forms.Timer(this.components);
     this.SelfishNetTrayIcon    = new System.Windows.Forms.NotifyIcon(this.components);
     this.SelfishNetTray        = new System.Windows.Forms.ContextMenuStrip(this.components);
     this.showToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     this.timerDiscovery        = new System.Windows.Forms.Timer(this.components);
     this.toolStrip1.SuspendLayout();
     ((System.ComponentModel.ISupportInitialize)(this.treeGridView1)).BeginInit();
     this.ContextMenuViews.SuspendLayout();
     this.SelfishNetTray.SuspendLayout();
     this.SuspendLayout();
     //
     // toolStrip1
     //
     this.toolStrip1.ImageScalingSize = new System.Drawing.Size(32, 32);
     this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
         this.toolStripButton1,
         this.toolStripSeparator1,
         this.toolStripButton2,
         this.toolStripSeparator2,
         this.toolStripButton3,
         this.toolStripSeparator3
     });
     this.toolStrip1.Location = new System.Drawing.Point(0, 0);
     this.toolStrip1.Name     = "toolStrip1";
     this.toolStrip1.Size     = new System.Drawing.Size(685, 39);
     this.toolStrip1.TabIndex = 0;
     this.toolStrip1.Text     = "toolStrip1";
     //
     // toolStripButton1
     //
     this.toolStripButton1.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     this.toolStripButton1.Image                 = global::SelfishNetv0.Properties.Resources.Network_Map;
     this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
     this.toolStripButton1.Name   = "toolStripButton1";
     this.toolStripButton1.Size   = new System.Drawing.Size(36, 36);
     this.toolStripButton1.Text   = "Network Discovery";
     this.toolStripButton1.Click += new System.EventHandler(this.ToolStripButton1_Click);
     //
     // toolStripSeparator1
     //
     this.toolStripSeparator1.Name = "toolStripSeparator1";
     this.toolStripSeparator1.Size = new System.Drawing.Size(6, 39);
     //
     // toolStripButton2
     //
     this.toolStripButton2.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     this.toolStripButton2.Image                 = global::SelfishNetv0.Properties.Resources.Network_ConnectTo;
     this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
     this.toolStripButton2.Name   = "toolStripButton2";
     this.toolStripButton2.Size   = new System.Drawing.Size(36, 36);
     this.toolStripButton2.Text   = "Start redirecting-spoofing";
     this.toolStripButton2.Click += new System.EventHandler(this.ToolStripButton2_Click);
     //
     // toolStripSeparator2
     //
     this.toolStripSeparator2.Name = "toolStripSeparator2";
     this.toolStripSeparator2.Size = new System.Drawing.Size(6, 39);
     //
     // toolStripButton3
     //
     this.toolStripButton3.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     this.toolStripButton3.Image                 = global::SelfishNetv0.Properties.Resources.DisconnectedDrive;
     this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta;
     this.toolStripButton3.Name   = "toolStripButton3";
     this.toolStripButton3.Size   = new System.Drawing.Size(36, 36);
     this.toolStripButton3.Text   = "stop redirecting- spoofing";
     this.toolStripButton3.Click += new System.EventHandler(this.ToolStripButton3_Click);
     //
     // toolStripSeparator3
     //
     this.toolStripSeparator3.Name = "toolStripSeparator3";
     this.toolStripSeparator3.Size = new System.Drawing.Size(6, 39);
     //
     // treeGridView1
     //
     this.treeGridView1.AllowUserToAddRows       = false;
     this.treeGridView1.AllowUserToDeleteRows    = false;
     this.treeGridView1.AutoSizeColumnsMode      = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
     this.treeGridView1.AutoSizeRowsMode         = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
     this.treeGridView1.BorderStyle              = System.Windows.Forms.BorderStyle.Fixed3D;
     this.treeGridView1.CellBorderStyle          = System.Windows.Forms.DataGridViewCellBorderStyle.RaisedHorizontal;
     this.treeGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
     this.treeGridView1.ColumnHeadersHeight      = 35;
     this.treeGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
         this.ColPCName,
         this.ColPCIP,
         this.ColPCMac,
         this.ColDownload,
         this.ColUpload,
         this.ColDownCap,
         this.ColUploadCap,
         this.ColBlock,
         this.ColSpoof
     });
     this.treeGridView1.ContextMenuStrip = this.ContextMenuViews;
     this.treeGridView1.Dock             = System.Windows.Forms.DockStyle.Fill;
     this.treeGridView1.EditMode         = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
     this.treeGridView1.ImageList        = this.imageList1;
     this.treeGridView1.Location         = new System.Drawing.Point(0, 39);
     this.treeGridView1.Name             = "treeGridView1";
     treeGridNode1.Height     = 20;
     treeGridNode1.ImageIndex = 0;
     this.treeGridView1.Nodes.Add(treeGridNode1);
     this.treeGridView1.RowHeadersVisible = false;
     this.treeGridView1.ShowCellErrors    = false;
     this.treeGridView1.ShowCellToolTips  = false;
     this.treeGridView1.ShowEditingIcon   = false;
     this.treeGridView1.ShowRowErrors     = false;
     this.treeGridView1.Size                          = new System.Drawing.Size(685, 525);
     this.treeGridView1.TabIndex                      = 1;
     this.treeGridView1.CellValueChanged             += new System.Windows.Forms.DataGridViewCellEventHandler(this.TreeGridView1_CellValueChanged);
     this.treeGridView1.CurrentCellDirtyStateChanged += new System.EventHandler(this.TreeGridView1_CurrentCellDirtyStateChanged);
     //
     // ColPCName
     //
     this.ColPCName.AutoSizeMode     = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColPCName.DefaultNodeImage = null;
     this.ColPCName.FillWeight       = 200F;
     this.ColPCName.HeaderText       = "PC Name";
     this.ColPCName.MinimumWidth     = 40;
     this.ColPCName.Name             = "ColPCName";
     this.ColPCName.ReadOnly         = true;
     this.ColPCName.SortMode         = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
     //
     // ColPCIP
     //
     this.ColPCIP.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColPCIP.HeaderText   = "IP";
     this.ColPCIP.MinimumWidth = 35;
     this.ColPCIP.Name         = "ColPCIP";
     this.ColPCIP.ReadOnly     = true;
     this.ColPCIP.SortMode     = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
     //
     // ColPCMac
     //
     this.ColPCMac.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColPCMac.HeaderText   = "Mac";
     this.ColPCMac.MinimumWidth = 35;
     this.ColPCMac.Name         = "ColPCMac";
     this.ColPCMac.ReadOnly     = true;
     this.ColPCMac.SortMode     = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
     //
     // ColDownload
     //
     this.ColDownload.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColDownload.HeaderText   = "Download KB/s";
     this.ColDownload.MinimumWidth = 20;
     this.ColDownload.Name         = "ColDownload";
     this.ColDownload.ReadOnly     = true;
     this.ColDownload.SortMode     = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
     //
     // ColUpload
     //
     this.ColUpload.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColUpload.HeaderText   = "Upload KB/s";
     this.ColUpload.MinimumWidth = 20;
     this.ColUpload.Name         = "ColUpload";
     this.ColUpload.ReadOnly     = true;
     this.ColUpload.SortMode     = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
     //
     // ColDownCap
     //
     this.ColDownCap.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColDownCap.HeaderText   = "DownCap";
     this.ColDownCap.MinimumWidth = 35;
     this.ColDownCap.Name         = "ColDownCap";
     this.ColDownCap.Resizable    = System.Windows.Forms.DataGridViewTriState.True;
     //
     // ColUploadCap
     //
     this.ColUploadCap.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColUploadCap.HeaderText   = "UploadCap";
     this.ColUploadCap.MinimumWidth = 35;
     this.ColUploadCap.Name         = "ColUploadCap";
     this.ColUploadCap.Resizable    = System.Windows.Forms.DataGridViewTriState.True;
     //
     // ColBlock
     //
     this.ColBlock.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColBlock.HeaderText   = "Block";
     this.ColBlock.MinimumWidth = 35;
     this.ColBlock.Name         = "ColBlock";
     //
     // ColSpoof
     //
     this.ColSpoof.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColSpoof.HeaderText   = "Spoof";
     this.ColSpoof.MinimumWidth = 35;
     this.ColSpoof.Name         = "ColSpoof";
     this.ColSpoof.Visible      = false;
     //
     // ContextMenuViews
     //
     this.ContextMenuViews.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
         this.ViewMenuIP,
         this.ViewMenuMAC,
         this.ViewMenuDownload,
         this.ViewMenuUpload,
         this.ViewMenuDownloadCap,
         this.ViewMenuUploadCap,
         this.ViewMenuBlock,
         this.ViewMenuSpoof
     });
     this.ContextMenuViews.Name = "ContextMenuViews";
     this.ContextMenuViews.Size = new System.Drawing.Size(178, 180);
     //
     // ViewMenuIP
     //
     this.ViewMenuIP.Checked            = true;
     this.ViewMenuIP.CheckOnClick       = true;
     this.ViewMenuIP.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuIP.Name               = "ViewMenuIP";
     this.ViewMenuIP.Size               = new System.Drawing.Size(177, 22);
     this.ViewMenuIP.Text               = "IP";
     this.ViewMenuIP.CheckStateChanged += new System.EventHandler(this.ViewMenuIP_CheckStateChanged);
     //
     // ViewMenuMAC
     //
     this.ViewMenuMAC.Checked            = true;
     this.ViewMenuMAC.CheckOnClick       = true;
     this.ViewMenuMAC.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuMAC.Name               = "ViewMenuMAC";
     this.ViewMenuMAC.Size               = new System.Drawing.Size(177, 22);
     this.ViewMenuMAC.Text               = "Mac Address";
     this.ViewMenuMAC.CheckStateChanged += new System.EventHandler(this.ViewMenuMAC_CheckStateChanged);
     //
     // ViewMenuDownload
     //
     this.ViewMenuDownload.Checked            = true;
     this.ViewMenuDownload.CheckOnClick       = true;
     this.ViewMenuDownload.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuDownload.Name               = "ViewMenuDownload";
     this.ViewMenuDownload.Size               = new System.Drawing.Size(177, 22);
     this.ViewMenuDownload.Text               = "Download";
     this.ViewMenuDownload.CheckStateChanged += new System.EventHandler(this.ViewMenuDownload_CheckStateChanged);
     //
     // ViewMenuUpload
     //
     this.ViewMenuUpload.Checked            = true;
     this.ViewMenuUpload.CheckOnClick       = true;
     this.ViewMenuUpload.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuUpload.Name               = "ViewMenuUpload";
     this.ViewMenuUpload.Size               = new System.Drawing.Size(177, 22);
     this.ViewMenuUpload.Text               = "Upload";
     this.ViewMenuUpload.CheckStateChanged += new System.EventHandler(this.ViewMenuUpload_CheckStateChanged);
     //
     // ViewMenuDownloadCap
     //
     this.ViewMenuDownloadCap.Checked            = true;
     this.ViewMenuDownloadCap.CheckOnClick       = true;
     this.ViewMenuDownloadCap.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuDownloadCap.Name               = "ViewMenuDownloadCap";
     this.ViewMenuDownloadCap.Size               = new System.Drawing.Size(177, 22);
     this.ViewMenuDownloadCap.Text               = "Download Capacity";
     this.ViewMenuDownloadCap.CheckStateChanged += new System.EventHandler(this.ViewMenuDownloadCap_CheckStateChanged);
     //
     // ViewMenuUploadCap
     //
     this.ViewMenuUploadCap.Checked            = true;
     this.ViewMenuUploadCap.CheckOnClick       = true;
     this.ViewMenuUploadCap.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuUploadCap.Name               = "ViewMenuUploadCap";
     this.ViewMenuUploadCap.Size               = new System.Drawing.Size(177, 22);
     this.ViewMenuUploadCap.Text               = "Upload Capacity";
     this.ViewMenuUploadCap.CheckStateChanged += new System.EventHandler(this.ViewMenuUploadCap_CheckStateChanged);
     //
     // ViewMenuBlock
     //
     this.ViewMenuBlock.Checked            = true;
     this.ViewMenuBlock.CheckOnClick       = true;
     this.ViewMenuBlock.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuBlock.Name               = "ViewMenuBlock";
     this.ViewMenuBlock.Size               = new System.Drawing.Size(177, 22);
     this.ViewMenuBlock.Text               = "Block";
     this.ViewMenuBlock.CheckStateChanged += new System.EventHandler(this.ViewMenuBlock_CheckStateChanged);
     //
     // ViewMenuSpoof
     //
     this.ViewMenuSpoof.CheckOnClick       = true;
     this.ViewMenuSpoof.Name               = "ViewMenuSpoof";
     this.ViewMenuSpoof.Size               = new System.Drawing.Size(177, 22);
     this.ViewMenuSpoof.Text               = "Spoof";
     this.ViewMenuSpoof.CheckStateChanged += new System.EventHandler(this.ViewMenuSpoof_CheckStateChanged);
     //
     // imageList1
     //
     this.imageList1.ImageStream      = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
     this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
     this.imageList1.Images.SetKeyName(0, "toolStripButton1.Image.png");
     this.imageList1.Images.SetKeyName(1, "toolStripButton2.Image.png");
     //
     // timer1
     //
     this.timer1.Tick += new System.EventHandler(this.Timer1_Tick);
     //
     // timer2
     //
     this.timer2.Tick += new System.EventHandler(this.Timer2_Tick);
     //
     // timerSpoof
     //
     this.timerSpoof.Tick += new System.EventHandler(this.TimerSpoof_Tick);
     //
     // SelfishNetTrayIcon
     //
     this.SelfishNetTrayIcon.BalloonTipText    = "SelfishNet is minimized";
     this.SelfishNetTrayIcon.BalloonTipTitle   = "\"SelfishNet\"";
     this.SelfishNetTrayIcon.ContextMenuStrip  = this.SelfishNetTray;
     this.SelfishNetTrayIcon.Icon              = ((System.Drawing.Icon)(resources.GetObject("SelfishNetTrayIcon.Icon")));
     this.SelfishNetTrayIcon.Text              = "notifyIcon1";
     this.SelfishNetTrayIcon.Visible           = true;
     this.SelfishNetTrayIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SelfishNetTrayIcon_MouseDoubleClick);
     //
     // SelfishNetTray
     //
     this.SelfishNetTray.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
         this.showToolStripMenuItem,
         this.exitToolStripMenuItem
     });
     this.SelfishNetTray.Name = "SelfishNetTray";
     this.SelfishNetTray.Size = new System.Drawing.Size(104, 48);
     //
     // showToolStripMenuItem
     //
     this.showToolStripMenuItem.Image  = global::SelfishNetv0.Properties.Resources._167;
     this.showToolStripMenuItem.Name   = "showToolStripMenuItem";
     this.showToolStripMenuItem.Size   = new System.Drawing.Size(103, 22);
     this.showToolStripMenuItem.Text   = "Show";
     this.showToolStripMenuItem.Click += new System.EventHandler(this.ShowToolStripMenuItem_Click);
     //
     // exitToolStripMenuItem
     //
     this.exitToolStripMenuItem.Image  = global::SelfishNetv0.Properties.Resources._172;
     this.exitToolStripMenuItem.Name   = "exitToolStripMenuItem";
     this.exitToolStripMenuItem.Size   = new System.Drawing.Size(103, 22);
     this.exitToolStripMenuItem.Text   = "Exit";
     this.exitToolStripMenuItem.Click += new System.EventHandler(this.ExitToolStripMenuItem_Click);
     //
     // timerDiscovery
     //
     this.timerDiscovery.Interval = 50;
     //
     // ArpForm
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.ClientSize          = new System.Drawing.Size(685, 564);
     this.ControlBox          = false;
     this.Controls.Add(this.treeGridView1);
     this.Controls.Add(this.toolStrip1);
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
     this.Icon            = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.Name            = "ArpForm";
     this.Text            = "SelfishNet v3";
     this.Load           += new System.EventHandler(this.ArpForm_Load);
     this.Resize         += new System.EventHandler(this.ArpForm_Resize);
     this.toolStrip1.ResumeLayout(false);
     this.toolStrip1.PerformLayout();
     ((System.ComponentModel.ISupportInitialize)(this.treeGridView1)).EndInit();
     this.ContextMenuViews.ResumeLayout(false);
     this.SelfishNetTray.ResumeLayout(false);
     this.ResumeLayout(false);
     this.PerformLayout();
 }
コード例 #2
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 public void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     AdvancedDataGridView.TreeGridNode treeGridNode1          = new AdvancedDataGridView.TreeGridNode();
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
     this.toolStrip1          = new System.Windows.Forms.ToolStrip();
     this.toolStripButton1    = new System.Windows.Forms.ToolStripButton();
     this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
     this.toolStripButton2    = new System.Windows.Forms.ToolStripButton();
     this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
     this.toolStripButton3    = new System.Windows.Forms.ToolStripButton();
     this.toolStripButton4    = new System.Windows.Forms.ToolStripButton();
     this.treeGridView1       = new AdvancedDataGridView.TreeGridView();
     this.ColPCName           = new AdvancedDataGridView.TreeGridColumn();
     this.ColPCIP             = new System.Windows.Forms.DataGridViewTextBoxColumn();
     this.ColPCMac            = new System.Windows.Forms.DataGridViewTextBoxColumn();
     this.ColDownload         = new System.Windows.Forms.DataGridViewTextBoxColumn();
     this.ColUpload           = new System.Windows.Forms.DataGridViewTextBoxColumn();
     this.ColDownCap          = new DataGridViewNumericUpDownElements.DataGridViewNumericUpDownColumn();
     this.ColUploadCap        = new DataGridViewNumericUpDownElements.DataGridViewNumericUpDownColumn();
     this.ColBlock            = new System.Windows.Forms.DataGridViewCheckBoxColumn();
     this.ColSpoof            = new System.Windows.Forms.DataGridViewCheckBoxColumn();
     this.ContextMenuViews    = new System.Windows.Forms.ContextMenuStrip(this.components);
     this.ViewMenuIP          = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuMAC         = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuDownload    = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuUpload      = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuDownloadCap = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuUploadCap   = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuBlock       = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuSpoof       = new System.Windows.Forms.ToolStripMenuItem();
     this.imageList1          = new System.Windows.Forms.ImageList(this.components);
     this.timer1             = new System.Windows.Forms.Timer(this.components);
     this.timer2             = new System.Windows.Forms.Timer(this.components);
     this.timerSpoof         = new System.Windows.Forms.Timer(this.components);
     this.SelfishNetTrayIcon = new System.Windows.Forms.NotifyIcon(this.components);
     this.timerDiscovery     = new System.Windows.Forms.Timer(this.components);
     this.toolStrip1.SuspendLayout();
     ((System.ComponentModel.ISupportInitialize)(this.treeGridView1)).BeginInit();
     this.ContextMenuViews.SuspendLayout();
     this.SuspendLayout();
     //
     // toolStrip1
     //
     this.toolStrip1.ImageScalingSize = new System.Drawing.Size(32, 32);
     this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
         this.toolStripButton1,
         this.toolStripSeparator1,
         this.toolStripButton2,
         this.toolStripSeparator2,
         this.toolStripButton3,
         this.toolStripButton4
     });
     this.toolStrip1.Location = new System.Drawing.Point(0, 0);
     this.toolStrip1.Name     = "toolStrip1";
     this.toolStrip1.Size     = new System.Drawing.Size(703, 39);
     this.toolStrip1.TabIndex = 0;
     this.toolStrip1.Text     = "toolStrip1";
     //
     // toolStripButton1
     //
     this.toolStripButton1.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     this.toolStripButton1.Image                 = global::Properties.Resources.search;
     this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
     this.toolStripButton1.Name   = "toolStripButton1";
     this.toolStripButton1.Size   = new System.Drawing.Size(36, 36);
     this.toolStripButton1.Text   = "Network Discovery";
     this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click);
     //
     // toolStripSeparator1
     //
     this.toolStripSeparator1.Name = "toolStripSeparator1";
     this.toolStripSeparator1.Size = new System.Drawing.Size(6, 39);
     //
     // toolStripButton2
     //
     this.toolStripButton2.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     this.toolStripButton2.Image                 = global::Properties.Resources.play;
     this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
     this.toolStripButton2.Name   = "toolStripButton2";
     this.toolStripButton2.Size   = new System.Drawing.Size(36, 36);
     this.toolStripButton2.Text   = "Start redirecting-spoofing";
     this.toolStripButton2.Click += new System.EventHandler(this.toolStripButton2_Click);
     //
     // toolStripSeparator2
     //
     this.toolStripSeparator2.Name = "toolStripSeparator2";
     this.toolStripSeparator2.Size = new System.Drawing.Size(6, 39);
     //
     // toolStripButton3
     //
     this.toolStripButton3.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     this.toolStripButton3.Image                 = global::Properties.Resources.pause;
     this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta;
     this.toolStripButton3.Name   = "toolStripButton3";
     this.toolStripButton3.Size   = new System.Drawing.Size(36, 36);
     this.toolStripButton3.Text   = "stop redirecting- spoofing";
     this.toolStripButton3.Click += new System.EventHandler(this.toolStripButton3_Click);
     //
     // toolStripButton4
     //
     this.toolStripButton4.Alignment             = System.Windows.Forms.ToolStripItemAlignment.Right;
     this.toolStripButton4.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     this.toolStripButton4.ImageTransparentColor = System.Drawing.Color.Magenta;
     this.toolStripButton4.Name   = "toolStripButton4";
     this.toolStripButton4.Size   = new System.Drawing.Size(23, 36);
     this.toolStripButton4.Text   = "Help";
     this.toolStripButton4.Click += new System.EventHandler(this.toolStripButton4_Click);
     //
     // treeGridView1
     //
     this.treeGridView1.AllowUserToAddRows       = false;
     this.treeGridView1.AllowUserToDeleteRows    = false;
     this.treeGridView1.AllowUserToOrderColumns  = true;
     this.treeGridView1.AllowUserToResizeRows    = false;
     this.treeGridView1.AutoSizeColumnsMode      = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
     this.treeGridView1.AutoSizeRowsMode         = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
     this.treeGridView1.BorderStyle              = System.Windows.Forms.BorderStyle.Fixed3D;
     this.treeGridView1.CellBorderStyle          = System.Windows.Forms.DataGridViewCellBorderStyle.RaisedHorizontal;
     this.treeGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
     this.treeGridView1.ColumnHeadersHeight      = 35;
     this.treeGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
         this.ColPCName,
         this.ColPCIP,
         this.ColPCMac,
         this.ColDownload,
         this.ColUpload,
         this.ColDownCap,
         this.ColUploadCap,
         this.ColBlock,
         this.ColSpoof
     });
     this.treeGridView1.ContextMenuStrip = this.ContextMenuViews;
     this.treeGridView1.Dock             = System.Windows.Forms.DockStyle.Fill;
     this.treeGridView1.EditMode         = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
     this.treeGridView1.ImageList        = this.imageList1;
     this.treeGridView1.Location         = new System.Drawing.Point(0, 39);
     this.treeGridView1.Name             = "treeGridView1";
     treeGridNode1.Height     = 20;
     treeGridNode1.ImageIndex = 1;
     this.treeGridView1.Nodes.Add(treeGridNode1);
     this.treeGridView1.RowHeadersVisible = false;
     this.treeGridView1.ShowCellErrors    = false;
     this.treeGridView1.ShowCellToolTips  = false;
     this.treeGridView1.ShowEditingIcon   = false;
     this.treeGridView1.ShowRowErrors     = false;
     this.treeGridView1.Size                          = new System.Drawing.Size(703, 363);
     this.treeGridView1.TabIndex                      = 1;
     this.treeGridView1.CellPainting                 += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.treeGridView1_CellPainting);
     this.treeGridView1.CellValueChanged             += new System.Windows.Forms.DataGridViewCellEventHandler(this.treeGridView1_CellValueChanged);
     this.treeGridView1.CurrentCellDirtyStateChanged += new System.EventHandler(this.treeGridView1_CurrentCellDirtyStateChanged);
     //
     // ColPCName
     //
     this.ColPCName.AutoSizeMode     = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColPCName.DefaultNodeImage = null;
     this.ColPCName.FillWeight       = 180.4366F;
     this.ColPCName.HeaderText       = "PC Name";
     this.ColPCName.MinimumWidth     = 40;
     this.ColPCName.Name             = "ColPCName";
     this.ColPCName.ReadOnly         = true;
     this.ColPCName.SortMode         = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
     //
     // ColPCIP
     //
     this.ColPCIP.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColPCIP.FillWeight   = 119.7174F;
     this.ColPCIP.HeaderText   = "IP";
     this.ColPCIP.MinimumWidth = 35;
     this.ColPCIP.Name         = "ColPCIP";
     this.ColPCIP.ReadOnly     = true;
     this.ColPCIP.SortMode     = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
     //
     // ColPCMac
     //
     this.ColPCMac.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColPCMac.FillWeight   = 106.599F;
     this.ColPCMac.HeaderText   = "MAC";
     this.ColPCMac.MinimumWidth = 35;
     this.ColPCMac.Name         = "ColPCMac";
     this.ColPCMac.ReadOnly     = true;
     this.ColPCMac.SortMode     = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
     //
     // ColDownload
     //
     this.ColDownload.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColDownload.FillWeight   = 74.57431F;
     this.ColDownload.HeaderText   = "Download KB/s";
     this.ColDownload.MinimumWidth = 20;
     this.ColDownload.Name         = "ColDownload";
     this.ColDownload.ReadOnly     = true;
     this.ColDownload.SortMode     = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
     //
     // ColUpload
     //
     this.ColUpload.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColUpload.FillWeight   = 70.42757F;
     this.ColUpload.HeaderText   = "Upload KB/s";
     this.ColUpload.MinimumWidth = 20;
     this.ColUpload.Name         = "ColUpload";
     this.ColUpload.ReadOnly     = true;
     this.ColUpload.SortMode     = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
     //
     // ColDownCap
     //
     this.ColDownCap.HeaderText = "Download Cap";
     this.ColDownCap.Maximum    = new decimal(new int[] {
         10000,
         0,
         0,
         0
     });
     this.ColDownCap.Name = "ColDownCap";
     this.ColDownCap.ThousandsSeparator = true;
     //
     // ColUploadCap
     //
     this.ColUploadCap.HeaderText = "Upload Cap";
     this.ColUploadCap.Maximum    = new decimal(new int[] {
         10000,
         0,
         0,
         0
     });
     this.ColUploadCap.Name = "ColUploadCap";
     this.ColUploadCap.ThousandsSeparator = true;
     //
     // ColBlock
     //
     this.ColBlock.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColBlock.FalseValue   = "False";
     this.ColBlock.FillWeight   = 48.2451F;
     this.ColBlock.HeaderText   = "Block";
     this.ColBlock.MinimumWidth = 10;
     this.ColBlock.Name         = "ColBlock";
     this.ColBlock.Resizable    = System.Windows.Forms.DataGridViewTriState.True;
     this.ColBlock.TrueValue    = "True";
     //
     // ColSpoof
     //
     this.ColSpoof.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColSpoof.FalseValue   = "False";
     this.ColSpoof.HeaderText   = "Spoof";
     this.ColSpoof.MinimumWidth = 10;
     this.ColSpoof.Name         = "ColSpoof";
     this.ColSpoof.Resizable    = System.Windows.Forms.DataGridViewTriState.True;
     this.ColSpoof.TrueValue    = "True";
     this.ColSpoof.Visible      = false;
     //
     // ContextMenuViews
     //
     this.ContextMenuViews.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
         this.ViewMenuIP,
         this.ViewMenuMAC,
         this.ViewMenuDownload,
         this.ViewMenuUpload,
         this.ViewMenuDownloadCap,
         this.ViewMenuUploadCap,
         this.ViewMenuBlock,
         this.ViewMenuSpoof
     });
     this.ContextMenuViews.Name = "ContextMenuViews";
     this.ContextMenuViews.Size = new System.Drawing.Size(153, 180);
     this.ContextMenuViews.Text = "Columns Views";
     //
     // ViewMenuIP
     //
     this.ViewMenuIP.Checked            = true;
     this.ViewMenuIP.CheckOnClick       = true;
     this.ViewMenuIP.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuIP.Name               = "ViewMenuIP";
     this.ViewMenuIP.Size               = new System.Drawing.Size(152, 22);
     this.ViewMenuIP.Text               = "IP";
     this.ViewMenuIP.CheckStateChanged += new System.EventHandler(this.ViewMenuIP_CheckStateChanged);
     //
     // ViewMenuMAC
     //
     this.ViewMenuMAC.Checked            = true;
     this.ViewMenuMAC.CheckOnClick       = true;
     this.ViewMenuMAC.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuMAC.Name               = "ViewMenuMAC";
     this.ViewMenuMAC.Size               = new System.Drawing.Size(152, 22);
     this.ViewMenuMAC.Text               = "MAC";
     this.ViewMenuMAC.CheckStateChanged += new System.EventHandler(this.ViewMenuMAC_CheckStateChanged);
     //
     // ViewMenuDownload
     //
     this.ViewMenuDownload.Checked            = true;
     this.ViewMenuDownload.CheckOnClick       = true;
     this.ViewMenuDownload.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuDownload.Name               = "ViewMenuDownload";
     this.ViewMenuDownload.Size               = new System.Drawing.Size(152, 22);
     this.ViewMenuDownload.Text               = "Download";
     this.ViewMenuDownload.CheckStateChanged += new System.EventHandler(this.ViewMenuDownload_CheckStateChanged);
     //
     // ViewMenuUpload
     //
     this.ViewMenuUpload.Checked            = true;
     this.ViewMenuUpload.CheckOnClick       = true;
     this.ViewMenuUpload.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuUpload.Name               = "ViewMenuUpload";
     this.ViewMenuUpload.Size               = new System.Drawing.Size(152, 22);
     this.ViewMenuUpload.Text               = "Upload";
     this.ViewMenuUpload.CheckStateChanged += new System.EventHandler(this.ViewMenuUpload_CheckStateChanged);
     //
     // ViewMenuDownloadCap
     //
     this.ViewMenuDownloadCap.Checked            = true;
     this.ViewMenuDownloadCap.CheckOnClick       = true;
     this.ViewMenuDownloadCap.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuDownloadCap.Name               = "ViewMenuDownloadCap";
     this.ViewMenuDownloadCap.Size               = new System.Drawing.Size(152, 22);
     this.ViewMenuDownloadCap.Text               = "Download Cap";
     this.ViewMenuDownloadCap.CheckStateChanged += new System.EventHandler(this.DownloadCapToolStripMenuItem_CheckStateChanged);
     this.ViewMenuDownloadCap.Click             += new System.EventHandler(this.DownloadCapToolStripMenuItem_Click);
     //
     // ViewMenuUploadCap
     //
     this.ViewMenuUploadCap.Checked            = true;
     this.ViewMenuUploadCap.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuUploadCap.Name               = "ViewMenuUploadCap";
     this.ViewMenuUploadCap.Size               = new System.Drawing.Size(152, 22);
     this.ViewMenuUploadCap.Text               = "Upload Cap";
     this.ViewMenuUploadCap.CheckStateChanged += new System.EventHandler(this.uploadCapToolStripMenuItem_CheckStateChanged);
     //
     // ViewMenuBlock
     //
     this.ViewMenuBlock.Checked            = true;
     this.ViewMenuBlock.CheckOnClick       = true;
     this.ViewMenuBlock.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuBlock.Name               = "ViewMenuBlock";
     this.ViewMenuBlock.Size               = new System.Drawing.Size(152, 22);
     this.ViewMenuBlock.Text               = "Block";
     this.ViewMenuBlock.CheckStateChanged += new System.EventHandler(this.ViewMenuBlock_CheckStateChanged);
     //
     // ViewMenuSpoof
     //
     this.ViewMenuSpoof.CheckOnClick       = true;
     this.ViewMenuSpoof.Name               = "ViewMenuSpoof";
     this.ViewMenuSpoof.Size               = new System.Drawing.Size(152, 22);
     this.ViewMenuSpoof.Text               = "Spoofed";
     this.ViewMenuSpoof.CheckStateChanged += new System.EventHandler(this.ViewMenuSpoof_CheckStateChanged);
     //
     // imageList1
     //
     this.imageList1.ImageStream      = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
     this.imageList1.TransparentColor = System.Drawing.Color.White;
     this.imageList1.Images.SetKeyName(0, "circle.png");
     this.imageList1.Images.SetKeyName(1, "router.png");
     //
     // timer1
     //
     this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
     //
     // timer2
     //
     this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
     //
     // timerSpoof
     //
     this.timerSpoof.Tick += new System.EventHandler(this.timerSpoof_Tick);
     //
     // SelfishNetTrayIcon
     //
     this.SelfishNetTrayIcon.BalloonTipIcon    = System.Windows.Forms.ToolTipIcon.Info;
     this.SelfishNetTrayIcon.BalloonTipText    = "SelfishNet is minimized";
     this.SelfishNetTrayIcon.BalloonTipTitle   = "SelfishNet";
     this.SelfishNetTrayIcon.Text              = "SelfishNet";
     this.SelfishNetTrayIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseDoubleClick);
     //
     // timerDiscovery
     //
     this.timerDiscovery.Interval = 600000;
     //
     // MainForm
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.ClientSize          = new System.Drawing.Size(703, 402);
     this.Controls.Add(this.treeGridView1);
     this.Controls.Add(this.toolStrip1);
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
     this.MaximizeBox     = false;
     this.Name            = "MainForm";
     this.Text            = "SelfishNetSabsab v0.1 Beta";
     this.FormClosing    += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
     this.Load           += new System.EventHandler(this.MainForm_Load);
     this.Resize         += new System.EventHandler(this.MainForm_Resize);
     this.toolStrip1.ResumeLayout(false);
     this.toolStrip1.PerformLayout();
     ((System.ComponentModel.ISupportInitialize)(this.treeGridView1)).EndInit();
     this.ContextMenuViews.ResumeLayout(false);
     this.ResumeLayout(false);
     this.PerformLayout();
 }
コード例 #3
0
		public ExpandingEventArgs(TreeGridNode node):base()
		{
			this._node = node;
		}
コード例 #4
0
		public ExpandedEventArgs(TreeGridNode node):base(node)
		{
		}
コード例 #5
0
		public CollapsedEventArgs(TreeGridNode node)
			: base(node)
		{
		}
コード例 #6
0
		public CollapsingEventArgs(TreeGridNode node)
			: base()
		{
			this._node = node;
		}
コード例 #7
0
		public TreeGridNodeEventBase(TreeGridNode node)
		{
			this._node = node;
		}
コード例 #8
0
        protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            TreeGridNode node = this.OwningNode;

            if (node == null)
            {
                return;
            }

            Image image = node.Image;

            if (this._imageHeight == 0 && image != null)
            {
                this.UpdateStyle();
            }

            // paint the cell normally
            base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);

            // TODO: Indent width needs to take image size into account
            Rectangle glyphRect = new Rectangle(cellBounds.X + this.GlyphMargin, cellBounds.Y, INDENT_WIDTH, cellBounds.Height - 1);
            int       glyphHalf = glyphRect.Width / 2;

            //TODO: This painting code needs to be rehashed to be cleaner
            int level = this.Level;

            //TODO: Rehash this to take different Imagelayouts into account. This will speed up drawing
            //		for images of the same size (ImageLayout.None)
            if (image != null)
            {
                Point pp;
                if (_imageHeight > cellBounds.Height)
                {
                    pp = new Point(glyphRect.X + this.glyphWidth, cellBounds.Y + _imageHeightOffset);
                }
                else
                {
                    pp = new Point(glyphRect.X + this.glyphWidth, (cellBounds.Height / 2 - _imageHeight / 2) + cellBounds.Y);
                }

                // Graphics container to push/pop changes. This enables us to set clipping when painting
                // the cell's image -- keeps it from bleeding outsize of cells.
                System.Drawing.Drawing2D.GraphicsContainer gc = graphics.BeginContainer();
                {
                    graphics.SetClip(cellBounds);
                    graphics.DrawImageUnscaled(image, pp);
                }
                graphics.EndContainer(gc);
            }

            // Paint tree lines
            if (node._grid.ShowLines)
            {
                using (Pen linePen = new Pen(SystemBrushes.ControlDark, 1.0f))
                {
                    linePen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                    bool isLastSibling  = node.IsLastSibling;
                    bool isFirstSibling = node.IsFirstSibling;
                    if (node.Level == 1)
                    {
                        // the Root nodes display their lines differently
                        if (isFirstSibling && isLastSibling)
                        {
                            // only node, both first and last. Just draw horizontal line
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2);
                        }
                        else if (isLastSibling)
                        {
                            // last sibling doesn't draw the line extended below. Paint horizontal then vertical
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2);
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2);
                        }
                        else if (isFirstSibling)
                        {
                            // first sibling doesn't draw the line extended above. Paint horizontal then vertical
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2);
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.X + 4, cellBounds.Bottom);
                        }
                        else
                        {
                            // normal drawing draws extended from top to bottom. Paint horizontal then vertical
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2);
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Bottom);
                        }
                    }
                    else
                    {
                        if (isLastSibling)
                        {
                            // last sibling doesn't draw the line extended below. Paint horizontal then vertical
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2);
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2);
                        }
                        else
                        {
                            // normal drawing draws extended from top to bottom. Paint horizontal then vertical
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2);
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Bottom);
                        }

                        // paint lines of previous levels to the root
                        TreeGridNode previousNode   = node.Parent;
                        int          horizontalStop = (glyphRect.X + 4) - INDENT_WIDTH;

                        while (!previousNode.IsRoot)
                        {
                            if (previousNode.HasChildren && !previousNode.IsLastSibling)
                            {
                                // paint vertical line
                                graphics.DrawLine(linePen, horizontalStop, cellBounds.Top, horizontalStop, cellBounds.Bottom);
                            }
                            previousNode   = previousNode.Parent;
                            horizontalStop = horizontalStop - INDENT_WIDTH;
                        }
                    }
                }
            }

            if (node.HasChildren || node._grid.VirtualNodes)
            {
                // Paint node glyphs
                //if (node.IsExpanded)
                //    node._grid.rOpen.DrawBackground(graphics, new Rectangle(glyphRect.X, glyphRect.Y + (glyphRect.Height / 2) - 4, 10, 10));
                //else
                //    node._grid.rClosed.DrawBackground(graphics, new Rectangle(glyphRect.X, glyphRect.Y + (glyphRect.Height / 2) - 4, 10, 10));
                // Paint node glyphs

                // VisualStyle 오류로 일단 VisualStyle 사용을 제거함.  Start
                //if (Application.RenderWithVisualStyles)
                //{
                //    VisualStyleRenderer rOpen = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Opened);
                //    VisualStyleRenderer rClosed = new VisualStyleRenderer(VisualStyleElement.TreeView.Glyph.Closed);
                //    // Paint node glyphs
                //    if (node.IsExpanded)
                //        rOpen.DrawBackground(graphics, new Rectangle(glyphRect.X, glyphRect.Y + (glyphRect.Height / 2) - 4, 10, 10));
                //    else
                //        rClosed.DrawBackground(graphics, new Rectangle(glyphRect.X, glyphRect.Y + (glyphRect.Height / 2) - 4, 10, 10));
                //}
                //else
                //{
                //    int h = 8;
                //    int w = 8;
                //    int x = glyphRect.X;
                //    int y = glyphRect.Y + (glyphRect.Height / 2) - 4;
                //    //MessageBox.Show("x = " + x.ToString() + ", y= " + y.ToString());

                //    graphics.DrawRectangle(new Pen(SystemBrushes.ControlDark), x, y, w, h);
                //    graphics.FillRectangle(new SolidBrush(Color.White), x + 1, y + 1, w - 1, h - 1);
                //    graphics.DrawLine(new Pen(new SolidBrush(Color.Black)), x + 2, y + 4, x + w - 2, y + 4);

                //    if (!node.IsExpanded)
                //        graphics.DrawLine(new Pen(new SolidBrush(Color.Black)), x + 4, y + 2, x + 4, y + h - 2);

                //}
                // VisualStyle 오류로 일단 VisualStyle 사용을 제거함. End
                int h = 8;
                int w = 8;
                int x = glyphRect.X;
                int y = glyphRect.Y + (glyphRect.Height / 2) - 4;
                //MessageBox.Show("x = " + x.ToString() + ", y= " + y.ToString());

                graphics.DrawRectangle(new Pen(SystemBrushes.ControlDark), x, y, w, h);
                graphics.FillRectangle(new SolidBrush(Color.White), x + 1, y + 1, w - 1, h - 1);
                graphics.DrawLine(new Pen(new SolidBrush(Color.Black)), x + 2, y + 4, x + w - 2, y + 4);

                if (!node.IsExpanded)
                {
                    graphics.DrawLine(new Pen(new SolidBrush(Color.Black)), x + 4, y + 2, x + 4, y + h - 2);
                }
            }
        }
コード例 #9
0
        protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds,
                                      int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue,
                                      string errorText, DataGridViewCellStyle cellStyle,
                                      DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            TreeGridNode node = this.OwningNode;

            if (node == null)
            {
                return;
            }

            Image image = node.Image;

            if (this.imageHeight == 0 && image != null)
            {
                this.UpdateStyle();
            }

            // paint the cell normally
            base.Paint(graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);

            int checkBoxWidth = 0, checkBoxHeight = 0;

            if (node.Grid.ShowCheckBox)
            {
                Size chkSize = CheckBoxRenderer.GetGlyphSize(graphics, CheckBoxState.CheckedNormal);
                checkBoxWidth  = chkSize.Width;
                checkBoxHeight = chkSize.Height;
            }

            // TODO: Indent width needs to take image size into account
            Rectangle glyphRect = new Rectangle(cellBounds.X + this.GlyphMargin, cellBounds.Y, INDENT_WIDTH, cellBounds.Height - 1);

            //TODO: Rehash this to take different Imagelayouts into account. This will speed up drawing
            //		for images of the same size (ImageLayout.None)
            if (image != null)
            {
                Point pp;
                if (imageHeight > cellBounds.Height)
                {
                    pp = new Point(glyphRect.X + checkBoxWidth + GLYPH_WIDTH, cellBounds.Y);
                }
                else
                {
                    pp = new Point(glyphRect.X + checkBoxWidth + GLYPH_WIDTH, (cellBounds.Height / 2 - imageHeight / 2) + cellBounds.Y);
                }

                // Graphics container to push/pop changes. This enables us to set clipping when painting
                // the cell's image -- keeps it from bleeding outsize of cells.
                System.Drawing.Drawing2D.GraphicsContainer gc = graphics.BeginContainer();
                {
                    graphics.SetClip(cellBounds);
                    graphics.DrawImageUnscaled(image, pp);
                }
                graphics.EndContainer(gc);
            }

            // Paint tree lines
            if (node.Grid.ShowLines)
            {
                using (Pen linePen = new Pen(SystemBrushes.ControlDark, 1.0f))
                {
                    linePen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                    bool isLastSibling  = node.IsLastSibling;
                    bool isFirstSibling = node.IsFirstSibling;
                    // the Root nodes display their lines differently
                    if (isFirstSibling && isLastSibling)
                    {
                        // only node, both first and last. Just draw horizontal line
                        graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2);
                        if (node.Parent != null && node.Level > 1)
                        {
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2);
                        }
                    }
                    else if (isLastSibling)
                    {
                        // last sibling doesn't draw the line extended below. Paint horizontal then vertical
                        graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2);
                        graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2);
                    }
                    else if (isFirstSibling)
                    {
                        // first sibling doesn't draw the line extended above. Paint horizontal then vertical
                        graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2);
                        if (node.Parent == null)
                        {
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.X + 4, cellBounds.Bottom);
                        }
                        else
                        {
                            graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Bottom);
                        }
                    }
                    else
                    {
                        // normal drawing draws extended from top to bottom. Paint horizontal then vertical
                        graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top + cellBounds.Height / 2, glyphRect.Right, cellBounds.Top + cellBounds.Height / 2);
                        graphics.DrawLine(linePen, glyphRect.X + 4, cellBounds.Top, glyphRect.X + 4, cellBounds.Bottom);
                    }
                    // paint lines of previous levels to the root
                    TreeGridNode previousNode   = node.Parent;
                    int          horizontalStop = (glyphRect.X + 4) - INDENT_WIDTH;

                    while (!previousNode.IsRoot)
                    {
                        if (previousNode.HasChildren && !previousNode.IsLastSibling)
                        {
                            // paint vertical line
                            graphics.DrawLine(linePen, horizontalStop, cellBounds.Top, horizontalStop, cellBounds.Bottom);
                        }
                        previousNode   = previousNode.Parent;
                        horizontalStop = horizontalStop - INDENT_WIDTH;
                    }
                }
            }

            if (node.HasChildren || node.Grid.VirtualNodes)
            {
                if (node.IsExpanded)
                {
                    RENDERER_OPEN.DrawBackground(graphics, new Rectangle(glyphRect.X, glyphRect.Y + (glyphRect.Height - 10) / 2, 10, 10));
                }
                else
                {
                    RENDERER_CLOSED.DrawBackground(graphics, new Rectangle(glyphRect.X, glyphRect.Y + (glyphRect.Height - 10) / 2, 10, 10));
                }
            }

            if (node.Grid.ShowCheckBox)
            {
                CheckBoxRenderer.DrawCheckBox(graphics,
                                              new Point(glyphRect.Left + GLYPH_WIDTH, glyphRect.Top + (glyphRect.Height - checkBoxHeight) / 2),
                                              node.Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal);
            }
        }