예제 #1
0
파일: BaseForm.cs 프로젝트: wwkkww1983/WMS
 private void InitializeControlBoxInfo()
 {
     _MinBoxState         = EnumControlState.Default;
     _MaxBoxState         = EnumControlState.Default;
     _CloseBoxState       = EnumControlState.Default;
     base.FormBorderStyle = FormBorderStyle.None;
 }
예제 #2
0
        private void DrawButton(Graphics g)
        {
            EnumControlState enumControlState = (!GetComboBoxButtonPressed()) ? EnumControlState.Default : EnumControlState.HeightLight;
            Rectangle        rect             = new Rectangle(ButtonRect.X - 2, ButtonRect.Y - 1, ButtonRect.Width + 1 + _Margin, ButtonRect.Height + 2);
            RoundRectangle   roundRect        = new RoundRectangle(rect, new CornerRadius(0, _CornerRadius, 0, _CornerRadius));
            Blend            blend            = new Blend(3);

            blend.Positions = new float[3]
            {
                0f,
                0.5f,
                1f
            };
            blend.Factors = new float[3]
            {
                0f,
                1f,
                0f
            };
            GDIHelper.FillRectangle(g, roundRect, SkinManager.CurrentSkin.DefaultControlColor);
            Size arrowSize = new Size(12, 7);

            System.Windows.Forms.ArrowDirection direction = System.Windows.Forms.ArrowDirection.Down;
            GDIHelper.DrawArrow(g, direction, rect, arrowSize, 0f, Color.FromArgb(30, 178, 239));
            Color borderColor = SkinManager.CurrentSkin.BorderColor;

            GDIHelper.DrawGradientLine(g, borderColor, 90, rect.X, rect.Y, rect.X, rect.Bottom - 1);
        }
예제 #3
0
 protected override void OnMouseUp(MouseEventArgs e)
 {
     base.OnMouseUp(e);
     if (e.Button == MouseButtons.Left && e.Clicks == 1)
     {
         _ControlState = EnumControlState.Default;
     }
 }
예제 #4
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     base.OnMouseDown(e);
     if (e.Button == MouseButtons.Left && e.Clicks == 1)
     {
         _ControlState = EnumControlState.Focused;
     }
 }
예제 #5
0
 protected override void OnKeyDown(KeyEventArgs e)
 {
     base.OnKeyDown(e);
     if (e.KeyCode == Keys.Space)
     {
         this._ControlState = EnumControlState.Focused;
         this.Invalidate();
     }
 }
예제 #6
0
 protected override void OnMouseUp(MouseEventArgs e)
 {
     base.OnMouseUp(e);
     if (e.Button == MouseButtons.Left)
     {
         this._ControlState = EnumControlState.HeightLight;
         this.Invalidate();
     }
 }
예제 #7
0
 public TXComboBox()
 {
     SetStyle(ControlStyles.AllPaintingInWmPaint, value: true);
     SetStyle(ControlStyles.OptimizedDoubleBuffer, value: true);
     SetStyle(ControlStyles.DoubleBuffer, value: true);
     UpdateStyles();
     base.Size     = new Size(150, 20);
     _ControlState = EnumControlState.Default;
 }
예제 #8
0
 protected override void OnMouseDown(MouseEventArgs e)
 {
     base.OnMouseDown(e);
     if (e.Button == MouseButtons.Left)
     {
         this._ControlState = EnumControlState.Focused;
         this.Invalidate();
     }
 }
예제 #9
0
 protected override void OnKeyUp(KeyEventArgs e)
 {
     base.OnKeyUp(e);
     if (e.KeyCode == Keys.Space)
     {
         this._ControlState = EnumControlState.Default;
         this.Invalidate();
         this.OnClick(e);
     }
 }
예제 #10
0
 public TXCheckBox()
 {
     SetStyle(ControlStyles.AllPaintingInWmPaint, value: true);
     SetStyle(ControlStyles.OptimizedDoubleBuffer, value: true);
     SetStyle(ControlStyles.DoubleBuffer, value: true);
     SetStyle(ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.SupportsTransparentBackColor, value: true);
     UpdateStyles();
     MinimumSize   = new Size(20, 20);
     _ControlState = EnumControlState.Default;
 }
예제 #11
0
 public TXComboBox()
     : base()
 {
     this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
     this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
     this.SetStyle(ControlStyles.DoubleBuffer, true);
     this.UpdateStyles();
     this.Size          = new Size(150, 20);
     this._ControlState = EnumControlState.Default;
 }
예제 #12
0
        private void DrawButton(Graphics g)
        {
            EnumControlState enumControlState = (!GetComboBoxButtonPressed()) ? EnumControlState.Default : EnumControlState.HeightLight;
            Rectangle        rect             = new Rectangle(ButtonRect.X, ButtonRect.Y - 1, ButtonRect.Width + 1 + _Margin, ButtonRect.Height + 2);
            RoundRectangle   roundRect        = new RoundRectangle(rect, new CornerRadius(0));

            GDIHelper.FillRectangle(g, roundRect, SkinManager.CurrentSkin.DefaultControlColor);
            GDIHelper.DrawArrow(arrowSize: new Size(12, 7), g: g, direction: System.Windows.Forms.ArrowDirection.Down, rect: rect, offset: 0f, c: Color.FromArgb(30, 178, 239));
            Color borderColor = SkinManager.CurrentSkin.BorderColor;

            GDIHelper.DrawGradientLine(g, borderColor, 90, rect.X, rect.Y, rect.X, rect.Bottom - 1);
        }
예제 #13
0
 protected override void ProcessMouseDown(Point p)
 {
     if (!RibbonBtnRect.IsEmpty && RibbonBtnRect.Contains(p))
     {
         _RibbonBtnState = EnumControlState.Focused;
     }
     if (!SkinBoxRect.IsEmpty && SkinBoxRect.Contains(p))
     {
         _SkinBtnState = EnumControlState.Focused;
     }
     base.ProcessMouseDown(p);
 }
예제 #14
0
 protected override void ProcessMouseMove(Point p)
 {
     _SkinBtnState = EnumControlState.Default;
     if (!RibbonBtnRect.IsEmpty && RibbonBtnRect.Contains(p))
     {
         _RibbonBtnState = EnumControlState.HeightLight;
     }
     if (!SkinBoxRect.IsEmpty && SkinBoxRect.Contains(p))
     {
         _SkinBtnState = EnumControlState.HeightLight;
     }
     base.ProcessMouseMove(p);
 }
예제 #15
0
파일: TXButton.cs 프로젝트: wwkkww1983/WMS
 public TXButton()
 {
     SetStyle(ControlStyles.UserPaint, value: true);
     SetStyle(ControlStyles.AllPaintingInWmPaint, value: true);
     SetStyle(ControlStyles.OptimizedDoubleBuffer, value: true);
     SetStyle(ControlStyles.DoubleBuffer, value: true);
     SetStyle(ControlStyles.ResizeRedraw, value: true);
     SetStyle(ControlStyles.SupportsTransparentBackColor, value: true);
     _ControlState          = EnumControlState.Default;
     base.TextImageRelation = TextImageRelation.ImageBeforeText;
     base.Size = new Size(100, 28);
     ResetRegion();
 }
예제 #16
0
 public TXRadioButton()
     : base()
 {
     this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
     this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
     this.SetStyle(ControlStyles.DoubleBuffer, true);
     SetStyle(
         ControlStyles.UserPaint |
         ControlStyles.ResizeRedraw |
         ControlStyles.SupportsTransparentBackColor, true);
     this.UpdateStyles();
     base.MinimumSize   = new Size(22, 22);
     this._ControlState = EnumControlState.Default;
 }
예제 #17
0
 protected override void OnMouseUp(MouseEventArgs e)
 {
     base.OnMouseUp(e);
     if (e.Button == MouseButtons.Left && e.Clicks == 1)
     {
         if (ClientRectangle.Contains(e.Location))
         {
             this._ControlState = EnumControlState.HeightLight;
         }
         else
         {
             this._ControlState = EnumControlState.Default;
         }
     }
 }
예제 #18
0
        private void DrawContent(Graphics g)
        {
            GDIHelper.InitializeGraphics(g);
            int       width     = base.Width;
            int       height    = base.Height;
            Rectangle rectangle = new Rectangle(_Margin, height / 2 - _BoxSize.Height / 2, _BoxSize.Width, _BoxSize.Height);
            Size      size      = g.MeasureString(Text, Font).ToSize();
            Rectangle rect      = default(Rectangle);

            rect.X      = rectangle.Right + _Margin;
            rect.Y      = _Margin;
            rect.Height = base.Height - _Margin * 2;
            rect.Width  = size.Width;
            RoundRectangle   roundRect    = new RoundRectangle(rectangle, _CornerRadius);
            EnumControlState controlState = _ControlState;

            if (controlState == EnumControlState.HeightLight)
            {
                GDIHelper.DrawPathBorder(g, roundRect, SkinManager.CurrentSkin.OuterBorderColor);
                GDIHelper.DrawPathInnerBorder(g, roundRect, SkinManager.CurrentSkin.HeightLightControlColor.First);
            }
            else
            {
                GDIHelper.DrawCheckBox(g, roundRect);
            }
            Color forceColor = base.Enabled ? ForeColor : SkinManager.CurrentSkin.UselessColor;

            GDIHelper.DrawImageAndString(g, rect, null, Size.Empty, Text, Font, forceColor);
            switch (base.CheckState)
            {
            case CheckState.Checked:
                GDIHelper.DrawCheckedStateByImage(g, rectangle);
                break;

            case CheckState.Indeterminate:
            {
                Rectangle rect2 = rectangle;
                rect2.Inflate(-3, -3);
                Color color = Color.FromArgb(46, 117, 35);
                GDIHelper.FillRectangle(g, new RoundRectangle(rect2, _CornerRadius), color);
                break;
            }
            }
        }
예제 #19
0
        /// <summary>
        ///  绘制按钮
        /// </summary>
        /// <param name="g">The Graphics.</param>
        /// User:Ryan  CreateTime:2011-08-02 14:23.
        private void DrawButton(Graphics g)
        {
            Rectangle        btnRect;
            EnumControlState btnState = this.GetComboBoxButtonPressed() ? EnumControlState.HeightLight : EnumControlState.Default;

            btnRect = new Rectangle(this.ButtonRect.X, this.ButtonRect.Y - 1, this.ButtonRect.Width + 1 + this._Margin, this.ButtonRect.Height + 2);
            RoundRectangle btnRoundRect = new RoundRectangle(btnRect, new CornerRadius(0));

            //Blend blend = new Blend(3);
            //blend.Positions = new float[] { 0f, 0.5f, 1f };
            //blend.Factors = new float[] { 0f, 1f, 0f };
            GDIHelper.FillRectangle(g, btnRoundRect, SkinManager.CurrentSkin.DefaultControlColor);
            Size btnSize = new Size(12, 7);

            GDIHelper.DrawArrow(g, ArrowDirection.Down, btnRect, btnSize, 0f, Color.FromArgb(30, 178, 239));
            Color lineColor = SkinManager.CurrentSkin.BorderColor;

            GDIHelper.DrawGradientLine(g, lineColor, 90, btnRect.X, btnRect.Y, btnRect.X, btnRect.Bottom - 1);
        }
예제 #20
0
        /// <summary>
        /// 绘制关闭按钮背景
        /// </summary>
        /// <param name="g">The g.</param>
        /// <param name="rect">The rect.</param>
        /// <param name="controlState">State of the control.</param>
        /// <param name="radius">The radius.</param>
        /// User:Ryan  CreateTime:2012-8-3 22:52.
        public void DrawCloseBox(Graphics g, Rectangle rect, EnumControlState controlState, int radius)
        {
            GradientColor color;

            switch (controlState)
            {
            case EnumControlState.HeightLight:
                color = SkinManager.CurrentSkin.CloseBoxHeightLightColor;
                break;

            case EnumControlState.Focused:
                color = SkinManager.CurrentSkin.CloseBoxPressedColor;
                break;

            default:
                color = SkinManager.CurrentSkin.ControlBoxDefaultColor;
                break;
            }
            Rectangle exRect = new Rectangle(rect.Left, rect.Bottom, rect.Width, 1);

            g.SetClip(exRect, CombineMode.Exclude);
            CornerRadius cr = new CornerRadius(0, radius + 2, 0, 0);

            GDIHelper.FillRectangle(g, new RoundRectangle(rect, cr), color);
            ////绘制边线
            Color c1, c2;

            c1 = SkinManager.CurrentSkin.BorderColor;
            c2 = Color.FromArgb(10, c1);
            using (LinearGradientBrush brush = new LinearGradientBrush(rect, c1, c2, 90))
            {
                brush.Blend.Positions = color.Positions;
                brush.Blend.Factors   = color.Factors;
                using (Pen pen = new Pen(brush, 1))
                {
                    g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Bottom);
                }
            }

            g.ResetClip();
        }
예제 #21
0
        /// <summary>
        /// 处理鼠标离开
        /// </summary>
        /// <param name="p">The Point.</param>
        /// User:Ryan  CreateTime:2011-07-28 10:44.
        protected virtual void ProcessMouseUp(Point p)
        {
            Rectangle closeRect = this.CloseBoxRect;
            Rectangle maxRect   = this.MaximizeBoxRect;
            Rectangle minRect   = this.MinimizeBoxRect;

            if (!closeRect.IsEmpty && closeRect.Contains(p))
            {
                base.Close();
                this.CloseBoxState = EnumControlState.Default;
            }

            if (!maxRect.IsEmpty && maxRect.Contains(p))
            {
                FormWindowState fs = FormWindowState.Normal;
                switch (base.WindowState)
                {
                case FormWindowState.Maximized:
                    fs = FormWindowState.Normal;
                    break;

                case FormWindowState.Normal:
                default:
                    fs = FormWindowState.Maximized;
                    break;
                }

                base.WindowState = fs;
                this.MaxBoxState = EnumControlState.Default;
            }

            if (!minRect.IsEmpty && minRect.Contains(p))
            {
                base.WindowState = FormWindowState.Minimized;
                this.MinBoxState = EnumControlState.Default;
            }

            this.Invalidate(this.CaptionRect);
        }
예제 #22
0
        /// <summary>
        /// 处理鼠标移动
        /// </summary>
        /// <param name="p">The Point.</param>
        /// User:Ryan  CreateTime:2011-07-28 10:44.
        protected virtual void ProcessMouseMove(Point p)
        {
            this.CloseBoxState = EnumControlState.Default;
            this.MaxBoxState   = EnumControlState.Default;
            this.MinBoxState   = EnumControlState.Default;
            if (this.CloseBoxRect.Contains(p))
            {
                this.CloseBoxState = EnumControlState.HeightLight;
            }

            if (this.MinimizeBoxRect.Contains(p))
            {
                this.MinBoxState = EnumControlState.HeightLight;
            }

            if (this.MaximizeBoxRect.Contains(p))
            {
                this.MaxBoxState = EnumControlState.HeightLight;
            }

            this.Invalidate(this.CaptionRect);
        }
예제 #23
0
 protected override void ProcessMouseUp(Point p)
 {
     if (!RibbonBtnRect.IsEmpty && RibbonBtnRect.Contains(p))
     {
         _RibbonBtnState = EnumControlState.Default;
         if (this.OnRibbonButtonClick != null)
         {
             BtnEventArgs e = new BtnEventArgs(RibbonBtnRect);
             this.OnRibbonButtonClick(null, e);
         }
     }
     if (!SkinBoxRect.IsEmpty && SkinBoxRect.Contains(p))
     {
         _SkinBtnState = EnumControlState.Default;
         if (this.OnSkinButtonClick != null)
         {
             BtnEventArgs e = new BtnEventArgs(SkinBoxRect);
             this.OnSkinButtonClick(null, e);
         }
     }
     base.ProcessMouseUp(p);
 }
예제 #24
0
        /// <summary>
        /// 处理鼠标离开
        /// </summary>
        /// <param name="p">The Point.</param>
        /// User:Ryan  CreateTime:2011-07-28 10:44.
        protected virtual void ProcessMouseLeave(Point p)
        {
            Rectangle closeRect = this.CloseBoxRect;
            Rectangle maxRect   = this.MaximizeBoxRect;
            Rectangle minRect   = this.MinimizeBoxRect;

            if (!closeRect.IsEmpty)
            {
                this.CloseBoxState = EnumControlState.Default;
            }

            if (!maxRect.IsEmpty)
            {
                this.MaxBoxState = EnumControlState.Default;
            }

            if (!minRect.IsEmpty)
            {
                this.MinBoxState = EnumControlState.Default;
            }

            this.Invalidate(this.CaptionRect);
        }
예제 #25
0
        /// <summary>
        /// 处理鼠标按下
        /// </summary>
        /// <param name="p">The Point.</param>
        /// User:Ryan  CreateTime:2011-07-28 10:44.
        protected virtual void ProcessMouseDown(Point p)
        {
            Rectangle closeRect = this.CloseBoxRect;
            Rectangle maxRect   = this.MaximizeBoxRect;
            Rectangle minRect   = this.MinimizeBoxRect;

            if (!closeRect.IsEmpty && closeRect.Contains(p))
            {
                this.CloseBoxState = EnumControlState.Focused;
            }

            if (!maxRect.IsEmpty && maxRect.Contains(p))
            {
                this.MaxBoxState = EnumControlState.Focused;
            }

            if (!minRect.IsEmpty && minRect.Contains(p))
            {
                this.MinBoxState = EnumControlState.Focused;
            }

            this.Invalidate(this.CaptionRect);
        }
예제 #26
0
        public void DrawControlBox(Graphics g, Rectangle rect, EnumControlState controlState)
        {
            GradientColor color;

            switch (controlState)
            {
            case EnumControlState.HeightLight:
                color = SkinManager.CurrentSkin.ControlBoxHeightLightColor;
                break;

            case EnumControlState.Focused:
                color = SkinManager.CurrentSkin.ControlBoxPressedColor;
                break;

            default:
                color = SkinManager.CurrentSkin.ControlBoxDefaultColor;
                break;
            }
            Rectangle rect2 = new Rectangle(rect.Left, rect.Bottom, rect.Width, 1);

            g.SetClip(rect2, CombineMode.Exclude);
            GDIHelper.FillRectangle(g, rect, color);
            Color borderColor = SkinManager.CurrentSkin.BorderColor;
            Color color2      = Color.FromArgb(10, borderColor);

            using (LinearGradientBrush linearGradientBrush = new LinearGradientBrush(rect, borderColor, color2, 90f))
            {
                linearGradientBrush.Blend.Positions = color.Positions;
                linearGradientBrush.Blend.Factors   = color.Factors;
                using (Pen pen = new Pen(linearGradientBrush, 1f))
                {
                    g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Bottom);
                }
            }
            g.ResetClip();
        }
예제 #27
0
 protected override void ProcessMouseLeave(Point p)
 {
     this._SkinBtnState   = EnumControlState.Default;
     this._RibbonBtnState = EnumControlState.Default;
     base.ProcessMouseLeave(p);
 }
예제 #28
0
 /// <summary>
 /// Initializes the control box info.
 /// </summary>
 /// User:Ryan  CreateTime:2012-8-3 15:59.
 private void InitializeControlBoxInfo()
 {
     this._MinBoxState   = EnumControlState.Default;
     this._MaxBoxState   = EnumControlState.Default;
     this._CloseBoxState = EnumControlState.Default;
 }
예제 #29
0
 private void _TextBox_GotFocus(object sender, EventArgs e)
 {
     this._ControlState = EnumControlState.HeightLight;
     this.Invalidate();
 }
예제 #30
0
 private void _TextBox_LostFocus(object sender, EventArgs e)
 {
     this._ControlState = EnumControlState.Default;
     this.Invalidate();
 }