System.Drawing.Pen.Dispose()

Here are the examples of the csharp api class System.Drawing.Pen.Dispose() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

1. Example

Project: Cyotek.Windows.Forms.ImageBox
Source File: GroupBox.cs
private void CleanUpResources()
    {
      if (_topPen != null)
      {
        _topPen.Dispose();
      }

      if (_bottomPen != null)
      {
        _bottomPen.Dispose();
      }
    }

2. Example

Project: Cyotek.Windows.Forms.ColorPicker
Source File: GroupBox.cs
private void CleanUpResources()
    {
      if (_topPen != null)
      {
        _topPen.Dispose();
      }

      if (_bottomPen != null)
      {
        _bottomPen.Dispose();
      }
    }

3. Example

Project: DotSpatial
Source File: Speedometer.cs
protected override void OnPaintOffScreen(PaintEventArgs e)
        {
            PolarGraphics f = C/n ..... /n //View Source file for more details /n }

4. Example

Project: gitter
Source File: BackgroundStyle.cs
public void Dispose()
			{
				_outerBorder.Dispose();
				_innerBorder.Dispose();
			}

5. Example

Project: gitter
Source File: BackgroundStyle.cs
public void Dispose()
			{
				_outerBorder.Dispose();
			}

6. Example

Project: ElectronicObserver
Source File: FormCandidate.cs
private void FormCandidate_FormClosed(object sender, FormClosedEventArgs e)
		{
			blackPen.Dispose();
		}

7. Example

Project: My-FyiReporting
Source File: ChartLine.cs
void DrawLinePoint(Report rpt, Graphics g, Brush brush, ChartMarkerEnum marker, Point p, int iRow, int iCol)
		{
			Pen pen=null;
			try
			{
				pen = new Pen(brush);
				// 20022008 AJM GJL - Added bigger points
				DrawLegendMarker(g, brush, pen, marker, p.X-5, p.Y-5, 10);
				DrawDataPoint(rpt, g, new Point(p.X-5, p.Y+5), iRow, iCol);
			}
			finally
			{
				if (pen != null)
					pen.Dispose();
			}

			return;
		}

8. Example

Project: referencesource
Source File: LineChart.cs
protected override void Dispose(bool disposing)
        {
            if (disposing)
            { 
                // Dispose managed resources
                if (this._linePen != null)
                {
                    this._linePen.Dispose();
                    this._linePen = null;
                }
            }
            base.Dispose(disposing);
        }

9. Example

Project: MultiversePlatform
Source File: ImageGrid.cs
protected void UpdateSelectionPen()
        {
            if (selectionPen != null)
            {
                selectionPen.Dispose();
            }

            selectionPen = new Pen(selectionBorderColor, selectionBorderWidth);
        }

10. Example

Project: mwinapi
Source File: Note.cs
private void InvalidatePen()
        {
            if (drawPen != null)
            {
                drawPen.Dispose();
                drawPen = null; ;
            }
        }

11. Example

Project: vs-window-title-changer
Source File: BackgroundExpressionCompiler.cs
public virtual void Dispose()
		{
			Enabled = false;
			if (m_UnderlinePen != null)
			{
				m_UnderlinePen.Dispose();
				m_UnderlinePen = null;
			}
		}

12. Example

Project: WOT-Statistics
Source File: StyleEdit.cs
public void Dispose() {
            if (highlightPen != null) {
                highlightPen.Dispose();
                highlightPen = null;
            }
        }

13. Example

Project: poderosa
Source File: Caret.cs
private void DisposePen() {
            if (_pen != null) {
                _pen.Dispose(); //???????????
                _pen = null;
            }
        }

14. Example

Project: ecsharp
Source File: DrawStyle.cs
private void DisposePen()
		{
			if (_pen != null) {
				_pen.Dispose();
				_pen = null;
			}
		}

15. Example

Project: SharpMap
Source File: LineSymbolizerTest.cs
protected override void ReleaseManagedResources()
    {
        base.ReleaseManagedResources();
        ArrowPen.Dispose();
    }

16. Example

Project: SharpMap
Source File: BasicPolygonSymbolizer.cs
protected override void ReleaseManagedResources()
        {
            CheckDisposed();

            if (Outline != null)
            {
                Outline.Dispose();
                Outline = null;
            }

            base.ReleaseManagedResources();
        }

17. Example

Project: SharpMap
Source File: CachedLineSymbolizer.cs
protected override void ReleaseManagedResources()
        {
            if (Line != null)
                Line.Dispose();

            base.ReleaseManagedResources();
        }

18. Example

Project: SharpMap
Source File: LineSymbolizer.cs
protected override void ReleaseManagedResources()
        {
            CheckDisposed();

            if (Line != null) 
                Line.Dispose();
            
            base.ReleaseManagedResources();
        }

19. Example

Project: ATF
Source File: StatechartRenderer.cs
private void UpdateToTheme()
        {
            if (m_dividerPen != null)
                m_dividerPen.Dispose();
            m_dividerPen = new Pen(m_theme.OutlinePen.Color);
            m_fontHeight = m_theme.Font.Height;
        }

20. Example

Project: ATF
Source File: TreeListControl.cs
protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (m_seperatorPen != null)
                {
                    m_seperatorPen.Dispose();
                    m_seperatorPen = null;
                }
            }
        }

21. Example

Project: xenadmin
Source File: CustomListRow.cs
private void RecalculateBorderPen()
        {
            if (BorderPen != null)
                BorderPen.Dispose();
            BorderPen = new Pen(BorderColor, BorderWidth);
        }

22. Example

Project: xenadmin
Source File: CustomListRow.cs
private void RecalculateForePen()
        {
            if (ForePen != null)
                ForePen.Dispose();
            ForePen = new Pen(ForeColor);
        }

23. Example

Project: WGestures
Source File: ColorButton.cs
protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                mainPen.Dispose();
                borderPen.Dispose();
                shadowPen.Dispose();
            }

            base.Dispose(disposing);

        }

24. Example

Project: screencast-capture
Source File: CaptureClick.cs
protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                // free managed resources
                if (context != null)
                {
                    context.Dispose();
                    context = null;
                }

                if (penOuter != null)
                {
                    penOuter.Dispose();
                    penInner.Dispose();

                    penOuter = null;
                    penInner = null;
                }
            }
        }

25. Example

Project: ClearCanvas
Source File: VtkPresentationImageRenderer.cs
protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (_pen != null)
				{
					_pen.Dispose();
					_pen = null;
				}

				if (_gdiObjectFactory != null)
				{
					_gdiObjectFactory.Dispose();
					_gdiObjectFactory = null;
				}
			}

			base.Dispose(disposing);
		}

26. Example

Project: RNGReporter
Source File: PlainBorderPainter.cs
protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            pent.Dispose();
            penb.Dispose();
            cleart.Dispose();
            clearb.Dispose();
        }

27. Example

Project: RNGReporter
Source File: RarBorderPainter.cs
protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            border.Dispose();
        }

28. Example

Project: ContinuousTests
Source File: CodeRenderingContext.cs
public void Dispose()
            {
                this.Brush.Dispose();
                this.Pen.Dispose();
            }

29. Example

Project: ContinuousTests
Source File: CodeRenderingContext.cs
public void Dispose()
            {
                this.Brush.Dispose();
                this.Pen.Dispose();
            }

30. Example

Project: ContinuousTests
Source File: CodeRenderingContext.cs
public void Dispose()
            {
                this.Brush.Dispose();
                this.Pen.Dispose();
            }

31. Example

Project: diagramnet
Source File: LabelElement.cs
protected virtual void DrawBorder(Graphics g, Rectangle r)
		{
			//Border
			Pen p = new Pen(borderColor, borderWidth);
			g.DrawRectangle(p, r);
			p.Dispose();
		}

32. Example

Project: diagramnet
Source File: RectangleElement.cs
protected virtual void DrawBorder(Graphics g, Rectangle r)
		{
			//Border
			Pen p = new Pen(borderColor, borderWidth);
			g.DrawRectangle(p, r);
			p.Dispose();
		}

33. Example

Project: diagramnet
Source File: Document.cs
internal void DrawGrid(Graphics g, Rectangle clippingRegion)
		{
//			ControlPaint.DrawGrid(g, clippingRegion, gridSize, Color.LightGray);
		
			Pen p = new Pen(new HatchBrush(HatchStyle.LargeGrid | HatchStyle.Percent90, Color.LightGray, Color.Transparent), 1);

			//Pen p = new Pen(Color.LightGray, 1);
			
			int maxX = location.X + this.Size.Width;
			int maxY = location.Y + this.Size.Height;

			if (windowSize.Width / zoom > maxX)
				maxX = (int)(windowSize.Width / zoom);

			if (windowSize.Height / zoom > maxY)
				maxY = (int)(windowSize.Height / zoom);

			for(int i = 0; i < maxX; i += gridSize.Width)
			{
				g.DrawLine(p, i, 0, i, maxY);
			}

			for(int i = 0; i < maxY; i += gridSize.Height)
			{
				g.DrawLine(p, 0, i, maxX, i);
			}

			p.Dispose();
		}

34. Example

Project: MapleShark
Source File: DrawingTools.cs
public static void DrawDesignTimeLine(Graphics g, int x1, int y1, int x2, int y2)
        {
            var p = new Pen(SystemColors.ControlDarkDark) {DashOffset = 10, DashStyle = DashStyle.Dash};
            g.DrawLine(p, x1, y1, x2, y2);
            p.Dispose();
        }

35. Example

Project: MapleShark
Source File: DrawingTools.cs
public static void DrawDesignTimeBorder(Graphics g, Rectangle rect)
        {
            rect.Width --;
            rect.Height --;
            var p = new Pen(SystemColors.ControlDarkDark) {DashStyle = DashStyle.Dash};
            g.DrawRectangle(p, rect);
            p.Dispose();
        }

36. Example

Project: dp2
Source File: QrRecognitionControl.cs
public void DisposeResource(bool disposing)
        {
            if (disposing)
            {
                if (resultRectPen != null)
                    resultRectPen.Dispose();

                decodingThread.Abort();
                if (camDevices.Current != null)
                {
                    if (camDevices.Current.IsRunning)
                    {
                        camDevices.Current.SignalToStop();
                    }
                    camDevices.Current.NewFrame -= Current_NewFrame;
                }
            }
        }

37. Example

Project: dp2
Source File: LineLayerForm.cs
public void Dispose()
            {
                if (this.Pen != null)
                    this.Pen.Dispose();
                if (this.Brush != null)
                    this.Brush.Dispose();
            }

38. Example

Project: DotSpatial
Source File: MoveVertexFunction.cs
protected override void OnDraw(MapDrawArgs e)
        {
            Rectangle mouseRect = new Rectan/n ..... /n //View Source file for more details /n }

39. Example

Project: DotSpatial
Source File: SquareButton.cs
private void DrawBorders(Graphics g, Color baseColor)
        {
            Color light = baseColor.Lighter(.3F);
            Color dark = baseColor.Darker(.3F);
            Color topLeftColor = light;
            Color bottomRightColor = dark;
            if (State.IsPressed())
            {
                topLeftColor = dark;
                bottomRightColor = light;
            }

            Pen topLeftPen = new Pen(topLeftColor);
            Pen bottomRightPen = new Pen(bottomRightColor);
            Pen middlePen = new Pen(baseColor);
            float l = Bounds.Left;
            float r = Bounds.Right;
            float t = Bounds.Top;
            float b = Bounds.Bottom;

            // Straight line parts
            g.DrawLine(topLeftPen, l + 1F, t, r - 1F, t);
            g.DrawLine(bottomRightPen, l + 1F, b, r - 1F, b);
            g.DrawLine(topLeftPen, l, t + 1F, l, b - 1F);
            g.DrawLine(bottomRightPen, r, t + 1F, r, b - 1F);

            // "rounded" corner lines
            g.DrawLine(topLeftPen, l, t + 2F, l + 2F, t);
            g.DrawLine(middlePen, r - 2F, t, r, t + 2F);
            g.DrawLine(middlePen, l, b - 2F, l + 2F, b);
            g.DrawLine(bottomRightPen, r, b - 2F, r - 2F, b);

            topLeftPen.Dispose();
            bottomRightPen.Dispose();
            middlePen.Dispose();
        }

40. Example

Project: NClass
Source File: TabBar.cs
private void DrawCloseIcon(Graphics g)
		{
			Color lineColor = activeCloseButton ? SystemColors.ControlText : SystemColors.ControlDark;
			int margin = (Height - ClosingSignSize) / 2;
			int left = Width - margin - ClosingSignSize;
			Pen linePen = new Pen(lineColor, 2);

			g.DrawLine(linePen, left, margin, left + ClosingSignSize, margin + ClosingSignSize);
			g.DrawLine(linePen, left, margin + ClosingSignSize, left + ClosingSignSize, margin);
			linePen.Dispose();
		}

41. Example

Project: gitextensions
Source File: SpellRichTextBox.cs
protected override void Dispose(bool disposing)
		{
			if( disposing )
			{
				// free pen resources
				if(_errorPen != null)
					_errorPen.Dispose();
			}
			base.Dispose( disposing );
		}

42. Example

Project: gitextensions
Source File: PieSlice.cs
public virtual void Dispose()
        {
            if (Pen != null)
            {
                Pen.Dispose();
                Pen = null;
            }
            DisposeBrushes();
        }

43. Example

Project: winappdriver
Source File: OverlayForm.cs
private void DrawTarget(Graphics g, int x, int y, int radius)
        {
            var pen = new Pen(Color.Red, 2);
            int segment = radius * 2 / 3;

            int vx = x - radius; // top-left vertex
            int vy = y - radius;
            g.DrawLine(pen, vx, vy, vx, vy + segment);
            g.DrawLine(pen, vx, vy, vx + segment, vy);

            vx = x + radius; // top-right
            vy = y - radius;
            g.DrawLine(pen, vx, vy, vx, vy + segment);
            g.DrawLine(pen, vx, vy, vx - segment, vy);

            vx = x - radius; // bottom-left
            vy = y + radius;
            g.DrawLine(pen, vx, vy, vx, vy - segment);
            g.DrawLine(pen, vx, vy, vx + segment, vy);

            vx = x + radius; // bottom-right
            vy = y + radius;
            g.DrawLine(pen, vx, vy, vx, vy - segment);
            g.DrawLine(pen, vx, vy, vx - segment, vy);

            pen.Width = 1;
            g.DrawLine(pen, x - (segment / 2), y, x + (segment / 2), y);
            g.DrawLine(pen, x, y - (segment / 2), x, y + (segment / 2));

            pen.Dispose();
        }

44. Example

Project: gitter
Source File: SelectableColor.cs
private void Dispose(bool disposing)
		{
			if(_brush != null)
				_brush.Dispose();
			if(_pen != null)
				_pen.Dispose();
			if(disposing)
			{
				_brush = null;
				_pen = null;
			}
		}

45. Example

Project: SAI-Editor
Source File: CustomTabControl.cs
private void PaintTabBorder(System.Drawing.Graphics graph, int index, System.Drawing.Drawing2D.GraphicsPath path)
        {
            Pen borderPen = new Pen(SystemColors.ControlDark);

            if (index == this.SelectedIndex)
            {
                borderPen = new Pen(ThemedColors.ToolBorder);
            }
            graph.DrawPath(borderPen, path);
            borderPen.Dispose();
        }

46. Example

Project: My-FyiReporting
Source File: PageDrawing.cs
private void DrawLine(Color c, BorderStyleEnum bs, float w, Graphics g,
                                float x, float y, float x2, float y2)
        {
            if (bs == BorderStyleEnum.None || c.IsEmpty || w <= 0)	// nothing to draw
                return;

            float tmpW = w;
            if (g.PageUnit == GraphicsUnit.Pixel)
                tmpW = (tmpW * g.DpiX) / 72;
            Pen p = new Pen(c, tmpW);
            try
            {
                p = new Pen(c, w);
                switch (bs)
                {
                    case BorderStyleEnum.Dashed:
                        p.DashStyle = DashStyle.Dash;
                        break;
                    case BorderStyleEnum.Dotted:
                        p.DashStyle = DashStyle.Dot;
                        break;
                    case BorderStyleEnum.Double:
                    case BorderStyleEnum.Groove:
                    case BorderStyleEnum.Inset:
                    case BorderStyleEnum.Solid:
                    case BorderStyleEnum.Outset:
                    case BorderStyleEnum.Ridge:
                    case BorderStyleEnum.WindowInset:
                    default:
                        p.DashStyle = DashStyle.Solid;
                        break;
                }

                g.DrawLine(p, x, y, x2, y2);
            }
            finally
            {
                if (p != null)
                    p.Dispose();
            }

        }

47. Example

Project: My-FyiReporting
Source File: DesignXmlDraw.cs
private void DrawLine(Color c, BorderStyleEnum bs, float w,  
								float x, float y, float x2, float y2)
		{
            Color lc = c;
            if (this.ShowReportItemOutline)
            {   // force an outline
                lc = (bs == BorderStyleEnum.None || c.IsEmpty)? Color.LightGray : c;
                if (w <= 0)
                    w = 1;
            }
            else if (bs == BorderStyleEnum.None || c.IsEmpty || w <= 0)	// nothing to draw
            {
                return;
            }
			// adjust coordinates for scrolling
			x -= _hScroll;
			y -= _vScroll;
			x2 -= _hScroll;
			y2 -= _vScroll;

			Pen p=null;
			try
			{
				p = new Pen(lc, w);
				switch (bs)
				{
					case BorderStyleEnum.Dashed:
						p.DashStyle = DashStyle.Dash;
						break;
					case BorderStyleEnum.Dotted:
						p.DashStyle = DashStyle.Dot;
						break;
					case BorderStyleEnum.Double:
					case BorderStyleEnum.Groove:
					case BorderStyleEnum.Inset:
					case BorderStyleEnum.Solid:
					case BorderStyleEnum.Outset:
					case BorderStyleEnum.Ridge:
					case BorderStyleEnum.WindowInset:
					default:
						p.DashStyle = DashStyle.Solid;		
						break;
				}

				g.DrawLine(p,  x, y, x2, y2);
			}
			finally
			{
				if (p != null)
					p.Dispose();
			}

		}

48. Example

Project: My-FyiReporting
Source File: RenderTif.cs
private void DrawLine(Color c, BorderStyleEnum bs, float w, Graphics g, float x, float y, float x2, float y2)
        {
            if (bs == BorderStyleEnum.None || c.IsEmpty || w <= 0)   // nothing to draw 
                return;

            Pen p = null;
            try
            {
                p = new Pen(c, w);
                switch (bs)
                {
                    case BorderStyleEnum.Dashed:
                        p.DashStyle = DashStyle.Dash;
                        break;
                    case BorderStyleEnum.Dotted:
                        p.DashStyle = DashStyle.Dot;
                        break;
                    case BorderStyleEnum.Double:
                    case BorderStyleEnum.Groove:
                    case BorderStyleEnum.Inset:
                    case BorderStyleEnum.Solid:
                    case BorderStyleEnum.Outset:
                    case BorderStyleEnum.Ridge:
                    case BorderStyleEnum.WindowInset:
                    default:
                        p.DashStyle = DashStyle.Solid;
                        break;
                }

                g.DrawLine(p, x, y, x2, y2);
            }
            finally
            {
                if (p != null)
                    p.Dispose();
            }
        }

49. Example

Project: My-FyiReporting
Source File: PageDrawing.cs
private void DrawLine(Color c, BorderStyleEnum bs, float w, Graphics g,
                                float x, float y, float x2, float y2)
        {
            if (bs == BorderStyleEnum.None || c.IsEmpty || w <= 0)	// nothing to draw
                return;

            float tmpW = w;
            if (g.PageUnit == GraphicsUnit.Pixel)
                tmpW = (tmpW * g.DpiX) / 72;
            Pen p = new Pen(c, tmpW);
            try
            {
                p = new Pen(c, w);
                switch (bs)
                {
                    case BorderStyleEnum.Dashed:
                        p.DashStyle = DashStyle.Dash;
                        break;
                    case BorderStyleEnum.Dotted:
                        p.DashStyle = DashStyle.Dot;
                        break;
                    case BorderStyleEnum.Double:
                    case BorderStyleEnum.Groove:
                    case BorderStyleEnum.Inset:
                    case BorderStyleEnum.Solid:
                    case BorderStyleEnum.Outset:
                    case BorderStyleEnum.Ridge:
                    case BorderStyleEnum.WindowInset:
                    default:
                        p.DashStyle = DashStyle.Solid;
                        break;
                }

                g.DrawLine(p, x, y, x2, y2);
            }
            finally
            {
                if (p != null)
                    p.Dispose();
            }

        }

50. Example

Project: referencesource
Source File: StateDesigner.cs
protected override void Dispose(bool disposing)
        {
            try
            {
                if (this._connectorPen != null)
                {
                    this._connectorPen.Dispose();
                    this._connectorPen = null;
                }
            }
            finally
            {
                base.Dispose(disposing);
            }
        }