Esempio n. 1
0
 /// <summary>
 /// Occurs when the mouse leaves the control
 /// </summary>
 /// <param name="e">Event parameters</param>
 protected override void OnMouseLeave(EventArgs e)
 {
     base.OnMouseLeave(e);
     m_b_hover_switch = false;
     if (m_item_hover_value != null && !this._ReadOnlyModel)
     {
         m_item_hover_value.OnMouseLeave(e);
     }
     m_item_hover = null;
     this.Invalidate();
 }
Esempio n. 2
0
        /// <summary>
        /// Occurs when the mouse is moved in the properties panel
        /// </summary>
        /// <param name="e">Mouse event parameters</param>
        protected virtual void OnProcessPropertyMouseMove(MouseEventArgs e)
        {
            if (m_item_down_value != null)
            {
                m_item_down_value.OnMouseMove(e);
                return;
            }
            STNodePropertyDescriptor item = null;

            foreach (var v in m_lst_item)
            {
                if (v.Rectangle.Contains(e.Location))
                {
                    item = v;
                    break;
                }
            }
            if (item != null)
            {
                if (item.RectangleR.Contains(e.Location))
                {
                    if (m_item_hover_value != item)
                    {
                        if (m_item_hover_value != null)
                        {
                            m_item_hover_value.OnMouseLeave(e);
                        }
                        m_item_hover_value = item;
                        m_item_hover_value.OnMouseEnter(e);
                    }
                    m_item_hover_value.OnMouseMove(e);
                }
                else
                {
                    if (m_item_hover_value != null)
                    {
                        m_item_hover_value.OnMouseLeave(e);
                    }
                }
            }
            if (m_item_hover != item)
            {
                m_item_hover = item;
                this.Invalidate();
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Occurs when the mouse is raised over the control
 /// </summary>
 /// <param name="e">Event parameters</param>
 protected override void OnMouseUp(MouseEventArgs e)
 {
     base.OnMouseUp(e);
     m_str_desc = null;
     if (m_item_down_value != null && !this._ReadOnlyModel)
     {
         Point          pt  = new Point(e.X, e.Y - (int)m_nOffsetY);
         MouseEventArgs mea = new MouseEventArgs(e.Button, e.Clicks, pt.X, pt.Y, e.Delta);
         m_item_down_value.OnMouseUp(mea);
         if (m_pt_down == e.Location && !this._ReadOnlyModel)
         {
             m_item_down_value.OnMouseClick(mea);
         }
     }
     m_item_down_value = null;
     this.Invalidate();
 }
Esempio n. 4
0
        private void SetItemRectangle()
        {
            int nw_p = 0, nw_h = 0;

            using (Graphics g = this.CreateGraphics()) {
                foreach (var v in m_lst_item)
                {
                    SizeF szf = g.MeasureString(v.Name, this.Font);
                    if (szf.Width > nw_p)
                    {
                        nw_p = (int)Math.Ceiling(szf.Width);
                    }
                }
                for (int i = 0; i < m_KeysString.Length - 1; i++)
                {
                    SizeF szf = g.MeasureString(m_KeysString[i], this.Font);
                    if (szf.Width > nw_h)
                    {
                        nw_h = (int)Math.Ceiling(szf.Width);
                    }
                }
                nw_p       += 5; nw_h += 5;
                nw_p        = Math.Min(nw_p, this.Width >> 1);
                m_nInfoLeft = Math.Min(nw_h, this.Width >> 1);

                int nTitleHeight = this._ShowTitle ? m_nTitleHeight : 0;
                for (int i = 0; i < m_lst_item.Count; i++)
                {
                    STNodePropertyDescriptor item = m_lst_item[i];
                    Rectangle rect = new Rectangle(0, i * m_item_height + nTitleHeight, this.Width, m_item_height);
                    item.Rectangle  = rect;
                    rect.Width      = nw_p;
                    item.RectangleL = rect;
                    rect.X          = rect.Right;
                    rect.Width      = this.Width - rect.Left - 1;
                    rect.Inflate(-4, -4);
                    item.RectangleR = rect;
                    item.OnSetItemLocation();
                }
                m_nPropertyVHeight = m_lst_item.Count * m_item_height;
                if (this._ShowTitle)
                {
                    m_nPropertyVHeight += m_nTitleHeight;
                }
            }
        }
        public FrmSTNodePropertySelect(STNodePropertyDescriptor descriptor)
        {
            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_descriptor         = descriptor;
            this.Size            = descriptor.RectangleR.Size;
            this.ShowInTaskbar   = false;
            this.BackColor       = descriptor.Control.BackColor;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            m_pen              = new Pen(descriptor.Control.AutoColor ? descriptor.Node.TitleColor : descriptor.Control.ItemSelectedColor, 1);
            m_brush            = new SolidBrush(this.BackColor);
            m_sf               = new StringFormat();
            m_sf.LineAlignment = StringAlignment.Center;
            m_sf.FormatFlags   = StringFormatFlags.NoWrap;
        }
Esempio n. 6
0
        /// <summary>
        /// Occurs when the mouse is clicked on the property panel
        /// </summary>
        /// <param name="e">Mouse event parameters</param>
        protected virtual void OnProcessPropertyMouseDown(MouseEventArgs e)
        {
            bool bRedraw = false;

            if (m_item_selected != m_item_hover)
            {
                m_item_selected = m_item_hover;
                bRedraw         = true;
            }
            m_item_down_value = null;
            if (m_item_selected == null)
            {
                if (bRedraw)
                {
                    this.Invalidate();
                }
                return;
            }
            if (m_item_selected.RectangleR.Contains(e.Location))
            {
                m_item_down_value = m_item_selected;
                if (!this._ReadOnlyModel)
                {
                    m_item_selected.OnMouseDown(e);
                }
                else
                {
                    return;
                }
            }
            else if (m_item_selected.RectangleL.Contains(e.Location))
            {
                m_str_desc = m_item_selected.Description;
                bRedraw    = true;
            }
            if (bRedraw)
            {
                this.Invalidate();
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Occurs when drawing attribute options
        /// </summary>
        /// <param name="dt">Drawing tool</param>
        /// <param name="item">Target attribute option descriptor</param>
        /// <param name="nIndex">The index of the option</param>
        protected virtual void OnDrawPropertyItem(DrawingTools dt, STNodePropertyDescriptor item, int nIndex)
        {
            Graphics g = dt.Graphics;

            m_brush.Color = (nIndex % 2 == 0) ? m_clr_item_1 : m_clr_item_2;
            g.FillRectangle(m_brush, item.Rectangle);
            if (item == m_item_hover || item == m_item_selected)
            {
                m_brush.Color = this._ItemHoverColor;
                g.FillRectangle(m_brush, item.Rectangle);
            }
            if (m_item_selected == item)
            {
                g.FillRectangle(m_brush, item.Rectangle.X, item.Rectangle.Y, 5, item.Rectangle.Height);
                if (this._AutoColor && this._STNode != null)
                {
                    m_brush.Color = this._STNode.TitleColor;
                }
                else
                {
                    m_brush.Color = this._ItemSelectedColor;
                }
                g.FillRectangle(m_brush, item.Rectangle.X, item.Rectangle.Y + 4, 5, item.Rectangle.Height - 8);
            }
            m_sf.Alignment = StringAlignment.Far;
            m_brush.Color  = this.ForeColor;
            g.DrawString(item.Name, this.Font, m_brush, item.RectangleL, m_sf);

            item.OnDrawValueRectangle(m_dt);
            if (this._ReadOnlyModel)
            {
                m_brush.Color = Color.FromArgb(125, 125, 125, 125);
                g.FillRectangle(m_brush, item.RectangleR);
                m_pen.Color = this.ForeColor;
                //g.DrawLine(m_pen,
                //    item.RectangleR.Left - 2, item.RectangleR.Top + item.RectangleR.Height / 2,
                //    item.RectangleR.Right + 1, item.RectangleR.Top + item.RectangleR.Height / 2);
            }
        }