Ejemplo n.º 1
0
 // Draw a simple button border.
 public static void DrawBorder
     (Graphics graphics, Rectangle bounds,
     Color color, ButtonBorderStyle style)
 {
     ThemeManager.MainPainter.DrawBorder
         (graphics, bounds, color, style);
 }
Ejemplo n.º 2
0
        private void MainTableLayout_CellPaint(object sender, TableLayoutCellPaintEventArgs e)
        {
            Color     borderColor = SystemColors.ControlDarkDark;
            const int borderWidth = 1;

            ButtonBorderStyle leftBorderStyle   = ButtonBorderStyle.None;
            ButtonBorderStyle topBorderStyle    = ButtonBorderStyle.None;
            ButtonBorderStyle rightBorderStyle  = ButtonBorderStyle.None;
            ButtonBorderStyle bottomBorderStyle = ButtonBorderStyle.None;

            if (e.Column == 0)
            {
                topBorderStyle    = ButtonBorderStyle.Solid;
                rightBorderStyle  = ButtonBorderStyle.Solid;
                bottomBorderStyle = ButtonBorderStyle.Solid;
            }

            ControlPaint.DrawBorder(
                e.Graphics,
                e.CellBounds,
                borderColor,
                borderWidth,
                leftBorderStyle,
                borderColor,
                borderWidth,
                topBorderStyle,
                borderColor,
                borderWidth,
                rightBorderStyle,
                borderColor,
                borderWidth,
                bottomBorderStyle);
        }
Ejemplo n.º 3
0
        private void panel1_MouseMove(object sender, MouseEventArgs e)
        {
            BorderColor = SystemColors.MenuHighlight;

            BorderLineStyle = ButtonBorderStyle.Solid;
            this.panel1.Refresh();
        }
Ejemplo n.º 4
0
        internal static async Task WriteSettings(
            Color foreColor,
            Color backColor,
            ButtonBorderStyle borderStyle,
            Font font,
            Point location)
        {
            using (var memoryStream = new MemoryStream())
            {
                var settings = new Settings(foreColor, backColor, borderStyle, font, location);

                var serializer = new DataContractJsonSerializer(typeof(Settings));
                serializer.WriteObject(memoryStream, settings);

                memoryStream.Position = 0;

                using (var streamReader = new StreamReader(memoryStream))
                {
                    var jsonStr = await streamReader.ReadToEndAsync();

                    try
                    {
                        await Task.Factory.StartNew(() => File.WriteAllText(SettingsPath, jsonStr));
                    }
                    catch
                    {
                        //ignore}
                    }

                    streamReader.Close();
                }

                memoryStream.Close();
            }
        }
Ejemplo n.º 5
0
        protected void SetBorder(TableLayoutCellPaintEventArgs e, Color color, ButtonBorderStyle borderStyle, int height, int width)
        {
            var rectangle = e.CellBounds;

            rectangle.Inflate(width, height);
            ControlPaint.DrawBorder(e.Graphics, rectangle, color, borderStyle);
        }
Ejemplo n.º 6
0
 public BorderStyle(int width, int height, Color color, ButtonBorderStyle style = ButtonBorderStyle.Solid)
 {
     borderWidth  = width;
     borderHeight = height;
     borderColor  = color;
     borderStyle  = style;
 }
Ejemplo n.º 7
0
        public DarkComboBox() : base()
        {
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.ResizeRedraw, true);
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);

            this.DrawMode = DrawMode.OwnerDrawVariable;

            this.mDrawBuffer     = null;
            this.mDrawTextBuffer = null;

            this.FlatStyle     = FlatStyle.Flat;
            this.DropDownStyle = ComboBoxStyle.DropDownList;

            this.BackColor = Color.FromArgb(69, 73, 74);
            this.ForeColor = Color.Gainsboro;

            this.mFocusColor = SystemColors.Highlight;
            this.mFocusBrush = new SolidBrush(this.mFocusColor);

            this.mBorderColor = Colors.LighterBorder;
            this.mBorderStyle = ButtonBorderStyle.Solid;

            this.mButtonColor = Colors.DarkBackground;
            this.mButtonIcon  = DefaultButtonIcon;

            this.mTextPadding = new Padding(2);
        }
Ejemplo n.º 8
0
        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            Color             col = Color.FromArgb(255, 25, 40, 66);
            ButtonBorderStyle bbs = ButtonBorderStyle.Solid;
            int thickness         = 3;

            ControlPaint.DrawBorder(e.Graphics, this.panel1.ClientRectangle, col, thickness, bbs, col, thickness, bbs, col, thickness, bbs, col, thickness, bbs);
        }
Ejemplo n.º 9
0
 public LayerFormOption()
 {
     IsShow            = true;
     BorderType        = BorderStyle.Fixed3D;
     Border3DStyle     = System.Windows.Forms.Border3DStyle.RaisedInner;
     BorderSingleStyle = ButtonBorderStyle.Solid;
     BorderColor       = Color.DarkGray;
 }
Ejemplo n.º 10
0
 public Settings(Color foreColor, Color backColor, ButtonBorderStyle borderStyle, Font font, Point location)
 {
     ForeColor   = foreColor;
     BackColor   = backColor;
     BorderStyle = borderStyle;
     FontFamily  = font.FontFamily.Name;
     FontSize    = font.Size;
     Location    = location;
 }
 public static void DrawBorder(Graphics graphics, Rectangle bounds, Color leftColor, int leftWidth,
                               ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
                               Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor, int bottomWidth,
                               ButtonBorderStyle bottomStyle)
 {
     ThemeEngine.Current.CPDrawBorder(graphics, bounds, leftColor, leftWidth,
                                      leftStyle, topColor, topWidth, topStyle, rightColor, rightWidth, rightStyle,
                                      bottomColor, bottomWidth, bottomStyle);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 以相同同颜色重写控件相同宽度的相同样式的边框
 /// </summary>
 /// <param name="gra">要画图的矩形区域</param>
 /// <param name="rec">表示矩形的位置和大小</param>
 /// <param name="borderS">边框样式</param>
 /// <param name="borderW">边框宽度</param>
 /// <param name="color">边框颜色</param>
 public static void SetControlBorderStyle(Graphics gra,
                                          Rectangle rec, ButtonBorderStyle borderS, int borderW, Color color)
 {
     ControlPaint.DrawBorder(gra, rec,
                             color, borderW, borderS,  //左边
                             color, borderW, borderS,  //上边
                             color, borderW, borderS,  //右边
                             color, borderW, borderS); //底边
 }
Ejemplo n.º 13
0
 public Button(string text, ButtonKind kind, ButtonBorderStyle style)
 {
     _ButtonBorderStyle = style;
     _Kind     = kind;
     _Text     = text;
     _Visible  = true;
     _Painter  = CreatePainter();
     _ViewInfo = CreateViewInfo();
 }
Ejemplo n.º 14
0
 public BorderPanel()
     : base()
 {
     m_DisplayRectangle = this.ClientRectangle;
     m_DisplayRectangle.Inflate(-BorderWidth, -BorderWidth);
     renderer = new VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal);
     this.SetStyle(ControlStyles.UserPaint, true);
     base.BorderStyle   = BorderStyle.None;
     this.BorderStyle   = BorderStyle.None;
     m_BorderStyle3DExt = ButtonBorderStyle.Inset;
 }
Ejemplo n.º 15
0
 /// <summary>
 /// 以不同颜色重写控件不同宽度的相同样式的边框
 /// </summary>
 /// <param name="gra">要画图的矩形区域</param>
 /// <param name="rec">表示矩形的位置和大小</param>
 /// <param name="borderS">边框样式</param>
 /// <param name="leftW">左边框宽度</param>
 /// <param name="topW">上边框宽度</param>
 /// <param name="rightW">右边框宽度</param>
 /// <param name="bottomW">下边框宽度</param>
 /// <param name="colorLeft">左边框颜色</param>
 /// <param name="colorTop">上边框颜色</param>
 /// <param name="colorRight">右边框颜色</param>
 /// <param name="colorBottom">下边框颜色</param>
 public static void SetControlBorderStyle(Graphics gra,
                                          Rectangle rec, ButtonBorderStyle borderS,
                                          int leftW, int topW, int rightW, int bottomW,
                                          Color colorLeft, Color colorTop, Color colorRight, Color colorBottom)
 {
     ControlPaint.DrawBorder(gra, rec,
                             colorLeft, leftW, borderS,      //左边
                             colorTop, topW, borderS,        //上边
                             colorRight, rightW, borderS,    //右边
                             colorBottom, bottomW, borderS); //底边
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Draw Border around control
        /// </summary>
        /// <param name="e">PaintEventArgs.</param>
        /// <param name="ctrl">Target Control.</param>
        /// <param name="color">Border color.</param>
        /// <param name="borderSize">Border Size.</param>
        /// <param name="borderStyle">Border Style.</param>
        /// <returns>none.</returns>
        public static void DrawBorder(PaintEventArgs e, Control ctrl,
                                      Color?color = null, int borderSize = 1,
                                      ButtonBorderStyle borderStyle = ButtonBorderStyle.Solid)
        {
            Color color2 = color.GetValueOrDefault(Color.Black);

            ControlPaint.DrawBorder(e.Graphics, ctrl.ClientRectangle,
                                    color2, borderSize, borderStyle,
                                    color2, borderSize, borderStyle,
                                    color2, borderSize, borderStyle,
                                    color2, borderSize, borderStyle);
        }
Ejemplo n.º 17
0
 /// <summary>
 ///
 /// </summary>
 public CFloatPopupBaseForm()
 {
     InitializeComponent();
     //初始化基类属性
     this.InitBaseProperties();
     //初始化边框相关
     this.defaultBorderType        = BorderStyle.Fixed3D;
     this.defaultBorder3DStyle     = System.Windows.Forms.Border3DStyle.RaisedInner;
     this.defaultBorderSingleStyle = ButtonBorderStyle.Solid;
     this.defaultBorderColor       = Color.DarkGray;
     //初始化消息筛选器。添加和移除在显示/隐藏时负责
     this.defaultMousMessageFilter = new MouseMessageFilter(this);
 }
Ejemplo n.º 18
0
        //构造函数
        public FloatLayerBase()
        {
            //初始化消息筛选器。添加和移除在显示/隐藏时负责
            _mouseMsgFilter = new AppMouseMessageHandler(this);

            //初始化基类属性
            InitBaseProperties();

            //初始化边框相关
            _borderType        = BorderStyle.Fixed3D;
            _border3DStyle     = System.Windows.Forms.Border3DStyle.RaisedInner;
            _borderSingleStyle = ButtonBorderStyle.Solid;
            _borderColor       = Color.DarkGray;
        }
Ejemplo n.º 19
0
        private static DashStyle BorderStyleToDashStyle(ButtonBorderStyle borderStyle)
        {
            switch (borderStyle)
            {
            case ButtonBorderStyle.Dotted: return(DashStyle.Dot);

            case ButtonBorderStyle.Dashed: return(DashStyle.Dash);

            case ButtonBorderStyle.Solid: return(DashStyle.Solid);

            default:
                return(DashStyle.Solid);
            }
        }
        private static DashStyle BorderStyleToDashStyle(ButtonBorderStyle borderStyle)
        {
            switch (borderStyle)
            {
                case ButtonBorderStyle.Dotted:
                    return DashStyle.Dot;

                case ButtonBorderStyle.Dashed:
                    return DashStyle.Dash;

                case ButtonBorderStyle.Solid:
                    return DashStyle.Solid;
            }
            return DashStyle.Solid;
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Añadir estilos al campo seleccionado.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Style_Selected(object sender, PaintEventArgs e)
        {
            //Marcar control como seleccionado.
            if (sender == FocusedControl)
            {
                Color             col = Color.DarkBlue;
                ButtonBorderStyle bbs = ButtonBorderStyle.Solid;
                int ancho             = 4;

                ControlPaint.DrawBorder(e.Graphics, FocusedControl.ClientRectangle, col, ancho, bbs,
                                        col, ancho, bbs,
                                        col, ancho, bbs,
                                        col, ancho, bbs);
            }
        }
Ejemplo n.º 22
0
        private void dragPanel_DragDrop(object sender, DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
            dirTextBox1.Text   = files[0];
            outputTextBox.Text = Path.GetDirectoryName(files[0]) + "\\" + Path.GetFileNameWithoutExtension(files[0]) + "_ps.exe";
            Globals._Output    = Path.GetDirectoryName(files[0]) + "\\" + Path.GetFileNameWithoutExtension(files[0]) + "_ps.exe";
            FileInfo f = new FileInfo(files[0]);

            filesizeChangeLbl.Text = $"{(f.Length / 1024)}kb";
            dashColor = ButtonBorderStyle.Dashed;
            dragPanel.Invalidate();
            Globals._Module = ModuleDefMD.Load(files[0]);

            extraListBox1.Enabled = true;
            extraListBox2.Enabled = true;
        }
Ejemplo n.º 23
0
 protected override void OnPaint(PaintEventArgs e)
 {
     base.OnPaint(e);
     if (this.BorderStyle == BorderStyle.FixedSingle)
     {
         // ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle, Color.LightGray, ButtonBorderStyle.Solid);
         //Draw Border around the control. Each side is specyfied individually.
         int               borderWidth = 2;
         Color             borderColor = Color.LightGray;
         ButtonBorderStyle borderStyle = ButtonBorderStyle.Solid;
         ControlPaint.DrawBorder(e.Graphics, ClientRectangle,
                                 borderColor, borderWidth, borderStyle,  //Left
                                 borderColor, borderWidth, borderStyle,  //Top
                                 borderColor, borderWidth, borderStyle,  //Right
                                 borderColor, borderWidth, borderStyle); //Bottom
     }
 }
Ejemplo n.º 24
0
        //设置PanelControl边框线
        public static void SetPanelControlBorderLines(PanelControl pnl, bool top, bool left, bool bottom, bool right)
        {
            ButtonBorderStyle topBorder    = top ? ButtonBorderStyle.Solid : ButtonBorderStyle.None;
            ButtonBorderStyle leftBorder   = left ? ButtonBorderStyle.Solid : ButtonBorderStyle.None;
            ButtonBorderStyle bottomBorder = bottom ? ButtonBorderStyle.Solid : ButtonBorderStyle.None;
            ButtonBorderStyle rightBorder  = right ? ButtonBorderStyle.Solid : ButtonBorderStyle.None;

            pnl.BorderStyle = BorderStyles.NoBorder;
            pnl.Paint      += (sender, e) =>
            {
                ControlPaint.DrawBorder(e.Graphics, pnl.ClientRectangle,
                                        Color.FromArgb(135, 182, 236), 1, leftBorder,    //左边
                                        Color.FromArgb(135, 182, 236), 1, topBorder,     //上边
                                        Color.FromArgb(135, 182, 236), 1, rightBorder,   //右边
                                        Color.FromArgb(135, 182, 236), 1, bottomBorder); //底边)
            };
        }
Ejemplo n.º 25
0
        private void button1_Click(object sender, EventArgs e)
        {
            ButtonBorderStyle style = ButtonBorderStyle.Solid;

            switch (comboBox1.SelectedIndex)
            {
            case 0:
                style = ButtonBorderStyle.None;
                break;

            case 1:
                style = ButtonBorderStyle.Dotted;
                break;

            case 2:
                style = ButtonBorderStyle.Dashed;
                break;

            case 3:
                style = ButtonBorderStyle.Solid;
                break;

            case 4:
                style = ButtonBorderStyle.Inset;
                break;

            case 5:
                style = ButtonBorderStyle.Outset;
                break;

            default:
                break;
            }

            panelMonth1.BordWidth = (int)numWidth.Value;

            panelMonth1.BordStyle = style;

            panelMonth1.BordColor = Color.FromArgb((int)numColor1.Value, (int)numColor2.Value, (int)numColor3.Value);
        }
Ejemplo n.º 26
0
        private void TreeViewVisualBrushTable_CellPaint(object sender, TableLayoutCellPaintEventArgs e)
        {
            Color     borderColor = SystemColors.ControlDarkDark;
            const int borderWidth = 1;

            ButtonBorderStyle leftBorderStyle   = ButtonBorderStyle.None;
            ButtonBorderStyle topBorderStyle    = ButtonBorderStyle.None;
            ButtonBorderStyle rightBorderStyle  = ButtonBorderStyle.None;
            ButtonBorderStyle bottomBorderStyle = ButtonBorderStyle.None;

            if (e.Column == 0)
            {
                rightBorderStyle = ButtonBorderStyle.Dotted;
            }

            if (e.Row == 0 || e.Row == 1)
            {
                bottomBorderStyle = ButtonBorderStyle.Dotted;
            }

            ControlPaint.DrawBorder(
                e.Graphics,
                e.CellBounds,
                borderColor,
                borderWidth,
                leftBorderStyle,
                borderColor,
                borderWidth,
                topBorderStyle,
                borderColor,
                borderWidth,
                rightBorderStyle,
                borderColor,
                borderWidth,
                bottomBorderStyle);
        }
Ejemplo n.º 27
0
		public abstract void CPDrawBorder (Graphics graphics, RectangleF bounds, Color leftColor, int leftWidth,
			ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
			Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor,
			int bottomWidth, ButtonBorderStyle bottomStyle);
        public static void DrawBorder(Graphics graphics, Rectangle bounds, Color leftColor, int leftWidth, ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle, Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor, int bottomWidth, ButtonBorderStyle bottomStyle)
        {
            Pen pen;
            if (graphics == null)
            {
                throw new ArgumentNullException("graphics");
            }
            int[] numArray = new int[topWidth];
            int[] numArray2 = new int[topWidth];
            int[] numArray3 = new int[leftWidth];
            int[] numArray4 = new int[leftWidth];
            int[] numArray5 = new int[bottomWidth];
            int[] numArray6 = new int[bottomWidth];
            int[] numArray7 = new int[rightWidth];
            int[] numArray8 = new int[rightWidth];
            float num = 0f;
            float num2 = 0f;
            if (leftWidth > 0)
            {
                num = ((float) topWidth) / ((float) leftWidth);
                num2 = ((float) bottomWidth) / ((float) leftWidth);
            }
            float num3 = 0f;
            float num4 = 0f;
            if (rightWidth > 0)
            {
                num3 = ((float) topWidth) / ((float) rightWidth);
                num4 = ((float) bottomWidth) / ((float) rightWidth);
            }
            HLSColor color = new HLSColor(topColor);
            HLSColor color2 = new HLSColor(leftColor);
            HLSColor color3 = new HLSColor(bottomColor);
            HLSColor color4 = new HLSColor(rightColor);
            if (topWidth > 0)
            {
                int index = 0;
                while (index < topWidth)
                {
                    int num6 = 0;
                    if (num > 0f)
                    {
                        num6 = (int) (((float) index) / num);
                    }
                    int num7 = 0;
                    if (num3 > 0f)
                    {
                        num7 = (int) (((float) index) / num3);
                    }
                    numArray[index] = bounds.X + num6;
                    numArray2[index] = ((bounds.X + bounds.Width) - num7) - 1;
                    if (leftWidth > 0)
                    {
                        numArray3[num6] = (bounds.Y + index) + 1;
                    }
                    if (rightWidth > 0)
                    {
                        numArray7[num7] = bounds.Y + index;
                    }
                    index++;
                }
                for (int i = index; i < leftWidth; i++)
                {
                    numArray3[i] = (bounds.Y + index) + 1;
                }
                for (int j = index; j < rightWidth; j++)
                {
                    numArray7[j] = bounds.Y + index;
                }
            }
            else
            {
                for (int k = 0; k < leftWidth; k++)
                {
                    numArray3[k] = bounds.Y;
                }
                for (int m = 0; m < rightWidth; m++)
                {
                    numArray7[m] = bounds.Y;
                }
            }
            if (bottomWidth > 0)
            {
                int num12 = 0;
                while (num12 < bottomWidth)
                {
                    int num13 = 0;
                    if (num2 > 0f)
                    {
                        num13 = (int) (((float) num12) / num2);
                    }
                    int num14 = 0;
                    if (num4 > 0f)
                    {
                        num14 = (int) (((float) num12) / num4);
                    }
                    numArray5[num12] = bounds.X + num13;
                    numArray6[num12] = ((bounds.X + bounds.Width) - num14) - 1;
                    if (leftWidth > 0)
                    {
                        numArray4[num13] = ((bounds.Y + bounds.Height) - num12) - 1;
                    }
                    if (rightWidth > 0)
                    {
                        numArray8[num14] = ((bounds.Y + bounds.Height) - num12) - 1;
                    }
                    num12++;
                }
                for (int n = num12; n < leftWidth; n++)
                {
                    numArray4[n] = ((bounds.Y + bounds.Height) - num12) - 1;
                }
                for (int num16 = num12; num16 < rightWidth; num16++)
                {
                    numArray8[num16] = ((bounds.Y + bounds.Height) - num12) - 1;
                }
            }
            else
            {
                for (int num17 = 0; num17 < leftWidth; num17++)
                {
                    numArray4[num17] = (bounds.Y + bounds.Height) - 1;
                }
                for (int num18 = 0; num18 < rightWidth; num18++)
                {
                    numArray8[num18] = (bounds.Y + bounds.Height) - 1;
                }
            }
            switch (topStyle)
            {
                case ButtonBorderStyle.Dotted:
                    pen = new Pen(topColor) {
                        DashStyle = DashStyle.Dot
                    };
                    for (int num19 = 0; num19 < topWidth; num19++)
                    {
                        graphics.DrawLine(pen, numArray[num19], bounds.Y + num19, numArray2[num19], bounds.Y + num19);
                    }
                    pen.Dispose();
                    break;

                case ButtonBorderStyle.Dashed:
                    pen = new Pen(topColor) {
                        DashStyle = DashStyle.Dash
                    };
                    for (int num20 = 0; num20 < topWidth; num20++)
                    {
                        graphics.DrawLine(pen, numArray[num20], bounds.Y + num20, numArray2[num20], bounds.Y + num20);
                    }
                    pen.Dispose();
                    break;

                case ButtonBorderStyle.Solid:
                    pen = new Pen(topColor) {
                        DashStyle = DashStyle.Solid
                    };
                    for (int num21 = 0; num21 < topWidth; num21++)
                    {
                        graphics.DrawLine(pen, numArray[num21], bounds.Y + num21, numArray2[num21], bounds.Y + num21);
                    }
                    pen.Dispose();
                    break;

                case ButtonBorderStyle.Inset:
                {
                    float num22 = InfinityToOne(1f / ((float) (topWidth - 1)));
                    for (int num23 = 0; num23 < topWidth; num23++)
                    {
                        pen = new Pen(color.Darker(1f - (num23 * num22))) {
                            DashStyle = DashStyle.Solid
                        };
                        graphics.DrawLine(pen, numArray[num23], bounds.Y + num23, numArray2[num23], bounds.Y + num23);
                        pen.Dispose();
                    }
                    break;
                }
                case ButtonBorderStyle.Outset:
                {
                    float num24 = InfinityToOne(1f / ((float) (topWidth - 1)));
                    for (int num25 = 0; num25 < topWidth; num25++)
                    {
                        pen = new Pen(color.Lighter(1f - (num25 * num24))) {
                            DashStyle = DashStyle.Solid
                        };
                        graphics.DrawLine(pen, numArray[num25], bounds.Y + num25, numArray2[num25], bounds.Y + num25);
                        pen.Dispose();
                    }
                    break;
                }
            }
            pen = null;
            switch (leftStyle)
            {
                case ButtonBorderStyle.Dotted:
                    pen = new Pen(leftColor) {
                        DashStyle = DashStyle.Dot
                    };
                    for (int num26 = 0; num26 < leftWidth; num26++)
                    {
                        graphics.DrawLine(pen, bounds.X + num26, numArray3[num26], bounds.X + num26, numArray4[num26]);
                    }
                    pen.Dispose();
                    break;

                case ButtonBorderStyle.Dashed:
                    pen = new Pen(leftColor) {
                        DashStyle = DashStyle.Dash
                    };
                    for (int num27 = 0; num27 < leftWidth; num27++)
                    {
                        graphics.DrawLine(pen, bounds.X + num27, numArray3[num27], bounds.X + num27, numArray4[num27]);
                    }
                    pen.Dispose();
                    break;

                case ButtonBorderStyle.Solid:
                    pen = new Pen(leftColor) {
                        DashStyle = DashStyle.Solid
                    };
                    for (int num28 = 0; num28 < leftWidth; num28++)
                    {
                        graphics.DrawLine(pen, bounds.X + num28, numArray3[num28], bounds.X + num28, numArray4[num28]);
                    }
                    pen.Dispose();
                    break;

                case ButtonBorderStyle.Inset:
                {
                    float num29 = InfinityToOne(1f / ((float) (leftWidth - 1)));
                    for (int num30 = 0; num30 < leftWidth; num30++)
                    {
                        pen = new Pen(color2.Darker(1f - (num30 * num29))) {
                            DashStyle = DashStyle.Solid
                        };
                        graphics.DrawLine(pen, bounds.X + num30, numArray3[num30], bounds.X + num30, numArray4[num30]);
                        pen.Dispose();
                    }
                    break;
                }
                case ButtonBorderStyle.Outset:
                {
                    float num31 = InfinityToOne(1f / ((float) (leftWidth - 1)));
                    for (int num32 = 0; num32 < leftWidth; num32++)
                    {
                        pen = new Pen(color2.Lighter(1f - (num32 * num31))) {
                            DashStyle = DashStyle.Solid
                        };
                        graphics.DrawLine(pen, bounds.X + num32, numArray3[num32], bounds.X + num32, numArray4[num32]);
                        pen.Dispose();
                    }
                    break;
                }
            }
            pen = null;
            switch (bottomStyle)
            {
                case ButtonBorderStyle.Dotted:
                    pen = new Pen(bottomColor) {
                        DashStyle = DashStyle.Dot
                    };
                    for (int num33 = 0; num33 < bottomWidth; num33++)
                    {
                        graphics.DrawLine(pen, numArray5[num33], ((bounds.Y + bounds.Height) - 1) - num33, numArray6[num33], ((bounds.Y + bounds.Height) - 1) - num33);
                    }
                    pen.Dispose();
                    break;

                case ButtonBorderStyle.Dashed:
                    pen = new Pen(bottomColor) {
                        DashStyle = DashStyle.Dash
                    };
                    for (int num34 = 0; num34 < bottomWidth; num34++)
                    {
                        graphics.DrawLine(pen, numArray5[num34], ((bounds.Y + bounds.Height) - 1) - num34, numArray6[num34], ((bounds.Y + bounds.Height) - 1) - num34);
                    }
                    pen.Dispose();
                    break;

                case ButtonBorderStyle.Solid:
                    pen = new Pen(bottomColor) {
                        DashStyle = DashStyle.Solid
                    };
                    for (int num35 = 0; num35 < bottomWidth; num35++)
                    {
                        graphics.DrawLine(pen, numArray5[num35], ((bounds.Y + bounds.Height) - 1) - num35, numArray6[num35], ((bounds.Y + bounds.Height) - 1) - num35);
                    }
                    pen.Dispose();
                    break;

                case ButtonBorderStyle.Inset:
                {
                    float num36 = InfinityToOne(1f / ((float) (bottomWidth - 1)));
                    for (int num37 = 0; num37 < bottomWidth; num37++)
                    {
                        pen = new Pen(color3.Lighter(1f - (num37 * num36))) {
                            DashStyle = DashStyle.Solid
                        };
                        graphics.DrawLine(pen, numArray5[num37], ((bounds.Y + bounds.Height) - 1) - num37, numArray6[num37], ((bounds.Y + bounds.Height) - 1) - num37);
                        pen.Dispose();
                    }
                    break;
                }
                case ButtonBorderStyle.Outset:
                {
                    float num38 = InfinityToOne(1f / ((float) (bottomWidth - 1)));
                    for (int num39 = 0; num39 < bottomWidth; num39++)
                    {
                        pen = new Pen(color3.Darker(1f - (num39 * num38))) {
                            DashStyle = DashStyle.Solid
                        };
                        graphics.DrawLine(pen, numArray5[num39], ((bounds.Y + bounds.Height) - 1) - num39, numArray6[num39], ((bounds.Y + bounds.Height) - 1) - num39);
                        pen.Dispose();
                    }
                    break;
                }
            }
            pen = null;
            switch (rightStyle)
            {
                case ButtonBorderStyle.None:
                    break;

                case ButtonBorderStyle.Dotted:
                    pen = new Pen(rightColor) {
                        DashStyle = DashStyle.Dot
                    };
                    for (int num40 = 0; num40 < rightWidth; num40++)
                    {
                        graphics.DrawLine(pen, ((bounds.X + bounds.Width) - 1) - num40, numArray7[num40], ((bounds.X + bounds.Width) - 1) - num40, numArray8[num40]);
                    }
                    pen.Dispose();
                    return;

                case ButtonBorderStyle.Dashed:
                    pen = new Pen(rightColor) {
                        DashStyle = DashStyle.Dash
                    };
                    for (int num41 = 0; num41 < rightWidth; num41++)
                    {
                        graphics.DrawLine(pen, ((bounds.X + bounds.Width) - 1) - num41, numArray7[num41], ((bounds.X + bounds.Width) - 1) - num41, numArray8[num41]);
                    }
                    pen.Dispose();
                    return;

                case ButtonBorderStyle.Solid:
                    pen = new Pen(rightColor) {
                        DashStyle = DashStyle.Solid
                    };
                    for (int num42 = 0; num42 < rightWidth; num42++)
                    {
                        graphics.DrawLine(pen, ((bounds.X + bounds.Width) - 1) - num42, numArray7[num42], ((bounds.X + bounds.Width) - 1) - num42, numArray8[num42]);
                    }
                    pen.Dispose();
                    return;

                case ButtonBorderStyle.Inset:
                {
                    float num43 = InfinityToOne(1f / ((float) (rightWidth - 1)));
                    for (int num44 = 0; num44 < rightWidth; num44++)
                    {
                        pen = new Pen(color4.Lighter(1f - (num44 * num43))) {
                            DashStyle = DashStyle.Solid
                        };
                        graphics.DrawLine(pen, ((bounds.X + bounds.Width) - 1) - num44, numArray7[num44], ((bounds.X + bounds.Width) - 1) - num44, numArray8[num44]);
                        pen.Dispose();
                    }
                    return;
                }
                case ButtonBorderStyle.Outset:
                {
                    float num45 = InfinityToOne(1f / ((float) (rightWidth - 1)));
                    for (int num46 = 0; num46 < rightWidth; num46++)
                    {
                        pen = new Pen(color4.Darker(1f - (num46 * num45))) {
                            DashStyle = DashStyle.Solid
                        };
                        graphics.DrawLine(pen, ((bounds.X + bounds.Width) - 1) - num46, numArray7[num46], ((bounds.X + bounds.Width) - 1) - num46, numArray8[num46]);
                        pen.Dispose();
                    }
                    break;
                }
                default:
                    return;
            }
        }
	// Draw a simple button border.
	public virtual void DrawBorder
				(Graphics graphics, Rectangle bounds,
				 Color color, ButtonBorderStyle style)
			{
				Pen pen;
				switch(style)
				{
					case ButtonBorderStyle.Dotted:
					{
						pen = new Pen(color, 1.0f);
						pen.EndCap = LineCap.Square;
						pen.DashStyle = DashStyle.Dot;
						graphics.DrawRectangle(pen, bounds);
						pen.Dispose();
					}
					break;

					case ButtonBorderStyle.Dashed:
					{
						pen = new Pen(color, 1.0f);
						pen.EndCap = LineCap.Square;
						pen.DashStyle = DashStyle.Dash;
						graphics.DrawRectangle(pen, bounds);
						pen.Dispose();
					}
					break;

					case ButtonBorderStyle.Solid:
					{
						pen = new Pen(color, 1.0f);
						pen.EndCap = LineCap.Square;
						Rectangle r = new Rectangle(bounds.X,
							bounds.Y, bounds.Width - 1, bounds.Height - 1);
						graphics.DrawRectangle(pen, r);
						pen.Color = ControlPaint.LightLight(color);
						graphics.DrawLine(pen, bounds.X + 1,
							bounds.Y + bounds.Height - 1,
							bounds.X + bounds.Width - 1,
							bounds.Y + bounds.Height - 1);
						graphics.DrawLine(pen, bounds.X + bounds.Width - 1,
							bounds.Y + bounds.Height - 2,
							bounds.X + bounds.Width - 1,
							bounds.Y + 1);
						pen.Dispose();
					}
					break;

					case ButtonBorderStyle.Inset:
					{
						pen = new Pen(ControlPaint.DarkDark(color), 1.0f);
						pen.EndCap = LineCap.Square;
						graphics.DrawLine(pen, bounds.X,
										  bounds.Y + bounds.Height - 1,
										  bounds.X, bounds.Y);
						graphics.DrawLine(pen, bounds.X + 1, bounds.Y,
										  bounds.X + bounds.Width - 1,
										  bounds.Y);
						pen.Color = ControlPaint.LightLight(color);
						graphics.DrawLine(pen, bounds.X + 1,
										  bounds.Y + bounds.Height - 1,
										  bounds.X + bounds.Width - 1,
										  bounds.Y + bounds.Height - 1);
						graphics.DrawLine(pen, bounds.X + bounds.Width - 1,
										  bounds.Y + bounds.Height - 2,
										  bounds.X + bounds.Width - 1,
										  bounds.Y + 1);
						pen.Color = ControlPaint.Light(color);
						graphics.DrawLine(pen, bounds.X + 1,
										  bounds.Y + bounds.Height - 2,
										  bounds.X + 1, bounds.Y + 1);
						graphics.DrawLine(pen, bounds.X + 2, bounds.Y + 1,
										  bounds.X + bounds.Width - 2,
										  bounds.Y + 1);
						if(color.ToKnownColor() == KnownColor.Control)
						{
							pen.Color = SystemColors.ControlLight;
							graphics.DrawLine(pen, bounds.X + 1,
											  bounds.Y + bounds.Height - 2,
											  bounds.X + bounds.Width - 2,
											  bounds.Y + bounds.Height - 2);
							graphics.DrawLine(pen, bounds.X + bounds.Width - 2,
											  bounds.Y + bounds.Height - 3,
											  bounds.X + bounds.Width - 2,
											  bounds.Y + 1);
						}
						pen.Dispose();
					}
					break;

					case ButtonBorderStyle.Outset:
					{
						pen = new Pen(ControlPaint.LightLight(color), 1.0f);
						pen.EndCap = LineCap.Square;
						graphics.DrawLine(pen, bounds.X,
										  bounds.Y + bounds.Height - 2,
										  bounds.X, bounds.Y);
						graphics.DrawLine(pen, bounds.X + 1, bounds.Y,
										  bounds.X + bounds.Width - 2,
										  bounds.Y);
						pen.Color = ControlPaint.DarkDark(color);
						graphics.DrawLine(pen, bounds.X,
										  bounds.Y + bounds.Height - 1,
										  bounds.X + bounds.Width - 1,
										  bounds.Y + bounds.Height - 1);
						graphics.DrawLine(pen, bounds.X + bounds.Width - 1,
										  bounds.Y + bounds.Height - 2,
										  bounds.X + bounds.Width - 1,
										  bounds.Y);
						pen.Color = ControlPaint.Light(color);
						graphics.DrawLine(pen, bounds.X + 1,
										  bounds.Y + bounds.Height - 3,
										  bounds.X + 1, bounds.Y + 1);
						graphics.DrawLine(pen, bounds.X + 1, bounds.Y + 1,
										  bounds.X + bounds.Width - 3,
										  bounds.Y + 1);
						pen.Color = ControlPaint.Dark(color);
						graphics.DrawLine(pen, bounds.X + 1,
										  bounds.Y + bounds.Height - 2,
										  bounds.X + bounds.Width - 2,
										  bounds.Y + bounds.Height - 2);
						graphics.DrawLine(pen, bounds.X + bounds.Width - 2,
										  bounds.Y + bounds.Height - 3,
										  bounds.X + bounds.Width - 2,
										  bounds.Y + 1);
						pen.Dispose();
					}
					break;
				}
			}
Ejemplo n.º 30
0
		private static void DrawBorderInternal (Graphics graphics, int startX, int startY, int endX, int endY,
			int width, Color color, ButtonBorderStyle style, Border3DSide side) 
		{
			DrawBorderInternal (graphics, (float) startX, (float) startY, (float) endX, (float) endY, 
				width, color, style, side);
		}
Ejemplo n.º 31
0
			public MonthBorderStyles(Month month)
			{
				m_month = month;
				m_borderStyle = ButtonBorderStyle.None;
				m_focusBorderStyle = ButtonBorderStyle.Solid;
				m_selectedBorderStyle = ButtonBorderStyle.Solid;
			}
Ejemplo n.º 32
0
	// Draw a simple button border.
	public static void DrawBorder
				(Graphics graphics, Rectangle bounds,
				 Color color, ButtonBorderStyle style)
			{
				ThemeManager.MainPainter.DrawBorder
					(graphics, bounds, color, style);
			}
Ejemplo n.º 33
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (TabCount <= 0)
            {
                return;
            }

            // clear the initial color
            e.Graphics.Clear(BackColor);

            //Draw a custom background for Transparent TabPages
            StringFormat sf = new StringFormat();

            sf.Alignment     = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Far;

            Rectangle  r = ClientRectangle;
            TabPage    tp;
            SolidBrush PaintBrush      = new SolidBrush(BackColor);
            SolidBrush SelectedBrush   = new SolidBrush(Color.White);
            Pen        BorderPenBottom = new Pen(Color.FromArgb(112, 151, 180));
            Pen        BorderPenTop    = new Pen(Color.FromArgb(149, 178, 199));


            //Draw the Tabs
            for (int index = 0; index <= TabCount - 1; index++)
            {
                tp = TabPages[index];
                r  = GetTabRect(index);

                ButtonBorderStyle bs = ButtonBorderStyle.None;

                // draw the border to seemless
                ControlPaint.DrawBorder(e.Graphics, r, PaintBrush.Color, bs);

                if (index == SelectedIndex)
                {
                    // draw different color for the selected tab
                    int x = 2;
                    int y = 0;
                    if (index == 0)
                    {
                        y = -2;
                    }
                    r.Inflate(x, y);
                    e.Graphics.FillRectangle(SelectedBrush, r);
                    r.Inflate(-x, -y);
                }

                // draw the bottom line of the tab
                if (index != 0)
                {
                    e.Graphics.DrawLine(BorderPenTop, new Point(r.Left, r.Top), new Point(r.Right, r.Top));
                }

                e.Graphics.DrawLine(BorderPenBottom, new Point(r.Left, r.Bottom), new Point(r.Right, r.Bottom));

                PaintBrush.Color = tp.ForeColor;

                //Set up rotation for left and right aligned tabs
                if (Alignment == TabAlignment.Left || Alignment == TabAlignment.Right)
                {
                    PointF cp = new PointF(r.Left + (r.Width >> 1), r.Top + (r.Height >> 1));
                    e.Graphics.TranslateTransform(cp.X, cp.Y);
                    r = new Rectangle(-(r.Height >> 1), -(r.Width >> 1), r.Height, r.Width);
                }

                //Draw the Tab Text
                if (tp.Enabled)
                {
                    e.Graphics.DrawString(tp.Text, Font, PaintBrush, (RectangleF)r, sf);
                }
                else
                {
                    ControlPaint.DrawStringDisabled(e.Graphics, tp.Text, Font, tp.BackColor, (RectangleF)r, sf);
                }

                // draw the tab image
                Image tabImage = null;
                if (this.ImageList != null)
                {
                    TabPage page = this.TabPages[index];
                    if (page.ImageIndex > -1 && page.ImageIndex < this.ImageList.Images.Count)
                    {
                        tabImage = this.ImageList.Images[page.ImageIndex];
                    }

                    if (page.ImageKey.Length > 0 && this.ImageList.Images.ContainsKey(page.ImageKey))
                    {
                        tabImage = this.ImageList.Images[page.ImageKey];
                    }

                    using (Bitmap bm = new Bitmap(r.Width, r.Height))
                    {
                        using (Graphics bmGraphics = Graphics.FromImage(bm))
                        {
                            if (tabImage != null)
                            {
                                Rectangle imageRect = new Rectangle(0, 0, tabImage.Width, tabImage.Height);
                                imageRect.Offset((r.Width - imageRect.Width) / 2, (r.Height - imageRect.Height) / 2);
                                bmGraphics.DrawImage(tabImage, imageRect);
                            }
                        }

                        e.Graphics.DrawImage(bm, r);
                    }
                }

                e.Graphics.ResetTransform();
            }

            BorderPenBottom.Dispose();
            PaintBrush.Dispose();
            SelectedBrush.Dispose();
        }
Ejemplo n.º 34
0
 private void dragPanel_DragLeave(object sender, EventArgs e)
 {
     dashColor = ButtonBorderStyle.Dashed;
     dragPanel.Invalidate();
 }
Ejemplo n.º 35
0
 /// <include file='doc\ControlPaint.uex' path='docs/doc[@for="ControlPaint.BorderStyleToDashStyle"]/*' />
 /// <devdoc>
 ///      Draws a border of the specified style and color to the given graphics.
 /// </devdoc>
 private static DashStyle BorderStyleToDashStyle(ButtonBorderStyle borderStyle) {
     switch (borderStyle) {
         case ButtonBorderStyle.Dotted: return DashStyle.Dot;
         case ButtonBorderStyle.Dashed: return DashStyle.Dash;
         case ButtonBorderStyle.Solid: return DashStyle.Solid;
         default:
             Debug.Fail("border style has no corresponding dash style");
             return DashStyle.Solid;
     }
 } 
Ejemplo n.º 36
0
        public MozPane()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            // TODO: remove the following lines after you know the resource names

            // This call is required by the Windows.Forms Form Designer.
            components = new Container();

            SetStyle(ControlStyles.DoubleBuffer, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.ResizeRedraw, true);
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            SetStyle(ControlStyles.ContainerControl, true);

            m_mozItemCollection = new MozItemCollection(this);

            // Enable Autoscroll
            AutoScroll = true;

            m_padding = new PaddingCollection(this);
            m_colorCollection = new ColorCollection(this);
            m_borderStyleCollection = new BorderStyleCollection(this);
            m_themeManager = new ThemeManager();
            m_selectButton = MozSelectButton.Left;
            m_style = MozPaneStyle.Vertical;
            m_toggle = false;
            m_maxSelectedItems = 1;
            m_selectedItems = 0;

            m_useTheme = false;
            m_theme = IntPtr.Zero;

            // Listen for changes to the parent
            ParentChanged += OnParentChanged;


            beginUpdateCount = 0;

            deserializing = false;
            initialising = false;

            m_borderColor = Color.FromArgb(127, 157, 185);
            BackColor = Color.White;
            m_borderStyle = ButtonBorderStyle.Solid;
        }
Ejemplo n.º 37
0
 public BorderStyleCollection(MozPane pane)
 {
     m_pane = pane;
     m_borderStyle = ButtonBorderStyle.None;
     m_focusBorderStyle = ButtonBorderStyle.Solid;
     m_selectedBorderStyle = ButtonBorderStyle.Solid;
 }
	public static void DrawBorder(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds, System.Drawing.Color leftColor, int leftWidth, ButtonBorderStyle leftStyle, System.Drawing.Color topColor, int topWidth, ButtonBorderStyle topStyle, System.Drawing.Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, System.Drawing.Color bottomColor, int bottomWidth, ButtonBorderStyle bottomStyle) {}
Ejemplo n.º 39
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            e.Graphics.Clear(BackColor);
            Rectangle r = ClientRectangle;

            if (TabCount <= 0)
            {
                return;
            }
            //Draw a custom background for Transparent TabPages
            r = SelectedTab.Bounds;


            StringFormat sf = new StringFormat();

            //sf.Alignment = StringAlignment.Center;
            sf.LineAlignment = StringAlignment.Center;
            Font textFont = Font;

            //Draw a border around TabPage
            r.Inflate(4, 23);

            TabPage tp = TabPages[SelectedIndex];
            //SolidBrush PaintBrush = new SolidBrush(tp.BackColor)

            SolidBrush PaintBrush = new SolidBrush(Color.FromArgb(35, 36, 38));

            e.Graphics.FillRectangle(PaintBrush, r);


            //ControlPaint.DrawBorder(e.Graphics, r, PaintBrush.Color, ButtonBorderStyle.None);

            //Draw the Tabs
            for (int index = 0; index <= TabCount - 1; index++)
            {
                tp = TabPages[index];
                r  = GetTabRect(index);
                ButtonBorderStyle bs = ButtonBorderStyle.None;
                SolidBrush        textBrush;

                if (index == SelectedIndex)
                {
                    bs        = ButtonBorderStyle.None;
                    textBrush = new SolidBrush(Color.Gainsboro);
                    textFont  = new Font(Font, FontStyle.Underline);
                }
                else
                {
                    textBrush = new SolidBrush(Color.White);
                    textFont  = new Font(Font, FontStyle.Regular);
                }
                r.X -= 3;
                PaintBrush.Color = tp.BackColor;
                e.Graphics.FillRectangle(PaintBrush, r);//이곳에서 배경색을 바꿈
                ControlPaint.DrawBorder(e.Graphics, r, PaintBrush.Color, bs);
                PaintBrush.Color = tp.ForeColor;

                //Set up rotation for left and right aligned tabs

                /*
                 * if (Alignment == TabAlignment.Left || Alignment == TabAlignment.Right)
                 * {
                 *  float RotateAngle = 90;
                 *  if (Alignment == TabAlignment.Left) RotateAngle = 270;
                 *  PointF cp = new PointF(r.Left + (r.Width >> 1), r.Top + (r.Height >> 1));
                 *  e.Graphics.TranslateTransform(cp.X, cp.Y);
                 *  e.Graphics.RotateTransform(RotateAngle);
                 *  r = new Rectangle(-(r.Height >> 1), -(r.Width >> 1), r.Height, r.Width);
                 *
                 * }
                 */
                r.Location = new Point(r.Location.X + 10, r.Location.Y);
                //Draw the Tab Text
                if (tp.Enabled)
                {
                    e.Graphics.DrawString(tp.Text, textFont, textBrush, (RectangleF)r, sf);
                }
                else
                {
                    ControlPaint.DrawStringDisabled(e.Graphics, tp.Text, textFont, tp.BackColor, (RectangleF)r, sf);
                }

                e.Graphics.ResetTransform();
            }

            PaintBrush.Dispose();
        }
Ejemplo n.º 40
0
		public static void DrawBorder (Graphics graphics, Rectangle bounds, Color color, ButtonBorderStyle style)
		{
			int line_width_top_left = 1;
			int line_width_bottom_right = 1;
			
			if (style == ButtonBorderStyle.Inset)
				line_width_top_left = 2;
			if (style == ButtonBorderStyle.Outset) {
				line_width_bottom_right = 2;
				line_width_top_left = 2;
			}
			
			DrawBorder(graphics, bounds, color, line_width_top_left, style, color, line_width_top_left, style, color, line_width_bottom_right, style, color, line_width_bottom_right, style);
		}
Ejemplo n.º 41
0
		public override void CPDrawBorder( Graphics dc, Rectangle bounds, Color leftColor, int leftWidth,
						  ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
						  Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor,
						  int bottomWidth, ButtonBorderStyle bottomStyle ) {
			dc.DrawRectangle( ResPool.GetPen( combobox_border_color ), bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1 );
		}
Ejemplo n.º 42
0
 private void dragPanel_DragEnter(object sender, DragEventArgs e)
 {
     dashColor = ButtonBorderStyle.Solid;
     dragPanel.Invalidate();
 }
Ejemplo n.º 43
0
		internal static void DrawBorder (Graphics graphics, RectangleF bounds, Color color, ButtonBorderStyle style)
		{
			int line_width_top_left = 1;
			int line_width_bottom_right = 1;
			
			if (style == ButtonBorderStyle.Inset)
				line_width_top_left = 2;
			if (style == ButtonBorderStyle.Outset) {
				line_width_bottom_right = 2;
				line_width_top_left = 2;
			}
			
			ThemeEngine.Current.CPDrawBorder (graphics, bounds, color, line_width_top_left, style, color, line_width_top_left, style, color, line_width_bottom_right, style, color, line_width_bottom_right, style);
		}
Ejemplo n.º 44
0
 public void DrawBorder(Graphics graphics, Rectangle bounds, Color color, ButtonBorderStyle style)
 {
     ControlPaint.DrawBorder(graphics, bounds, color, style);
 }
Ejemplo n.º 45
0
		public static void DrawBorder( Graphics graphics, Rectangle bounds, Color leftColor, int leftWidth,
			ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
			Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor, int bottomWidth,
			ButtonBorderStyle bottomStyle) {

			ThemeEngine.Current.CPDrawBorder (graphics, bounds, leftColor, leftWidth,
				leftStyle, topColor, topWidth, topStyle, rightColor, rightWidth, rightStyle,
				bottomColor, bottomWidth, bottomStyle);
		}
Ejemplo n.º 46
0
 private void UpdateAppearance()
 {
     if (m_wasMouseDown)
     {
         m_topColor = m_btMiddleColor;
         m_buttonBorderStyle = ButtonBorderStyle.Inset;
         m_wasButtonPressed = true;
         this.Refresh();
     }
     else
     {
         if(m_wasButtonPressed) {
             m_topColor = m_btTopColor;
             m_buttonBorderStyle = ButtonBorderStyle.Outset;
             this.Refresh();
         }
         m_wasButtonPressed = false;
     }
 }
 private static void DrawBorderComplex(Graphics graphics, Rectangle bounds, Color color, ButtonBorderStyle style)
 {
     if (graphics == null)
     {
         throw new ArgumentNullException("graphics");
     }
     if (style == ButtonBorderStyle.Inset)
     {
         HLSColor color2 = new HLSColor(color);
         Pen pen = new Pen(color2.Darker(1f));
         graphics.DrawLine(pen, bounds.X, bounds.Y, (bounds.X + bounds.Width) - 1, bounds.Y);
         graphics.DrawLine(pen, bounds.X, bounds.Y, bounds.X, (bounds.Y + bounds.Height) - 1);
         pen.Color = color2.Lighter(1f);
         graphics.DrawLine(pen, bounds.X, (bounds.Y + bounds.Height) - 1, (bounds.X + bounds.Width) - 1, (bounds.Y + bounds.Height) - 1);
         graphics.DrawLine(pen, (bounds.X + bounds.Width) - 1, bounds.Y, (bounds.X + bounds.Width) - 1, (bounds.Y + bounds.Height) - 1);
         pen.Color = color2.Lighter(0.5f);
         graphics.DrawLine(pen, (int) (bounds.X + 1), (int) (bounds.Y + 1), (int) ((bounds.X + bounds.Width) - 2), (int) (bounds.Y + 1));
         graphics.DrawLine(pen, (int) (bounds.X + 1), (int) (bounds.Y + 1), (int) (bounds.X + 1), (int) ((bounds.Y + bounds.Height) - 2));
         if (color.ToKnownColor() == SystemColors.Control.ToKnownColor())
         {
             pen.Color = SystemColors.ControlLight;
             graphics.DrawLine(pen, (int) (bounds.X + 1), (int) ((bounds.Y + bounds.Height) - 2), (int) ((bounds.X + bounds.Width) - 2), (int) ((bounds.Y + bounds.Height) - 2));
             graphics.DrawLine(pen, (int) ((bounds.X + bounds.Width) - 2), (int) (bounds.Y + 1), (int) ((bounds.X + bounds.Width) - 2), (int) ((bounds.Y + bounds.Height) - 2));
         }
         pen.Dispose();
     }
     else
     {
         bool flag = color.ToKnownColor() == SystemColors.Control.ToKnownColor();
         HLSColor color3 = new HLSColor(color);
         Pen controlDarkDark = flag ? SystemPens.ControlLightLight : new Pen(color3.Lighter(1f));
         graphics.DrawLine(controlDarkDark, bounds.X, bounds.Y, (bounds.X + bounds.Width) - 1, bounds.Y);
         graphics.DrawLine(controlDarkDark, bounds.X, bounds.Y, bounds.X, (bounds.Y + bounds.Height) - 1);
         if (flag)
         {
             controlDarkDark = SystemPens.ControlDarkDark;
         }
         else
         {
             controlDarkDark.Color = color3.Darker(1f);
         }
         graphics.DrawLine(controlDarkDark, bounds.X, (bounds.Y + bounds.Height) - 1, (bounds.X + bounds.Width) - 1, (bounds.Y + bounds.Height) - 1);
         graphics.DrawLine(controlDarkDark, (bounds.X + bounds.Width) - 1, bounds.Y, (bounds.X + bounds.Width) - 1, (bounds.Y + bounds.Height) - 1);
         if (flag)
         {
             if (SystemInformation.HighContrast)
             {
                 controlDarkDark = SystemPens.ControlLight;
             }
             else
             {
                 controlDarkDark = SystemPens.Control;
             }
         }
         else
         {
             controlDarkDark.Color = color;
         }
         graphics.DrawLine(controlDarkDark, (int) (bounds.X + 1), (int) (bounds.Y + 1), (int) ((bounds.X + bounds.Width) - 2), (int) (bounds.Y + 1));
         graphics.DrawLine(controlDarkDark, (int) (bounds.X + 1), (int) (bounds.Y + 1), (int) (bounds.X + 1), (int) ((bounds.Y + bounds.Height) - 2));
         if (flag)
         {
             controlDarkDark = SystemPens.ControlDark;
         }
         else
         {
             controlDarkDark.Color = color3.Darker(0.5f);
         }
         graphics.DrawLine(controlDarkDark, (int) (bounds.X + 1), (int) ((bounds.Y + bounds.Height) - 2), (int) ((bounds.X + bounds.Width) - 2), (int) ((bounds.Y + bounds.Height) - 2));
         graphics.DrawLine(controlDarkDark, (int) ((bounds.X + bounds.Width) - 2), (int) (bounds.Y + 1), (int) ((bounds.X + bounds.Width) - 2), (int) ((bounds.Y + bounds.Height) - 2));
         if (!flag)
         {
             controlDarkDark.Dispose();
         }
     }
 }
Ejemplo n.º 48
0
		public override void CPDrawBorder (Graphics graphics, RectangleF bounds, Color leftColor, int leftWidth,
			ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
			Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor,
			int bottomWidth, ButtonBorderStyle bottomStyle) {
			DrawBorderInternal(graphics, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom-1, leftWidth, leftColor, leftStyle, Border3DSide.Left);
			DrawBorderInternal(graphics, bounds.Left, bounds.Top, bounds.Right-1, bounds.Top, topWidth, topColor, topStyle, Border3DSide.Top);
			DrawBorderInternal(graphics, bounds.Right-1, bounds.Top, bounds.Right-1, bounds.Bottom-1, rightWidth, rightColor, rightStyle, Border3DSide.Right);
			DrawBorderInternal(graphics, bounds.Left, bounds.Bottom-1, bounds.Right-1, bounds.Bottom-1, bottomWidth, bottomColor, bottomStyle, Border3DSide.Bottom);
		}
	public virtual void DrawBorder
				(Graphics graphics, Rectangle bounds, Color leftColor,
			     int leftWidth, ButtonBorderStyle leftStyle, Color topColor,
				 int topWidth, ButtonBorderStyle topStyle, Color rightColor,
				 int rightWidth, ButtonBorderStyle rightStyle,
				 Color bottomColor, int bottomWidth,
				 ButtonBorderStyle bottomStyle)
			{
				Pen pen;
				float percent, change;

				// Paint the left side of the border.
				if(leftWidth > 0)
				{
					switch(leftStyle)
					{
						case ButtonBorderStyle.Dotted:
						{
							pen = new Pen(leftColor, 1.0f);
							pen.EndCap = LineCap.Square;
							pen.DashStyle = DashStyle.Dot;
							while(leftWidth > 0)
							{
								--leftWidth;
								graphics.DrawLine
									(pen, bounds.X + leftWidth,
									 bounds.Y + leftWidth + 1,
									 bounds.X + leftWidth,
									 bounds.Y + bounds.Height - leftWidth - 2);
							}
							pen.Dispose();
						}
						break;

						case ButtonBorderStyle.Dashed:
						{
							pen = new Pen(leftColor, 1.0f);
							pen.EndCap = LineCap.Square;
							pen.DashStyle = DashStyle.Dash;
							while(leftWidth > 0)
							{
								--leftWidth;
								graphics.DrawLine
									(pen, bounds.X + leftWidth,
									 bounds.Y + leftWidth + 1,
									 bounds.X + leftWidth,
									 bounds.Y + bounds.Height - leftWidth - 2);
							}
							pen.Dispose();
						}
						break;

						case ButtonBorderStyle.Solid:
						{
							pen = new Pen(leftColor, 1.0f);
							pen.EndCap = LineCap.Square;
							while(leftWidth > 0)
							{
								--leftWidth;
								graphics.DrawLine
									(pen, bounds.X + leftWidth,
									 bounds.Y + leftWidth + 1,
									 bounds.X + leftWidth,
									 bounds.Y + bounds.Height - leftWidth - 2);
							}
							pen.Dispose();
						}
						break;

						case ButtonBorderStyle.Inset:
						{
							change = (1.0f / leftWidth);
							percent = 1.0f;
							while(leftWidth > 0)
							{
								--leftWidth;
								pen = new Pen(ControlPaint.Dark
												(leftColor, percent), 1.0f);
								pen.EndCap = LineCap.Square;
								graphics.DrawLine
									(pen, bounds.X + leftWidth,
									 bounds.Y + leftWidth + 1,
									 bounds.X + leftWidth,
									 bounds.Y + bounds.Height - leftWidth - 2);
								pen.Dispose();
								percent -= change;
							}
						}
						break;

						case ButtonBorderStyle.Outset:
						{
							change = (1.0f / leftWidth);
							percent = change;
							while(leftWidth > 0)
							{
								--leftWidth;
								pen = new Pen(ControlPaint.Light
												(leftColor, percent), 1.0f);
								pen.EndCap = LineCap.Square;
								graphics.DrawLine
									(pen, bounds.X + leftWidth,
									 bounds.Y + leftWidth + 1,
									 bounds.X + leftWidth,
									 bounds.Y + bounds.Height - leftWidth - 2);
								pen.Dispose();
								percent += change;
							}
						}
						break;
					}
				}

				// Paint the top side of the border.
				if(topWidth > 0)
				{
					switch(topStyle)
					{
						case ButtonBorderStyle.Dotted:
						{
							pen = new Pen(topColor, 1.0f);
							pen.EndCap = LineCap.Square;
							pen.DashStyle = DashStyle.Dot;
							while(topWidth > 0)
							{
								--topWidth;
								graphics.DrawLine
									(pen, bounds.X + topWidth,
									 bounds.Y + topWidth,
									 bounds.X + bounds.Width - 1 - topWidth,
									 bounds.Y + topWidth);
							}
							pen.Dispose();
						}
						break;

						case ButtonBorderStyle.Dashed:
						{
							pen = new Pen(topColor, 1.0f);
							pen.EndCap = LineCap.Square;
							pen.DashStyle = DashStyle.Dash;
							while(topWidth > 0)
							{
								--topWidth;
								graphics.DrawLine
									(pen, bounds.X + topWidth,
									 bounds.Y + topWidth,
									 bounds.X + bounds.Width - 1 - topWidth,
									 bounds.Y + topWidth);
							}
							pen.Dispose();
						}
						break;

						case ButtonBorderStyle.Solid:
						{
							pen = new Pen(topColor, 1.0f);
							pen.EndCap = LineCap.Square;
							while(topWidth > 0)
							{
								--topWidth;
								graphics.DrawLine
									(pen, bounds.X + topWidth,
									 bounds.Y + topWidth,
									 bounds.X + bounds.Width - 1 - topWidth,
									 bounds.Y + topWidth);
							}
							pen.Dispose();
						}
						break;

						case ButtonBorderStyle.Inset:
						{
							change = (1.0f / topWidth);
							percent = 1.0f;
							while(topWidth > 0)
							{
								--topWidth;
								pen = new Pen(ControlPaint.Dark
												(leftColor, percent), 1.0f);
								pen.EndCap = LineCap.Square;
								graphics.DrawLine
									(pen, bounds.X + topWidth,
									 bounds.Y + topWidth,
									 bounds.X + bounds.Width - 1 - topWidth,
									 bounds.Y + topWidth);
								pen.Dispose();
								percent -= change;
							}
						}
						break;

						case ButtonBorderStyle.Outset:
						{
							change = (1.0f / topWidth);
							percent = change;
							while(topWidth > 0)
							{
								--topWidth;
								pen = new Pen(ControlPaint.Light
												(leftColor, percent), 1.0f);
								pen.EndCap = LineCap.Square;
								graphics.DrawLine
									(pen, bounds.X + topWidth,
									 bounds.Y + topWidth,
									 bounds.X + bounds.Width - 1 - topWidth,
									 bounds.Y + topWidth);
								pen.Dispose();
								percent += change;
							}
						}
						break;
					}
				}

				// Paint the right side of the border.
				if(rightWidth > 0)
				{
					switch(rightStyle)
					{
						case ButtonBorderStyle.Dotted:
						{
							pen = new Pen(rightColor, 1.0f);
							pen.EndCap = LineCap.Square;
							pen.DashStyle = DashStyle.Dot;
							while(rightWidth > 0)
							{
								--rightWidth;
								graphics.DrawLine
									(pen,
									 bounds.X + bounds.Width - 1 - rightWidth,
									 bounds.Y + rightWidth,
									 bounds.X + bounds.Width - 1 - rightWidth,
									 bounds.Y + bounds.Height - 1 - rightWidth);
							}
							pen.Dispose();
						}
						break;

						case ButtonBorderStyle.Dashed:
						{
							pen = new Pen(rightColor, 1.0f);
							pen.EndCap = LineCap.Square;
							pen.DashStyle = DashStyle.Dash;
							while(rightWidth > 0)
							{
								--rightWidth;
								graphics.DrawLine
									(pen,
									 bounds.X + bounds.Width - 1 - rightWidth,
									 bounds.Y + rightWidth,
									 bounds.X + bounds.Width - 1 - rightWidth,
									 bounds.Y + bounds.Height - 1 - rightWidth);
							}
							pen.Dispose();
						}
						break;

						case ButtonBorderStyle.Solid:
						{
							pen = new Pen(rightColor, 1.0f);
							pen.EndCap = LineCap.Square;
							while(rightWidth > 0)
							{
								--rightWidth;
								graphics.DrawLine
									(pen,
									 bounds.X + bounds.Width - 1 - rightWidth,
									 bounds.Y + rightWidth,
									 bounds.X + bounds.Width - 1 - rightWidth,
									 bounds.Y + bounds.Height - 1 - rightWidth);
							}
							pen.Dispose();
						}
						break;

						case ButtonBorderStyle.Inset:
						{
							change = (1.0f / rightWidth);
							percent = 1.0f;
							while(rightWidth > 0)
							{
								--rightWidth;
								pen = new Pen(ControlPaint.Dark
												(leftColor, percent), 1.0f);
								pen.EndCap = LineCap.Square;
								graphics.DrawLine
									(pen,
									 bounds.X + bounds.Width - 1 - rightWidth,
									 bounds.Y + rightWidth,
									 bounds.X + bounds.Width - 1 - rightWidth,
									 bounds.Y + bounds.Height - 1 - rightWidth);
								pen.Dispose();
								percent -= change;
							}
						}
						break;

						case ButtonBorderStyle.Outset:
						{
							change = (1.0f / rightWidth);
							percent = change;
							while(rightWidth > 0)
							{
								--rightWidth;
								pen = new Pen(ControlPaint.Light
												(leftColor, percent), 1.0f);
								pen.EndCap = LineCap.Square;
								graphics.DrawLine
									(pen,
									 bounds.X + bounds.Width - 1 - rightWidth,
									 bounds.Y + rightWidth,
									 bounds.X + bounds.Width - 1 - rightWidth,
									 bounds.Y + bounds.Height - 1 - rightWidth);
								pen.Dispose();
								percent += change;
							}
						}
						break;
					}
				}

				// Paint the bottom side of the border.
				if(bottomWidth > 0)
				{
					switch(bottomStyle)
					{
						case ButtonBorderStyle.Dotted:
						{
							pen = new Pen(bottomColor, 1.0f);
							pen.EndCap = LineCap.Square;
							pen.DashStyle = DashStyle.Dot;
							while(bottomWidth > 0)
							{
								--bottomWidth;
								graphics.DrawLine
									(pen,
									 bounds.X + bottomWidth,
									 bounds.Y + bounds.Height - 1 - bottomWidth,
									 bounds.X + bounds.Width - 2 - bottomWidth,
									 bounds.Y +
									 	bounds.Height - 1 - bottomWidth);
							}
							pen.Dispose();
						}
						break;

						case ButtonBorderStyle.Dashed:
						{
							pen = new Pen(bottomColor, 1.0f);
							pen.EndCap = LineCap.Square;
							pen.DashStyle = DashStyle.Dash;
							while(bottomWidth > 0)
							{
								--bottomWidth;
								graphics.DrawLine
									(pen,
									 bounds.X + bottomWidth,
									 bounds.Y + bounds.Height - 1 - bottomWidth,
									 bounds.X + bounds.Width - 2 - bottomWidth,
									 bounds.Y +
									 	bounds.Height - 1 - bottomWidth);
							}
							pen.Dispose();
						}
						break;

						case ButtonBorderStyle.Solid:
						{
							pen = new Pen(bottomColor, 1.0f);
							pen.EndCap = LineCap.Square;
							while(bottomWidth > 0)
							{
								--bottomWidth;
								graphics.DrawLine
									(pen,
									 bounds.X + bottomWidth,
									 bounds.Y + bounds.Height - 1 - bottomWidth,
									 bounds.X + bounds.Width - 2 - bottomWidth,
									 bounds.Y +
									 	bounds.Height - 1 - bottomWidth);
							}
							pen.Dispose();
						}
						break;

						case ButtonBorderStyle.Inset:
						{
							change = (1.0f / bottomWidth);
							percent = 1.0f;
							while(bottomWidth > 0)
							{
								--bottomWidth;
								pen = new Pen(ControlPaint.Dark
												(leftColor, percent), 1.0f);
								pen.EndCap = LineCap.Square;
								graphics.DrawLine
									(pen,
									 bounds.X + bottomWidth,
									 bounds.Y + bounds.Height - 1 - bottomWidth,
									 bounds.X + bounds.Width - 2 - bottomWidth,
									 bounds.Y +
									 	bounds.Height - 1 - bottomWidth);
								pen.Dispose();
								percent -= change;
							}
						}
						break;

						case ButtonBorderStyle.Outset:
						{
							change = (1.0f / bottomWidth);
							percent = change;
							while(bottomWidth > 0)
							{
								--bottomWidth;
								pen = new Pen(ControlPaint.Light
												(leftColor, percent), 1.0f);
								pen.EndCap = LineCap.Square;
								graphics.DrawLine
									(pen,
									 bounds.X + bottomWidth,
									 bounds.Y + bounds.Height - 1 - bottomWidth,
									 bounds.X + bounds.Width - 2 - bottomWidth,
									 bounds.Y +
									 	bounds.Height - 1 - bottomWidth);
								pen.Dispose();
								percent += change;
							}
						}
						break;
					}
				}
			}
Ejemplo n.º 50
0
		private static void DrawBorderInternal (Graphics graphics, float startX, float startY, float endX, float endY,
			int width, Color color, ButtonBorderStyle style, Border3DSide side) {

			Pen pen = null;

			switch (style) {
			case ButtonBorderStyle.Solid:
			case ButtonBorderStyle.Inset:
			case ButtonBorderStyle.Outset:
					pen = ThemeEngine.Current.ResPool.GetDashPen (color, DashStyle.Solid);
					break;
			case ButtonBorderStyle.Dashed:
					pen = ThemeEngine.Current.ResPool.GetDashPen (color, DashStyle.Dash);
					break;
			case ButtonBorderStyle.Dotted:
					pen = ThemeEngine.Current.ResPool.GetDashPen (color, DashStyle.Dot);
					break;
			default:
			case ButtonBorderStyle.None:
					return;
			}

			switch(style) {
			case ButtonBorderStyle.Outset: {
				Color		colorGrade;
				int		hue, brightness, saturation;
				int		brightnessSteps;
				int		brightnessDownSteps;

				ControlPaint.Color2HBS(color, out hue, out brightness, out saturation);

				brightnessDownSteps=brightness/width;
				if (brightness>127) {
					brightnessSteps=Math.Max(6, (160-brightness)/width);
				} else {
					brightnessSteps=(127-brightness)/width;
				}

				for (int i=0; i<width; i++) {
					switch(side) {
					case Border3DSide.Left:	{
						colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
						pen = ThemeEngine.Current.ResPool.GetPen (colorGrade);
						graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
						break;
					}

					case Border3DSide.Right: {
						colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
						pen = ThemeEngine.Current.ResPool.GetPen (colorGrade);
						graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
						break;
					}

					case Border3DSide.Top: {
						colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
						pen = ThemeEngine.Current.ResPool.GetPen (colorGrade);
						graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
						break;
					}

					case Border3DSide.Bottom: {
						colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
						pen = ThemeEngine.Current.ResPool.GetPen (colorGrade);
						graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
						break;
					}
					}
				}
				break;
			}

			case ButtonBorderStyle.Inset: {
				Color		colorGrade;
				int		hue, brightness, saturation;
				int		brightnessSteps;
				int		brightnessDownSteps;

				ControlPaint.Color2HBS(color, out hue, out brightness, out saturation);

				brightnessDownSteps=brightness/width;
				if (brightness>127) {
					brightnessSteps=Math.Max(6, (160-brightness)/width);
				} else {
					brightnessSteps=(127-brightness)/width;
				}

				for (int i=0; i<width; i++) {
					switch(side) {
					case Border3DSide.Left:	{
						colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
						pen = ThemeEngine.Current.ResPool.GetPen (colorGrade);
						graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
						break;
					}

					case Border3DSide.Right: {
						colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
						pen = ThemeEngine.Current.ResPool.GetPen (colorGrade);
						graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
						break;
					}

					case Border3DSide.Top: {
						colorGrade=ControlPaint.HBS2Color(hue, Math.Max(0, brightness-brightnessDownSteps*(width-i)), saturation);
						pen = ThemeEngine.Current.ResPool.GetPen (colorGrade);
						graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
						break;
					}

					case Border3DSide.Bottom: {
						colorGrade=ControlPaint.HBS2Color(hue, Math.Min(255, brightness+brightnessSteps*(width-i)), saturation);
						pen = ThemeEngine.Current.ResPool.GetPen (colorGrade);
						graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
						break;
					}
					}
				}
				break;
			}

				/*
					I decided to have the for-loop duplicated for speed reasons;
					that way we only have to switch once (as opposed to have the
					for-loop around the switch)
				*/
			default: {
				switch(side) {
				case Border3DSide.Left:	{
					for (int i=0; i<width; i++) {
						graphics.DrawLine(pen, startX+i, startY+i, endX+i, endY-i);
					}
					break;
				}

				case Border3DSide.Right: {
					for (int i=0; i<width; i++) {
						graphics.DrawLine(pen, startX-i, startY+i, endX-i, endY-i);
					}
					break;
				}

				case Border3DSide.Top: {
					for (int i=0; i<width; i++) {
						graphics.DrawLine(pen, startX+i, startY+i, endX-i, endY+i);
					}
					break;
				}

				case Border3DSide.Bottom: {
					for (int i=0; i<width; i++) {
						graphics.DrawLine(pen, startX+i, startY-i, endX-i, endY-i);
					}
					break;
				}
				}
				break;
			}
			}
		}
Ejemplo n.º 51
0
        /// <include file='doc\ControlPaint.uex' path='docs/doc[@for="ControlPaint.DrawBorder"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public static void DrawBorder(Graphics graphics, Rectangle bounds, Color color, ButtonBorderStyle style) {
            // Optimized version
            switch (style) {
                case ButtonBorderStyle.None:
                    // nothing
                    break;
                
                case ButtonBorderStyle.Dotted:
                case ButtonBorderStyle.Dashed:
                case ButtonBorderStyle.Solid:
                    DrawBorderSimple(graphics, bounds, color, style);
                    break;

                case ButtonBorderStyle.Inset:
                case ButtonBorderStyle.Outset:
                    DrawBorderComplex(graphics, bounds, color, style);
                    break;

                default:
                    Debug.Fail("Unknown border style");
                    break;
            }
        }
Ejemplo n.º 52
0
Archivo: Theme.cs Proyecto: yonder/mono
 public abstract void CPDrawBorder(Graphics graphics, RectangleF bounds, Color leftColor, int leftWidth,
                                   ButtonBorderStyle leftStyle, Color topColor, int topWidth, ButtonBorderStyle topStyle,
                                   Color rightColor, int rightWidth, ButtonBorderStyle rightStyle, Color bottomColor,
                                   int bottomWidth, ButtonBorderStyle bottomStyle);
Ejemplo n.º 53
0
		public MonthCalendar()
		{
			
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			// TODO: Add any initialization after the InitComponent call
			
			this.SetStyle(ControlStyles.DoubleBuffer, true);
			this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
			this.SetStyle(ControlStyles.UserPaint, true);
			this.SetStyle(ControlStyles.ResizeRedraw, true);
			this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            			
			m_borderColor = Color.Black; 
			m_selectButton = MouseButtons.Left; 
			m_extendedKey = mcExtendedSelectionKey.Ctrl;

           	m_activeRegion = mcCalendarRegion.None; 
			m_selectionMode = mcSelectionMode.MultiSimple; 										
			m_dateTimeFormat = DateTimeFormatInfo.CurrentInfo;
			m_theme = IntPtr.Zero;
										
			m_installedCultures = CultureInfo.GetCultures(CultureTypes.InstalledWin32Cultures);
			m_culture = CultureInfo.CurrentCulture; 
			
			m_showToday = true;
			m_showTrailing = true;
			m_showFocus = true;
			m_todayColor = Color.Red;
			//initiate regions	
			m_weekday = new Weekday(this);
			m_month = new Month(this);
			m_footer = new Footer(this);
			m_weeknumber = new Weeknumber(this);
			m_header = new Header(this);

            m_keyboard = new KeyboardConfig(this);
            m_keyboardEnabled = true;
			m_activeMonth = new ActiveMonth(this);
			m_dateItemCollection = new DateItemCollection(this);
            m_selectedDates = new SelectedDatesCollection(this); 

			// setup callback for weeknumbers
			WeeknumberCallBack = new WeekCallBack(m_weeknumber.CalcWeek);  	
			
			// setup internal events
			m_hook.KeyDown+=new KeyEventHandler(m_hook_KeyDown); 
			m_hook.KeyUp+=new KeyEventHandler(m_hook_KeyUp); 
			
			m_dateItemCollection.DateItemModified+=new DateItemEventHandler(m_dateItemCollection_DateItemModified); 
			
			m_month.DayRender+=new DayRenderEventHandler(m_month_DayRender);
            m_month.DayQueryInfo += new DayQueryInfoEventHandler(m_month_DayQueryInfo);  
            m_month.DayLostFocus+=new DayEventHandler(m_month_DayLostFocus); 
			m_month.DayGotFocus +=new DayEventHandler(m_month_DayGotFocus);
            m_month.ImageClick += new DayClickEventHandler(m_month_ImageClick);
            m_month.DayMouseMove += new DayMouseMoveEventHandler(m_month_DayMouseMove); 
            m_month.DayClick+=new DayClickEventHandler(m_month_DayClick);
			m_month.DayDoubleClick +=new DayClickEventHandler(m_month_DayDoubleClick);	
			m_month.DaySelected+=new DaySelectedEventHandler(m_month_DaySelected); 
			m_month.DayDeselected+=new DaySelectedEventHandler(m_month_DayDeselected); 
			m_month.ColorChanged+=new MonthColorEventHandler(m_month_ColorChanged);
			m_month.BorderStyleChanged+=new MonthBorderStyleEventHandler(m_month_BorderStyleChanged);
			m_month.PropertyChanged+=new MonthPropertyEventHandler(m_month_PropertyChanged);
            m_month.BeforeDaySelected += new DayStateChangedEventHandler(m_month_BeforeDaySelected);
            m_month.BeforeDayDeselected += new DayStateChangedEventHandler(m_month_BeforeDayDeselected); 

			m_footer.Click +=new ClickEventHandler(m_footer_Click);	
			m_footer.DoubleClick +=new ClickEventHandler(m_footer_DoubleClick);
			m_footer.PropertyChanged +=new FooterPropertyEventHandler(m_footer_PropertyChanged);
			
			m_weeknumber.PropertyChanged+=new WeeknumberPropertyEventHandler(m_weeknumber_PropertyChanged); 
			m_weeknumber.Click+=new WeeknumberClickEventHandler(m_weeknumber_Click); 
			m_weeknumber.DoubleClick+=new WeeknumberClickEventHandler(m_weeknumber_DoubleClick); 	
			
			m_weekday.PropertyChanged+=new WeekdayPropertyEventHandler(m_weekday_PropertyChanged); 
			m_weekday.Click+=new WeekdayClickEventHandler(m_weekday_Click); 	
			m_weekday.DoubleClick +=new WeekdayClickEventHandler(m_weekday_DoubleClick);		
			
			m_header.PropertyChanged+=new HeaderPropertyEventHandler(m_header_PropertyChanged); 
			m_header.Click +=new ClickEventHandler(m_header_Click);	
			m_header.DoubleClick +=new ClickEventHandler(m_header_DoubleClick);	
			m_header.PrevMonthButtonClick +=new EventHandler(m_header_PrevMonthButtonClick);		
			m_header.NextMonthButtonClick+=new EventHandler(m_header_NextMonthButtonClick); 		
			m_header.PrevYearButtonClick +=new EventHandler(m_header_PrevYearButtonClick);		
			m_header.NextYearButtonClick+=new EventHandler(m_header_NextYearButtonClick); 		
			

			m_activeMonth.MonthChanged+=new MonthChangedEventHandler(m_activeMonth_MonthChanged);
            m_activeMonth.BeforeMonthChanged += new BeforeMonthChangedEventHandler(m_activeMonth_BeforeMonthChanged); 

			m_printDoc.BeginPrint+=new PrintEventHandler(m_printDoc_BeginPrint); 
			m_printDoc.PrintPage+=new PrintPageEventHandler(m_printDoc_PrintPage);
			m_printDoc.QueryPageSettings+=new QueryPageSettingsEventHandler(m_printDoc_QueryPageSettings); 
			
			m_borderStyle = ButtonBorderStyle.Solid; 
			
			m_printDoc.DocumentName = "MonthCalendar"; 

			m_showFooter = true;
			m_showHeader = true;
			m_showWeekday = true;
						
			m_selectTrailing = true;
            m_selectKeyDown = false;
	
			m_activeMonth.Month = DateTime.Today.Month; 
			m_activeMonth.Year = DateTime.Today.Year;
			  
			m_minDate = DateTime.Now.AddYears(-10);
			m_maxDate = DateTime.Now.AddYears(10);
			
			m_month.SelectedMonth = DateTime.Parse(m_activeMonth.Year+"-"+m_activeMonth.Month+"-01");

            m_hook.InstallKeyboardHook();

            this.Width = 176;
            this.Height = 184;
            m_keyHandled = false;
            Setup();
						
		}
        public static void DrawBorder(Graphics graphics, Rectangle bounds, Color color, ButtonBorderStyle style)
        {
            switch (style)
            {
                case ButtonBorderStyle.None:
                    break;

                case ButtonBorderStyle.Dotted:
                case ButtonBorderStyle.Dashed:
                case ButtonBorderStyle.Solid:
                    DrawBorderSimple(graphics, bounds, color, style);
                    return;

                case ButtonBorderStyle.Inset:
                case ButtonBorderStyle.Outset:
                    DrawBorderComplex(graphics, bounds, color, style);
                    break;

                default:
                    return;
            }
        }
Ejemplo n.º 55
0
        /// <include file='doc\ControlPaint.uex' path='docs/doc[@for="ControlPaint.DrawBorder1"]/*' />
        /// <devdoc>
        ///      Draws a border of the specified style and color to the given graphics.
        /// </devdoc>
        public static void DrawBorder(Graphics graphics, Rectangle bounds,
                                      Color leftColor, int leftWidth, ButtonBorderStyle leftStyle,
                                      Color topColor, int topWidth, ButtonBorderStyle topStyle,
                                      Color rightColor, int rightWidth, ButtonBorderStyle rightStyle,
                                      Color bottomColor, int bottomWidth, ButtonBorderStyle bottomStyle) {
            // Very general, and very slow
            if (graphics == null) {
                throw new ArgumentNullException("graphics");
            }

            int[] topLineLefts = new int[topWidth];
            int[] topLineRights = new int[topWidth];
            int[] leftLineTops = new int[leftWidth];
            int[] leftLineBottoms = new int[leftWidth];
            int[] bottomLineLefts = new int[bottomWidth];
            int[] bottomLineRights = new int[bottomWidth];
            int[] rightLineTops = new int[rightWidth];
            int[] rightLineBottoms = new int[rightWidth];

            float topToLeft = 0.0f;
            float bottomToLeft = 0.0f;
            if (leftWidth > 0) {
                topToLeft = ((float)topWidth)/((float)leftWidth);
                bottomToLeft = ((float)bottomWidth)/((float)leftWidth);
            }
            float topToRight = 0.0f;
            float bottomToRight = 0.0f;
            if (rightWidth > 0) {
                topToRight = ((float)topWidth)/((float)rightWidth);
                bottomToRight = ((float)bottomWidth)/((float)rightWidth);
            }

            HLSColor topHLSColor = new HLSColor(topColor);
            HLSColor leftHLSColor = new HLSColor(leftColor);
            HLSColor bottomHLSColor = new HLSColor(bottomColor);
            HLSColor rightHLSColor = new HLSColor(rightColor);

            if (topWidth > 0) {
                int i=0;
                for (; i<topWidth; i++) {
                    int leftOffset = 0;
                    if (topToLeft > 0) {
                        leftOffset = (int)(((float)i) / topToLeft);
                    }
                    int rightOffset = 0;
                    if (topToRight > 0) {
                        rightOffset = (int)(((float)i) / topToRight);
                    }
                    topLineLefts[i] = bounds.X + leftOffset;
                    topLineRights[i] = bounds.X + bounds.Width - rightOffset - 1;
                    if (leftWidth > 0) {
                        leftLineTops[leftOffset] = bounds.Y + i + 1;
                    }
                    if (rightWidth > 0) {
                        rightLineTops[rightOffset] = bounds.Y + i;
                    }
                }
                for (int j=i; j<leftWidth; j++) {
                    leftLineTops[j] = bounds.Y + i + 1;
                }
                for (int j=i; j<rightWidth; j++) {
                    rightLineTops[j] = bounds.Y + i;
                }
            }
            else {
                for (int i=0; i<leftWidth; i++) {
                    leftLineTops[i] = bounds.Y;
                }
                for (int i=0; i<rightWidth; i++) {
                    rightLineTops[i] = bounds.Y;
                }
            }

            if (bottomWidth > 0) {
                int i=0;
                for (; i<bottomWidth; i++) {
                    int leftOffset = 0;
                    if (bottomToLeft > 0) {
                        leftOffset = (int)(((float)i) / bottomToLeft);
                    }
                    int rightOffset = 0;
                    if (bottomToRight > 0) {
                        rightOffset = (int)(((float)i) / bottomToRight);
                    }
                    bottomLineLefts[i] = bounds.X + leftOffset;
                    bottomLineRights[i] = bounds.X + bounds.Width - rightOffset - 1;
                    if (leftWidth > 0) {
                        leftLineBottoms[leftOffset] = bounds.Y + bounds.Height - i - 1;
                    }
                    if (rightWidth > 0) {
                        rightLineBottoms[rightOffset] = bounds.Y + bounds.Height - i - 1;
                    }
                }
                for (int j=i; j<leftWidth; j++) {
                    leftLineBottoms[j] = bounds.Y + bounds.Height - i - 1;
                }
                for (int j=i; j<rightWidth; j++) {
                    rightLineBottoms[j] = bounds.Y + bounds.Height - i - 1;
                }
            }
            else {
                for (int i=0; i<leftWidth; i++) {
                    leftLineBottoms[i] = bounds.Y + bounds.Height - 1;
                }
                for (int i=0; i<rightWidth; i++) {
                    rightLineBottoms[i] = bounds.Y + bounds.Height - 1;
                }
            }

            Pen pen;

            // draw top line
            switch (topStyle) {
                case ButtonBorderStyle.None:
                    // nothing
                    break;
                case ButtonBorderStyle.Dotted:
                    pen = new Pen(topColor);
                    pen.DashStyle = DashStyle.Dot;
                    for (int i=0; i<topWidth; i++) {
                        graphics.DrawLine(pen, topLineLefts[i], bounds.Y + i, topLineRights[i], bounds.Y + i);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Dashed:
                    pen = new Pen(topColor);
                    pen.DashStyle = DashStyle.Dash;
                    for (int i=0; i<topWidth; i++) {
                        graphics.DrawLine(pen, topLineLefts[i], bounds.Y + i, topLineRights[i], bounds.Y + i);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Solid:
                    pen = new Pen(topColor);
                    pen.DashStyle = DashStyle.Solid;
                    for (int i=0; i<topWidth; i++) {
                        graphics.DrawLine(pen, topLineLefts[i], bounds.Y + i, topLineRights[i], bounds.Y + i);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Inset: {
                        float inc = InfinityToOne(1.0f/(float)(topWidth-1));
                        for (int i=0; i<topWidth; i++) {
                            pen = new Pen(topHLSColor.Darker(1.0f - ((float)i)*inc));
                            pen.DashStyle = DashStyle.Solid;
                            graphics.DrawLine(pen, topLineLefts[i], bounds.Y + i, topLineRights[i], bounds.Y + i);
                            pen.Dispose();
                        }
                        break;
                    }
                case ButtonBorderStyle.Outset: {
                        float inc = InfinityToOne(1.0f/(float)(topWidth-1));

                        for (int i=0; i<topWidth; i++) {
                            pen = new Pen(topHLSColor.Lighter(1.0f - ((float)i)*inc));
                            pen.DashStyle = DashStyle.Solid;
                            graphics.DrawLine(pen, topLineLefts[i], bounds.Y + i, topLineRights[i], bounds.Y + i);
                            pen.Dispose();
                        }
                        break;
                    }
            }

            // Assertion: pen has been disposed
            pen = null;

            // draw left line
            switch (leftStyle) {
                case ButtonBorderStyle.None:
                    // nothing
                    break;
                case ButtonBorderStyle.Dotted:
                    pen = new Pen(leftColor);
                    pen.DashStyle = DashStyle.Dot;
                    for (int i=0; i<leftWidth; i++) {
                        graphics.DrawLine(pen, bounds.X + i, leftLineTops[i], bounds.X + i, leftLineBottoms[i]);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Dashed:
                    pen = new Pen(leftColor);
                    pen.DashStyle = DashStyle.Dash;
                    for (int i=0; i<leftWidth; i++) {
                        graphics.DrawLine(pen, bounds.X + i, leftLineTops[i], bounds.X + i, leftLineBottoms[i]);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Solid:
                    pen = new Pen(leftColor);
                    pen.DashStyle = DashStyle.Solid;
                    for (int i=0; i<leftWidth; i++) {
                        graphics.DrawLine(pen, bounds.X + i, leftLineTops[i], bounds.X + i, leftLineBottoms[i]);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Inset: {
                        float inc = InfinityToOne(1.0f/(float)(leftWidth-1));
                        for (int i=0; i<leftWidth; i++) {
                            pen = new Pen(leftHLSColor.Darker(1.0f - ((float)i)*inc));
                            pen.DashStyle = DashStyle.Solid;
                            graphics.DrawLine(pen, bounds.X + i, leftLineTops[i], bounds.X + i, leftLineBottoms[i]);
                            pen.Dispose();
                        }
                        break;
                    }
                case ButtonBorderStyle.Outset: {
                        float inc = InfinityToOne(1.0f/(float)(leftWidth-1));
                        for (int i=0; i<leftWidth; i++) {
                            pen = new Pen(leftHLSColor.Lighter(1.0f - ((float)i)*inc));
                            pen.DashStyle = DashStyle.Solid;
                            graphics.DrawLine(pen, bounds.X + i, leftLineTops[i], bounds.X + i, leftLineBottoms[i]);
                            pen.Dispose();
                        }
                        break;
                    }
            }

            // Assertion: pen has been disposed
            pen = null;

            // draw bottom line
            switch (bottomStyle) {
                case ButtonBorderStyle.None:
                    // nothing
                    break;
                case ButtonBorderStyle.Dotted:
                    pen = new Pen(bottomColor);
                    pen.DashStyle = DashStyle.Dot;
                    for (int i=0; i<bottomWidth; i++) {
                        graphics.DrawLine(pen, bottomLineLefts[i], bounds.Y + bounds.Height - 1 - i, bottomLineRights[i], bounds.Y + bounds.Height - 1 - i);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Dashed:
                    pen = new Pen(bottomColor);
                    pen.DashStyle = DashStyle.Dash;
                    for (int i=0; i<bottomWidth; i++) {
                        graphics.DrawLine(pen, bottomLineLefts[i], bounds.Y + bounds.Height - 1 - i, bottomLineRights[i], bounds.Y + bounds.Height - 1 - i);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Solid:
                    pen = new Pen(bottomColor);
                    pen.DashStyle = DashStyle.Solid;
                    for (int i=0; i<bottomWidth; i++) {
                        graphics.DrawLine(pen, bottomLineLefts[i], bounds.Y + bounds.Height - 1 - i, bottomLineRights[i], bounds.Y + bounds.Height - 1 - i);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Inset: {
                        float inc = InfinityToOne(1.0f/(float)(bottomWidth-1));
                        for (int i=0; i<bottomWidth; i++) {
                            pen = new Pen(bottomHLSColor.Lighter(1.0f - ((float)i)*inc));
                            pen.DashStyle = DashStyle.Solid;
                            graphics.DrawLine(pen, bottomLineLefts[i], bounds.Y + bounds.Height - 1 - i, bottomLineRights[i], bounds.Y + bounds.Height - 1 - i);
                            pen.Dispose();
                        }
                        break;
                    }
                case ButtonBorderStyle.Outset: {
                        float inc = InfinityToOne(1.0f/(float)(bottomWidth-1));

                        for (int i=0; i<bottomWidth; i++) {
                            pen = new Pen(bottomHLSColor.Darker(1.0f - ((float)i)*inc));
                            pen.DashStyle = DashStyle.Solid;
                            graphics.DrawLine(pen, bottomLineLefts[i], bounds.Y + bounds.Height - 1 - i, bottomLineRights[i], bounds.Y + bounds.Height - 1 - i);
                            pen.Dispose();
                        }
                        break;
                    }
            }

            // Assertion: pen has been disposed
            pen = null;

            // draw right line
            switch (rightStyle) {
                case ButtonBorderStyle.None:
                    // nothing
                    break;
                case ButtonBorderStyle.Dotted:
                    pen = new Pen(rightColor);
                    pen.DashStyle = DashStyle.Dot;
                    for (int i=0; i<rightWidth; i++) {
                        graphics.DrawLine(pen, bounds.X + bounds.Width - 1 - i, rightLineTops[i], bounds.X + bounds.Width - 1 - i, rightLineBottoms[i]);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Dashed:
                    pen = new Pen(rightColor);
                    pen.DashStyle = DashStyle.Dash;
                    for (int i=0; i<rightWidth; i++) {
                        graphics.DrawLine(pen, bounds.X + bounds.Width - 1 - i, rightLineTops[i], bounds.X + bounds.Width - 1 - i, rightLineBottoms[i]);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Solid:
                    pen = new Pen(rightColor);
                    pen.DashStyle = DashStyle.Solid;
                    for (int i=0; i<rightWidth; i++) {
                        graphics.DrawLine(pen, bounds.X + bounds.Width - 1 - i, rightLineTops[i], bounds.X + bounds.Width - 1 - i, rightLineBottoms[i]);
                    }
                    pen.Dispose();
                    break;
                case ButtonBorderStyle.Inset: {
                        float inc = InfinityToOne(1.0f/(float)(rightWidth-1));
                        for (int i=0; i<rightWidth; i++) {
                            pen = new Pen(rightHLSColor.Lighter(1.0f - ((float)i)*inc));
                            pen.DashStyle = DashStyle.Solid;
                            graphics.DrawLine(pen, bounds.X + bounds.Width - 1 - i, rightLineTops[i], bounds.X + bounds.Width - 1 - i, rightLineBottoms[i]);
                            pen.Dispose();
                        }
                        break;
                    }
                case ButtonBorderStyle.Outset: {
                        float inc = InfinityToOne(1.0f/(float)(rightWidth-1));

                        for (int i=0; i<rightWidth; i++) {
                            pen = new Pen(rightHLSColor.Darker(1.0f - ((float)i)*inc));
                            pen.DashStyle = DashStyle.Solid;
                            graphics.DrawLine(pen, bounds.X + bounds.Width - 1 - i, rightLineTops[i], bounds.X + bounds.Width - 1 - i, rightLineBottoms[i]);
                            pen.Dispose();
                        }

                        break;
                    }
            }
        }
	public static void DrawBorder(System.Drawing.Graphics graphics, System.Drawing.Rectangle bounds, System.Drawing.Color color, ButtonBorderStyle style) {}
Ejemplo n.º 57
0
		/// <summary>
		/// Initializes a new instance of the <see cref="NuGenCalendar"/> class.
		/// </summary>
		/// <param name="serviceProvider">
		/// <para>Requires:</para>
		/// <para><see cref="INuGenControlStateService"/></para>
		/// <para><see cref="INuGenCalendarRenderer"/></para>
		/// </param>
		public NuGenCalendar(INuGenServiceProvider serviceProvider)
			: base(serviceProvider)
		{
			this.SetStyle(ControlStyles.DoubleBuffer, true);
			this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
			this.SetStyle(ControlStyles.UserPaint, true);
			this.SetStyle(ControlStyles.ResizeRedraw, true);
			this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);

			_borderColor = Color.Black;
			_selectButton = MouseButtons.Left;
			_extendedKey = NuGenExtendedSelectionKey.Ctrl;

			_activeRegion = NuGenCalendarRegion.None;
			_selectionMode = NuGenSelectionMode.MultiSimple;
			_dateTimeFormat = DateTimeFormatInfo.CurrentInfo;
			_theme = IntPtr.Zero;

			_installedCultures = CultureInfo.GetCultures(CultureTypes.InstalledWin32Cultures);
			_culture = CultureInfo.CurrentCulture;

			_showToday = true;
			_showTrailing = true;
			_showFocus = true;
			_todayColor = Color.Red;
			//initiate regions	
			_weekday = new NuGenWeekday(this);
			_month = new NuGenMonth(this);
			_footer = new NuGenFooter(this);
			_weeknumber = new NuGenWeeknumber(this);
			_header = new NuGenHeader(this, serviceProvider);

			_keyboard = new KeyboardConfig(this);
			_keyboardEnabled = true;
			_activeMonth = new NuGenActiveMonth(this);
			_dateItemCollection = new NuGenDateItemCollection(this);
			_selectedDates = new NuGenSelectedDatesCollection(this);

			// setup callback for weeknumbers
			WeeknumberCallBack = new NuGenWeekCallback(_weeknumber.CalcWeek);

			// setup internal events
			_hook.KeyDown += new KeyEventHandler(m_hook_KeyDown);
			_hook.KeyUp += new KeyEventHandler(m_hook_KeyUp);

			_dateItemCollection.DateItemModified += m_dateItemCollection_DateItemModified;

			_month.DayRender += m_month_DayRender;
			_month.DayQueryInfo += m_month_DayQueryInfo;
			_month.DayLostFocus += m_month_DayLostFocus;
			_month.DayGotFocus += m_month_DayGotFocus;
			_month.ImageClick += m_month_ImageClick;
			_month.DayMouseMove += m_month_DayMouseMove;
			_month.DayClick += m_month_DayClick;
			_month.DayDoubleClick += m_month_DayDoubleClick;
			_month.DaySelected += m_month_DaySelected;
			_month.DayDeselected += m_month_DayDeselected;
			_month.ColorChanged += m_month_ColorChanged;
			_month.BorderStyleChanged += m_month_BorderStyleChanged;
			_month.PropertyChanged += m_month_PropertyChanged;
			_month.BeforeDaySelected += m_month_BeforeDaySelected;
			_month.BeforeDayDeselected += m_month_BeforeDayDeselected;

			_footer.Click += m_footer_Click;
			_footer.DoubleClick += m_footer_DoubleClick;
			_footer.PropertyChanged += m_footer_PropertyChanged;

			_weeknumber.PropertyChanged += m_weeknumber_PropertyChanged;
			_weeknumber.Click += m_weeknumber_Click;
			_weeknumber.DoubleClick += m_weeknumber_DoubleClick;

			_weekday.PropertyChanged += m_weekday_PropertyChanged;
			_weekday.Click += m_weekday_Click;
			_weekday.DoubleClick += m_weekday_DoubleClick;

			_header.PropertyChanged += m_header_PropertyChanged;
			_header.Click += m_header_Click;
			_header.DoubleClick += m_header_DoubleClick;
			_header.PrevMonthButtonClick += m_header_PrevMonthButtonClick;
			_header.NextMonthButtonClick += m_header_NextMonthButtonClick;
			_header.PrevYearButtonClick += m_header_PrevYearButtonClick;
			_header.NextYearButtonClick += m_header_NextYearButtonClick;


			_activeMonth.MonthChanged += m_activeMonth_MonthChanged;
			_activeMonth.BeforeMonthChanged += m_activeMonth_BeforeMonthChanged;

			_printDoc.BeginPrint += m_printDoc_BeginPrint;
			_printDoc.PrintPage += m_printDoc_PrintPage;
			_printDoc.QueryPageSettings += m_printDoc_QueryPageSettings;

			_borderStyle = ButtonBorderStyle.Solid;

			_printDoc.DocumentName = "MonthCalendar";

			_showFooter = true;
			_showHeader = true;
			_showWeekday = true;

			_selectTrailing = true;
			_selectKeyDown = false;

			_activeMonth.Month = DateTime.Today.Month;
			_activeMonth.Year = DateTime.Today.Year;

			_minDate = DateTime.Now.AddYears(-10);
			_maxDate = DateTime.Now.AddYears(10);

			_month.SelectedMonth = DateTime.Parse(_activeMonth.Year + "-" + _activeMonth.Month + "-01");

			_hook.InstallKeyboardHook();
			_keyHandled = false;
			this.Size = new Size(250, 250);
			Setup();
			this.UseTheme = true;
		}
 private static void DrawBorderSimple(Graphics graphics, Rectangle bounds, Color color, ButtonBorderStyle style)
 {
     Pen pen;
     if (graphics == null)
     {
         throw new ArgumentNullException("graphics");
     }
     bool flag = (style == ButtonBorderStyle.Solid) && color.IsSystemColor;
     if (flag)
     {
         pen = SystemPens.FromSystemColor(color);
     }
     else
     {
         pen = new Pen(color);
         if (style != ButtonBorderStyle.Solid)
         {
             pen.DashStyle = BorderStyleToDashStyle(style);
         }
     }
     graphics.DrawRectangle(pen, bounds.X, bounds.Y, bounds.Width - 1, bounds.Height - 1);
     if (!flag)
     {
         pen.Dispose();
     }
 }
Ejemplo n.º 59
0
        /// <devdoc>
        ///     Helper function that draws a more complex border.  This is used by DrawBorder for less common
        ///     rendering cases.  We split DrawBorder into DrawBorderSimple and DrawBorderComplex so we maximize
        ///     the % of the function call.  It is less performant to have large functions that do many things.
        /// </devdoc>
        private static void DrawBorderComplex(Graphics graphics, Rectangle bounds, Color color, ButtonBorderStyle style) {
            if (graphics == null) {
                throw new ArgumentNullException("graphics");
            }
            if (style == ButtonBorderStyle.Inset) { // button being pushed
                HLSColor hls = new HLSColor(color);

                // top + left
                Pen pen = new Pen(hls.Darker(1.0f));
                graphics.DrawLine(pen, bounds.X, bounds.Y, 
                                  bounds.X + bounds.Width - 1, bounds.Y);
                graphics.DrawLine(pen, bounds.X, bounds.Y, 
                                  bounds.X, bounds.Y + bounds.Height - 1);

                // bottom + right
                pen.Color = hls.Lighter(1.0f);
                graphics.DrawLine(pen, bounds.X, bounds.Y + bounds.Height - 1, 
                                  bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
                graphics.DrawLine(pen, bounds.X + bounds.Width - 1, bounds.Y, 
                                  bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);

                // Top + left inset
                pen.Color = hls.Lighter(0.5f);
                graphics.DrawLine(pen, bounds.X + 1, bounds.Y + 1,
                                      bounds.X + bounds.Width - 2, bounds.Y + 1);
                graphics.DrawLine(pen, bounds.X + 1, bounds.Y + 1,
                                  bounds.X + 1, bounds.Y + bounds.Height - 2);

                // bottom + right inset
                if (color.ToKnownColor() == SystemColors.Control.ToKnownColor()) {
                    pen.Color = SystemColors.ControlLight;
                    graphics.DrawLine(pen, bounds.X + 1, bounds.Y + bounds.Height - 2,
                                              bounds.X + bounds.Width - 2, bounds.Y + bounds.Height - 2);
                    graphics.DrawLine(pen, bounds.X + bounds.Width - 2, bounds.Y + 1,
                                      bounds.X + bounds.Width - 2, bounds.Y + bounds.Height - 2);
                }

                pen.Dispose();
            }
            else { // Standard button
                Debug.Assert(style == ButtonBorderStyle.Outset, "Caller should have known how to use us.");
                
                bool stockColor = color.ToKnownColor() == SystemColors.Control.ToKnownColor();
                HLSColor hls = new HLSColor(color);

                // top + left
                Pen pen = stockColor ? SystemPens.ControlLightLight : new Pen(hls.Lighter(1.0f));
                graphics.DrawLine(pen, bounds.X, bounds.Y,
                                            bounds.X + bounds.Width - 1, bounds.Y);
                graphics.DrawLine(pen, bounds.X, bounds.Y, 
                                  bounds.X, bounds.Y + bounds.Height - 1);
                // bottom + right
                if (stockColor) {
                    pen = SystemPens.ControlDarkDark;
                }
                else {
                    pen.Color = hls.Darker(1.0f);
                }
                graphics.DrawLine(pen, bounds.X, bounds.Y + bounds.Height - 1, 
                                  bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
                graphics.DrawLine(pen, bounds.X + bounds.Width - 1, bounds.Y, 
                                  bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1);
                // top + left inset
                if (stockColor) {
                    if (SystemInformation.HighContrast) {
                        pen = SystemPens.ControlLight;
                    }
                    else {
                        pen = SystemPens.Control;
                    }
                }
                else {
                    pen.Color = color;
                }
                graphics.DrawLine(pen, bounds.X + 1, bounds.Y + 1,
                                  bounds.X + bounds.Width - 2, bounds.Y + 1);
                graphics.DrawLine(pen, bounds.X + 1, bounds.Y + 1,
                                  bounds.X + 1, bounds.Y + bounds.Height - 2);

                // Bottom + right inset                        
                if (stockColor) {
                    pen = SystemPens.ControlDark;
                }
                else {
                    pen.Color = hls.Darker(0.5f);
                }

                graphics.DrawLine(pen, bounds.X + 1, bounds.Y + bounds.Height - 2,
                                  bounds.X + bounds.Width - 2, bounds.Y + bounds.Height - 2);
                graphics.DrawLine(pen, bounds.X + bounds.Width - 2, bounds.Y + 1,
                                  bounds.X + bounds.Width - 2, bounds.Y + bounds.Height - 2);
                                  
                if (!stockColor) {
                    pen.Dispose();
                }
            }
        }