System.Drawing.Graphics.Dispose()

Here are the examples of the csharp api class System.Drawing.Graphics.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: Krypton
Source File: ViewContext.cs
public void Dispose()
        {
            // Is there a graphics instance that might need disposed?
            if (_graphics != null)
            {
                // Only dispose if we created it
                if (_disposeGraphics)
                    _graphics.Dispose();

                _graphics = null;
            }

            // Is there a manager instance that might need disposed?
            if (_manager != null)
            {
                // Only dispose if we created it
                if (_disposeManager)
                    _manager.Dispose();

                _manager = null;
            }
        }

2. Example

Project: xsddiagram
Source File: MainForm.cs
private void UpdateDiagram()
		{
			if (this.diagram.RootElements.Count != 0)
			{
				Graphics g = this.panelDiagram.DiagramControl.CreateGraphics();
				this.diagram.Layout(g);
				g.Dispose();
				Size bbSize = this.diagram.BoundingBox.Size + this.diagram.Padding + this.diagram.Padding;
				this.panelDiagram.VirtualSize = new Size((int)(bbSize.Width * this.diagram.Scale), (int)(bbSize.Height * this.diagram.Scale));
			}
			else
				this.panelDiagram.VirtualSize = new Size(0, 0);
		}

3. Example

Project: arcobjects-sdk-community-samples
Source File: SpatialQuery.cs
private void UpdateValueDisplay()
		{
			Graphics graphics = this.CreateGraphics();

			dataGridView/n ..... /n //View Source file for more details /n }

4. Example

Project: cassette
Source File: SpriteWriter.cs
public void Dispose()
        {
            if (drawingSurface != null)
                drawingSurface.Dispose();
        }

5. Example

Project: just-gestures
Source File: UC_TP_baseActivator.cs
public virtual void Display_MouseClick(object sender, MouseEventArgs e)
        {
            if (m_tempGesture.Activator != null)
            {
                if (m_gp != null) m_gp.Dispose();
                m_tempGesture.Activator.AnimateToPictureBox(m_pbDisplay);
            }
        }

6. Example

Project: MultiversePlatform
Source File: LayeredComplexText.cs
protected void ReleaseGraphics(Graphics g) {
            if (dynamic) {
                g.Dispose();
                chunkAtlas.texture.ReleaseGraphics();
            }
        }

7. Example

Project: RequestReduce
Source File: SpriteWriter.cs
public void Dispose()
        {
            if (drawingSurface != null)
                drawingSurface.Dispose();
        }

8. Example

Project: ATF
Source File: D2dGraphics.cs
public void EndGdiSection()
        {
            if (m_graphics == null)
                throw new InvalidOperationException("BeginGDISection() call required");

            m_graphics.Dispose();
            m_graphics = null;
            m_gdiInterop.ReleaseDC();
        }

9. Example

Project: GestureSign
Source File: DiBitmap.cs
public void Dispose()
        {
            if (_graphics != null)
            {
                _graphics.Dispose();
                _graphics = null;
            }

            NativeMethods.SelectObject(_memDc, _oldObject);
            NativeMethods.DeleteDC(_memDc);

            if (HBitmap != IntPtr.Zero)
            {
                NativeMethods.DeleteObject(HBitmap);
                HBitmap = IntPtr.Zero;
            }

        }

10. Example

Project: SQLMonitor
Source File: TreeBuilder.cs
public void Dispose()
        {
            _tree = null;

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

11. Example

Project: PersianBingCalendar
Source File: PersianCalendarRenderer.cs
protected virtual void Dispose(bool disposeManagedResources)
        {
            if (_disposed) return;
            if (!disposeManagedResources) return;

            _graphics?.Dispose();
            _disposed = true;
        }

12. Example

Project: WGestures
Source File: DiBitmap.cs
public void Dispose()
        {
            if (_graphics != null)
            {
                _graphics.Dispose();
                _graphics = null;
            }

            Native.SelectObject(_memDc, _oldObject);
            Native.DeleteDC(_memDc);

            if (HBitmap != IntPtr.Zero)
            {
                Native.DeleteObject(HBitmap);
                HBitmap = IntPtr.Zero;
            }

        }

13. Example

Project: ContinuousTests
Source File: DefaultErrorListRenderer.cs
public void Dispose()
            {
                if (_workingImage != null)
                {
                    _workingImage.Dispose();
                    WorkingGraphics.Dispose();
                }

                return;
            }

14. Example

Project: ContinuousTests
Source File: DefaultErrorListRenderer.cs
public void Dispose()
            {
                if (_workingImage != null)
                {
                    _workingImage.Dispose();
                    WorkingGraphics.Dispose();
                }

                return;
            }

15. Example

Project: ContinuousTests
Source File: DefaultErrorListRenderer.cs
public void Dispose()
            {
                if (_workingImage != null)
                {
                    _workingImage.Dispose();
                    WorkingGraphics.Dispose();
                }

                return;
            }

16. Example

Project: nextra
Source File: DataGridViewExtensionsBehvaior.cs
[TearDown]
		public void TearDown()
		{
			_dgv.Dispose();
			_graphics.Dispose();
			_imageList.Dispose();
			_paintingEventArgs = null;
		}

17. Example

Project: EDDiscovery
Source File: TabControlCustom.cs
private void CleanUp()
        {
            if (backImageControlBitmap != null)
            {
                backImageControlBitmap.Dispose();
                backImageControlBitmap = null;
            }
            if (backImageBitmap != null)
            {
                backImageBitmap.Dispose();
                backImageBitmap = null;
            }
            if (backImageGraphics != null)
            {
                backImageGraphics.Dispose();
                backImageGraphics = null;
            }
            if (tabImageBitmap != null)
            {
                tabImageBitmap.Dispose();
                tabImageBitmap = null;
            }
            if (tabImageGraphics != null)
            {
                tabImageGraphics.Dispose();
                tabImageGraphics = null;
            }
        }

18. Example

Project: tesvsnip
Source File: virtuallistview.cs
private void DisposeInternal()
        {
            if (internalGraphics != null)
                internalGraphics.Dispose();
            if (internalBitmap != null)
                internalBitmap.Dispose();
        }

19. Example

Project: falloutsnip
Source File: virtuallistview.cs
private void DisposeInternal()
        {
            if (internalGraphics != null)
                internalGraphics.Dispose();
            if (internalBitmap != null)
                internalBitmap.Dispose();
        }

20. Example

Project: Afterglow
Source File: CopyScreenCapture.cs
public override void Stop()
        {
            _running = false;
            if (_img != null)
            {
                _img.Dispose();
                _img = null;
            }
            if (_graphics != null)
            {
                _graphics.Dispose();
                _graphics = null;
            }
        }

21. Example

Project: MGE-XE
Source File: MainForm.cs
protected override void OnPaint (System.Windows.Forms.PaintEventArgs e) {
                Graphics graphics = e.Graphics;
                Icon ic = new Icon (Properties.Resources.AppIcon, 96, 96);
                graphics.DrawIcon (ic, 12, 24);
                graphics.Dispose ();
            }

22. Example

Project: gitter
Source File: FlowLayoutControl.cs
protected override void UpdateHover(int x, int y)
		{
			if(_mouseDownPanel != null && _mouseDownPanel.FlowControl == this)
			{
				int panelY = ClientArea.Y - VScrollPos;
				for(int i = 0; i < _panels.Count; ++i)
				{
					var panel = _panels[i];
					var size = GetPanelSize(panel);
					int maxY = panelY + size.Height;
					if(panel == _mouseDownPanel)
					{
						_panelHover.Track(i, panel);
						panel.MouseMove(x - ClientArea.X + HScrollPos, y - panelY);
						break;
					}
					panelY = maxY;
				}
			}
			else
			{
				if(x >= ClientArea.X && x < ClientArea.Right)
				{
					bool hover = false;
					Graphics graphics = null;
					int panelY = ClientArea.Y - VScrollPos;
					for(int i = 0; i < _panels.Count; ++i)
					{
						var panel = _panels[i];
						var size = GetPanelSize(panel);
						int maxY = panelY + size.Height;
						if(maxY >= y)
						{
							hover = true;
							_panelHover.Track(i, panel);
							panel.MouseMove(x - ClientArea.X + HScrollPos, y - panelY);
							break;
						}
						if(maxY >= ClientRectangle.Bottom)
						{
							break;
						}
						panelY = maxY;
					}
					if(!hover)
					{
						_panelHover.Drop();
					}
					if(graphics != null)
					{
						graphics.Dispose();
					}
				}
				else
				{
					_panelHover.Drop();
				}
			}
			base.UpdateHover(x, y);
		}

23. Example

Project: gitter
Source File: TextBoxSpellChecker.cs
private void OnSizeChanged(object sender, EventArgs e)
		{
			if(_textBoxGraphics != null)
			{
				_textBoxGraphics.Dispose();
			}
			_textBoxGraphics = Graphics.FromHwnd(_textBox.Handle);
		}

24. Example

Project: Mario-Game
Source File: Form1.cs
private void MainForm_Paint(object sender, PaintEventArgs e)
        {
            Graphics xGraph = e.Graphics;
            xGraph.DrawImage(MainImage, 0, 0);
            xGraph.Dispose();


        }

25. Example

Project: ElectronicObserver
Source File: DialogHalloween.cs
private void DialogHalloween_FormClosed(object sender, FormClosedEventArgs e)
		{

			Updater.Stop();

			paintbrush.Dispose();
			canvas.Dispose();
			for (int i = 0; i < fairies.Length; i++)
				if (fairies[i] != null)
					fairies[i].Dispose();

		}

26. Example

Project: WzComparerR2
Source File: Gif.cs
private Bitmap GetFrame(int i, Rectangle canvasRect)
        {
            var iFrame = this.Frames[i];
            Bitmap bmp = new Bitmap(canvasRect.Width, canvasRect.Height, PixelFormat.Format32bppArgb);
            Graphics g = Graphics.FromImage(bmp);
            iFrame.Draw(g, canvasRect);
            g.Dispose();
            return bmp;
        }

27. Example

Project: My-FyiReporting
Source File: RenderHtmlTable.cs
public void Dispose() 
		{
			// These should already be cleaned up; but in case of an unexpected error 
			//   these still need to be disposed of
			if (_bm != null)
				_bm.Dispose();
			if (_g != null)
				_g.Dispose();
		}

28. Example

Project: My-FyiReporting
Source File: RenderExcel.cs
public void Dispose() 
		{
			// These should already be cleaned up; but in case of an unexpected error 
			//   these still need to be disposed of
			if (_bm != null)
				_bm.Dispose();
			if (_g != null)
				_g.Dispose();
		}

29. Example

Project: My-FyiReporting
Source File: RenderExcel.cs
public virtual void End()
        {
            Stream fs = _sg.GetStream();
            _Excel.WriteExcel(fs);

			if (_g != null)
			{
				_g.Dispose();
				_g = null;
			}
			if (_bm != null)
			{
				_bm.Dispose();
				_bm = null;
			}
			return;
		}

30. Example

Project: My-FyiReporting
Source File: RenderHtml.cs
public void Dispose() 
		{
			// These should already be cleaned up; but in case of an unexpected error 
			//   these still need to be disposed of
			if (_bm != null)
				_bm.Dispose();
			if (_g != null)
				_g.Dispose();
		}

31. Example

Project: My-FyiReporting
Source File: RenderRtf.cs
public void Dispose() 
		{
			// These should already be cleaned up; but in case of an unexpected error 
			//   these still need to be disposed of
			if (_bm != null)
				_bm.Dispose();
			if (_g != null)
				_g.Dispose();
		}

32. Example

Project: My-FyiReporting
Source File: Pages.cs
public void CleanUp()
		{
			if (_g != null)
			{
				_g.Dispose();
				_g = null;
			}
			if (_bm != null)
			{
				_bm.Dispose();
				_bm = null;
			}
		}

33. Example

Project: just-gestures
Source File: Form_addGesture.cs
private void panel_ForButtons_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = panel_ForButtons.CreateGraphics();
            g.DrawLine(new Pen(Brushes.Gray, 1), 0, 2, panel_ForButtons.Width, 2);
            //g.DrawLine(new Pen(Brushes.Black, 1), 0, 2, panel_ForButtons.Width, 2);
            g.DrawLine(new Pen(Brushes.White, 1), 0, 1, panel_ForButtons.Width, 1);
            g.Dispose();

        }

34. Example

Project: just-gestures
Source File: Form_modifyGesture.cs
private void panel_down_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = panel_down.CreateGraphics();
            g.DrawLine(new Pen(Brushes.Gray, 1), 0, 2, panel_down.Width, 2);
            g.DrawLine(new Pen(Brushes.White, 1), 0, 1, panel_down.Width, 1);
            g.Dispose();
            
        }

35. Example

Project: just-gestures
Source File: Form_options.cs
private void panel_down_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = panel_down.CreateGraphics();
            g.DrawLine(new Pen(Brushes.Gray, 1), 0, 2, panel_down.Width, 2);
            g.DrawLine(new Pen(Brushes.White, 1), 0, 1, panel_down.Width, 1);
            g.Dispose();
        }

36. Example

Project: just-gestures
Source File: Form_wizard.cs
private void panel_ForButtons_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = panel_ForButtons.CreateGraphics();
            g.DrawLine(new Pen(Brushes.Gray, 1), 0, 2, panel_ForButtons.Width, 2);
            //g.DrawLine(new Pen(Brushes.Black, 1), 0, 2, panel_ForButtons.Width, 2);
            g.DrawLine(new Pen(Brushes.White, 1), 0, 1, panel_ForButtons.Width, 1);
            g.Dispose();
        }

37. Example

Project: just-gestures
Source File: Form_gestures.cs
private void pB_display_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left && m_pathPoints.Count > 1)
            {
                m_gp.Dispose();
                m_mouseDown = false;
                RedrawAll();
            }
        }

38. Example

Project: MultiversePlatform
Source File: LayeredComplexText.cs
protected void DisposeBitmap()
        {
            if (staticGraphics != null)
            {
                staticGraphics.Dispose();
                staticGraphics = null;
            }
            // dispose of the bitmap
            if (bitmap != null)
            {
                bitmap.Dispose();
                bitmap = null;
            }
        }

39. Example

Project: HTML-Renderer
Source File: GraphicsAdapter.cs
public override void Dispose()
        {
            ReleaseHdc();
            if (_releaseGraphics)
                _g.Dispose();

            if (_useGdiPlusTextRendering && _setRtl)
                _stringFormat2.FormatFlags ^= StringFormatFlags.DirectionRightToLeft;
        }

40. Example

Project: oxyplot
Source File: SvgExporter.cs
public void Dispose()
        {
            this.g.Dispose();
            this.grc.Dispose();
        }

41. Example

Project: partcover.net4
Source File: TextControl.cs
protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (disposing)
            {
                if (null != graphics)
                {
                    graphics.Dispose();
                    graphics = null;
                }
                view = null;
            }
        }

42. Example

Project: GEDKeeper
Source File: GdiRenderer.cs
public void Dispose()
        {
            if (fCurrentFont != null) fCurrentFont.Dispose();
            fGraphics.Dispose();
        }

43. Example

Project: SharpMap
Source File: Utf8Grid.cs
public void Dispose()
        {
            if (this.bitmap != null)
            {
                this.bitmap.Dispose();
                this.bitmap = null;
            }
            if (this.graphics != null)
            {
                this.graphics.Dispose();
                this.graphics = null;
            }
        }

44. Example

Project: Gorgon
Source File: Spray.cs
private void Dispose(bool disposing)
        {
	        if (_disposed)
	        {
		        return;
	        }

	        if (disposing)
	        {
		        if (Surface != null)
		        {
			        Surface.Dispose();
			        Surface = null;
		        }

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

	        _disposed = true;
        }

45. Example

Project: Gorgon
Source File: FormCharacterPicker.cs
protected override void OnFormClosing(FormClosingEventArgs e)
		{
			base.OnFormClosing(e);

			DeselectFont();

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

46. Example

Project: xenadmin
Source File: GridView.cs
private void DisposeBuffer()
        {
            BackBuffer.Dispose();
            BufferGraphics.Dispose();
            Graphics.Dispose();
        }

47. Example

Project: xenadmin
Source File: DoubleBufferedPanel.cs
private void DisposeBuffer()
        {
            if (BufferGraphics != null)
            {
                BufferGraphics.Dispose();
                BufferGraphics = null;
            }

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

48. Example

Project: Cropper
Source File: PaintLayerEventArgs.cs
public void Dispose()
        {
            if (Graphics != null)
                Graphics.Dispose();
            if (Image != null)
                Image.Dispose();
        }

49. Example

Project: AutoTest.Net
Source File: DefaultErrorListRenderer.cs
public void Dispose()
            {
                if (_workingImage != null)
                {
                    _workingImage.Dispose();
                    WorkingGraphics.Dispose();
                }

                return;
            }

50. Example

Project: AutoTest.Net
Source File: DefaultErrorListRenderer.cs
public void Dispose()
            {
                if (_workingImage != null)
                {
                    _workingImage.Dispose();
                    WorkingGraphics.Dispose();
                }

                return;
            }