// Initialize start of line drawing routine. public void StartLineDraw(Graphics grPad, Point ptStart) { // Set MousePressed flag to true at start of line drawing. f_bMousePressed = true; // Allocate temp working LineGraphic object. f_lgWorking = new LineGraphic(); // Add starting point to temp object. f_lgWorking.AddPoint(ptStart); }
/* -------------------------------- PRIVATE UTILITY METHODS --------------------------------- */ // Initialize Scratch Pad. private void InitScratchPad(Color clrCurrent, int nCurrentLineWidth) { // Allocate collection of LineGraphic objects. f_collLineGraphics = new List<LineGraphic>(); // Temp working LineGraphic initially set to null. f_lgWorking = null; // MousePressed flag set to false (not pressed to start.) f_bMousePressed = false; // Allocate Pen object. f_penLine = new Pen(Color.Black); // Set current line color & width for future lines drawn. CurrentLineColor = clrCurrent; CurrentLineWidth = nCurrentLineWidth; // Set both start & end caps for line segments to rounded ends. f_penLine.StartCap = LineCap.Round; f_penLine.EndCap = LineCap.Round; }
// End line stroke procedure. public void EndLineDraw() { if ((f_bMousePressed == true) && (f_lgWorking != null)) { // Store line color & width when object is committed. f_lgWorking.LineColor = CurrentLineColor; f_lgWorking.LineWidth = CurrentLineWidth; // Add Temp LineGraphic to LineGraphics collection. f_collLineGraphics.Add(f_lgWorking); // null temp object. f_lgWorking = null; // Reset MousePressed flag. f_bMousePressed = false; } }