public void TestSelectShape( )
        {
            Drawing myDrawing = new Drawing();

            Shape [] testShapes =
            {
                new Rectangle(Color.Red,   25, 25, 50, 50),
                new Rectangle(Color.Green, 25, 10, 50, 50),
                new Rectangle(Color.Blue,  10, 25, 50, 50)
            };

            foreach (Shape s in testShapes)
            {
                myDrawing.AddShape(s);
            }

            List <Shape> Selected;
            Point2D      point;

            point = SwinGame.PointAt(70, 70);
            myDrawing.SelectShapeAt(point);
            Selected = myDrawing.SelectedShape;

            CollectionAssert.Contains(Selected, testShapes [0]);
            Assert.AreEqual(1, Selected.Count);

            point = SwinGame.PointAt(70, 50);
            myDrawing.SelectShapeAt(point);
            Selected = myDrawing.SelectedShape;

            CollectionAssert.Contains(Selected, testShapes [0]);
            CollectionAssert.Contains(Selected, testShapes [1]);
            Assert.AreEqual(2, Selected.Count);
        }
        public void TestRemoveShape( )
        {
            Drawing myDrawing = new Drawing();

            Shape[] testShapes =
            {
                new Rectangle(Color.Red,   25, 25, 50, 50),
                new Rectangle(Color.Green, 25, 10, 50, 50),
                new Rectangle(Color.Blue,  10, 25, 50, 50)
            };

            Point2D      point;
            List <Shape> selected;
            Shape        shapeRemoved = testShapes [1];

            foreach (Shape s in testShapes)
            {
                myDrawing.AddShape(s);
            }

            point = SwinGame.PointAt(25, 10);
            myDrawing.SelectShapeAt(point);
            selected = myDrawing.SelectedShape;

            Assert.AreEqual(3, myDrawing.ShapeCount);
            CollectionAssert.Contains(selected, shapeRemoved);

            myDrawing.RemoveShape(shapeRemoved);
            selected = myDrawing.SelectedShape;

            myDrawing.SelectShapeAt(point);

            Assert.AreEqual(2, myDrawing.ShapeCount);
            CollectionAssert.DoesNotContain(selected, shapeRemoved);
        }
        public static void Main()
        {
            //Open the game window
            SwinGame.OpenGraphicsWindow("GameMain", 800, 600);
            SwinGame.ShowSwinGameSplashScreen();

            //Shape myShape = new Shape();
            Drawing myDrawing = new Drawing();


            //Run the game loop
            while (false == SwinGame.WindowCloseRequested())
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();

                // If the user clicks the LeftButton on their mouse, set the shapes x, y to be at the mouse's position
                if (SwinGame.MouseClicked(MouseButton.LeftButton))
                {
                    myDrawing.AddShape(new Shape((int)SwinGame.MousePosition().X, (int)SwinGame.MousePosition().Y));
                }

                if (SwinGame.MouseClicked(MouseButton.RightButton))
                {
                    myDrawing.SelectShapeAt(SwinGame.MousePosition());
                }

                if (SwinGame.KeyTyped(KeyCode.SpaceKey))
                {
                    myDrawing.Background = SwinGame.RandomRGBColor(255);
                }

                if ((SwinGame.KeyTyped(KeyCode.DeleteKey)) | (SwinGame.KeyTyped(KeyCode.BackspaceKey)))
                {
                    myDrawing.DeleteShapes();
                }

                //Clear the screen and draw the framerate
                SwinGame.ClearScreen(Color.White);
                myDrawing.Draw();
                SwinGame.DrawFramerate(0, 0);

                //Draw onto the screen
                SwinGame.RefreshScreen(60);
            }
        }
        public static void Main()
        {
            //Register shapes
            Shape.RegisterShape("Rectangle", typeof(Rectangle));
            Shape.RegisterShape("Circle", typeof(Circle));
            Shape.RegisterShape("Line", typeof(Line));

            //Open the game window
            SwinGame.OpenGraphicsWindow("GameMain", 800, 600);
            SwinGame.ShowSwinGameSplashScreen();

            //Shape myShape = new Shape();
            Drawing   myDrawing = new Drawing();
            ShapeKind kindToAdd = ShapeKind.Circle;


            //Run the game loop
            while (false == SwinGame.WindowCloseRequested())
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();

                string _path = @"C:\Users\Klim\Documents\Code\5.3D\TestDrawing.txt";

                if (SwinGame.KeyTyped(KeyCode.SKey))
                {
                    myDrawing.Save(_path);
                }

                if (SwinGame.KeyTyped(KeyCode.OKey))
                {
                    try
                    {
                        myDrawing.Load(_path);
                    }
                    catch (Exception e)
                    {
                        Console.Error.WriteLine("Error loadingfile: {0}", e.Message);
                    }
                }

                if (SwinGame.KeyTyped(KeyCode.RKey))
                {
                    kindToAdd = ShapeKind.Rectangle;
                }

                if (SwinGame.KeyTyped(KeyCode.CKey))
                {
                    kindToAdd = ShapeKind.Circle;
                }

                if (SwinGame.KeyTyped(KeyCode.LKey))
                {
                    kindToAdd = ShapeKind.Line;
                }

                // If the user clicks the LeftButton on their mouse, set the shapes x, y to be at the mouse's position
                if (SwinGame.MouseClicked(MouseButton.LeftButton))
                {
                    Shape newShape;
                    float x = SwinGame.MouseX();
                    float y = SwinGame.MouseY();

                    if (kindToAdd == ShapeKind.Circle)
                    {
                        Circle newCircle = new Circle();
                        newShape = newCircle;
                    }
                    else if (kindToAdd == ShapeKind.Rectangle)
                    {
                        Rectangle newRect = new Rectangle();
                        newShape = newRect;
                    }
                    else
                    {
                        Line newLine = new Line();
                        newShape = newLine;
                    }

                    newShape.X = x;
                    newShape.Y = y;
                    myDrawing.AddShape(newShape);
                }

                if (SwinGame.MouseClicked(MouseButton.RightButton))
                {
                    myDrawing.SelectShapeAt(SwinGame.MousePosition());
                }

                if (SwinGame.KeyTyped(KeyCode.SpaceKey))
                {
                    myDrawing.Background = SwinGame.RandomRGBColor(255);
                }

                if ((SwinGame.KeyTyped(KeyCode.DeleteKey)) | (SwinGame.KeyTyped(KeyCode.BackspaceKey)))
                {
                    myDrawing.DeleteShapes();
                }

                //Clear the screen and draw the framerate
                SwinGame.ClearScreen(Color.White);
                myDrawing.Draw();
                SwinGame.DrawFramerate(0, 0);

                //Draw onto the screen
                SwinGame.RefreshScreen(60);
            }
        }
        public static void Main()
        {
            //Open the game window
            SwinGame.OpenGraphicsWindow("GameMain", 800, 600);
            SwinGame.ShowSwinGameSplashScreen();

            //Shape myShape = new Shape();
            Drawing   myDrawing = new Drawing();
            ShapeKind kindToAdd = ShapeKind.Circle;


            //Run the game loop
            while (false == SwinGame.WindowCloseRequested())
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();


                if (SwinGame.KeyTyped(KeyCode.RKey))
                {
                    kindToAdd = ShapeKind.Rectangle;
                }

                if (SwinGame.KeyTyped(KeyCode.CKey))
                {
                    kindToAdd = ShapeKind.Circle;
                }

                if (SwinGame.KeyTyped(KeyCode.LKey))
                {
                    kindToAdd = ShapeKind.Line;
                }

                // If the user clicks the LeftButton on their mouse, set the shapes x, y to be at the mouse's position
                if (SwinGame.MouseClicked(MouseButton.LeftButton))
                {
                    Shape newShape;
                    float x = SwinGame.MouseX();
                    float y = SwinGame.MouseY();

                    if (kindToAdd == ShapeKind.Circle)
                    {
                        Circle newCircle = new Circle();
                        newShape = newCircle;
                    }
                    else if (kindToAdd == ShapeKind.Rectangle)
                    {
                        Rectangle newRect = new Rectangle();
                        newShape = newRect;
                    }
                    else
                    {
                        Line newLine = new Line();
                        newShape = newLine;
                    }
                    newShape.X = x;
                    newShape.Y = y;
                    myDrawing.AddShape(newShape);
                }

                if (SwinGame.MouseClicked(MouseButton.RightButton))
                {
                    myDrawing.SelectShapeAt(SwinGame.MousePosition());
                }

                if (SwinGame.KeyTyped(KeyCode.SpaceKey))
                {
                    myDrawing.Background = SwinGame.RandomRGBColor(255);
                }

                if ((SwinGame.KeyTyped(KeyCode.DeleteKey)) | (SwinGame.KeyTyped(KeyCode.BackspaceKey)))
                {
                    myDrawing.DeleteShapes();
                }

                //Clear the screen and draw the framerate
                SwinGame.ClearScreen(Color.White);
                myDrawing.Draw();
                SwinGame.DrawFramerate(0, 0);

                //Draw onto the screen
                SwinGame.RefreshScreen(60);
            }
        }
        public static void Main()
        {
            SwinGame.OpenAudio();
            SwinGame.OpenGraphicsWindow("GameMain", 800, 600);
            SwinGame.ShowSwinGameSplashScreen();

            Drawing myDrawing = new Drawing();

            ShapeKind KindtoAdd = ShapeKind.Circle;


            while (false == SwinGame.WindowCloseRequested())
            {
                SwinGame.ProcessEvents();

                SwinGame.ClearScreen(Color.White);
                SwinGame.DrawFramerate(0, 0);

                myDrawing.Draw();

                if (Input.KeyTyped(KeyCode.vk_r))
                {
                    KindtoAdd = ShapeKind.Rectangle;
                }
                if (Input.KeyTyped(KeyCode.vk_c))
                {
                    KindtoAdd = ShapeKind.Circle;
                }
                if (Input.KeyTyped(KeyCode.vk_l))
                {
                    KindtoAdd = ShapeKind.Line;
                }

                Point2D mouseLocation = SwinGame.MousePosition();


                if (SwinGameSDK.Input.MouseClicked(MouseButton.LeftButton))
                {
                    /*Shape myShape = new Shape();
                     * myShape.Color = SwinGame.RandomRGBColor (255);
                     * myShape.X = SwinGame.MouseX();
                     * myShape.Y = SwinGame.MouseY();
                     * myDrawing.AddShape (myShape);*/

                    Shape newShape = default(Shape);
                    if (KindtoAdd == ShapeKind.Circle)
                    {
                        Circle newCircle = new Circle();
                        newCircle.X = SwinGame.MouseX();
                        newCircle.Y = SwinGame.MouseY();
                        newShape    = newCircle;
                    }
                    else if (KindtoAdd == ShapeKind.Rectangle)
                    {
                        Rectangle newRect = new Rectangle();
                        newRect.X = SwinGame.MouseX();
                        newRect.Y = SwinGame.MouseY();
                        newShape  = newRect;
                    }
                    else if (KindtoAdd == ShapeKind.Line)
                    {
                        Line newLine = new Line();
                        newLine.X = SwinGame.MouseX();
                        newLine.Y = SwinGame.MouseY();
                        newShape  = newLine;
                    }
                    myDrawing.AddShape(newShape);
                }

                if (SwinGame.MouseClicked(MouseButton.RightButton))
                {
                    myDrawing.SelectShapeAt(SwinGame.MousePosition());
                }
                if (SwinGame.KeyTyped(KeyCode.vk_DELETE))
                {
                    List <Shape> selected = myDrawing.SelectedShape;
                    foreach (Shape s in selected)
                    {
                        myDrawing.RemoveShape(s);
                    }
                }

                //if (myShape.IsAt (mouseLocation))
                //{
                if (SwinGame.KeyTyped(KeyCode.vk_SPACE))
                {
                    myDrawing.Mybackground = SwinGame.RandomRGBColor(255);
                }
                //}
                SwinGame.DrawFramerate(0, 0);
                SwinGame.RefreshScreen();
            }


            //End the audio
            SwinGame.CloseAudio();

            //Close any resources we were using
            SwinGame.ReleaseAllResources();
        }