public STNodeEditorPannel() { this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.ResizeRedraw, true); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); m_editor = new STNodeEditor(); m_tree = new STNodeTreeView(); m_grid = new STNodePropertyGrid(); m_grid.Text = "NodeProperty"; this.Controls.Add(m_editor); this.Controls.Add(m_tree); this.Controls.Add(m_grid); this.Size = new Size(500, 500); this.MinimumSize = new Size(250, 250); this.BackColor = Color.FromArgb(255, 34, 34, 34); m_pen = new Pen(this.BackColor, 3); Type t = typeof(ConnectionStatus); var vv = Enum.GetValues(t); var vvv = vv.GetValue(0); foreach (var f in t.GetFields()) { if (!f.FieldType.IsEnum) { continue; } foreach (var a in f.GetCustomAttributes(true)) { if (!(a is DescriptionAttribute)) { continue; } m_dic_status_key.Add((ConnectionStatus)f.GetValue(f), ((DescriptionAttribute)a).Description); } } m_editor.ActiveChanged += (s, e) => m_grid.SetNode(m_editor.ActiveNode); m_editor.CanvasScaled += (s, e) => { if (this._ShowScale) { m_editor.ShowAlert(m_editor.CanvasScale.ToString("F2"), Color.White, Color.FromArgb(127, 255, 255, 0)); } }; m_editor.OptionConnected += (s, e) => { if (this._ShowConnectionStatus) { m_editor.ShowAlert(m_dic_status_key[e.Status], Color.White, e.Status == ConnectionStatus.Connected ? Color.FromArgb(125, Color.Lime) : Color.FromArgb(125, Color.Red)); } }; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); m_node = (STNode)Activator.CreateInstance(m_type); m_node.Left = 20; m_node.Top = 20; m_editor.Nodes.Add(m_node); m_property.SetNode(m_node); m_rect_panel = new Rectangle(0, 0, 402, 202); m_rect_handle = new Rectangle(m_ptHandle.X, m_ptHandle.Y, m_nHandleSize, m_nHandleSize); m_rect_exclude = new Rectangle(0, m_nHandleSize, m_nHandleSize, this.Height - m_nHandleSize); if (m_bRight) { this.Left = m_ptHandle.X; m_rect_panel.X = m_ptHandle.X + m_nHandleSize; } else { this.Left = m_ptHandle.X - this.Width + m_nHandleSize; m_rect_exclude.X = this.Width - m_nHandleSize; m_rect_panel.X = this.Left; } if (m_ptHandle.Y + this.Height > Screen.GetWorkingArea(this).Bottom) { this.Top = m_ptHandle.Y - this.Height + m_nHandleSize; m_rect_exclude.Y -= m_nHandleSize; } else { this.Top = m_ptHandle.Y; } m_rect_panel.Y = this.Top; m_region = new Region(new Rectangle(Point.Empty, this.Size)); m_region.Exclude(m_rect_exclude); using (Graphics g = this.CreateGraphics()) { IntPtr h = m_region.GetHrgn(g); FrmNodePreviewPanel.SetWindowRgn(this.Handle, h, false); m_region.ReleaseHrgn(h); } this.MouseLeave += Event_MouseLeave; m_editor.MouseLeave += Event_MouseLeave; m_property.MouseLeave += Event_MouseLeave; this.BeginInvoke(new MethodInvoker(() => { m_property.Focus(); })); }