Пример #1
0
        public FrmNodePreviewPanel(Type stNodeType, Point ptHandle, int nHandleSize, bool bRight, STNodeEditor editor, STNodePropertyGrid propertyGrid)
        {
            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);

            if (m_last_frm != null)
            {
                m_last_frm.Close();
            }
            m_last_frm = this;

            m_editor                   = editor;
            m_property                 = propertyGrid;
            m_editor.Size              = new Size(200, 200);
            m_property.Size            = new Size(200, 200);
            m_editor.Location          = new Point(1 + (bRight ? nHandleSize : 0), 1);
            m_property.Location        = new Point(m_editor.Right, 1);
            m_property.InfoFirstOnDraw = true;
            this.Controls.Add(m_editor);
            this.Controls.Add(m_property);
            this.ShowInTaskbar   = false;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.Size            = new Size(402 + nHandleSize, 202);

            m_type        = stNodeType;
            m_ptHandle    = ptHandle;
            m_nHandleSize = nHandleSize;
            m_bRight      = bRight;

            this.AutoBorderColor = true;
            this.BorderColor     = Color.DodgerBlue;
        }
Пример #2
0
 protected override void OnClosing(CancelEventArgs e)
 {
     base.OnClosing(e);
     this.Controls.Clear();
     m_editor.Nodes.Clear();
     m_editor.MouseLeave   -= Event_MouseLeave;
     m_property.MouseLeave -= Event_MouseLeave;
     m_last_frm             = null;
 }
Пример #3
0
        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();
            }));
        }
Пример #4
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     base.OnMouseDown(e);
     this.Focus();
     if (!string.IsNullOrEmpty(m_str_search) && m_rect_clear.Contains(e.Location))
     {
         m_tbx.Text = string.Empty;
         return;
     }
     m_pt_offsety    = m_pt_control = e.Location;
     m_pt_offsety.Y -= m_nOffsetY;
     if (m_item_hover == null)
     {
         return;
     }
     if (m_item_hover.SwitchRectangle.Contains(m_pt_offsety))
     {
         m_item_hover.IsOpen = !m_item_hover.IsOpen;
         this.Invalidate();
     }
     else if (m_item_hover.InfoRectangle.Contains(m_pt_offsety))
     {
         Rectangle           rect = this.RectangleToScreen(m_item_hover.DisplayRectangle);
         FrmNodePreviewPanel frm  = new FrmNodePreviewPanel(m_item_hover.STNodeType,
                                                            new Point(rect.Right - m_nItemHeight, rect.Top + m_nOffsetY),
                                                            m_nItemHeight,
                                                            this._InfoPanelIsLeftLayout,
                                                            this._Editor, this._PropertyGrid);
         frm.BackColor = this.BackColor;
         frm.Show(this);
     }
     else if (m_item_hover.STNodeType != null)
     {
         DataObject d = new DataObject("STNodeType", m_item_hover.STNodeType);
         this.DoDragDrop(d, DragDropEffects.Copy);
     }
 }