private Bitmap RecreateBackground() { lock (GlobalFont) { if (Background != null) { Background.Dispose(); } bool tabsDisplayed = StatsForm.CurrentSettings.ShowOverlayTabs; Bitmap newImage = new Bitmap(drawWidth, drawHeight, PixelFormat.Format32bppArgb); using (Graphics g = Graphics.FromImage(newImage)) { g.DrawImage(Properties.Resources.background, 0, tabsDisplayed ? 35 : 0); if (tabsDisplayed) { g.DrawImage(Properties.Resources.tab_unselected, drawWidth - 110, 0); } } if (flippedImage) { newImage.RotateFlip(RotateFlipType.RotateNoneFlipX); } DrawGraphics.Dispose(); DrawImage.Dispose(); DrawImage = new Bitmap(newImage.Width, newImage.Height, PixelFormat.Format32bppArgb); DrawGraphics = Graphics.FromImage(DrawImage); return(newImage); } }
private void DisplayBox_MouseMove(object sender, MouseEventArgs e) { var result = DrawGraphics.DrawBitmap(e, this.DisplayBox, vectorPointsList, pivotX, pivotY); DrawGrids(); DrawAngleAxis(result); DisplayBox.Refresh(); }
/// <summary> /// Gets called when the timer thread needs to render a new Scene / frame. /// </summary> /// <param name="graphics">A Graphics surface.</param> protected virtual void OnDrawGraphics(Graphics graphics) { graphics.BeginScene(); DrawGraphics?.Invoke(this, new DrawGraphicsEventArgs(graphics)); graphics.EndScene(); }
/// <summary> /// Отрисовка кривых из списка /// </summary> /// <param name="list"> Список кривых </param> private void Draw(List <VisualCurve> list) { IDrawer draw = new DrawGraphics(g, 1); foreach (VisualCurve c in list) { c.Draw(draw); } }
private void DrawMove(List <VisualCurve> list, VisualCurve move) { IDrawer draw = new DrawGraphics(g, 1); IDrawer drawMove = new DrawGraphics(g, 4); int ind = list.IndexOf(move); for (int i = 0; i < list.Count; i++) { if (i != ind) { list[i].Draw(draw); } else { list[i].Draw(drawMove); } } }
protected override void OnPaint(PaintEventArgs e) { lock (GlobalFont) { DrawGraphics.Clear(Color.Transparent); DrawGraphics.DrawImage(Background, 0, 0); foreach (Control control in Controls) { if (control is TransparentLabel label) { DrawGraphics.TranslateTransform(label.Location.X, label.Location.Y); label.Draw(DrawGraphics); DrawGraphics.TranslateTransform(-label.Location.X, -label.Location.Y); } } e.Graphics.InterpolationMode = InterpolationMode.Default; e.Graphics.PixelOffsetMode = PixelOffsetMode.None; e.Graphics.SmoothingMode = SmoothingMode.None; e.Graphics.DrawImage(DrawImage, new Rectangle(0, 0, ClientSize.Width, ClientSize.Height), new Rectangle(0, 0, DrawImage.Width, DrawImage.Height), GraphicsUnit.Pixel); } }
private void DrawAngleAxis(_3Matrix rotationResult) { DrawGraphics.AngleAxis(rotationResult, AnglePictureBox, AngleX, AngleY, AngleZ); AnglePictureBox.Refresh(); }
protected override void OnPaint(PaintEventArgs e) { try { base.OnPaint(e); if (base.ClientRectangle.Width - 2 * (this.m_BorderExteriorLength + this.m_OuterBorderLength + this.m_MiddleBorderLength + this.m_InnerBorderLength) > 0 && base.ClientRectangle.Height - 2 * (this.m_BorderExteriorLength + this.m_OuterBorderLength + this.m_MiddleBorderLength + this.m_InnerBorderLength) > 0) { DrawGraphics _DrawGraphics = new DrawGraphics(); int left = base.ClientRectangle.Left; int top = base.ClientRectangle.Top; Rectangle clientRectangle = base.ClientRectangle; Rectangle rectangle = base.ClientRectangle; Rectangle width = new Rectangle(left, top, clientRectangle.Width - 1, rectangle.Height - 1); e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias; SolidBrush solidBrush = new SolidBrush(base.Parent.BackColor); e.Graphics.FillRectangle(solidBrush, base.ClientRectangle); Pen pen = new Pen(solidBrush); e.Graphics.DrawRectangle(pen, base.ClientRectangle); pen.Dispose(); solidBrush.Dispose(); StringFormat stringFormat = new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; if (this.m_TextVisible && this.Text != string.Empty || !this.m_IndicatorAutoSize) { int m_IndicatorWidth2 = this.m_IndicatorWidth; int m_IndicatorHeight2 = this.m_IndicatorHeight; if (m_IndicatorWidth2 > width.Width) { m_IndicatorWidth2 = width.Width; } if (m_IndicatorHeight2 > width.Height) { m_IndicatorHeight2 = width.Height; } width.Width = m_IndicatorWidth2; width.Height = m_IndicatorHeight2; if (this.m_TextPosition == DAS_TextPosStyle.TPS_Left) { int x_ClientRectangle = base.ClientRectangle.X; Rectangle clientRectangle1 = base.ClientRectangle; width.X = x_ClientRectangle + clientRectangle1.Width - 1 - m_IndicatorWidth2; int y_ClientRectangle = base.ClientRectangle.Y; Rectangle rectangle1 = base.ClientRectangle; width.Y = y_ClientRectangle + (rectangle1.Height - 1 - m_IndicatorHeight2) / 2; stringFormat.Alignment = StringAlignment.Near; } else if (this.m_TextPosition == DAS_TextPosStyle.TPS_Right) { width.X = base.ClientRectangle.X; int num = base.ClientRectangle.Y; Rectangle clientRectangle2 = base.ClientRectangle; width.Y = num + (clientRectangle2.Height - 1 - m_IndicatorHeight2) / 2; stringFormat.Alignment = StringAlignment.Far; } else if (this.m_TextPosition == DAS_TextPosStyle.TPS_Top) { int x1 = base.ClientRectangle.X; Rectangle rectangle2 = base.ClientRectangle; width.X = x1 + (rectangle2.Width - 1 - m_IndicatorWidth2) / 2; int y1 = base.ClientRectangle.Y; Rectangle clientRectangle3 = base.ClientRectangle; width.Y = y1 + (clientRectangle3.Height - 1 - m_IndicatorHeight2); stringFormat.LineAlignment = StringAlignment.Near; } else if (this.m_TextPosition != DAS_TextPosStyle.TPS_Bottom) { int num1 = base.ClientRectangle.X; Rectangle rectangle3 = base.ClientRectangle; width.X = num1 + (rectangle3.Width - 1 - m_IndicatorWidth2) / 2; int y2 = base.ClientRectangle.Y; Rectangle clientRectangle4 = base.ClientRectangle; width.Y = y2 + (clientRectangle4.Height - 1 - m_IndicatorHeight2) / 2; } else { int x2 = base.ClientRectangle.X; Rectangle rectangle4 = base.ClientRectangle; width.X = x2 + (rectangle4.Width - 1 - m_IndicatorWidth2) / 2; width.Y = base.ClientRectangle.Y; stringFormat.LineAlignment = StringAlignment.Far; } } Rectangle rectangle5 = new Rectangle(width.Left + this.m_BorderExteriorLength + this.m_OuterBorderLength + this.m_MiddleBorderLength + this.m_InnerBorderLength - 1, width.Top + this.m_BorderExteriorLength + this.m_OuterBorderLength + this.m_MiddleBorderLength + this.m_InnerBorderLength - 1, width.Width - 2 * (this.m_BorderExteriorLength + this.m_OuterBorderLength + this.m_MiddleBorderLength + this.m_InnerBorderLength - 1), width.Height - 2 * (this.m_BorderExteriorLength + this.m_OuterBorderLength + this.m_MiddleBorderLength + this.m_InnerBorderLength - 1)); GraphicsPath graphicsPath = null; if (this.m_Shape != DAS_ShapeStyle.SS_Rect && this.m_Shape != DAS_ShapeStyle.SS_RoundRect && this.m_Shape != DAS_ShapeStyle.SS_Circle) { graphicsPath = new GraphicsPath(); _DrawGraphics.method_6(graphicsPath, width, this.m_Shape, this.m_ArrowWidth + this.m_BorderExteriorLength + this.m_OuterBorderLength + this.m_MiddleBorderLength + this.m_InnerBorderLength, this.m_BorderExteriorLength + this.m_OuterBorderLength + this.m_MiddleBorderLength + this.m_InnerBorderLength); } if (!this.m_Value) { _DrawGraphics.SetValue(e.Graphics, rectangle5, this.m_Shape, graphicsPath, this.m_OffColor, this.m_OffGradientColor, this.m_GradientType, this.m_GradientAngle, this.m_GradientRate, this.m_RoundRadius - this.m_BorderExteriorLength - this.m_OuterBorderLength - this.m_MiddleBorderLength - this.m_InnerBorderLength, this.m_ArrowWidth, this.m_ShinePosition); } else { _DrawGraphics.SetValue(e.Graphics, rectangle5, this.m_Shape, graphicsPath, this.m_OnColor, this.m_OnGradientColor, this.m_GradientType, this.m_GradientAngle, this.m_GradientRate, this.m_RoundRadius - this.m_BorderExteriorLength - this.m_OuterBorderLength - this.m_MiddleBorderLength - this.m_InnerBorderLength, this.m_ArrowWidth, this.m_ShinePosition); } if (graphicsPath != null) { graphicsPath.Dispose(); } if (this.m_Shape == DAS_ShapeStyle.SS_Rect) { _DrawGraphics.SetRect(e.Graphics, width, this.m_OuterBorderLength, this.m_OuterBorderDarkColor, this.m_OuterBorderLightColor, this.m_MiddleBorderLength, this.m_MiddleBorderColor, this.m_InnerBorderLength, this.m_InnerBorderDarkColor, this.m_InnerBorderLightColor, this.m_BorderExteriorLength, this.m_BorderExteriorColor, this.m_BorderGradientType, this.m_BorderGradientAngle, this.m_BorderGradientRate, this.m_BorderGradientLightPos1, this.m_BorderGradientLightPos2, this.m_BorderLightIntermediateBrightness); } else if (this.m_Shape == DAS_ShapeStyle.SS_RoundRect) { System.Drawing.Region region = new System.Drawing.Region(base.ClientRectangle); GraphicsPath graphicsPath1 = new GraphicsPath(); _DrawGraphics.SetRoundRect(graphicsPath1, rectangle5, this.m_RoundRadius - this.m_BorderExteriorLength - this.m_OuterBorderLength - this.m_MiddleBorderLength - this.m_InnerBorderLength); region.Exclude(graphicsPath1); SolidBrush solidBrush1 = new SolidBrush(base.Parent.BackColor); e.Graphics.FillRegion(solidBrush1, region); solidBrush1.Dispose(); graphicsPath1.Dispose(); region.Dispose(); _DrawGraphics.SetRoundRect2(e.Graphics, width, this.m_RoundRadius, this.m_OuterBorderLength, this.m_OuterBorderDarkColor, this.m_OuterBorderLightColor, this.m_MiddleBorderLength, this.m_MiddleBorderColor, this.m_InnerBorderLength, this.m_InnerBorderDarkColor, this.m_InnerBorderLightColor, this.m_BorderExteriorLength, this.m_BorderExteriorColor, this.m_BorderGradientType, (long)this.m_BorderGradientAngle, this.m_BorderGradientRate, this.m_BorderGradientLightPos1, this.m_BorderGradientLightPos2, this.m_BorderLightIntermediateBrightness); } else if (this.m_Shape != DAS_ShapeStyle.SS_Circle) { _DrawGraphics.SetArrow(e.Graphics, width, this.m_Shape, this.m_RoundRadius, this.m_ArrowWidth, this.m_OuterBorderLength, this.m_OuterBorderDarkColor, this.m_OuterBorderLightColor, this.m_MiddleBorderLength, this.m_MiddleBorderColor, this.m_InnerBorderLength, this.m_InnerBorderDarkColor, this.m_InnerBorderLightColor, this.m_BorderExteriorLength, this.m_BorderExteriorColor, this.m_BorderGradientType, (long)this.m_BorderGradientAngle, this.m_BorderGradientRate, this.m_BorderGradientLightPos1, this.m_BorderGradientLightPos2, this.m_BorderLightIntermediateBrightness); } else { System.Drawing.Region region1 = new System.Drawing.Region(base.ClientRectangle); GraphicsPath graphicsPath2 = new GraphicsPath(); graphicsPath2.AddEllipse(rectangle5); region1.Exclude(graphicsPath2); SolidBrush solidBrush2 = new SolidBrush(base.Parent.BackColor); e.Graphics.FillRegion(solidBrush2, region1); solidBrush2.Dispose(); graphicsPath2.Dispose(); region1.Dispose(); _DrawGraphics.SetCircle(e.Graphics, width, this.m_OuterBorderLength, this.m_OuterBorderDarkColor, this.m_OuterBorderLightColor, this.m_MiddleBorderLength, this.m_MiddleBorderColor, this.m_InnerBorderLength, this.m_InnerBorderDarkColor, this.m_InnerBorderLightColor, this.m_BorderExteriorLength, this.m_BorderExteriorColor, this.m_BorderGradientType, (long)this.m_BorderGradientAngle, this.m_BorderGradientRate, this.m_BorderGradientLightPos1, this.m_BorderGradientLightPos2, this.m_BorderLightIntermediateBrightness); } if (this.m_TextVisible && this.Text != string.Empty) { SolidBrush solidBrush3 = new SolidBrush(this.ForeColor); e.Graphics.DrawString(this.Text, this.Font, solidBrush3, base.ClientRectangle, stringFormat); solidBrush3.Dispose(); } } } catch (ApplicationException applicationException) { MessageBox.Show(applicationException.ToString()); } }