draw problem
-
I have problem with this code is draw ships many time if u have any idea about it using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Diagnostics; using System.Text; using System.Windows.Forms; namespace DrawingGeomerticShips { public partial class Form1 : System.Windows.Forms.Form { private Pen nPen; public Form1():base() { InitializeComponent(); nPen = new Pen(Color.Black); } protected override void Dispose(bool disposing) { if (disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing); } //private Bitmap ColorMap; public enum dModes : int { Line, Rectangle, Ellipse, Brush, Path, Text, Eraser } //private Bitmap bmp; private Bitmap bmp2; private Graphics g2; private Color clr= Color.Red; //private Color clr2 = Color.blue; private int StartX; private int StartY; private int EndX; private int EndY; private int BoxWidth; private int BoxHeight; private System.Drawing.Drawing2D.GraphicsPath mpath = new System.Drawing.Drawing2D.GraphicsPath(); private dModes dmode; private int xLoc; private int yLoc; //private dStyles dstyle = dStyles.Outline; private Int16 pWidth = 1; //private Cursor c = new Cursor(GetEmbeddedFile("Whiteboard.ColorPicker.ico")); //private Cursor er = new Cursor(GetEmbeddedFile("Whiteboard.Eraser.ico")); private bool isDraw; private PointF pF; private PointF pFOld; [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint="HideCaret", ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Ansi, SetLastError=true)] public static extern Int32 HideCaret(Int32 hwnd); private bool allow; [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint="ShowCaret", ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Ansi, SetLastError=true)] public static extern Int32 ShowCaret(Int32 hwnd); [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint="CreateCaret", ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Ansi, SetLast
-
I have problem with this code is draw ships many time if u have any idea about it using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Diagnostics; using System.Text; using System.Windows.Forms; namespace DrawingGeomerticShips { public partial class Form1 : System.Windows.Forms.Form { private Pen nPen; public Form1():base() { InitializeComponent(); nPen = new Pen(Color.Black); } protected override void Dispose(bool disposing) { if (disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing); } //private Bitmap ColorMap; public enum dModes : int { Line, Rectangle, Ellipse, Brush, Path, Text, Eraser } //private Bitmap bmp; private Bitmap bmp2; private Graphics g2; private Color clr= Color.Red; //private Color clr2 = Color.blue; private int StartX; private int StartY; private int EndX; private int EndY; private int BoxWidth; private int BoxHeight; private System.Drawing.Drawing2D.GraphicsPath mpath = new System.Drawing.Drawing2D.GraphicsPath(); private dModes dmode; private int xLoc; private int yLoc; //private dStyles dstyle = dStyles.Outline; private Int16 pWidth = 1; //private Cursor c = new Cursor(GetEmbeddedFile("Whiteboard.ColorPicker.ico")); //private Cursor er = new Cursor(GetEmbeddedFile("Whiteboard.Eraser.ico")); private bool isDraw; private PointF pF; private PointF pFOld; [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint="HideCaret", ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Ansi, SetLastError=true)] public static extern Int32 HideCaret(Int32 hwnd); private bool allow; [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint="ShowCaret", ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Ansi, SetLastError=true)] public static extern Int32 ShowCaret(Int32 hwnd); [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint="CreateCaret", ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Ansi, SetLast
-
I have problem with this code is draw ships many time if u have any idea about it using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Diagnostics; using System.Text; using System.Windows.Forms; namespace DrawingGeomerticShips { public partial class Form1 : System.Windows.Forms.Form { private Pen nPen; public Form1():base() { InitializeComponent(); nPen = new Pen(Color.Black); } protected override void Dispose(bool disposing) { if (disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing); } //private Bitmap ColorMap; public enum dModes : int { Line, Rectangle, Ellipse, Brush, Path, Text, Eraser } //private Bitmap bmp; private Bitmap bmp2; private Graphics g2; private Color clr= Color.Red; //private Color clr2 = Color.blue; private int StartX; private int StartY; private int EndX; private int EndY; private int BoxWidth; private int BoxHeight; private System.Drawing.Drawing2D.GraphicsPath mpath = new System.Drawing.Drawing2D.GraphicsPath(); private dModes dmode; private int xLoc; private int yLoc; //private dStyles dstyle = dStyles.Outline; private Int16 pWidth = 1; //private Cursor c = new Cursor(GetEmbeddedFile("Whiteboard.ColorPicker.ico")); //private Cursor er = new Cursor(GetEmbeddedFile("Whiteboard.Eraser.ico")); private bool isDraw; private PointF pF; private PointF pFOld; [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint="HideCaret", ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Ansi, SetLastError=true)] public static extern Int32 HideCaret(Int32 hwnd); private bool allow; [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint="ShowCaret", ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Ansi, SetLastError=true)] public static extern Int32 ShowCaret(Int32 hwnd); [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint="CreateCaret", ExactSpelling=true, CharSet=System.Runtime.InteropServices.CharSet.Ansi, SetLast
That is unformatted and unreadable. I think I saw some CreateGraphics which is probably very wrong. Please edit your question to include PRE tags, then read this[^]. :)
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.