public static GeoHatchStyle ConvertBack(HatchStyle drawingHatchStyle) { GeoHatchStyle geoHatchStyle = GeoHatchStyle.BackwardDiagonal; Enum.TryParse <GeoHatchStyle>(drawingHatchStyle.ToString(), out geoHatchStyle); return(geoHatchStyle); }
public Form1() { InitializeComponent(); fyear = 1988; arr_values = new int[] { 150, 170, 180, 175, 200, 250, 210, 240, 280, 140 }; // T_fontstring = "Times New Roman"; T_fontsize = 16; T_text = "ABC Company"; T_color = Color.Black; T_format = new StringFormat(); T_format.Alignment = StringAlignment.Center; // rect_color = Color.DarkKhaki; rect_pen = new Pen(rect_color); // rect_stpoint = new Point(ClientSize.Width -60, ClientSize - 20); rect_stptx = this.Width; rect_stpty = 80; rect_length = 550; rect_width = 500; // C_font = new Font("Times New Roman", 14); C_textcolor = Color.Aqua; C_brush = new SolidBrush(C_textcolor); C_Format = new StringFormat(); C_Format.Alignment = StringAlignment.Center; C_Format.LineAlignment = StringAlignment.Center; // l_color = Color.Ivory; // l_brush = new SolidBrush(l_color); l_pen = new Pen(l_color, 3.5f); l_stpt = new Point(40, 650); l_pen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor; l_endpth = new Point(640, 650); l_endptv = new Point(40, 80); chart_width = 600; chart_length = 560; // label_font = new Font("Times New Roman", 8); label_tcolor = Color.DarkGoldenrod; label_brush = new SolidBrush(label_tcolor); // BC_color = Color.DarkRed; BC_style = HatchStyle.BackwardDiagonal; BC_brush = new HatchBrush(BC_style, BC_color); BC_width = 20; // LC_color = Color.DeepSkyBlue; LC_pen = new Pen(Color.Blue, 3.5f); // this.toolStripMenuItem1.Text = BC_color.ToString(); this.toolStripMenuItem1.Checked = checked (true); this.toolStripMenuItem2.Text = BC_style.ToString(); this.toolStripMenuItem2.Checked = checked (true); }
public static int GetWidthOfHatchStyle(Graphics g, Font font, int index) { HatchStyle hatchStyle = StiBrushes.HatchStyles[index]; string str = StiLocalization.Get("PropertyHatchStyle", hatchStyle.ToString()); int strWidth = (int)g.MeasureString(str, font).Width; return(strWidth + 40); }
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { HatchStyle hatchStyle = (HatchStyle)value; return(StiLocalization.Get("PropertyHatchStyle", hatchStyle.ToString())); } return(base.ConvertTo(context, culture, value, destinationType)); }
public Brush Brush(HatchStyle style, Color foreColor, Color backColor) { this.m_StringBuilder.Length = 0; this.m_StringBuilder.Append(style.ToString()); this.m_StringBuilder.Append(foreColor.GetHashCode().ToString()); this.m_StringBuilder.Append(backColor.GetHashCode().ToString()); string key = this.m_StringBuilder.ToString(); Brush brush = this.m_CacheBrushes[key] as Brush; if (brush == null) { brush = new HatchBrush(style, foreColor, backColor); this.m_CacheBrushes.Add(key, brush); } return(brush); }
protected override void OnDrawItem(DrawItemEventArgs e) { e.DrawBackground(); Graphics g = e.Graphics; if (e.Index >= 0) { HatchStyle style = (HatchStyle)Items[e.Index]; Rectangle rect = new Rectangle(e.Bounds.Left + 2, e.Bounds.Top + 2, 20, 20); using (Brush b = new HatchBrush(style, Color.Black, Color.White)) { g.FillRectangle(b, rect); g.DrawRectangle(Pens.Black, rect); using (Brush br = new SolidBrush(e.ForeColor)) { g.DrawString(style.ToString(), e.Font, br, e.Bounds.Left + 28, e.Bounds.Top + 5); } } } }
private void MainForm_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; int yOffSet = 10; // Get all members of the HatchStyle enum. Array obj = Enum.GetValues(typeof(HatchStyle)); // Draw an oval with first 5 HatchStyle values. for (int x = 0; x < 5; x++) { // Configure Brush. HatchStyle temp = (HatchStyle)obj.GetValue(x); HatchBrush theBrush = new HatchBrush(temp, Color.White, Color.Black); // Print name of HatchStyle enum. g.DrawString(temp.ToString(), new Font("Times New Roman", 10), Brushes.Black, 0, yOffSet); // Fill a rectangle with the correct brush. g.FillEllipse(theBrush, 150, yOffSet, 200, 25); yOffSet += 40; } }
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(); } HatchStyle item = e.Index >= 0 ? (HatchStyle)Items[e.Index] : HatchStyle.Min; HatchBrush hatchBrush = new HatchBrush(item, e.ForeColor, e.BackColor); SolidBrush foreColorBrush = new SolidBrush(e.ForeColor); grfx.FillRectangle(hatchBrush, rectColor); grfx.DrawString(item.ToString(), Font, foreColorBrush, rectText); }
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; } }
public override string GetName(HatchStyle style) { return(style.ToString()); }
protected void OnHatchImageButtonsClick(object sender, EventArgs e) { for (int ii = 0; ii < images.Length; ii++) { if (hatch_image_btns[ii] == sender) { style = (HatchStyle)ii; FillImageByHatch(review_image, style); pictureboxHatchPreview.Refresh(); label1.Text = style.ToString(); break; } } }