static void Main(string[] args) { bool EndPointPending = false; //Am I in the middle of drawing a line? Point StartPoint = new Point(); Point EndPoint = new Point(); Point FillPoint = new Point(); Draw.Scale = 10; for (;;) { if (!EndPointPending) { if (Draw.GetLastMouseLeftClickScaled(out StartPoint)) { EndPointPending = true; } } else { if (Draw.GetLastMouseLeftClickScaled(out EndPoint)) { EndPointPending = false; AddBBLineScaled(StartPoint, EndPoint, Color.Blue); } } if (Draw.GetLastMouseRightClickScaled(out FillPoint)) { FloodFill(FillPoint, Color.Red); } } if (Debugger.IsAttached) { Console.ReadKey(); } }
/*********************************** * Author: Angelo M Sanches * Sets us up to draw things *************************************/ private void Bu_Draw_Click(object sender, EventArgs e) { // if we are using the exteed draw creat a form for it and grab results if (Ch_DrawShape.Checked && DrawChecker.Enabled == false) { DrawModel newDraws = new DrawModel(Scale, DrawLife); if (newDraws.ShowDialog() == DialogResult.OK) { DrawLife = newDraws.DrawLife; } } // else just grab a colour and go else if (DrawChecker.Enabled == false) { colorDialog1.ShowDialog(); if (Colour != Color.Black) { Colour = colorDialog1.Color; } } // if we want to clear clear if (DrawChecker.Enabled == false && !Ch_DoNotDrawClear.Checked) { Eco = new Life[wSizeX, wSizeY]; Draw(); } // clear last mouse click and start tick Point dummy; Box.GetLastMouseLeftClickScaled(out dummy); DrawChecker.Enabled = !DrawChecker.Enabled; }
//whenever the timer ticks check for a left click, //in the GDI window, and call the FloodFill method private void timer1_Tick(object sender, EventArgs e) { Point mouseClick; //Point variable to determine mouseclick //if user left cliked in GDI window if (_Canvas.GetLastMouseLeftClickScaled(out mouseClick)) { //call FloodFill method FloodFill(mouseClick.X, mouseClick.Y, Color.Black, _selectedColor); } }
/// <summary> /// this just pulls for mouse clicks and spawns sand if their holding the mouse down /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer_Tick(object sender, EventArgs e) { Point p; if (_Canvas != null && _Canvas.GetLastMouseLeftClickScaled(out p)) { for (int i = 0; i < trackBarBrushSize.Value; i++) { try { sandArray[p.X, p.Y] = _Selected_Type; sandArray[p.X + i, p.Y] = _Selected_Type; sandArray[p.X, p.Y + i] = _Selected_Type; sandArray[p.X - i, p.Y] = _Selected_Type; sandArray[p.X, p.Y - i] = _Selected_Type; sandArray[p.X + i, p.Y + i] = _Selected_Type; sandArray[p.X - i, p.Y + i] = _Selected_Type; sandArray[p.X - i, p.Y - i] = _Selected_Type; sandArray[p.X + i, p.Y - i] = _Selected_Type; } catch { //lol } } last_coords = p; } if (_Canvas != null && _Canvas.GetMouseDown()) { _Canvas.GetLastMousePositionScaled(out last_coords); for (int i = 0; i < trackBarBrushSize.Value; i++) { try { //v shit way to draw a bunch of sand. throws when trying to draw off screen sandArray[last_coords.X, last_coords.Y] = _Selected_Type; sandArray[last_coords.X + i, last_coords.Y] = _Selected_Type; sandArray[last_coords.X, last_coords.Y + i] = _Selected_Type; sandArray[last_coords.X - i, last_coords.Y] = _Selected_Type; sandArray[last_coords.X, last_coords.Y - i] = _Selected_Type; sandArray[last_coords.X + i, last_coords.Y + i] = _Selected_Type; sandArray[last_coords.X - i, last_coords.Y + i] = _Selected_Type; sandArray[last_coords.X - i, last_coords.Y - i] = _Selected_Type; sandArray[last_coords.X + i, last_coords.Y - i] = _Selected_Type; } catch { //lol } } } }
//When Timer tick occurs private void UI_Timer1_Tick(object sender, EventArgs e) { drawSpace.GetLastMouseLeftClickScaled(out getPoint); //Periodically check mouse in drawer window if (getPoint != lastPoint && getPoint.X >= 0) { lastPoint = getPoint; //Create new thread //Apply method DrawingData newData = new DrawingData(getPoint, numPixels); Wanderer((object)newData); //pass to wanderer method } }
/*********************************** * Author: Angelo M Sanches * draws every time we click or eraces if need be *************************************/ private void DrawCheck_Tick(object sender, EventArgs e) { Point Get; if (Drawer.GetLastMouseLeftClickScaled(out Get)) { if (!DrawLife[Get.X, Get.Y].bIsAlive) { DrawLife[Get.X, Get.Y].bIsAlive = true; DrawLife[Get.X, Get.Y].Colour = DrawColour; Drawer.SetBBScaledPixel(Get.X, Get.Y, DrawColour); } else { DrawLife[Get.X, Get.Y].bIsAlive = false; Drawer.SetBBScaledPixel(Get.X, Get.Y, Color.Black); } Drawer.Render(); } }