Ejemplo n.º 1
0
        private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            Graphics  g = e.Graphics;
            Rectangle r = new Rectangle(10, 10, 100, 100);

            // A gradient brush.
            LinearGradientBrush theBrush = null;
            int yOffSet = 10;

            // Get all members of the LinearGradientMode enum.
            Array obj = Enum.GetValues(typeof(LinearGradientMode));

            // Draw an oval with a LinearGradientMode member.
            for (int x = 0; x < obj.Length; x++)
            {
                // Configure Brush.
                LinearGradientMode temp = (LinearGradientMode)obj.GetValue(x);
                theBrush = new LinearGradientBrush(r, Color.Red,
                                                   Color.Blue, temp);

                // Print name of LinearGradientMode enum.
                g.DrawString(temp.ToString(), new Font("Times New Roman", 10),
                             new SolidBrush(Color.Black), 0, yOffSet);

                // Fill a rectangle with the correct brush.
                g.FillRectangle(theBrush, 150, yOffSet, 200, 50);
                yOffSet += 80;
            }
        }
Ejemplo n.º 2
0
        void PaintView1(Graphics g)
        {
            Rectangle r = new Rectangle(10, 10, 100, 100);

            LinearGradientBrush theBrush = null;
            int yOffSet = 10;

            Array obj = Enum.GetValues(typeof(LinearGradientMode));

            for (int x = 0; x < obj.Length; x++)
            {
                LinearGradientMode temp = (LinearGradientMode)obj.GetValue(x);
                theBrush = new LinearGradientBrush(r, Color.Red,
                                                   Color.Blue, temp);

                theBrush.LinearColors = new Color[] { Color.Red, Color.Blue };
                g.DrawString(temp.ToString(), new Font("Times New Roman", 11),
                             new SolidBrush(Color.Black), 0, yOffSet);

                g.FillRectangle(theBrush, 120, yOffSet, 200, 50);

                RectangleF boundingRec4 = theBrush.Rectangle;
                var        pennn4       = new Pen(Color.Green, 1);
                g.DrawRectangle(pennn4, boundingRec4.X, boundingRec4.Y, boundingRec4.Width, boundingRec4.Height);

                yOffSet += 80;
            }
        }
Ejemplo n.º 3
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            Graphics  grfx      = e.Graphics;
            Rectangle rectColor = new Rectangle(e.Bounds.Left, e.Bounds.Top, 2 * e.Bounds.Height, e.Bounds.Height);

            rectColor.Inflate(-1, -1);

            Rectangle rectText = new Rectangle(e.Bounds.Left + 2 * e.Bounds.Height,
                                               e.Bounds.Top,
                                               e.Bounds.Width - 2 * e.Bounds.Height,
                                               e.Bounds.Height);

            if (this.Enabled)
            {
                e.DrawBackground();
            }

            LinearGradientMode item = e.Index >= 0 ? (LinearGradientMode)Items[e.Index] : LinearGradientMode.Horizontal;

            using (LinearGradientBrush br = new LinearGradientBrush(rectColor, e.ForeColor, e.BackColor, item))
            {
                grfx.FillRectangle(br, rectColor);
            }

            using (SolidBrush foreColorBrush = new SolidBrush(e.ForeColor))
            {
                grfx.DrawString(item.ToString(), Font, foreColorBrush, rectText);
            }
        }
Ejemplo n.º 4
0
        public Config GetConfig(Logger l)
        {
            Config cn = new Config(l);

            cn.BeginSection("[MainWindow]");
            cn.AddEntry("Opacity", opacity.ToString());
            cn.AddEntry("Color", color.Name);

            cn.BeginSection("[MainText]");
            cn.AddEntry("FontName", textFont.Name);
            cn.AddEntry("FontSize", textFont.Size.ToString());
            cn.AddEntry("Color", textColor.Name);

            cn.BeginSection("[DesktopText]");
            cn.AddEntry("FontName", desktopFont.Name);
            cn.AddEntry("FontSize", desktopFont.Size.ToString());
            cn.AddEntry("Color1", desktopLabelColor1.Name);
            cn.AddEntry("Color2", desktopLabelColor2.Name);
            cn.AddEntry("X", desktopLabelCoordinates.X.ToString());
            cn.AddEntry("Y", desktopLabelCoordinates.Y.ToString());
            cn.AddEntry("Effect", desktopLabelEffect.ToString());
            return(cn);
        }
Ejemplo n.º 5
0
        public Config GetConfig()
        {
            Config cn = new Config();

            cn.BeginSection("[MainWindow]");
            cn.AddEntry("Opacity", MOpacity.ToString());
            cn.AddEntry("Color", MColor.ToString());

            cn.BeginSection("[MainText]");
            cn.AddEntry("FontName", TextFont.FontFamily.ToString());
            cn.AddEntry("FontSize", TextFont.Size.ToString());
            cn.AddEntry("Color", TextColor.ToString());

            cn.BeginSection("[DesktopText]");
            cn.AddEntry("FontName", DeskFont.FontFamily.ToString());
            cn.AddEntry("FontSize", DeskFont.Size.ToString());
            cn.AddEntry("Color1", DeskColor1.ToString());
            cn.AddEntry("Color2", DeskColor2.ToString());
            cn.AddEntry("X", DeskX.ToString());
            cn.AddEntry("Y", DeskY.ToString());
            cn.AddEntry("Effect", DeskEffect.ToString());
            return(cn);
        }
Ejemplo n.º 6
0
        public void DrawSolidCircleAndChangeBrushes(Graphics graphicsMain, int brushesTypeCounter)
        {
            graphicsMain = form1.panelForDisplaying.CreateGraphics();
            graphicsMain.SmoothingMode = SmoothingMode.HighQuality;

            if (brushesTypeCounter == 6)
            {
                brushesTypeCounter = 1;
            }
            switch (brushesTypeCounter)
            {
            case 1:
            {
                SolidBrush mySolidBrush = new SolidBrush(RandomColor.getRandomColor());
                graphicsMain.FillEllipse(mySolidBrush, 50, 50, 100, 100);
                form1.labelDescriptionOfMode.Text = "SolidBrush";
                brushesTypeCounter++;
            } break;

            case 2:
            {
                Random     random           = new Random();
                var        value            = Enum.GetValues(typeof(HatchStyle));
                HatchStyle randomHatchStyle = (HatchStyle)value.GetValue(random.Next(value.Length));

                HatchBrush myHatchBrush = new HatchBrush(randomHatchStyle,
                                                         RandomColor.getRandomColor(), RandomColor.getRandomColor());

                graphicsMain.FillEllipse(myHatchBrush, 50, 50, 100, 100);

                form1.labelDescriptionOfMode.Text = "HatchBrush";
                form1.labelForBrushMode.Text      = randomHatchStyle.ToString();
                brushesTypeCounter++;
            } break;

            case 3:
            {
                TextureBrush myTextureBrush = new TextureBrush(new Bitmap(
                                                                   "D:\\water.jpg"));
                graphicsMain.FillEllipse(myTextureBrush, 50, 50, 100, 100);

                form1.labelDescriptionOfMode.Text = "TextureBrush";
                form1.labelForBrushMode.Text      = "";

                brushesTypeCounter++;
            } break;

            case 4:
            {
                Random             random          = new Random();
                var                values          = Enum.GetValues(typeof(LinearGradientMode));
                LinearGradientMode randLinGradMode = (LinearGradientMode)values.GetValue(random.Next(values.Length));

                LinearGradientBrush myLinGradBrush = new LinearGradientBrush(
                    new Rectangle(50, 50, 100, 100), Color.Black, Color.Blue,
                    randLinGradMode);
                graphicsMain.FillEllipse(myLinGradBrush, 50, 50, 100, 100);

                form1.labelDescriptionOfMode.Text = "LinearGradientBrush";
                form1.labelForBrushMode.Text      = randLinGradMode.ToString();

                brushesTypeCounter++;
                form1.labelForBrushMode.Text = "";
            } break;

            case 5:
            {
                GraphicsPath path = new GraphicsPath();
                path.AddEllipse(50, 50, 100, 100);
                PathGradientBrush myPathGradBrush = new PathGradientBrush(path);
                myPathGradBrush.CenterColor = RandomColor.getRandomColor();
                Color[] myColors = { RandomColor.getRandomColor() };
                myPathGradBrush.SurroundColors = myColors;

                graphicsMain.FillEllipse(myPathGradBrush, 50, 50, 100, 100);

                form1.labelDescriptionOfMode.Text = "PathGradientBrush";
                brushesTypeCounter++;
            } break;
            }
        }