public static void RepertoryImage(Graphics drawDestination) { StringFormat itemStringFormat = new StringFormat(); RectangleF itemBox = new RectangleF(10, 30, 42, 10); RectangleF itemBox2 = new RectangleF(60, 48, 10, 10); itemStringFormat.Alignment = StringAlignment.Center; itemStringFormat.LineAlignment = StringAlignment.Far; drawDestination.DrawLine(Pens.LightGray,10,10,10,70); if (mMscStyle == MscStyle.SDL){ PointF[] capPolygon = new PointF[3]; capPolygon[0] = new PointF(61, 40); capPolygon[1] = new PointF(53, 44); capPolygon[2] = new PointF(53, 36); drawDestination.FillPolygon(Brushes.Black,capPolygon); drawDestination.DrawString("Lost",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); drawDestination.DrawString("g",new Font("Arial",8),Brushes.Black,itemBox2,itemStringFormat); drawDestination.DrawLine(Pens.Black,10, 40, 60,40); drawDestination.FillEllipse(Brushes.Black, new RectangleF(60,35, 10,10)); } else if(mMscStyle == MscStyle.UML2){ drawDestination.DrawString("Lost",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); drawDestination.DrawString("g",new Font("Arial",8),Brushes.Black,itemBox2,itemStringFormat); drawDestination.DrawLine(Pens.Black,10, 40, 60,40); drawDestination.DrawLine(Pens.Black,60, 40, 54,43); drawDestination.DrawLine(Pens.Black,60, 40, 54,37); drawDestination.FillEllipse(Brushes.Black, new RectangleF(60,35, 10,10)); } itemStringFormat.Dispose(); }
public static void RepertoryImage(Graphics drawDestination) { StringFormat itemStringFormat = new StringFormat(); RectangleF itemBox = new RectangleF(5, 20, 70, 20); itemStringFormat.Alignment = StringAlignment.Center; drawDestination.DrawString("Message",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); if (mMscStyle == MscStyle.SDL){ drawDestination.DrawLine(Pens.Black,5,55,40,55); drawDestination.DrawLine(Pens.Black,40,35,40,55); drawDestination.DrawLine(Pens.Black,40,35,75,35); PointF[] messagePolygon = new PointF[3]; messagePolygon[0] = new PointF(5, 55); messagePolygon[1] = new PointF(5+8, 55-4); messagePolygon[2] = new PointF(5+8, 55+4); drawDestination.FillPolygon(Brushes.Black,messagePolygon); } else if(mMscStyle == MscStyle.UML2){ drawDestination.DrawLine(Pens.Black,5,55,40,55); drawDestination.DrawLine(Pens.Black,40,35,40,55); drawDestination.DrawLine(Pens.Black,40,35,75,35); drawDestination.DrawLine(Pens.Black,5,55,5+8, 55-4); drawDestination.DrawLine(Pens.Black,5,55,5+8, 55+4); } itemStringFormat.Dispose(); }
private void monthCalendar1_DayRender(object sender, Pabo.Calendar.DayRenderEventArgs e) { Brush bgBrush = new SolidBrush(Color.White); Brush dateBrush = new SolidBrush(Color.Black); Font dateFont = new Font("Microsoft Sans Serif",(float)8.25); StringFormat dateAlign = new StringFormat(); dateAlign.Alignment = StringAlignment.Far; dateAlign.LineAlignment = StringAlignment.Near; Rectangle rect = new Rectangle(0,0,e.Width,e.Height); // Set OwnerDraw = true to override built in formatting... e.OwnerDraw = true; // ...then Draw the appearance of the date e.Graphics.FillRectangle(bgBrush,rect); e.Graphics.DrawString(e.Date.Day.ToString(), dateFont,dateBrush,rect,dateAlign); // Clean up bgBrush.Dispose(); dateBrush.Dispose(); dateAlign.Dispose(); dateFont.Dispose(); }
public static void RepertoryImage(Graphics drawDestination) { StringFormat itemStringFormat = new StringFormat(); RectangleF itemBox = new RectangleF(5, 15, 30, 15); RectangleF itemBox2 = new RectangleF(5, 35, 70, 15); itemStringFormat.Alignment = StringAlignment.Near; itemStringFormat.LineAlignment = StringAlignment.Near; PointF[] statePolygon = new PointF[5]; statePolygon[0] = new PointF(5,15); statePolygon[1] = new PointF(40,15); statePolygon[2] = new PointF(40,25); statePolygon[3] = new PointF(35,30); statePolygon[4] = new PointF(5,30); drawDestination.FillPolygon(Brushes.White,statePolygon); drawDestination.DrawPolygon(Pens.LightGray,statePolygon); drawDestination.DrawRectangle(Pens.LightGray,5,15,70,50); drawDestination.DrawString("frag",new Font("Arial",8,FontStyle.Regular),Brushes.LightGray,itemBox,itemStringFormat); Pen rPen = new Pen(Color.Black); float[] pattern = {4f,4f}; rPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom; rPen.DashPattern = pattern; itemStringFormat.Alignment = StringAlignment.Center; drawDestination.DrawString("separator",new Font("Arial",8,FontStyle.Italic),Brushes.Black,itemBox2,itemStringFormat); drawDestination.DrawLine(rPen, 5, 50, 75, 50); rPen.Dispose(); itemStringFormat.Dispose(); }
public static void RepertoryImage(Graphics drawDestination) { StringFormat itemStringFormat = new StringFormat(); RectangleF itemBox = new RectangleF(15, 30, 50, 20); itemStringFormat.Alignment = StringAlignment.Center; itemStringFormat.LineAlignment = StringAlignment.Center; drawDestination.DrawLine(Pens.LightGray,40,10,40,70); if (mMscStyle == MscStyle.SDL){ PointF[] statePolygon = new PointF[6]; statePolygon[0] = new PointF(5,40); statePolygon[1] = new PointF(15,30); statePolygon[2] = new PointF(65,30); statePolygon[3] = new PointF(75,40); statePolygon[4] = new PointF(65,50); statePolygon[5] = new PointF(15,50); drawDestination.FillPolygon(Brushes.White,statePolygon); drawDestination.DrawString("State",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); drawDestination.DrawPolygon(Pens.Black,statePolygon); } else if(mMscStyle == MscStyle.UML2){ drawDestination.FillRectangle(Brushes.White,itemBox); drawDestination.FillEllipse(Brushes.White,5,30,20,20); drawDestination.FillEllipse(Brushes.White,55,30,20,20); drawDestination.DrawLine(Pens.Black,15,30,65,30); drawDestination.DrawLine(Pens.Black,15,50,65,50); drawDestination.DrawArc(Pens.Black,5,30,20,20,90,180); drawDestination.DrawArc(Pens.Black,55,30,20,20,270,180); drawDestination.DrawString("State",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); } itemStringFormat.Dispose(); }
public static RectangleF MeasureDisplayStringF(Graphics graphics, string text, Font font, int width, int height) { if (text == string.Empty || text == null) { return(new RectangleF(0, 0, 0, 0)); } System.Drawing.StringFormat format = new System.Drawing.StringFormat(); System.Drawing.RectangleF rect = new System.Drawing.RectangleF(0, 0, width, height); System.Drawing.CharacterRange[] ranges = { new System.Drawing.CharacterRange(0, text.Length) }; System.Drawing.Region[] regions = new System.Drawing.Region[1]; format.SetMeasurableCharacterRanges(ranges); regions = graphics.MeasureCharacterRanges(text, font, rect, format); rect = regions[0].GetBounds(graphics); //cleanup format.Dispose(); ranges = null; regions[0].Dispose(); regions = null; return(rect); }
public static void RepertoryImage(Graphics drawDestination) { StringFormat itemStringFormat = new StringFormat(); RectangleF itemBox = new RectangleF(10, 30, 60, 20); float[] pattern = {4f,4f}; Pen rPen = new Pen(Color.Black); rPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom; rPen.DashPattern = pattern; itemStringFormat.Alignment = StringAlignment.Center; itemStringFormat.LineAlignment = StringAlignment.Center; drawDestination.DrawLine(Pens.LightGray,10,10,10,70); drawDestination.DrawLine(rPen,10,20,70,20); drawDestination.DrawLine(rPen,10,60,70,60); PointF[] capPolygon = new PointF[3]; capPolygon[0] = new PointF(65, 19); capPolygon[1] = new PointF(69, 11); capPolygon[2] = new PointF(61, 11); drawDestination.DrawPolygon(Pens.Black,capPolygon); capPolygon[0] = new PointF(65, 61); capPolygon[1] = new PointF(69, 69); capPolygon[2] = new PointF(61, 69); drawDestination.DrawPolygon(Pens.Black,capPolygon); drawDestination.DrawLine(rPen,65,20,65,60); drawDestination.DrawString("Measure",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); rPen.Dispose(); itemStringFormat.Dispose(); }
protected override void WndProc(ref Message m) { switch (m.Msg) { case (int)Msgs.WmPaint: base.WndProc(ref m); using (Graphics g = Graphics.FromHwnd(Handle)) { g.SmoothingMode = SmoothingMode.HighQuality; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; StringFormat format = new StringFormat(); // format.Alignment = StringAlignment.Center; // format.LineAlignment = StringAlignment.Center; Brush labelBrush = new SolidBrush(ForeColor); Rectangle rect = new Rectangle(0, 0, Bounds.Width, Bounds.Height); g.DrawStringWithGraphicsPath(Text, Font, labelBrush, rect, format); format.Dispose(); } break; default: base.WndProc(ref m); break; } }
public virtual void DrawPanel(DrawItemEventArgs e) { string text = base.Text; if ((text != null) && (text.Length != 0)) { int num = 0; StringFormat format = new StringFormat(StringFormatFlags.NoWrap); format.LineAlignment = StringAlignment.Center; format.HotkeyPrefix = HotkeyPrefix.Hide; format.Trimming = StringTrimming.EllipsisCharacter; switch (base.Alignment) { case HorizontalAlignment.Right: format.Alignment = StringAlignment.Far; break; case HorizontalAlignment.Center: format.Alignment = StringAlignment.Center; break; default: format.Alignment = StringAlignment.Near; num = 3; break; } Rectangle layoutRectangle = new Rectangle((e.Bounds.X + 1) + num, e.Bounds.Y, (e.Bounds.Width - 2) - num, e.Bounds.Height); e.Graphics.DrawString(base.Text, base.Parent.Font, SystemBrushes.ControlText, layoutRectangle, format); format.Dispose(); } this.DrawPanelBorder(e); }
public static void RepertoryImage(Graphics drawDestination) { StringFormat itemStringFormat = new StringFormat(); RectangleF itemBox = new RectangleF(10, 20, 60, 20); float[] pattern = {4f,4f}; Pen rPen = new Pen(Color.Black); rPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom; rPen.DashPattern = pattern; itemStringFormat.Alignment = StringAlignment.Center; itemStringFormat.LineAlignment = StringAlignment.Center; drawDestination.DrawLine(Pens.LightGray,10,10,10,70); drawDestination.DrawLine(Pens.LightGray,55,50,55,70); drawDestination.DrawLine(Pens.Black,10,45,40,45); if (mMscStyle==MscStyle.SDL){ PointF[] messagePolygon = new PointF[3]; messagePolygon[0] = new PointF(40, 45); messagePolygon[1] = new PointF(40-8, 45-4); messagePolygon[2] = new PointF(40-8, 45+4); drawDestination.FillPolygon(Brushes.Black,messagePolygon); } else if (mMscStyle==MscStyle.UML2){ drawDestination.DrawLine(Pens.Black,40, 45,40-8, 45-4); drawDestination.DrawLine(Pens.Black,40, 45,40-8, 45+4); } drawDestination.DrawRectangle(Pens.Black, 40,40,30,10); drawDestination.DrawString("Create",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); rPen.Dispose(); itemStringFormat.Dispose(); }
public TerrainEditorControl() { InitializeComponent(); int itemHieght = m_header + m_thumbSize + 6; m_decoList.ItemHeight = itemHieght; m_layerList.ItemHeight = itemHieght; m_decoList.DrawItem2 += DrawItem; m_layerList.DrawItem2 += DrawItem; m_addBtn.Image = ResourceUtil.GetImage16(ATFResources.AddImage); m_deleteBtn.Image = ResourceUtil.GetImage16(ATFResources.RemoveImage); m_moveUpBtn.Image = ResourceUtil.GetImage16(ATFResources.ArrowUpImage); m_moveDownBtn.Image = ResourceUtil.GetImage16(ATFResources.ArrowDownImage); Application.Idle += (sender, e) => { UpdateButtonStatus(); }; m_thumbnailReslovers = Globals.MEFContainer.GetExportedValues<IThumbnailResolver>(); // create no-tex bmp. m_noTexBmp = new Bitmap(m_thumbSize, m_thumbSize); Graphics g = Graphics.FromImage(m_noTexBmp); StringFormat strFormat = new StringFormat(); strFormat.Alignment = StringAlignment.Center; strFormat.LineAlignment = StringAlignment.Center; g.Clear(Color.White); Rectangle texRect = new Rectangle(0, 0, m_noTexBmp.Width, m_noTexBmp.Height); g.DrawString("No\n\rTexture", Font, Brushes.Red, texRect, strFormat); strFormat.Dispose(); g.Dispose(); m_flattenRdo.Text = "Flatten".Localize(); m_flattenRdo.Tag = new FlattenBrush(m_flattenRdo.Text); m_brushRiseLowRdo.Text = "Raise/Lower".Localize(); m_brushRiseLowRdo.Tag = new RaiseLowerBrush(m_brushRiseLowRdo.Text); m_brushSmoothRdo.Text = "Smooth".Localize(); m_brushSmoothRdo.Tag = new SmoothenBrush(m_brushSmoothRdo.Text); m_noiseRdo.Text = "Noise".Localize(); m_noiseRdo.Tag = new NoiseBrush(m_noiseRdo.Text); m_paintEraseRdo.Text = "Paint/Erase".Localize(); m_paintEraseRdo.Tag = new PaintEraseBrush(m_paintEraseRdo.Text); SizeChanged += (sender, e) => { m_propertyGrid.Width = Width - m_propertyGrid.Left; m_brushProps.Width = Width - m_brushProps.Left; }; }
public override void OnPaint(PaintEventArgs pe, ISkinProvider skin) { StringFormat drawFormat = new StringFormat(); pe.Graphics.DrawString(TextLabel, skin.PrimaryFont, skin.PrimaryFontColor, Margin.Left, Offset.Y + Margin.Top, drawFormat); pe.Graphics.DrawString(TextValue, skin.SecondaryFont, skin.SecondaryFontColor, Size.Width - TextRenderer.MeasureText(TextValue, skin.SecondaryFont).Width - Margin.Left, Offset.Y + Margin.Top, drawFormat); drawFormat.Dispose(); }
public override void OnPaint(PaintEventArgs pe, ISkinProvider skin) { StringFormat drawFormat = new StringFormat(); pe.Graphics.DrawString(TextLabel, skin.PrimaryFont, skin.PrimaryFontColor, Margin.Left, Offset.Y + Margin.Top, drawFormat); pe.Graphics.DrawString(TextValue, skin.SecondaryFont, skin.SecondaryFontColor, new RectangleF(Margin.Left, Offset.Y + 3 * Margin.Top, Size.Width - (Margin.Left+Margin.Right), Size.Height - 3 * Margin.Top)); drawFormat.Dispose(); }
private void IsLoadingDialog_Paint(object sender, PaintEventArgs e) { Graphics gr = e.Graphics; Font font = new Font(Font.FontFamily, 18F); StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; gr.DrawString(String.Format(RShare.Properties.Resources.StealthNetIsClosing,Core.Version), font, Brushes.AntiqueWhite, new RectangleF(new PointF(16F, 302F), new SizeF(489F, 37F)), sf); sf.Dispose(); font.Dispose(); }
//Рисовалки private void DrawArrowandLines(Rectangle r, Graphics g) { Pen pen = new Pen(Color.Black); int a = tb_shoots.Location.X - 30; SolidBrush brush = new SolidBrush(Color.Black); Font font = new Font("Courier New", 10, FontStyle.Regular); StringFormat drawFormat = new System.Drawing.StringFormat(); PointF f = new PointF((-0.8f) * R + O.X, O.Y - R * 0.6f); //x g.DrawLine(pen, 10, O.Y, a, O.Y); g.DrawLine(pen, a, O.Y, a - 5, O.Y - 5); g.DrawLine(pen, a, O.Y, a - 5, O.Y + 5); //y g.DrawLine(pen, O.X, O.Y + R + 10, O.X, 15); g.DrawLine(pen, O.X, 15, O.X - 5, 20); g.DrawLine(pen, O.X, 15, O.X + 5, 20); g.DrawLine(pen, O.X, O.Y, f.X, f.Y); g.DrawLine(pen, f.X, f.Y, f.X + 5, f.Y); g.DrawLine(pen, f.X, f.Y, f.X, f.Y + 5); int z = 0, dz = 5; while (z <= R) { g.DrawLine(pen, O.X + R / 2, O.Y + z, O.X + R / 2, O.Y + z + dz); z += 2 * dz; } z = 0; dz = 3; int k = Convert.ToInt32(R / 2); while (z <= k) { g.DrawLine(pen, O.X + z, O.Y + R, O.X + z + dz, O.Y + R); z += 2 * dz; } g.DrawString("R", font, brush, O.X - 10, O.Y + R - 7, drawFormat); g.DrawString("R/2", font, brush, O.X + R / 2 - 10, O.Y - 15, drawFormat); g.DrawString("R", font, brush, O.X + R - 10, O.Y - 15, drawFormat); g.DrawString("R", font, brush, f.X + 10, f.Y + 10, drawFormat); g.DrawString("Y", font, brush, O.X + 5, 15, drawFormat); g.DrawString("X", font, brush, a - 5, O.Y, drawFormat); g.DrawString("(0, 0)", font, brush, O.X - 40, O.Y + 5, drawFormat); brush.Dispose(); pen.Dispose(); g.Dispose(); drawFormat.Dispose(); font.Dispose(); }
private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { if (e.RowIndex == -1) { using (Brush br = new SolidBrush(Color.FromArgb(253, 14, 0))) { e.Graphics.FillRectangle(br, e.CellBounds); e.Paint(e.ClipBounds, (DataGridViewPaintParts.All & ~DataGridViewPaintParts.Background)); } } if (e.RowIndex >= 0) { e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; if (e.RowIndex % 2 == 0) { e.Graphics.FillRectangle(Brushes.Black, e.CellBounds); } else { using (Brush br = new LinearGradientBrush(new Point(0, 0), new Point(e.ClipBounds.Width, 0), Color.FromArgb(0, 0, 0), Color.FromArgb(253, 0, 0))) e.Graphics.FillRectangle(br, e.CellBounds); } string content = bestResult_dataGridView1[e.ColumnIndex, e.RowIndex].Value == null ? "" : bestResult_dataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString();; using (Pen p = new Pen(Color.FromArgb(68, 31, 31))) e.Graphics.DrawRectangle(p, e.CellBounds); // Прорисовка данных int th = 20; if (e.ColumnIndex >= 2) { th = 15; } using (Font f2 = new Font("Tahoma", th)) { System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat(); drawFormat.LineAlignment = StringAlignment.Center; if (e.ColumnIndex != 2) { drawFormat.Alignment = StringAlignment.Near; } else { drawFormat.Alignment = StringAlignment.Center; } e.Graphics.DrawString(content, f2, Brushes.White, e.CellBounds, drawFormat); drawFormat.Dispose(); } } e.Handled = true; }
public static void RepertoryImage(Graphics drawDestination) { StringFormat itemStringFormat = new StringFormat(); RectangleF itemBox = new RectangleF(20, 30, 50, 20); itemStringFormat.Alignment = StringAlignment.Center; itemStringFormat.LineAlignment = StringAlignment.Center; drawDestination.DrawLine(Pens.LightGray,20,10,20,50); drawDestination.DrawLine(Pens.Black,16,46,24,54); drawDestination.DrawLine(Pens.Black,24,46,16,54); drawDestination.DrawString("Stop",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); itemStringFormat.Dispose(); }
public static void RepertoryImage(Graphics drawDestination) { StringFormat itemStringFormat = new StringFormat(); RectangleF itemBox = new RectangleF(10, 10, 60, 20); itemStringFormat.Alignment = StringAlignment.Center; itemStringFormat.LineAlignment = StringAlignment.Center; drawDestination.DrawLine(Pens.Black,40,30,40,70); drawDestination.FillRectangle(Brushes.White,10,10,60,20); drawDestination.DrawString("Process",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); drawDestination.DrawRectangle(Pens.Black,10,10,60,20); itemStringFormat.Dispose(); }
private static void addHintText(ref Bitmap bmp) { using (Graphics g = Graphics.FromImage(bmp)) { StringFormat strFormat = new StringFormat(); strFormat.Alignment = StringAlignment.Far; g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; g.DrawString("OK - switch screen", new Font("Arial", 9, FontStyle.Regular, GraphicsUnit.Pixel), Brushes.White, new Rectangle(0, 2, bmp.Width - 2, bmp.Height), strFormat); strFormat.Dispose(); } }
public static void RepertoryImage(Graphics drawDestination) { if (mMscStyle==MscStyle.UML2){ StringFormat itemStringFormat = new StringFormat(); RectangleF itemBox = new RectangleF(5, 20, 30, 15); itemStringFormat.Alignment = StringAlignment.Near; itemStringFormat.LineAlignment = StringAlignment.Near; PointF[] statePolygon = new PointF[5]; statePolygon[0] = new PointF(5,20); statePolygon[1] = new PointF(40,20); statePolygon[2] = new PointF(40,30); statePolygon[3] = new PointF(35,35); statePolygon[4] = new PointF(5,35); drawDestination.FillRectangle(Brushes.White,5,20,70,40); drawDestination.DrawString("ref",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); drawDestination.DrawPolygon(Pens.Black,statePolygon); itemBox = new RectangleF(5, 30, 70, 30); itemStringFormat.Alignment = StringAlignment.Center; itemStringFormat.LineAlignment = StringAlignment.Center; drawDestination.DrawString("Reference",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); drawDestination.DrawRectangle(Pens.Black,5,20,70,40); itemStringFormat.Dispose(); } else if (mMscStyle==MscStyle.SDL){ StringFormat itemStringFormat = new StringFormat(); RectangleF itemBox = new RectangleF(10, 25, 60, 30); itemStringFormat.Alignment = StringAlignment.Center; itemStringFormat.LineAlignment = StringAlignment.Center; drawDestination.FillPie(Brushes.White,5,20,10,10,180,90); drawDestination.FillPie(Brushes.White,5,50,10,10,90,90); drawDestination.FillPie(Brushes.White,65,20,10,10,270,90); drawDestination.FillPie(Brushes.White,65,50,10,10,0,90); drawDestination.FillRectangle(Brushes.White, 5, 25, 5, 30); drawDestination.FillRectangle(Brushes.White, 70, 25, 5, 30); drawDestination.FillRectangle(Brushes.White, 10, 20, 60, 40); drawDestination.DrawLine(Pens.Black,10,20,70,20); drawDestination.DrawLine(Pens.Black,5,25,5,55); drawDestination.DrawLine(Pens.Black,10,60,70,60); drawDestination.DrawLine(Pens.Black,75,25,75,55); drawDestination.DrawArc(Pens.Black,5,20,10,10,180,90); drawDestination.DrawArc(Pens.Black,5,50,10,10,90,90); drawDestination.DrawArc(Pens.Black,65,20,10,10,270,90); drawDestination.DrawArc(Pens.Black,65,50,10,10,0,90); drawDestination.DrawString("Reference",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); } }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { base.OnPaint(e); StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; RectangleF rect = new RectangleF(ClientRectangle.X, ClientRectangle.Y + 16, ClientRectangle.Width, ClientRectangle.Height - 17); //if (condition is TigerClient.Document.Condition.AndCondition) e.Graphics.DrawString(operatorString, Font, SystemBrushes.ControlDark, rect, sf); //else // e.Graphics.DrawString("OR", Font, SystemBrushes.ControlDark, rect, sf); sf.Dispose(); }
public static void RepertoryImage(Graphics drawDestination) { StringFormat itemStringFormat = new StringFormat(); itemStringFormat.Alignment = StringAlignment.Near; itemStringFormat.LineAlignment = StringAlignment.Center; RectangleF itemBox = new RectangleF(30, 30, 40, 20); drawDestination.DrawString("Region",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); drawDestination.DrawLine(Pens.LightGray,20,10,20,20); drawDestination.DrawLine(Pens.LightGray,20,60,20,70); drawDestination.FillRectangle(Brushes.LightGray,15, 20, 10, 40); drawDestination.DrawLine(Pens.Black,15,20,25,20); drawDestination.DrawLine(Pens.Black,15,60,25,60); drawDestination.DrawLine(Pens.Black,15,20, 15,60); drawDestination.DrawLine(Pens.Black,25,20, 25,60); itemStringFormat.Dispose(); }
public override void OnPaint(PaintEventArgs pe, ISkinProvider skin) { StringFormat drawFormat = new StringFormat(); pe.Graphics.DrawImage(Icon, new Rectangle (Margin.Left, // X Offset.Y + Margin.Top, // Y Icon.Width / 4, // Width Icon.Height / 4)); // Height pe.Graphics.DrawString(TextLabel, skin.SmallFont, skin.PrimaryFontColor, 4 * Margin.Left, Offset.Y + 1.5f * Margin.Top, drawFormat); pe.Graphics.DrawString(TextValue, skin.SmallFont, skin.SecondaryFontColor, Size.Width - TextRenderer.MeasureText(TextValue, skin.SecondaryFont).Width - Margin.Left, Offset.Y + 1.5f * Margin.Top, drawFormat); drawFormat.Dispose(); }
private void listBox1_DrawItem(object sender, DrawItemEventArgs e) { ListBox lb=sender as ListBox; e.DrawBackground(); e.DrawFocusRectangle(); if (e.Index < 0) return; StringFormat frm = new StringFormat(); frm.Alignment = StringAlignment.Center; frm.LineAlignment = StringAlignment.Center; Brush brush=new SolidBrush(e.ForeColor); string text=lb.GetItemText(lb.Items[e.Index]); Rectangle rc=lb.GetItemRectangle(e.Index); e.Graphics.DrawString(text, e.Font, brush, rc, frm); frm.Dispose(); brush.Dispose(); }
public static void RepertoryImage(Graphics drawDestination) { StringFormat itemStringFormat = new StringFormat(); RectangleF itemBox = new RectangleF(10, 20, 60, 20); float[] pattern = {4f,4f}; Pen rPen = new Pen(Color.Black); rPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom; rPen.DashPattern = pattern; itemStringFormat.Alignment = StringAlignment.Far; itemStringFormat.LineAlignment = StringAlignment.Far; drawDestination.DrawLine(Pens.LightGray,10,10,10,70); drawDestination.DrawLine(rPen,10,50,20,40); drawDestination.DrawLine(rPen,20,40,70,40); drawDestination.DrawString("Mark",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); rPen.Dispose(); itemStringFormat.Dispose(); }
public static void RepertoryImage(Graphics drawDestination) { StringFormat itemStringFormat = new StringFormat(); RectangleF itemBox = new RectangleF(5, 15, 30, 15); itemStringFormat.Alignment = StringAlignment.Near; itemStringFormat.LineAlignment = StringAlignment.Near; PointF[] statePolygon = new PointF[5]; statePolygon[0] = new PointF(5,15); statePolygon[1] = new PointF(40,15); statePolygon[2] = new PointF(40,25); statePolygon[3] = new PointF(35,30); statePolygon[4] = new PointF(5,30); drawDestination.FillPolygon(Brushes.White,statePolygon); drawDestination.DrawPolygon(Pens.Black,statePolygon); drawDestination.DrawRectangle(Pens.Black,5,15,70,50); drawDestination.DrawString("frag",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); itemStringFormat.Dispose(); }
public static void RepertoryImage(Graphics drawDestination, ProcessType type) { StringFormat itemStringFormat = new StringFormat(); RectangleF itemBox = new RectangleF(10, 10, 60, 20); Pen pen = new Pen(Color.Black); float[] pattern = {3f,3f}; if(MSCItem.Style == MscStyle.UML2){ pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom; pen.DashPattern = pattern; } else if (MSCItem.Style == MscStyle.SDL){ pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; } if(type == ProcessType.Actor){ itemBox = new RectangleF(10, 0, 60, 14); itemStringFormat.Alignment = StringAlignment.Center; itemStringFormat.LineAlignment = StringAlignment.Near; drawDestination.DrawString("Description",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); itemStringFormat.LineAlignment = StringAlignment.Center; drawDestination.DrawEllipse(Pens.Black,36,14,8,8); drawDestination.DrawLine(Pens.Black,40,22,40,32); drawDestination.DrawLine(Pens.Black,32,24,48,24); drawDestination.DrawLine(Pens.Black,40,32,48,40); drawDestination.DrawLine(Pens.Black,40,32,32,40); itemBox = new RectangleF(10, 42, 60, 12); drawDestination.DrawString("Actor",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); drawDestination.DrawLine(pen,40,56,40,75); } else if (type == ProcessType.Normal){ itemBox = new RectangleF(10, 0, 60, 14); itemStringFormat.Alignment = StringAlignment.Center; itemStringFormat.LineAlignment = StringAlignment.Near; drawDestination.DrawString("Description",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); itemStringFormat.LineAlignment = StringAlignment.Center; drawDestination.FillRectangle(Brushes.White,10,14,60,20); itemBox = new RectangleF(10, 14, 60, 20); drawDestination.DrawString("Process",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); drawDestination.DrawRectangle(Pens.Black,10,14,60,20); drawDestination.DrawLine(pen,40,34,40,75); } itemStringFormat.Dispose(); pen.Dispose(); }
private static void TestLibrary() { if (OsInfo.IsWindows) { return; } try { // We use StringFormat as test coz it gets properly cleaned up by the finalizer even if gdiplus is absent and is relatively non-invasive. var strFormat = new StringFormat(); strFormat.Dispose(); } catch (Exception ex) { _gdiPlusException = ex; } }
public override void OnPaint(PaintEventArgs pe, ISkinProvider skin) { StringFormat drawFormat = new StringFormat(); pe.Graphics.DrawString(TextLabel, skin.PrimaryFont, skin.PrimaryFontColor, Margin.Left, Offset.Y + Margin.Top, drawFormat); Image toggleImage = ToggleState == ToggleStateEnum.On ? Resource.toggle_on : Resource.toggle_off; pe.Graphics.DrawImage(toggleImage, new Rectangle (Size.Width - toggleImage.Width / 4 - Margin.Right, // X Offset.Y + Margin.Top, // Y toggleImage.Width / 4, // Width toggleImage.Height / 4)); // Height if (IsFocused) pe.Graphics.FillRectangle(skin.AccentColor, new Rectangle(Offset.X, Offset.Y + Margin.Top, 2, Size.Height - (Margin.Bottom + Margin.Top) )); drawFormat.Dispose(); }
public static void RepertoryImage(Graphics drawDestination) { StringFormat itemStringFormat = new StringFormat(); RectangleF itemBox = new RectangleF(10, 30, 60, 20); itemStringFormat.Alignment = StringAlignment.Center; itemStringFormat.LineAlignment = StringAlignment.Center; PointF[] statePolygon = new PointF[5]; statePolygon[0] = new PointF(20,10); statePolygon[1] = new PointF(70,10); statePolygon[2] = new PointF(70,70); statePolygon[3] = new PointF(10,70); statePolygon[4] = new PointF(10,20); drawDestination.FillPolygon(Brushes.White,statePolygon); drawDestination.DrawString("Comment",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); drawDestination.DrawPolygon(Pens.Black,statePolygon); drawDestination.DrawLine(Pens.Black,10,20,20,20); drawDestination.DrawLine(Pens.Black,20,10,20,20); itemStringFormat.Dispose(); }
public static void RepertoryImage(Graphics drawDestination) { StringFormat itemStringFormat = new StringFormat(); RectangleF itemBox = new RectangleF(10, 30, 60, 30); itemStringFormat.Alignment = StringAlignment.Center; itemStringFormat.LineAlignment = StringAlignment.Center; drawDestination.DrawLine(Pens.LightGray,10,10,10,70); drawDestination.DrawLine(Pens.Black,10,30,65,30); PointF[] capPolygon = new PointF[3]; capPolygon[0] = new PointF(65, 30); capPolygon[1] = new PointF(70, 25); capPolygon[2] = new PointF(60, 25); drawDestination.DrawPolygon(Pens.Black,capPolygon); capPolygon[0] = new PointF(65, 30); capPolygon[1] = new PointF(70, 35); capPolygon[2] = new PointF(60, 35); drawDestination.DrawPolygon(Pens.Black,capPolygon); drawDestination.DrawString("SetTimer",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); itemStringFormat.Dispose(); }
private void dataGridView2_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { if (e.RowIndex >= 0) { e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; if (e.RowIndex % 2 == 0) { e.Graphics.FillRectangle(Brushes.Black, e.CellBounds); } else { using (Brush br = new LinearGradientBrush(new Point(0, 0), new Point(e.ClipBounds.Width, 0), Color.FromArgb(0, 0, 0), Color.FromArgb(253, 0, 0))) e.Graphics.FillRectangle(br, e.CellBounds); } string content = dataGridView2[e.ColumnIndex, e.RowIndex].Value == null ? " * " : dataGridView2[e.ColumnIndex, e.RowIndex].Value.ToString();; string[] data = content.Split(new string[] { "*" }, StringSplitOptions.None); // Никнейм пилота using (Font f2 = new Font("Tahoma", 21)) { System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat(); drawFormat.Alignment = StringAlignment.Near; content = data.Length > 0 ? data[0] : ""; e.Graphics.DrawString(content, f2, Brushes.White, e.CellBounds.X, e.CellBounds.Y, drawFormat); drawFormat.Dispose(); } // Имя пилота using (Font f2 = new Font("Tahoma", 11)) { System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat(); drawFormat.Alignment = StringAlignment.Near; content = data.Length > 1 ? data[1] : ""; e.Graphics.DrawString(content, f2, Brushes.DarkGray, e.CellBounds.X + 6, e.CellBounds.Bottom - 17, drawFormat); drawFormat.Dispose(); } } e.Handled = true; }
protected override void Render(GH_Canvas canvas, Sd.Graphics graphics, GH_CanvasChannel channel) { base.Render(canvas, graphics, channel); ImageViewer comp = Owner as ImageViewer; if (channel == GH_CanvasChannel.Objects) { GH_Capsule capsule = GH_Capsule.CreateCapsule(ButtonBounds, GH_Palette.Normal, 0, 0); capsule.Render(graphics, Selected, Owner.Locked, true); capsule.AddOutputGrip(this.OutputGrip.Y); capsule.Dispose(); capsule = null; Sd.StringFormat format = new Sd.StringFormat(); format.Alignment = Sd.StringAlignment.Center; format.LineAlignment = Sd.StringAlignment.Center; Sd.RectangleF textRectangle = ButtonBounds; graphics.DrawImage(comp.img, Bounds.X + 2, m_innerBounds.Y - (ButtonBounds.Height - Bounds.Height), comp.img.Width - 4, comp.img.Height - 2); format.Dispose(); } }
/// <summary> /// Draw the day/hour grid and hour labels for the frame of the calendar /// </summary> /// <param name="pe">PaintEventArgs for drawing graphics on the control</param> public void DrawCalendarFrame(PaintEventArgs pe) { int width = this.ClientRectangle.Width - leftMargin - rightMargin; int height = 1920; int left = this.ClientRectangle.Left + leftMargin; int top = this.ClientRectangle.Top + topMargin; int right = left + width; int bottom = top + height; // fire the resize event with the needed positions for the day dividers CalendarResizedEventArgs r = new CalendarResizedEventArgs { dayStartPositions = new int[] { left, left + width / 5, left + 2 * width / 5, left + 3 * width / 5, left + 4 * width / 5, right }, }; ResizeEvent?.Invoke(this, r); Pen pen = new Pen(Color.LightGray); // draw horizontal divider lines of calendar int startX; for (int i = 0; i < 48; i++) { if (i % 2 == 0) { startX = 0; } else { startX = leftMargin; } pe.Graphics.DrawLine(pen, new Point(startX, top + 40 * i), new Point(right, top + 40 * i)); } pen.Color = Color.Black; // draw vertical divider lines of calendar pe.Graphics.DrawLine(pen, new Point(left, top), new Point(left, bottom)); // left vertical border line pe.Graphics.DrawLine(pen, new Point(left + width / 5, top), new Point(left + width / 5, bottom)); pe.Graphics.DrawLine(pen, new Point(left + 2 * width / 5, top), new Point(left + 2 * width / 5, bottom)); pe.Graphics.DrawLine(pen, new Point(left + 3 * width / 5, top), new Point(left + 3 * width / 5, bottom)); pe.Graphics.DrawLine(pen, new Point(left + 4 * width / 5, top), new Point(left + 4 * width / 5, bottom)); pe.Graphics.DrawLine(pen, new Point(right, top), new Point(right, bottom)); // right vertical border line // draw bottom border line pen.Width *= 2; pe.Graphics.DrawLine(pen, new Point(left, bottom), new Point(right, bottom)); // finished with pen for drawing, so dispose pen.Dispose(); // prepare to draw hour divider labels (using SolidBrush) System.Drawing.Font drawFont = new System.Drawing.Font("Segoe UI", 12); System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.Gray); System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat(); // draw label for each hour for (int i = 0; i < 24; i++) { pe.Graphics.DrawString(GetHourLabel(i), drawFont, brush, 5, top + 80 * i, drawFormat); } // dispose of string drawing resources drawFont.Dispose(); brush.Dispose(); drawFormat.Dispose(); }
/// <summary> /// On get glyph /// </summary> public override System.Drawing.Bitmap OnGetGlyph(DrawItemEventArgs e) { // Get glyph based on data type switch (_listboxMode) { case ListboxType.Brushes: // Get brush, return the glyph of the brush GMareBrush brush = Items[e.Index] as GMareBrush; return(brush == null || brush.Glyph == null ? (GDI.Bitmap)GMare.Properties.Resources.brush.Clone() : (GDI.Bitmap)brush.Glyph.Clone()); case ListboxType.Projects: // Get background GMareBackground background = (Items[e.Index] as ExportProject).Background; // If the background is empty, return null if (background == null) { return(null); } // Image to draw GDI.Bitmap image = null; // Get the background image if (background.Image != null) { image = ScaleImage(background.Image.ToBitmap(), _cellSize.Width, _cellSize.Height); } else { // Create an empty image image = new GDI.Bitmap(_cellSize.Width, _cellSize.Height); GDI.Pen border = new GDI.Pen(GDI.Color.Gray); GDI.Pen innerBorder = new GDI.Pen(GDI.Color.White); GDI.Graphics gfx = GDI.Graphics.FromImage(image); GDI.Rectangle rect = new GDI.Rectangle(0, 0, image.Width - 1, image.Height - 1); GDI.RectangleF rectF = new GDI.RectangleF(0, 0, image.Width, image.Height); LinearGradientBrush gradient = new LinearGradientBrush(rect.Location, new GDI.Point(rect.Right, rect.Bottom), GDI.Color.Gray, GDI.Color.LightGray); // String render format GDI.StringFormat stringFormat = new GDI.StringFormat(); stringFormat.Alignment = GDI.StringAlignment.Center; stringFormat.LineAlignment = GDI.StringAlignment.Center; // Draw image gfx.FillRectangle(gradient, rect); gfx.DrawRectangle(border, rect); rect.Inflate(new GDI.Size(-1, -1)); gfx.DrawRectangle(innerBorder, rect); rect.Inflate(new GDI.Size(-1, -1)); gfx.DrawRectangle(border, rect); gfx.DrawString("?", this.DisplayFont, GDI.Brushes.White, rectF, stringFormat); // Dispose border.Dispose(); innerBorder.Dispose(); stringFormat.Dispose(); gradient.Dispose(); gfx.Dispose(); } return(image); default: return(Glyph); } }
public static void RepertoryImage(Graphics drawDestination) { StringFormat itemStringFormat = new StringFormat(); RectangleF itemBox = new RectangleF(10, 30, 60, 20); itemStringFormat.Alignment = StringAlignment.Center; itemStringFormat.LineAlignment = StringAlignment.Center; drawDestination.DrawLine(Pens.LightGray,10,10,10,70); if (mMscStyle==MscStyle.SDL){ drawDestination.DrawLine(Pens.Black,10,20,65,20); drawDestination.DrawLine(Pens.Black,10,60,65,60); PointF[] capPolygon = new PointF[3]; capPolygon[0] = new PointF(65, 20); capPolygon[1] = new PointF(70, 15); capPolygon[2] = new PointF(60, 15); drawDestination.DrawPolygon(Pens.Black,capPolygon); capPolygon[0] = new PointF(65, 20); capPolygon[1] = new PointF(70, 25); capPolygon[2] = new PointF(60, 25); drawDestination.DrawPolygon(Pens.Black,capPolygon); drawDestination.DrawLine(Pens.Black,65,25,65,60); drawDestination.DrawLine(Pens.Black,62,57,68,63); drawDestination.DrawLine(Pens.Black,62,63,68,57); } else if(mMscStyle==MscStyle.UML2){ drawDestination.DrawLine(Pens.Black,10,20,25,20); drawDestination.DrawLine(Pens.Black,10,60,25,60); drawDestination.DrawLine(Pens.Black,20,20,20,60); drawDestination.DrawLine(Pens.Black,20,21,23,27); drawDestination.DrawLine(Pens.Black,20,21,17,27); drawDestination.DrawLine(Pens.Black,17,57,23,63); drawDestination.DrawLine(Pens.Black,17,63,23,57); } drawDestination.DrawString("Timer",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); itemStringFormat.Dispose(); }
public static void RepertoryImage(Graphics drawDestination, ItemPos position) { StringFormat itemStringFormat = new StringFormat(); if (position == ItemPos.Left){ drawDestination.DrawLine(Pens.DarkGray,70,10,70,70); RectangleF itemBox = new RectangleF(15, 12, 60, 14); itemStringFormat.Alignment = StringAlignment.Near; itemStringFormat.LineAlignment = StringAlignment.Near; drawDestination.DrawLine(Pens.Black,15,30,70,30); drawDestination.DrawLine(Pens.Black,11,26,19,34); drawDestination.DrawLine(Pens.Black,11,34,19,26); drawDestination.DrawString("StopTimer",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); } else if (position == ItemPos.Right){ drawDestination.DrawLine(Pens.DarkGray,10,10,10,70); RectangleF itemBox = new RectangleF(11, 12, 60, 14); itemStringFormat.Alignment = StringAlignment.Near; itemStringFormat.LineAlignment = StringAlignment.Near; drawDestination.DrawLine(Pens.Black,10,30,65,30); drawDestination.DrawLine(Pens.Black,61,26,69,34); drawDestination.DrawLine(Pens.Black,61,34,69,26); drawDestination.DrawString("StopTimer",new Font("Arial",8),Brushes.Black,itemBox,itemStringFormat); } itemStringFormat.Dispose(); }