Example #1
0
        ///////////////////////////////////////////////Method\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

        /************************************************************************************************
        * Method: Wanderer()
        * Effect: Receives an object of strucure when thread is started. A random color will be chosen,
        *         and will draw pixels based on a random direction/velocity.
        * **********************************************************************************************/
        public static void Wanderer(object holder)
        {
            DrawingData info         = (DrawingData)(holder); //Unboxes structure
            Color       drawingColor = RandColor.GetColor();  //Holds random color for drawing
            Point       newPoint     = info.m_pCoor;

            drawSpace.SetBBScaledPixel(info.m_pCoor.X, info.m_pCoor.Y, drawingColor);
            drawSpace.Render();


            //Draw pixels
            for (int i = 0; i < info.m_iPixels; i++)
            {
                newPoint.X += rnd.Next(-1, 2);
                newPoint.Y += rnd.Next(-1, 2);
                newPoint.X  = (newPoint.X < 0) ? 0 : newPoint.X;
                newPoint.Y  = (newPoint.Y < 0) ? 0 : newPoint.Y;
                newPoint.X  = (newPoint.X > 799) ? 799 : newPoint.X;
                newPoint.Y  = (newPoint.Y > 599) ? 599 : newPoint.Y;

                drawSpace.SetBBScaledPixel(newPoint.X, newPoint.Y, drawingColor);
                Thread.Sleep(1);
                drawSpace.Render();
            }


            //lock gdi drawer during loop
        }
Example #2
0
        //[Make List]
        //extract the divisor as an integer.Using that divisor and the ScaledWidth and ScaledHeight of the CDrawer
        //use nested for() loops to generate all possible Points within the CDrawer window (based on the divisor increments)
        private void MakeList_Click(object sender, EventArgs e)
        {
            int divisor = (int)divisorUpDown.Value;

            //nested loops to generate all points in cdrawer
            for (int y = 0; y < drawer.ScaledHeight; y += divisor)    //y vals
            {
                for (int x = 0; x < drawer.ScaledWidth; x += divisor) //x vals
                {
                    ptr.Add(new Point(x, y));
                }
            }

            //once list has been populated , clear the drawer
            drawer.Clear();

            //itterate through list points while drawing fuchsia lines between all adjcent points
            for (int i = 1; i < ptr.Count; i++)
            {
                if (i != 1)
                {
                    drawer.AddLine(ptr[i - 1].X, ptr[i - 1].Y, ptr[i].X, ptr[i].Y, Color.Fuchsia);
                }
            }

            //render drawn lines
            drawer.Render();

            //display number of points in list
            ListButton.Text = $"List contains: {ptr.Count} points";
        }
Example #3
0
 //on button click provide a distinct set of shapes
 private void _btnDistinct_Click(object sender, EventArgs e)
 {
     shapes = shapes.Distinct().ToList();
     _drawer.Clear();
     render();
     _drawer.Render();
 }
Example #4
0
 private void UI_List_Butt_Click(object sender, EventArgs e)
 {
     pointList.Clear();
     while (pointList.Count != ((canvas.ScaledWidth / (int)UI_NumUpDown.Value) * (canvas.ScaledHeight / (int)UI_NumUpDown.Value)))
     {
         Point newPoint = new Point(rng.Next(0, (canvas.ScaledWidth / (int)UI_NumUpDown.Value)) * (int)UI_NumUpDown.Value,
                                    rng.Next(0, (canvas.ScaledHeight / (int)UI_NumUpDown.Value)) * (int)UI_NumUpDown.Value);
         if (pointList.Count == 0)
         {
             pointList.Add(newPoint);
         }
         else
         {
             if (!pointList.Contains(newPoint))
             {
                 pointList.Add(newPoint);
             }
         }
     }
     canvas.Clear();
     for (int i = 0; i < pointList.Count - 1; i++)
     {
         canvas.AddLine(pointList[i].X, pointList[i].Y, pointList[i + 1].X, pointList[i + 1].Y, Color.Magenta);
     }
     canvas.Render();
     Text = "Made N Points";
     UI_List_Butt.Text = "List contains: " + pointList.Count + " points";
 }
Example #5
0
        //***********************************************************************************************************************************************
        //Purpose:  recursive method as an attempt to solve a loaded maze, checking surrounding positions to find the valid path.
        //Parameter:MazeInfo maze - used to determine the current state of maze (solved or not) and the steps taken to solve the maze
        //          Point curPos  - the moved position to check if the current position is a valid path to take
        //Returns:  The maze's updated detail will be returned to check if the maze was solved or not
        //***********************************************************************************************************************************************
        private MazeInfo MazeSolver(MazeInfo maze, Point curPos)
        {
            if (!_mazeDets.result && !_cancel)
            {
                Thread.Sleep(_throttle);

                //exit conditions
                if (curPos.X == maze.endPos.X && curPos.Y == maze.endPos.Y)
                {
                    _stop.Stop();
                    _mazeDets.result = true;

                    //changes the state and label of buttons
                    this.Invoke(new MethodInvoker(delegate() { btnSolve.Enabled = false; }));
                    this.Invoke(new MethodInvoker(delegate() { btnSolve.Text = "Solve"; }));
                    this.Invoke(new MethodInvoker(delegate() { btnLoad.Enabled = true; }));

                    //adds the collected final information to the listbox
                    this.Invoke(new MethodInvoker(delegate() { listMazeLog.Items.Insert(0, $"The maze is solved in {maze.steps} steps / {_stop.ElapsedMilliseconds}ms"); }));

                    return(maze);
                }

                //out of bounds -> return to previous position
                //wall/visited -> return to previous position
                if (curPos.X < 0 || curPos.X >= maze.mazeWidth || curPos.Y < 0 || curPos.Y >= maze.mazeHeight ||
                    _state[curPos.Y, curPos.X] == Wall.wall || _state[curPos.Y, curPos.X] == Wall.visited)
                {
                    return(maze);
                }

                //will not colour the starting green pixel to another colour
                if (curPos.X != maze.startPos.X || curPos.Y != maze.startPos.Y)
                {
                    _canvas.SetBBScaledPixel(curPos.X, curPos.Y, maze.livePath);
                    _canvas.Render();
                }

                maze.steps += 1;
                _state[curPos.Y, curPos.X] = Wall.visited;

                //attempt to move position
                MazeSolver(maze, new Point(curPos.X + 1, curPos.Y));
                MazeSolver(maze, new Point(curPos.X - 1, curPos.Y));
                MazeSolver(maze, new Point(curPos.X, curPos.Y - 1));
                MazeSolver(maze, new Point(curPos.X, curPos.Y + 1));

                //reached a dead end, colour the return path to grey
                if (_mazeDets.result == false)
                {
                    _canvas.SetBBScaledPixel(curPos.X, curPos.Y, maze.deadPath);
                    _canvas.Render();
                }
            }
            return(_mazeDets);
        }
Example #6
0
        // occurs evertime program starts
        // when loaded gdi window is opened and initalized
        private void Form1_Load(object sender, EventArgs e)
        {
            _canvas.ContinuousUpdate = false;                          // allows objects to be drawn and animated cleanly
            const int SCALE = 20;                                      // scale constant

            _canvas.Scale = SCALE;                                     // sets pixels range for x and y
            _color        = Color.Red;                                 // set default shape color to red

            // draw circle in center of draw window for starting point
            _canvas.AddEllipse(_XPOS, _YPOS, 1, 1, Color.Red);
            _canvas.Render();
        }
Example #7
0
        // Main Menu Screen
        public static void MainMenu(ref CDrawer HangingPost)
        {
            bool  play_game = false;
            Point click;

            HangingPost.Clear();
            ////Draw hanged man, can use this for reference later
            //HangingPost.AddCenteredEllipse(270, 215, 50, 50, Color.Black);      //head
            //HangingPost.AddLine(250, 215, 245, 285, Color.Black, 5);            //torso
            //HangingPost.AddLine(250, 215, 230, 305, Color.Black, 5);            //right arm
            //HangingPost.AddLine(250, 215, 270, 305, Color.Black, 5);            //left arm
            //HangingPost.AddLine(245, 285, 230, 365, Color.Black, 5);            //right leg
            //HangingPost.AddLine(245, 285, 265, 365, Color.Black, 5);            //left leg

            ////Add peanut gallery
            //AddStickMan(60, 380, "Black", ref HangingPost, true);
            //AddStickMan(160, 420, "Black", ref HangingPost, true);
            //AddStickMan(300, 400, "Black", ref HangingPost, true);
            //AddStickMan(420, 420, "Black", ref HangingPost, true);

            //HangingPost.AddText("Let's Hang Someone!", 36, 0, 0, 800, 100, Color.DarkRed);

            //PG VERSION of Hangman
            HangingPost.AddCenteredEllipse(250, 245, 60, 60, Color.Empty, 5, Color.Black);      //head
            HangingPost.AddLine(250, 275, 250, 350, Color.Black, 5);                            //torso
            HangingPost.AddLine(250, 275, 220, 360, Color.Black, 5);                            //left arm
            HangingPost.AddLine(250, 275, 280, 360, Color.Black, 5);                            //right arm
            HangingPost.AddLine(250, 350, 230, 460, Color.Black, 5);                            //left leg
            HangingPost.AddLine(250, 350, 270, 460, Color.Black, 5);                            //right leg

            HangingPost.AddText("Let's Play Hangman!", 36, 0, 0, 800, 100, Color.DarkRed);
            HangingPost.AddText("Click anywhere to begin...", 12, 200, 500, 800, 100);
            HangingPost.Render();

            while (!play_game)
            {
                if (HangingPost.GetLastMouseLeftClick(out click))
                {
                    play_game = true;
                }
            }
            HangingPost.Clear();
            //// Idle peanut gallery
            //AddStickMan(60, 380, "Black", ref HangingPost, false);
            //AddStickMan(160, 420, "Black", ref HangingPost, false);
            //AddStickMan(300, 400, "Black", ref HangingPost, false);
            //AddStickMan(420, 420, "Black", ref HangingPost, false);
            HangingPost.Render();
        }
Example #8
0
        //Take in a canvas and scale, draw all of the blocks
        public void Render(CDrawer canvas, int Size)
        {
            canvas.Clear();

            for (int x = 0; x < XLength; x++)
            {
                for (int y = 0; y < YLength; y++)
                {
                    //Ignore nulls and retainer blocks, don't need to render them
                    if (grid[x, y] != null && !(grid[x, y] is RetainerBlock))
                    {
                        //Centered point
                        Point point = new Point(x * Size + (Size / 2), y * Size + (Size / 2));
                        //If free block, offset the point by Animation state
                        if (grid[x, y] is FreeBlock && grid[x, y].life != Life.Dying)
                        {
                            point.Y += (Size / 10) * grid[x, y].AnimationState; //Move down 1/10 of the size, per AnimationState
                        }

                        //Get our side length, shrunk by death
                        int sideLength = Size;
                        if (grid[x, y].life == Life.Dying)
                        {
                            // (-10%) * State + Size
                            sideLength = (-(Size / 10)) * grid[x, y].AnimationState + Size; //Shrink by 10% of size for every AnimationState
                        }

                        //Add every block using the point and size we just made
                        canvas.AddCenteredRectangle(point.X, point.Y, sideLength, sideLength, grid[x, y].Colour, 1, Color.Black);
                    }
                }
            }

            canvas.Render();
        }
Example #9
0
 private void grow()
 {
   canvas.SetBBScaledPixel(start.X, start.Y, color);
   pointDict.Add(this.start, 64);
   Point cur_point = start;
   while (growing)
   {
     List<Point> adjacent = this.getAdjacent(cur_point);
     adjacent.ShuffleList();
     var paired_list = adjacent.ToDictionary(x => x, x => pointDict.ContainsKey(x) ? pointDict[x] : 0).ToList();
     paired_list.Sort((x, y) => x.Value.CompareTo(y.Value));
     cur_point = paired_list[0].Key;
     if (pointDict.ContainsKey(cur_point))
     {
       pointDict[cur_point] += (pointDict[cur_point] <= 191) ? 64 : 255 - pointDict[cur_point];
       color_strength = pointDict[cur_point];
     }
     else
     {
       pointDict.Add(cur_point, 64);
       color_strength = 64;
     }
     updateColor();
     canvas.SetBBScaledPixel(cur_point.X, cur_point.Y, color);
     canvas.Render();
     Thread.Sleep(1);
   }
 }
Example #10
0
        private void Display()
        {
            _Canvas.Clear();

            foreach (Tree e in _Entities)
            {
                if (DEBUG_FLAG)
                {
                    if (e.onFire)
                    {
                        Color redtransparent;
                        if (_RNG.Next(0, 100) < 50)
                        {
                            redtransparent = Color.FromArgb(40, Color.Red);
                        }
                        else
                        {
                            redtransparent = Color.FromArgb(40, Color.Orange);
                        }

                        _Canvas.AddCenteredEllipse(e.pos.X, e.pos.Y, e.radiusOfFire, e.radiusOfFire, redtransparent);
                    }
                }
                _Canvas.AddCenteredEllipse(e.pos.X, e.pos.Y, e.size, e.size, e.color);
            }

            foreach (Ember e in _Embers)
            {
                _Canvas.AddCenteredEllipse(e.pos.X, e.pos.Y, e.size, e.size, e.color);
            }

            _Canvas.Render();
        }
Example #11
0
 private void Animate(object ListOBalls)
 {
     //Quick and dirty erase everything (could get fancy and overwrite
     //existing balls with black just before move and redraw, but that's
     //probably premature optimization).
     if (!(ListOBalls is List <Ball> Balls))
     {
         return;  //What is this thing?
     }
     while (true) //Forevs, unless parent thread goes away.
     {
         canvas.Clear();
         //My kingdom for a foreach with mutable list elements
         for (int i = 0; i < Balls.Count; ++i)
         {
             Ball b = Balls[i];
             //Move first.  That makes sure everything is on the canvas.
             b.Move();//This changes b! no other threads should be changing b, or I need to do more.
             canvas.AddCenteredEllipse((int)b.Location.X, (int)b.Location.Y, b.Size, b.Size, b.Color);
         }
         //Show the pretty thingees
         canvas.Render();
         Thread.Sleep(delay);
     }
 }
Example #12
0
        private void casio_Tick(object sender, EventArgs e)
        {
            Point vertex = new Point();

            if (Canvas.GetLastMouseLeftClick(out vertex))
            {
                Ball bola = new Ball(Canvas, vertex);

                foreach (Ball b in LBalls)
                {
                    bola.MarkOverlap(b);
                }

                LBalls.Add(bola);
            }
            Canvas.Clear();


            foreach (Ball b in LBalls)
            {
                b.Render();
            }

            Canvas.Render();
            if (Canvas.DrawerWindowSize.IsEmpty)
            {
                Application.Exit();
            }
        }
        public void Render(CDrawer canvas, Color bColor)
        {
            const int ballSize = 10;

            canvas.AddCenteredEllipse(_pos.X, _pos.Y, ballSize, ballSize, bColor);
            canvas.Render();
        }
Example #14
0
        /// <summary>
        /// Method for updating the canvas
        /// </summary>
        public void UpdateCanvas()
        {
            //clearing the canvas
            _canvas.Clear();

            //getting the max value of the dicitonary
            int max = drawDic.Max(x => x.Value);

            lock (drawDic)
            {
                //for each key value pair creating a rectangel and coloring it based its value/max value ratio
                foreach (KeyValuePair <byte, int> kvp in drawDic)
                {
                    int x   = (int)kvp.Key % 16;
                    int y   = (int)kvp.Key / 16;
                    int col = (int)(((double)kvp.Value / max) * 255);
                    _canvas.AddRectangle(x * 50, y * 50, 50, 50, Color.FromArgb(col, col, col));;

                    //if the color isn't black drawing it to the screen
                    if (col > 0)
                    {
                        _canvas.AddText($"{kvp.Key:X}", 10, x * 50, y * 50, 50, 50, Color.Yellow);
                    }
                }
            }
            //rending the canvas
            _canvas.Render();
        }
Example #15
0
 private void Animate(object ListOShapes)
 {
     //Quick and dirty erase everything (could get fancy and overwrite
     //existing Shapes with black just before move and redraw, but that's
     //probably premature optimization).
     if (!(ListOShapes is List <Shape> Shapes))
     {
         return;  //What is this thing?
     }
     while (true) //Forevs, unless parent thread goes away.
     {
         if (cbErase.Checked)
         {
             canvas.Clear();
         }
         //My kingdom for a foreach with mutable list elements
         lock (Shapes)
         {//Added because my event handlers could crossthread
             for (int i = 0; i < Shapes.Count; ++i)
             {
                 Shape s = Shapes[i];
                 //Move first.  That makes sure everything is on the canvas.
                 s.Move();//This changes b! no other threads should be changing b, or I need to do more.
                 s.Render(canvas);
             }
         }
         //Show the pretty thingees
         canvas.Render();
         Thread.Sleep(delay);
     }
 }
 /// <summary>
 /// the classes main worker function more or less it loads up the form
 /// </summary>
 void Load()
 {
     try
     {
         // load in a bit map
         Bitmap TempBitMap = (Bitmap)Bitmap.FromFile(Path);
         //---------------------------------------------------------------------------
         // the manditory check remove for any size
         if (TempBitMap.Width > 190 || TempBitMap.Height > 100)
         {
             throw new Exception("We are sorry but the image is too big. Please keep the images size to 190px by 100px as a larger object could result in a stack overflow. ");
         }
         //----------------------------------------------------------------------------------
         // if the file loads close the old one if it is not Null and create a display box insished to what we need based on the bit map
         Display?.Close();
         Display       = new CDrawer(TempBitMap.Width * 10, TempBitMap.Height * 10, false);
         Display.Scale = 10;
         // create a spaces state identifyer as a 2D rep of it
         SpaceStates[,] Spaces = new SpaceStates[TempBitMap.Width, TempBitMap.Height];
         // Set up a End and Start
         Point End   = new Point();
         Point Start = new Point();
         // now we can begin a case by case pixle checking/ set them in the box
         for (int x = 0; x < TempBitMap.Width; x++)
         {
             for (int y = 0; y < TempBitMap.Height; y++)
             {
                 Display.SetBBScaledPixel(x, y, TempBitMap.GetPixel(x, y));
                 // if it is black it is a wall
                 if (TempBitMap.GetPixel(x, y) == Color.FromArgb(0, 0, 0))
                 {
                     Spaces[x, y] = SpaceStates.closed;
                 }
                 // else its open but that is the default state so checking and writing will just slow us down
                 // so now we check for start(green) and end(red) that fall into the open side and store them acordingly
                 else if (TempBitMap.GetPixel(x, y) == Color.FromArgb(255, 0, 0))// red end
                 {
                     End = new Point(x, y);
                 }
                 else if (TempBitMap.GetPixel(x, y) == Color.FromArgb(0, 255, 0))// green start
                 {
                     Start = new Point(x, y);
                 }
             }
         }
         if (End.X == 0 && End.Y == 0 && Start.X == 0 && Start.Y == 0)
         {
             throw new Exception("odd the maze seems to be missing start or end or we some how put them on top of one another");
         }
         // only at the end render them
         Display.Render();
         Maze.DoneLoadCallBack.Invoke(Display, Start, End, Spaces);
     }
     //throw out some message boxes for failed attempts
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
Example #17
0
 //Show all Grid in white border
 //FOR TESTING ONLY
 public void ShowAll(CDrawer canvas)
 {
     foreach (Grid item in arrayGrid)
     {
         canvas.AddRectangle(item.currentGrid.X * Bsize, item.currentGrid.Y * Bsize, Bsize, Bsize, Color.Black, 2, Color.White);
         canvas.Render();
     }
 }
Example #18
0
        public void Show(CDrawer cDrawer, int add)
        {
            Color comp = Color.FromArgb(_BallColor.ToArgb() ^ 0x00fffffff);

            add++;
            cDrawer.Render();
            cDrawer.AddCenteredEllipse((int)ballCenter.X, (int)ballCenter.Y, radius * 2, radius * 2, _BallColor);
            cDrawer.AddText($"{add}", 14, new Rectangle(new Point((int)ballCenter.X, (int)ballCenter.Y), new Size(0, 0)), comp);
        }
Example #19
0
        private void BallTick_Tick(object sender, EventArgs e)
        {
            Point    rightClick = new Point(-1, -1);
            Point    leftClick  = new Point(-1, -1);
            PropBall ball;

            canvas.Clear();

            if (canvas.GetLastMouseRightClick(out rightClick))
            {
                ball = new PropBall(rightClick, PropBall.BallColor.Purple);
                ballList.Add(ball);
            }

            if (canvas.GetLastMouseLeftClick(out leftClick))
            {
                ball = new PropBall(leftClick, PropBall.BallColor.Orange);
                ballList.Add(ball);
            }

            for (int ballCount = 0; ballCount < ballList.Count(); ++ballCount)
            {
                foreach (PropBall ball2 in ballList)
                {
                    if (!ball2.Equals(ballList[ballCount]))
                    {
                        if (ball2.GetColor != ballList[ballCount].GetColor)
                        {
                            ballList[ballCount].Love = ball2;
                        }
                        else
                        {
                            ballList[ballCount].Hate = ball2;
                        }
                    }
                }
                if (ballList[ballCount].Pos.X < 0 ||
                    ballList[ballCount].Pos.X > 800 ||
                    ballList[ballCount].Pos.Y < 0 ||
                    ballList[ballCount].Pos.Y > 600)
                {
                    outBound.Add(ballList[ballCount]);
                }
            }

            foreach (PropBall outBall in outBound)
            {
                ballList.Remove(outBall);
            }


            foreach (PropBall mBall in ballList)
            {
                mBall.Render(canvas);
            }
            canvas.Render();
        }
Example #20
0
        // Button Constructor/Controller; User selects button and returns a char
        static char SelectLetter(ref CDrawer HangingPost)
        {
            char  selection = ' ';
            Point click;
            bool  valid_click = false;
            int   counter     = 0;
            // Generate buttons
            var button = new Button[26];                //create array of class Button

            for (int i = 0; i < 26; i++)
            {
                button[i]       = new Button();         //construct new Button for each element in array
                button[i].alpha = (char)(i + 65);
                if (i < 13)
                {
                    button[i].xMin_coord = 250 + counter * 40;
                    button[i].xMax_coord = button[i].xMin_coord + 30;
                    button[i].yMin_coord = 10;
                    button[i].yMax_coord = 40;
                }
                else
                {
                    button[i].xMin_coord = 250 + counter * 40;
                    button[i].xMax_coord = button[i].xMin_coord + 30;
                    button[i].yMin_coord = 50;
                    button[i].yMax_coord = 80;
                }
                counter++;
                if (counter >= 13)
                {
                    counter = 0;
                }
            }
            while (!valid_click)
            {
                if (HangingPost.GetLastMouseLeftClick(out click))
                {
                    for (int i = 0; i < 26; i++)
                    {
                        int xmin = button[i].xMin_coord;
                        int xmax = button[i].xMax_coord;
                        int ymin = button[i].yMin_coord;
                        int ymax = button[i].yMax_coord;
                        if (click.X > xmin && click.X < xmax && click.Y > ymin && click.Y < ymax)
                        {
                            HangingPost.AddLine(xmin, ymin, xmax, ymax, Color.Red, 2);
                            HangingPost.AddLine(xmax, ymin, xmin, ymax, Color.Red, 2);
                            HangingPost.Render();
                            selection   = button[i].alpha;
                            valid_click = true;
                        }
                    }
                }
            }
            return(selection);
        }
Example #21
0
        static void SBlocks()
        {
            CDrawer can = new CDrawer(800, 600, false);

            for (int i = 0; i < 500; ++i)
            {
                can.AddCenteredEllipse(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), RandColor.GetColor(), 1, RandColor.GetColor());
                can.AddCenteredEllipse(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), RandColor.GetColor(), 1);
                can.AddCenteredEllipse(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), RandColor.GetColor());
                can.AddCenteredEllipse(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800));

                can.AddEllipse(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), RandColor.GetColor(), 1, RandColor.GetColor());
                can.AddEllipse(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), RandColor.GetColor(), 1);
                can.AddEllipse(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), RandColor.GetColor());
                can.AddEllipse(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 800));

                try
                {
                    can.AddPolygon(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 300), s_rnd.Next(0, 64), s_rnd.NextDouble() * Math.PI * 2, RandColor.GetColor(), 1, RandColor.GetColor());
                    can.AddPolygon(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 300), s_rnd.Next(0, 64), s_rnd.NextDouble() * Math.PI * 2, RandColor.GetColor(), 1);
                    can.AddPolygon(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 300), s_rnd.Next(0, 64), s_rnd.NextDouble() * Math.PI * 2, RandColor.GetColor());
                    can.AddPolygon(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 300), s_rnd.Next(0, 64), s_rnd.NextDouble() * Math.PI * 2);
                    can.AddPolygon(s_rnd.Next(0, 800), s_rnd.Next(0, 800), s_rnd.Next(0, 300), s_rnd.Next(0, 64));
                }
                catch (Exception err)
                {
                    Console.WriteLine(err.Message);
                }

                try
                {
                    can.AddRectangle(s_rnd.Next(-10, 810), s_rnd.Next(-10, 610), s_rnd.Next(-10, 810), s_rnd.Next(-10, 610), RandColor.GetColor(), 1, RandColor.GetColor());
                    can.AddRectangle(s_rnd.Next(-10, 810), s_rnd.Next(-10, 610), s_rnd.Next(-10, 810), s_rnd.Next(-10, 610), RandColor.GetColor(), 1);
                    can.AddRectangle(s_rnd.Next(-10, 810), s_rnd.Next(-10, 610), s_rnd.Next(-10, 810), s_rnd.Next(-10, 610), RandColor.GetColor());
                    can.AddRectangle(s_rnd.Next(-10, 810), s_rnd.Next(-10, 610), s_rnd.Next(-10, 810), s_rnd.Next(-10, 610));
                }
                catch (Exception err)
                {
                    Console.WriteLine(err.Message);
                }

                try
                {
                    can.AddText("Rats", s_rnd.Next(0, 100), s_rnd.Next(0, 800), s_rnd.Next(0, 600), s_rnd.Next(0, 200), s_rnd.Next(0, 200), RandColor.GetColor());
                    can.AddText("Rats", s_rnd.Next(0, 100), s_rnd.Next(0, 800), s_rnd.Next(0, 600), s_rnd.Next(0, 200), s_rnd.Next(0, 200));
                    can.AddText("Rats", s_rnd.Next(0, 100), RandColor.GetColor());
                }
                catch (Exception err)
                {
                    Console.WriteLine(err.Message);
                }
            }

            can.Render();
            Console.ReadKey();
        }
Example #22
0
        //runs everytime when pressed
        // when enabled draw on moseclick with desied shape
        private void timer1_Tick(object sender, EventArgs e)
        {
            Point click;                                 // tracks mouse clicks to draw shape

            _draw.GetLastMouseLeftClick(out click);      // draw on mouse click

            if (_bColorSet && _shape)
            {
                if (_iShape == 1)
                {
                    if (_borderCheck)
                    {
                        _draw.AddCenteredRectangle(click.X, click.Y, 50, 50, _color, 2, Color.White);
                        _draw.Render();
                    }
                    else
                    {
                        _draw.AddCenteredRectangle(click.X, click.Y, 50, 50, _color);
                        _draw.Render();
                    }
                }
                if (_iShape == 0)
                {
                    if (_borderCheck)
                    {
                        _draw.AddCenteredEllipse(click.X, click.Y, 50, 50, _color, 2, Color.White);
                        _draw.Render();
                    }
                    else
                    {
                        _draw.AddCenteredEllipse(click.X, click.Y, 50, 50, _color);
                        _draw.Render();
                    }
                }
            }
            else
            {
                if (!_borderCheck && !_shape)
                {
                    MessageBox.Show("Error: Properties have not been set.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #23
0
        /***********************************
         * Author: Angelo M Sanches
         * Does the actual drawing
         *************************************/
        private void DrawChecker_Tick(object sender, EventArgs e)
        {
            // get a point of last mouse click scaled
            Point Point;

            if (Box.GetLastMouseLeftClickScaled(out Point))
            {
                // we draw off cursor if using extended draw
                if (Ch_DrawShape.Checked)
                {
                    for (int i = 0; i < DrawLife.GetLength(0); i++)
                    {
                        for (int j = 0; j < DrawLife.GetLength(1); j++)
                        {
                            // for each point draw off of the click
                            Eco[LimWraper(Point.X + i, 0, Eco.GetLength(0)),
                                LimWraper(Point.Y + j, 0, Eco.GetLength(1))].bIsAlive = DrawLife[i, j].bIsAlive;
                            Eco[LimWraper(Point.X + i, 0, Eco.GetLength(0)),
                                LimWraper(Point.Y + j, 0, Eco.GetLength(1))].Colour = DrawLife[i, j].Colour;
                        }
                    }
                    // re-render all
                    Draw();
                }
                // else we just set a single point and render that difference
                else
                {
                    if (!Eco[Point.X, Point.Y].bIsAlive)
                    {
                        Eco[Point.X, Point.Y].bIsAlive = true;
                        Eco[Point.X, Point.Y].Colour   = Colour;
                        Box.SetBBScaledPixel(Point.X, Point.Y, Colour);
                    }
                    else
                    {
                        Eco[Point.X, Point.Y].bIsAlive = false;
                        Box.SetBBScaledPixel(Point.X, Point.Y, Color.Black);
                    }
                    Box.Render();
                }
            }
        }
Example #24
0
        static void CenteredRectangleTest()
        {
            CDrawer can = new CDrawer(800, 600, false);

            can.AddCenteredRectangle(400, 300, 796, 596, Color.Red);
            for (int i = 0; i < 500; ++i)
            {
                can.AddCenteredRectangle(s_rnd.Next(100, 700), s_rnd.Next(100, 500), s_rnd.Next(5, 190), s_rnd.Next(5, 190), RandColor.GetColor(), s_rnd.Next(6), RandColor.GetColor());
            }
            can.Render();
            Console.ReadKey();
        }
Example #25
0
        static void Bezier()
        {
            CDrawer can = new CDrawer(800, 600, false);

            for (int ix = 0; ix < 800; ix += 50)
            {
                can.AddBezier(0, 600, ix, 0, 800 - ix, 600, 800, 0, Color.Red, 2);
                can.AddBezier(0, 0, ix, 0, 800 - ix, 600, 800, 600, Color.Red, 2);
            }

            can.Render();
            Console.ReadKey();
        }
Example #26
0
        private void Render()
        {
            drawSpace.Clear();

            lock (ballList)
            {
                foreach (ball b in ballList)
                {
                    b.Render(drawSpace);
                }
            }
            drawSpace.Render();
        }
Example #27
0
 /// <summary>
 /// render the lights on gdi window
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void _timer_Tick(object sender, EventArgs e)
 {
     _cDrawer.Clear();
     foreach (var item in _trekLampsList)
     {
         item.Tick();
     }
     for (int i = 0; i < _trekLampsList.Count; i++)
     {
         _trekLampsList[i].RenderLamp(_cDrawer, i);
     }
     _cDrawer.Render();
 }
Example #28
0
        /// <summary>
        /// balls will move with this
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _timer_Tick(object sender, EventArgs e)
        {
            //left click add ball sing point val
            if (_cDrawer.GetLastMouseLeftClick(out ctr))
            {
                _balls.Add(new ball(ctr));
            }

            //right click clear
            //clear collections and render gdi to show no shapes
            if (_cDrawer.GetLastMouseRightClick(out ctr))
            {
                _balls.Clear();
                _cDrawer.Clear();
                _cDrawer.Render();
            }

            //clear and call methods in respective loop
            _cDrawer.Clear();
            //move balls in collection
            for (int i = 0; i < _balls.Count; i++)
            {
                _balls[i].MoveBall(_cDrawer);
            }

            //display every ball in lisy collection
            foreach (var item in _balls)
            {
                item.ShowBall(_cDrawer);
            }
            _cDrawer.Render();

            //ball position in list
            //does for all balls
            for (int i = 0; i < _balls.Count; i++)
            {
                this.Text = _balls[i].ToString();
            }
        }
Example #29
0
        private void UI_timer_Tick(object sender, EventArgs e)
        {
            if (canvas == null)
            {
                return;
            }
            if (mySheeple.Count != 0)
            {
                foreach (Queue <Sheeple> thisQueue in queue)
                {
                    if (thisQueue.Count < 10 && mySheeple.Count != 0)
                    {
                        thisQueue.Enqueue(mySheeple.Pop());
                    }
                }
            }
            UI_ListBox.Items.Clear();
            foreach (Sheeple i in mySheeple)
            {
                totalNum += i._totalItem;
            }

            foreach (Queue <Sheeple> i in queue)
            {
                if (i.Count != 0)
                {
                    UI_ListBox.Items.Add(i.Count());
                    Sheeple temp = i.Peek();
                    temp.Process();
                    if (temp.Done)
                    {
                        totalNum += temp._totalItem;
                        i.Dequeue();
                    }
                }
                canvas.Clear();
                int sumX = 0;
                int sumY = 0;
                foreach (Queue <Sheeple> myQueue in queue)
                {
                    sumX = 0;
                    foreach (Sheeple eeple in myQueue)
                    {
                        canvas.AddRectangle(sumX, sumY, eeple._currentItem, 1, Color.FromArgb(eeple._Color));
                        sumX += eeple._currentItem;
                    }
                    sumY += 1;
                }
                canvas.Render();
            }
        }
Example #30
0
        public void freshStart()
        {
            Random randomNumber = new Random();

            numberOfInitallyEnabledPoints = randomNumber.Next(60, 1000);
            btn_Stop.Enabled = false;
            timer1.Stop();

            foregroundArray = new byte[80, 60];   //Reference: Rectangular/two-dimentional arrays
            backgroundArray = new byte[80, 60];   //Reference: Rectangular/two-dimentional arrays
            for (int i = 0; i < 80; i++)
            {
                for (int j = 0; j < 60; j++)
                {
                    foregroundArray[i, j] = 0;
                    backgroundArray[i, j] = 0;
                }
            }

            for (int i = 0; i < numberOfInitallyEnabledPoints; i++)
            {
                foregroundArray[randomNumber.Next(0, 79), randomNumber.Next(0, 59)] = 1;
            }

            for (int i = 0; i < 79; i++)
            {
                for (int j = 0; j < 59; j++)
                {
                    if (foregroundArray[i, j] == 1)
                    {
                        drawingBoard.AddRectangle(i, j, 1, 1, Color.White);
                    }
                }
            }

            drawingBoard.Render();
        }