Exemple #1
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();
        }
Exemple #2
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();
        }
 /// <summary>
 /// darw circles
 /// </summary>
 public void ShowBall()
 {
     if (_radius == 0)
     {
         drawer.AddCenteredEllipse((int)ballCenter.X, (int)ballCenter.Y, ((int)_radius * 2) + 1, ((int)_radius * 2) + 1, _Color);
     }
     else
     {
         drawer.AddCenteredEllipse((int)ballCenter.X, (int)ballCenter.Y, (int)_radius * 2, (int)_radius * 2, _Color);
     }
 }
 /// <summary>
 /// display ball(s)
 /// </summary>
 public void ShowBall()
 {
     //crashed when zero//prevnted
     if (_radius == 0)
     {
         _drawer.AddCenteredEllipse(_location.X, _location.Y, _radius * 2, _radius * 2, Color.FromArgb(_iAlive, _ballColor));
     }
     else
     {
         _drawer.AddCenteredEllipse(_location.X, _location.Y, _radius * 2, _radius * 2, Color.FromArgb(_iAlive, _ballColor));
     }
 }
Exemple #5
0
 /***************************************************************************
 * Method: Render()
 * Description: Accepts a CDrawer object reference and will render a ball.
 *              Wil make it yellow if highlighted. Otherwise make it dark
 *              cyan.
 ***************************************************************************/
 public void Render(CDrawer canvas)
 {
     if (highlightFlag)
     {
         canvas.AddCenteredEllipse(new Point((int)position.X, (int)position.Y), (int)radius * 2, (int)radius * 2, Color.Yellow, 1, Color.White);
         canvas.AddText(equalCalls.ToString(), 8, (int)position.X - 12, (int)position.Y - 5, 25, 10, Color.Black);
     }
     else
     {
         canvas.AddCenteredEllipse(new Point((int)position.X, (int)position.Y), (int)radius * 2, (int)radius * 2, Color.DarkCyan, 1, Color.White);
         canvas.AddText(equalCalls.ToString(), 8, (int)position.X - 12, (int)position.Y - 5, 25, 10, Color.Black);
     }
 }
        public void Render(CDrawer canvas)
        {
            if (bFlag)
            {
                canvas.AddCenteredEllipse((int)bPosition.X, (int)bPosition.Y, (int)(_radius * 2), (int)(_radius * 2), Color.Yellow, 2, Color.Black);
            }
            else
            {
                canvas.AddCenteredEllipse((int)bPosition.X, (int)bPosition.Y, (int)(_radius * 2), (int)(_radius * 2), Color.DarkCyan, 2, Color.Black);
            }

            canvas.AddText(EqualCalls.ToString(), 10, (int)(bPosition.X - _radius), (int)(bPosition.Y - _radius), (int)(_radius * 2), (int)(_radius * 2), Color.Black);
        }
Exemple #7
0
        //******************************************************
        //Render Method: Draw shape as a ball.
        //******************************************************
        public override void Render(CDrawer drawer)
        {
            //Draw line to parent
            base.Render(drawer);

            drawer?.AddCenteredEllipse((int)_position.X, (int)_position.Y, _size, _size, _color);
        }
        public void Render(CDrawer canvas, Color bColor)
        {
            const int ballSize = 10;

            canvas.AddCenteredEllipse(_pos.X, _pos.Y, ballSize, ballSize, bColor);
            canvas.Render();
        }
        /// <summary>
        /// check if missile is friendly or an enemy
        /// then render it
        /// </summary>
        public void DrawMissiles()
        {
            //foe missile
            if (whoIsIt == false)
            {
                _drawer.AddCenteredEllipse(Where(), radius * 2, radius * 2, Color.Red);
                _drawer.AddLine(missleStart.X, missleStart.Y, Where().X, Where().Y, Color.Red);
            }

            //friendly missile
            else
            {
                _drawer.AddCenteredEllipse(Where(), radius * 2, radius * 2, Color.FromArgb(alpha, Color.Green));
                _drawer.AddLine(missleStart.X, missleStart.Y, Where().X, Where().Y, Color.Green);
            }
        }
Exemple #10
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);
     }
 }
Exemple #11
0
 public void Render(CDrawer canvas)
 {
     canvas.AddCenteredEllipse((int)position.X, (int)position.Y,
                               (int)size,
                               (int)size,
                               color,
                               1,
                               Color.Orchid);
 }
Exemple #12
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);
        }
Exemple #13
0
        //Allows for clicks
        private void timer1_Tick(object sender, EventArgs e)
        {
            Point ptClick;

            if (canvas.GetLastMouseLeftClick(out ptClick))
            {
                canvas.AddCenteredEllipse(ptClick.X, ptClick.Y, circleSize, circleSize, customCol);
            }
        }
        //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);
                }
            }
        }
Exemple #15
0
        private void Draw(object sender, EventArgs e)
        {
            Random rng       = new Random();
            int    locationX = rng.Next(400);
            int    locationY = rng.Next(400);

            gdi.AddCenteredEllipse(locationX, locationY, 3, 3, Color.Red, 0, Color.Red);
            listBox1.Items.Add("Dot drawn at: X = " + locationX + " and Y = " + locationY);
            xLocations.Add(locationX);
            yLocations.Add(locationY);
        }
        // Render for use in Circle class Render
        protected override void vRender(CDrawer dr)
        {
            dr.AddCenteredEllipse(Pos, (int)diameter, (int)diameter, Color.LightCyan, 2, Color.Blue);
            Rectangle tout = new Rectangle(
                (int)(Pos.X - diameter),
                (int)(Pos.Y - diameter),
                (int)(diameter * 2),
                (int)(diameter * 2));

            dr.AddText($"{diameter}", Math.Max((int)(diameter * 0.4), 8), tout, Color.Black);
        }
Exemple #17
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();
        }
Exemple #18
0
        static void Main(string[] args)
        {
            //int x = 0;
            //ConsoleKeyInfo keyPressed;



            //while(x < 10)
            //{
            //  Console.WriteLine(x);
            //++x;
            //}


            //keyPressed = Console.ReadKey();

            //Console.WriteLine(keyPressed.Key);

            //Console.ReadKey();


            /// end of that part
            //start of new part



            CDrawer canvas = new CDrawer(800, 600);

            Console.WriteLine("Draw Something");

            canvas.AddCenteredEllipse(200, 100, 100, 100, Color.Red, 2, Color.White);

            canvas.AddLine(50, 50, 400, 500, Color.Green, 5);

            canvas.AddRectangle(400, 300, 100, 50, Color.Purple, 2, Color.White);
            canvas.AddText("meat", 24, Color.Magenta);
            canvas.AddText("Bacon", 36, 300, 150, 250, 50, Color.Lime);

            Console.ReadKey();


            //to have random color:-    "RandColor.GetColor()"
        }
Exemple #19
0
        // Add a stick figure to drawing window with head at (x, y) in cheering pose or idle pose
        public static void AddStickMan(int x, int y, string color, ref CDrawer HangingPost, bool cheer)
        {
            HangingPost.AddCenteredEllipse(x, y, 50, 50, Color.FromName(color));            //head
            HangingPost.AddLine(x, y + 25, x, y + 95, Color.FromName(color), 5);            //torso
            HangingPost.AddLine(x, y + 95, x - 15, y + 180, Color.FromName(color), 5);      //left leg
            HangingPost.AddLine(x, y + 95, x + 15, y + 180, Color.FromName(color), 5);      //right leg

            if (cheer)
            {
                HangingPost.AddLine(x, y + 40, x - 40, y - 5, Color.FromName(color), 5);        //left upper arm
                HangingPost.AddLine(x - 40, y - 5, x - 60, y - 40, Color.FromName(color), 5);   //left lower arm
                HangingPost.AddLine(x, y + 40, x + 40, y - 5, Color.FromName(color), 5);        //right upper arm
                HangingPost.AddLine(x + 40, y - 5, x + 60, y - 40, Color.FromName(color), 5);   //right lower arm
            }
            else
            {
                HangingPost.AddLine(x, y + 30, x - 25, y + 105, Color.FromName(color), 5);      //left arm
                HangingPost.AddLine(x, y + 30, x + 25, y + 105, Color.FromName(color), 5);      //right arm
            }
        }
Exemple #20
0
 public override void Render(CDrawer dr)
 {
     dr.AddCenteredEllipse((int)_pos.X, (int)_pos.Y, 20, 20, _color);
 }
        //***********************************************************************************
        //Method: static private void DrawScreen(CDrawer canvas, ref int wrongCounter, ref int WinCond, ref string[] secretWord, ref string[] guessResult, ref bool gameOn)
        //Purpose: Controls all elements that will appear in GDI drawer and controls game running loop
        //parameters: (described in main)
        //***********************************************************************************
        static private void DrawScreen(CDrawer canvas, ref int wrongCounter, ref int WinCond, ref string[] secretWord, ref string[] guessResult, ref string[] usedLetters, ref bool gameOn, ref int xPosition)
        {
            xPosition = 195;  //incremental x position to draw the letters that have already been used

            //***********************************************************************************
            //Draw the gallows
            //***********************************************************************************

            //draws the rope
            canvas.AddLine(400, 200, 400, 250, Color.Red, 2);

            //main vertical scaffold beam
            canvas.AddLine(300, 175, 300, 450, Color.DarkOrange, 3);

            //scaffold arm and supporting strut
            //arm
            canvas.AddLine(300, 200, 425, 200, Color.DarkOrange, 3);
            //support
            canvas.AddLine(300, 225, 325, 200, Color.DarkOrange, 3);

            //scaffold floor
            canvas.AddLine(300, 400, 450, 400, Color.DarkOrange, 3);

            //front support leg
            canvas.AddLine(425, 400, 425, 450, Color.DarkOrange, 3);

            //floor supporting struts
            canvas.AddLine(300, 440, 425, 410, Color.DarkOrange, 3);
            canvas.AddLine(300, 410, 425, 440, Color.DarkOrange, 3);

            //***********************************************************************************
            //Draws the hangman if answers are wrong
            //***********************************************************************************
            if (wrongCounter >= 1)
            {
                //draws the head
                canvas.AddCenteredEllipse(400, 250, 50, 50, Color.White);
            }
            if (wrongCounter >= 2)
            {
                //draws torso
                canvas.AddCenteredEllipse(400, 300, 50, 100, Color.Blue);
            }
            if (wrongCounter >= 3)
            {
                //draws arm
                canvas.AddLine(380, 290, 350, 320, Color.Blue, 5);
            }
            if (wrongCounter >= 4)
            {
                //draws arm 2
                canvas.AddLine(420, 290, 450, 320, Color.Blue, 5);
            }
            if (wrongCounter >= 5)
            {
                //draws leg 1
                canvas.AddLine(410, 330, 420, 390, Color.Green, 5);
            }
            if (wrongCounter >= 6)
            {
                //draws leg 2
                canvas.AddLine(390, 330, 380, 390, Color.Green, 5);
            }

            //***********************************************************************************
            //Draws currently used letters and win / loss results
            //***********************************************************************************

            //text to show the currently used letters
            canvas.AddText($"Letters used: ", 20, 100, 50, 400, 75, Color.White);

            for (int i = 0; i <= usedLetters.Length - 1; i++)
            {
                canvas.AddText($"{usedLetters[i]}", 20, xPosition, 50, 400, 75, Color.White);
                xPosition += 20;
            }

            //Displays result if user wins
            if (WinCond == 0)
            {
                //win text
                canvas.AddText("You Win!", 50, Color.Yellow);
                gameOn = false;
            }

            //Displays result if user loses
            else if ((WinCond > 0) && (wrongCounter == 6))
            {
                //displays the full secret word
                for (int index = 0; index <= secretWord.Length - 1; index++)
                {
                    guessResult[index] = secretWord[index];
                }
                //loss text
                canvas.AddText("You Lose!", 50, Color.Gray);
                gameOn = false;
            }
        }
Exemple #22
0
 protected override void vRender(CDrawer dr)
 {
     dr.AddCenteredEllipse(position.X, position.Y, size, size, color);
 }
 public void Render()
 {
     _canvas.AddCenteredEllipse(_pos.X, _pos.Y, ballRadius, ballRadius, bColor, 2, Color.Black);
     _canvas.AddText(DisplacementCalls.ToString(), ballRadius / 4, _pos.X, _pos.Y, 0, 0, Color.Black);
 }
Exemple #24
0
        static private void Draw()
        {
            int  X          = 0;
            int  Y          = 0;
            int  A          = 0;
            int  B          = 0;
            int  avelocit   = 2;
            int  bvelocit   = 2;
            int  xvelocity  = 3;
            int  yvelocity  = 3;
            bool operation  = true;
            int  bole       = 7;
            bool ioperation = true;


            CDrawer canvas = new CDrawer();

            canvas.Scale            = 5;
            canvas.ContinuousUpdate = false;


            while (operation)
            {
                canvas.AddCenteredEllipse(X, Y, 10, 10, Color.Aqua, 6);
                canvas.AddLine(X, Y, 88, 4, Color.Red, 4);


                canvas.Render();
                System.Threading.Thread.Sleep(10);



                canvas.Clear();



                X += xvelocity;
                Y += yvelocity;



                if ((Y >= canvas.ScaledHeight) || (Y <= 0))
                {
                    yvelocity *= -1;
                }

                //check for left or right side of the screen
                if ((X >= canvas.ScaledWidth) || (X <= 0))
                {
                    xvelocity *= -1;
                }
                if (ioperation)
                {
                    canvas.AddCenteredEllipse(A, B, 10, 10, Color.Red, 5);
                    canvas.AddLine(A, B, 85, 4, Color.Blue, 6);

                    canvas.Render();
                    System.Threading.Thread.Sleep(bole);
                    canvas.Clear();

                    A += avelocit; _ = A != X;
                    B += bvelocit; _ = B != Y;


                    if ((A >= canvas.ScaledWidth) || (A <= 0))
                    {
                        avelocit *= -1;
                    }
                    if ((B >= canvas.ScaledHeight) || (B <= 0))
                    {
                        bvelocit *= -1;
                    }
                }
            }



            Console.Read();
        }
Exemple #25
0
 protected override void vRender(CDrawer dr)
 {
     dr.AddCenteredEllipse(position.X, position.Y, temp_size, temp_size, Color.White);
 }
Exemple #26
0
 //display the ball(s)
 public void ShowBall(CDrawer cDrawer)
 {
     cDrawer.AddCenteredEllipse(Center, ballRadius * 2, 2 * ballRadius, Color.FromArgb(opacity, _ballColor));
     cDrawer.Render();
 }
Exemple #27
0
        // Draw Hanged Man 1 bodypart at a time
        public static void DisplayHangedMan(ref CDrawer HangingPost, int body_count, bool PGversion)
        {
            if (PGversion)
            {
                switch (body_count)
                {
                case 1:
                    HangingPost.AddCenteredEllipse(250, 245, 60, 60, Color.Empty, 5, Color.Black);
                    break;

                case 2:
                    HangingPost.AddLine(250, 275, 250, 350, Color.Black, 5);
                    break;

                case 3:
                    HangingPost.AddLine(250, 275, 220, 360, Color.Black, 5);
                    break;

                case 4:
                    HangingPost.AddLine(250, 275, 280, 360, Color.Black, 5);
                    break;

                case 5:
                    HangingPost.AddLine(250, 350, 230, 460, Color.Black, 5);
                    break;

                case 6:
                    HangingPost.AddLine(250, 350, 270, 460, Color.Black, 5);
                    break;
                }
            }
            else
            {
                switch (body_count)
                {
                case 1:
                    HangingPost.AddCenteredEllipse(270, 215, 50, 50, Color.Black);
                    break;

                case 2:
                    HangingPost.AddLine(250, 215, 245, 285, Color.Black, 5);
                    break;

                case 3:
                    HangingPost.AddLine(250, 215, 230, 305, Color.Black, 5);
                    break;

                case 4:
                    HangingPost.AddLine(250, 215, 270, 305, Color.Black, 5);
                    break;

                case 5:
                    HangingPost.AddLine(245, 285, 230, 365, Color.Black, 5);
                    break;

                case 6:
                    HangingPost.AddLine(245, 285, 265, 365, Color.Black, 5);
                    break;
                }
            }
            HangingPost.Render();
        }
Exemple #28
0
        static void Main(string[] args)
        {
            //intializing
            Color       objColor       = new Color();
            List <info> structureslist = new List <info>();
            CDrawer     canvas         = new CDrawer();
            Point       location       = new Point(200, 200);
            info        infoN;
            string      filename;
            Shape       shape = Shape.Circle;
            int         i     = 0;

            Options(ref canvas);                                // Open Menu

            while (true)                                        // go into while loop unless it fails
            {
                if (canvas.GetLastMouseLeftClick(out location)) //catch mouse click point
                {
                    //change shape information depends on click location
                    if (location.X > 20 && location.X < 70 && location.Y > 40 && location.Y < 90)
                    {
                        objColor = Color.Red;
                    }

                    else if (location.X > 80 && location.X < 170 && location.Y > 20 && location.Y < 90)
                    {
                        objColor = Color.Green;
                    }

                    else if (location.X > 180 && location.X < 270 && location.Y > 40 && location.Y < 90)
                    {
                        objColor = Color.Blue;
                    }

                    else if (location.X > 280 && location.X < 350 && location.Y > 40 && location.Y < 90)
                    {
                        shape = Shape.Circle;
                    }

                    else if (location.X > 360 && location.X < 450 && location.Y > 40 && location.Y < 90)
                    {
                        shape = Shape.Squre;
                    }

                    else if (location.X > 460 && location.X < 510 && location.Y > 40 && location.Y < 90)
                    {
                        shape = Shape.Star;
                    }

                    else if (location.X > 520 && location.X < 590 && location.Y > 40 && location.Y < 90) //Save option
                    {
                        Console.Write("Enter your filename: ");                                          //choosing saving file name
                        filename = Console.ReadLine();

                        StreamWriter swOutputFile = new StreamWriter(filename);
                        //save shape information each line
                        foreach (info item in structureslist)
                        {
                            swOutputFile.WriteLine("{0},{1},{2},{3}", item._shape, item._shapeColor, item.XLocation, item.YLocatoin);
                        }
                        swOutputFile.Close(); //save
                    }


                    else if (location.X > 600 && location.X < 670 && location.Y > 40 && location.Y < 90) //Load Option
                    {
                        Console.Write("Enter your filename: ");                                          // choose loading file name
                        filename = Console.ReadLine();

                        //initializing for load variables
                        StreamReader  swInputFile;
                        List <string> LoadList = new List <string>();
                        string        text;
                        try // catch error while opening file
                        {
                            swInputFile = new StreamReader(filename);
                            while ((text = swInputFile.ReadLine()) != null)
                            {
                                string[] text2;
                                text2 = text.Split(',');
                                info infoO;
                                infoO._shapeColor = Color.Red;
                                infoO._shape      = Shape.Circle;
                                infoO.XLocation   = 0;
                                infoO.YLocatoin   = 0;
                                switch (text2[0]) //check shape type
                                {
                                case "Cirlce": { infoO._shape = Shape.Circle; break; }

                                case "Square": { infoO._shape = Shape.Squre; break; }

                                case "Star": { infoO._shape = Shape.Star; break; }
                                }
                                switch (text2[1])//check shape color
                                {
                                case "Color [Red]": { infoO._shapeColor = Color.Red; break; }

                                case "Color [Green]": { infoO._shapeColor = Color.Green; break; }

                                case "Color [Blue]": { infoO._shapeColor = Color.Blue; break; }
                                }
                                infoO.XLocation = Convert.ToInt64(text2[2]); //check shape X location
                                infoO.YLocatoin = Convert.ToInt64(text2[3]); //check shape Y location
                                structureslist.Add(infoO);                   //add on to list to save information

                                foreach (info item in structureslist)        //Call information on to GDI drawer from list
                                {
                                    switch (item._shape)
                                    {
                                    case Shape.Circle:
                                    {
                                        if (item._shapeColor == Color.Red)
                                        {
                                            canvas.AddCenteredEllipse((int)item.XLocation, (int)item.YLocatoin, 20, 20, Color.Red);
                                        }
                                        else if (item._shapeColor == Color.Green)
                                        {
                                            canvas.AddCenteredEllipse((int)item.XLocation, (int)item.YLocatoin, 20, 20, Color.Green);
                                        }
                                        else if (item._shapeColor == Color.Blue)
                                        {
                                            canvas.AddCenteredEllipse((int)item.XLocation, (int)item.YLocatoin, 20, 20, Color.Blue);
                                        }
                                        break;
                                    }

                                    case Shape.Squre:
                                    {
                                        if (item._shapeColor == Color.Red)
                                        {
                                            canvas.AddCenteredRectangle((int)item.XLocation, (int)item.YLocatoin, 20, 20, Color.Red);
                                        }
                                        else if (item._shapeColor == Color.Green)
                                        {
                                            canvas.AddCenteredRectangle((int)item.XLocation, (int)item.YLocatoin, 20, 20, Color.Green);
                                        }
                                        else if (item._shapeColor == Color.Blue)
                                        {
                                            canvas.AddCenteredRectangle((int)item.XLocation, (int)item.YLocatoin, 20, 20, Color.Blue);
                                        }
                                        break;
                                    }

                                    case Shape.Star:
                                    {
                                        if (item._shapeColor == Color.Red)
                                        {
                                            canvas.AddText("S", 20, (int)item.XLocation, (int)item.YLocatoin, 20, 20, Color.Red);
                                        }
                                        else if (item._shapeColor == Color.Green)
                                        {
                                            canvas.AddText("S", 20, (int)item.XLocation, (int)item.YLocatoin, 20, 20, Color.Green);
                                        }
                                        else if (item._shapeColor == Color.Blue)
                                        {
                                            canvas.AddText("S", 20, (int)item.XLocation, (int)item.YLocatoin, 20, 20, Color.Blue);
                                        }
                                        break;
                                    }
                                    }
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine("Error, the error was {0}", e);
                        }
                    }

                    else if (location.X > 680 && location.X < 750 && location.Y > 40 && location.Y < 90)
                    {
                        canvas.Clear();      // clear GDI drawer
                        Options(ref canvas); //Recall menu
                    }
                    else //If mouse click location is out of menu area draw the shapes
                    {
                        switch (shape)//Goes into diffrent options depends on the shape
                        {
                        case Shape.Circle:
                        {
                            canvas.AddCenteredEllipse(location, 20, 20, objColor);
                            infoN._shape      = shape;
                            infoN._shapeColor = objColor;
                            infoN.XLocation   = location.X;
                            infoN.YLocatoin   = location.Y;
                            structureslist.Add(infoN);

                            break;
                        }

                        case Shape.Squre:
                        {
                            canvas.AddCenteredRectangle(location, 20, 20, objColor);
                            infoN._shape      = shape;
                            infoN._shapeColor = objColor;
                            infoN.XLocation   = location.X;
                            infoN.YLocatoin   = location.Y;
                            structureslist.Add(infoN);
                            break;
                        }

                        case Shape.Star:
                        {
                            canvas.AddText("S", 20, location.X, location.Y, 20, 30, objColor);
                            infoN._shape      = shape;
                            infoN._shapeColor = objColor;
                            infoN.XLocation   = location.X;
                            infoN.YLocatoin   = location.Y;
                            structureslist.Add(infoN);
                            break;
                        }
                        }
                    }
                }
            }
        }
 public override void Render(CDrawer canvas)
 {
     canvas.AddCenteredEllipse((int)point.X, (int)point.Y, 20, 20, color);
     base.Render(canvas);
 }
Exemple #30
0
 //Initializes gdi canvas and puts a first dot
 private void Form1_Load(object sender, EventArgs e)
 {
     canvas.Scale = 20;
     canvas.AddCenteredEllipse(15, 15, 1, 1, Color.Red);
 }