Draw() public abstract method

public abstract Draw ( ) : void
return void
Example #1
0
 public override void Execute()
 {
     if (Canvas.IsCreated)
     {
         LineShape?.Draw(Character.ToString());
         Canvas.PrintOutPut();
     }
 }
Example #2
0
 public override void Execute()
 {
     if (Canvas?.IsCreated != null)
     {
         LeftLine?.Draw(Character.ToString());
         RightLine?.Draw(Character.ToString());
         TopLine?.Draw(Character.ToString());
         BottomLine?.Draw(Character.ToString());
         Canvas.PrintOutPut();
     }
 }
Example #3
0
        static void Main(string[] args)
        {
            ShapeFactory shapeFactory = new ShapeFactory();

            IShape shape1 = shapeFactory.Create(ShapeEnum.Circle);

            shape1.Draw();

            IShape shape2 = shapeFactory.Create(ShapeEnum.Rectangle);

            shape2.Draw();

            IShape shape3 = shapeFactory.Create(ShapeEnum.Square);

            shape3.Draw();

            Console.ReadKey();
        }
Example #4
0
 private void HandleDrawShape()
 {
     ViewAllShapes();
     do
     {
         try
         {
             currentShape = GetShapeToDraw();
             currentShape.Draw();
             canvas.Add(currentShape);
         }
         catch (ShapeNotFoundException)
         {
             Console.WriteLine("This id is not associated to an available shape.");
         }
     } while (currentShape == null);
     Console.ReadLine();
 }
Example #5
0
        public static void DoMain(String[] args)
        {
            //获取形状工厂
            AbstractFactory shapeFactory = FactoryProducer.getFactory("SHAPE");

            //获取形状为 Circle 的对象
            IShape shape1 = shapeFactory.getShape("CIRCLE");

            //调用 Circle 的 Draw 方法
            shape1.Draw();

            //获取形状为 Rectangle 的对象
            IShape shape2 = shapeFactory.getShape("RECTANGLE");

            //调用 Rectangle 的 Draw 方法
            shape2.Draw();

            //获取形状为 Square 的对象
            IShape shape3 = shapeFactory.getShape("SQUARE");

            //调用 Square 的 Draw 方法
            shape3.Draw();

            //获取颜色工厂
            AbstractFactory colorFactory = FactoryProducer.getFactory("COLOR");

            //获取颜色为 Red 的对象
            IColor color1 = colorFactory.getColor("RED");

            //调用 Red 的 Fill 方法
            color1.Fill();

            //获取颜色为 Green 的对象
            IColor color2 = colorFactory.getColor("Green");

            //调用 Green 的 Fill 方法
            color2.Fill();

            //获取颜色为 Blue 的对象
            IColor color3 = colorFactory.getColor("BLUE");

            //调用 Blue 的 Fill 方法
            color3.Fill();
        }
Example #6
0
        static void TestPaint()
        {
            //get IShape factory
            PaintAbstractFactory shapeFactory = PaintFactoryProducer.GetPaintFactory("Shape");

            //get an object of IShape Circle
            IShape shape1 = shapeFactory.CreateShape("CIRCLE");

            //call Draw method of IShape Circle
            shape1.Draw();

            //get an object of IShape Rectangle
            IShape shape2 = shapeFactory.CreateShape("RECTANGLE");

            //call Draw method of IShape Rectangle
            shape2.Draw();

            //get an object of IShape Square
            IShape shape3 = shapeFactory.CreateShape("SQUARE");

            //call Draw method of IShape Square
            shape3.Draw();

            //get color factory
            PaintAbstractFactory colorFactory = PaintFactoryProducer.GetPaintFactory("COLOR");

            //get an object of Color Red
            IColor color1 = colorFactory.CreateColor("RED");

            //call fill method of Red
            color1.Fill();

            //get an object of Color Green
            IColor color2 = colorFactory.CreateColor("Green");

            //call fill method of Green
            color2.Fill();

            //get an object of Color Blue
            IColor color3 = colorFactory.CreateColor("BLUE");

            //call fill method of Color Blue
            color3.Fill();
        }
Example #7
0
        private static void Main(string[] args)
        {
            AbstractFactory shapeFactory = FactoryProducer.GetFactory(FactoryProducer.objType.Shape);
            IShape          shape        = shapeFactory.GetShape(AbstractFactory.ShapeType.Rectangle);

            shape.Draw();
            IShape shape2 = shapeFactory.GetShape(AbstractFactory.ShapeType.Cricle);

            shape2.Draw();

            AbstractFactory Colorfactory = FactoryProducer.GetFactory(FactoryProducer.objType.Color);
            Icolor          myColor      = Colorfactory.GetColor(AbstractFactory.ColorType.blue);

            myColor.Fill();
            Icolor myColor2 = Colorfactory.GetColor(AbstractFactory.ColorType.red);

            myColor2.Fill();
            Console.ReadLine();
        }
Example #8
0
        static void Main(string[] args)
        {
            #region Exemplo ConnectionFactory

            /* //METODO PROCEDURAL
             * IDbConnection conexao = new SqlConnection();
             * conexao.ConnectionString = "User Id=root;Password=;Server=localhost;Database=meuBanco";
             * conexao.Open();
             */

            // UTILIZAÇÃO DA FACTORY QUE RETORNA A CONEXÃO COM O BANCO DE DADOS.
            //IDbConnection conexao = new ConnectionFactory().GetConnection();

            //IDbCommand comando = conexao.CreateCommand();
            //comando.CommandText = "select * from tabela";
            #endregion

            #region Exemplo ShapeFactory
            ShapeFactory shapeFactory = new ShapeFactory();

            //get an object of Circle and call its draw method.
            IShape shape1 = shapeFactory.getShape("CIRCLE");
            //call draw method of Circle.
            shape1.Draw();

            //get an object of Rectangle and call its draw method.
            IShape shape2 = shapeFactory.getShape("RECTANGLE");
            //call draw method of Rectangle.
            shape2.Draw();

            //get an object of Square and call its draw method.
            IShape shape3 = shapeFactory.getShape("SQUARE");
            //call draw method of Square.
            shape3.Draw();

            //get an object of Circle using a basis constructor.
            IShape shape4 = shapeFactory.getShape(new Circle());
            shape4.Draw();

            #endregion

            Console.ReadKey();
        }
Example #9
0
 private void Repaint()
 {
     if (_bl.isBoolCount())
     {
         IShape currentShape = _bl.Last();
         _bufferedBitmap = _currentBitmap.Clone() as PaintBitmap;
         PaintGraphics _bufferedGraphics = PaintGraphics.FromImage(_bufferedBitmap);
         currentShape.Draw(_bufferedGraphics);
         if (currentShape.EShapeStatus == EShapeStatus.IN_PROGRESS)
         {
             pictureBoxMain.Image = _bufferedBitmap?.ToImage();
         }
         if (currentShape.EShapeStatus == EShapeStatus.DONE)
         {
             _currentBitmap       = _bufferedBitmap?.Clone() as PaintBitmap;
             pictureBoxMain.Image = _currentBitmap?.ToImage();
         }
     }
 }
Example #10
0
        static void Main(string[] args)
        {
            //获取形状工厂
            AbstractFactory shapeFactory = MyFactory.CreateFactory("SHAPE");

            //获取形状为 Circle 的对象,并调用 Circle 的 draw 方法
            IShape shape1 = shapeFactory.GetShape("CIRCLE");

            shape1.Draw();

            //获取形状为 Rectangle 的对象,并调用 Rectangle 的 draw 方法
            IShape shape2 = shapeFactory.GetShape("RECTANGLE");

            shape2.Draw();

            //获取形状为 Square 的对象,并调用 Square 的 draw 方法
            IShape shape3 = shapeFactory.GetShape("SQUARE");

            shape3.Draw();



            //获取颜色工厂
            AbstractFactory colorFactory = MyFactory.CreateFactory("COLOR");

            //获取颜色为 Red 的对象,并调用 Red 的 fill 方法
            IColor color1 = colorFactory.GetColor("RED");

            color1.Fill();

            //获取颜色为 Green 的对象,并调用 Green 的 fill 方法
            IColor color2 = colorFactory.GetColor("Green");

            color2.Fill();

            //获取颜色为 Blue 的对象,并调用 Blue 的 fill 方法
            IColor color3 = colorFactory.GetColor("BLUE");

            color3.Fill();

            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            AbstractFactory shapeFactory = FactoryProducer.GetFactory(false);
            IShape          rectangle    = shapeFactory.GetShape(ShapeType.Rectangle);

            rectangle.Draw();

            IShape square = shapeFactory.GetShape(ShapeType.Square);

            square.Draw();

            AbstractFactory roundedShapeFactory = FactoryProducer.GetFactory(true);
            IShape          roundedRectangle    = roundedShapeFactory.GetShape(ShapeType.Rectangle);

            roundedRectangle.Draw();

            IShape roundedSquare = roundedShapeFactory.GetShape(ShapeType.Square);

            roundedSquare.Draw();
        }
Example #12
0
        public static void GetAbstractFactory()
        {
            AbstractFactory shapeFactory = FactoryProducer.getFactory("Shape");
            IShape          shape1       = shapeFactory.getShape("Circle");
            IShape          shape2       = shapeFactory.getShape("Square");
            IShape          shape3       = shapeFactory.getShape("Rectangle");

            shape1.Draw();
            shape2.Draw();
            shape3.Draw();

            AbstractFactory colorFactory = FactoryProducer.getFactory("Color");
            IColor          color1       = colorFactory.getColor("Red");
            IColor          color2       = colorFactory.getColor("Blue");
            IColor          color3       = colorFactory.getColor("Green");

            color1.Fill();
            color2.Fill();
            color3.Fill();
        }
Example #13
0
        static void Main(string[] args)
        {
            FactoryProducer Fproducer    = new FactoryProducer();
            AbstractFactory shapeFactory = Fproducer.GetFactory("Shape");
            IShape          Circle       = shapeFactory.GetShape(shape.Circle);

            Circle.Draw(10);
            IShape Square = shapeFactory.GetShape(shape.Square);

            Square.Draw(20);

            IColor temp = shapeFactory.GetColor("");

            AbstractFactory colorFactory = Fproducer.GetFactory("Color");
            IColor          Red          = colorFactory.GetColor("Red");
            IColor          Blue         = colorFactory.GetColor("Blue");

            Red.Fill("");
            Blue.Fill("");
            Console.ReadKey();
        }
Example #14
0
        public static void DoMain(String[] args)
        {
            ShapeFactory shapeFactory = new ShapeFactory();

            //获取 Circle 的对象,并调用它的 draw 方法
            IShape shape1 = shapeFactory.getShape("CIRCLE");

            //调用 Circle 的 draw 方法
            shape1.Draw();

            //获取 Rectangle 的对象,并调用它的 draw 方法
            IShape shape2 = shapeFactory.getShape("RECTANGLE");

            //调用 Rectangle 的 draw 方法
            shape2.Draw();

            //获取 Square 的对象,并调用它的 draw 方法
            IShape shape3 = shapeFactory.getShape("SQUARE");

            //调用 Square 的 draw 方法
            shape3.Draw();
        }
Example #15
0
        private void DrawLastMarkers(SKCanvas canvas, SKPaint paint, int lastDrawableShapeIndex, int lastMarkers)
        {
            int startIndex = lastDrawableShapeIndex - lastMarkers;

            startIndex = startIndex < 0 ? 0 : startIndex;

            float opacityStep = 0.9f / lastMarkers;
            float opacity     = opacityStep;

            for (int index = startIndex; index < Layer.Length; index++)
            {
                IShape shape = Layer[index];
                if (shape == null || shape.Time > MaxTime)
                {
                    return;
                }

                shape.UpdateOpacity(opacity);
                opacity += opacityStep;

                shape.Draw(canvas, paint);
            }
        }
        static void Main(string[] args)
        {
            ShapeFactory shapeFactory = new ShapeFactory();

            IShape shape1 = shapeFactory.GetShape("Square");

            shape1.Draw();

            IShape shape2 = shapeFactory.GetShape("Rectangle");

            shape2.Draw();

            try
            {
                IShape shape3 = shapeFactory.GetShape("Circle");
                shape3.Draw();
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Exception received.");
            }
        }
Example #17
0
        public MainWindow()
        {
            InitializeComponent();
            this.Height           = 950;
            this.Width            = 925;
            this.GuiUC.DefineText = "In Factory pattern, we create object without exposing the creation logic to the client and refer to newly created object using a common interface.";

            StringBuilder stringBuilder = new StringBuilder();

            ShapeFactory shapeFactory = new ShapeFactory();

            // get an object of Circle and call its draw method.
            Factory.IShape shape1 = shapeFactory.GetShape("Circle");

            // call draw method of Circle
            stringBuilder.Append(shape1.Draw() + "\n");

            // get an object of Rectangle and call its draw method.
            IShape shape2 = shapeFactory.GetShape("Rectangle");

            // call draw method of Rectangle
            stringBuilder.Append(shape2.Draw() + "\n");

            // get an object of Square and call its draw method.
            IShape shape3 = shapeFactory.GetShape("Square");

            // call draw method of circle
            stringBuilder.Append(shape3.Draw() + "\n");

            this.GuiUC.TextBlockText        = stringBuilder.ToString();
            this.GuiUC.TextBlockConsequence = @" Provides hooks for subclasses
• Creating objects inside a class with a factory method is always more flexible than creating an object directly
• Gives subclasses a hook for providing an extended version of an object
 Connects parallel class hierarchies
• In the examples we've considered so far, the factory method is only called by Creators. But this doesn't have to be the case;
clients can find factory methods useful, especially in the case of parallel class hierarchies";
        }
Example #18
0
        static void Main(string[] args)
        {
            ShapeFactory shapeFactory = new ShapeFactory();

            //获取 Circle 的对象,并调用它的 draw 方法
            IShape shape1 = shapeFactory.GetShape("CIRCLE");

            //调用 Circle 的 draw 方法
            shape1.Draw();

            //获取 Rectangle 的对象,并调用它的 draw 方法
            IShape shape2 = shapeFactory.GetShape("RECTANGLE");

            //调用 Rectangle 的 draw 方法
            shape2.Draw();

            //获取 Square 的对象,并调用它的 draw 方法
            IShape shape3 = shapeFactory.GetShape("SQUARE");

            //调用 Square 的 draw 方法
            shape3.Draw();

            Console.ReadKey();
        }
Example #19
0
        static void Main(string[] args)
        {
            Factory shapeFact = Producer.GetFactory("shape");

            IShape circle = shapeFact.GetShape("circle");

            circle.Draw();

            IShape rectangle = shapeFact.GetShape("rectangle");

            rectangle.Draw();

            Factory colorFactory = Producer.GetFactory("color");

            IColor blueColor = colorFactory.GetColor("blue");

            blueColor.Fill();

            IColor redColor = colorFactory.GetColor("red");

            redColor.Fill();

            Console.ReadKey();
        }
 public void Draw(IShape shape)
 {
     shape.Draw(this.renderer, this.drawingContext);
 }
Example #21
0
 public static void Draw(IShape shape)
 {
     shape.Draw();
 }
Example #22
0
 public void drawLine()
 {
     line.Draw();
 }
Example #23
0
 public virtual void Draw()
 {
     DecoratorShape.Draw();
 }
 public static void Draw(IShape shape)
 {
     shape.Draw();
 }
Example #25
0
 public void drawCircle()
 {
     circle.Draw();
 }
Example #26
0
 public void DrawShape(IShape shape)
 {
     shape.Draw();
 }
Example #27
0
 public void DrawCircle()
 {
     m_circle.Draw();
 }
Example #28
0
 public virtual void Draw()
 {
     shape.Draw();
 }
Example #29
0
 public override void Draw()
 {
     shape.Draw();
     System.Console.WriteLine("with Blue color");
 }
Example #30
0
 public void Draw()
 {
     shape.Draw();
 }
Example #31
0
 public void DrawShape(IShape shape)
 {
     Console.WriteLine(shape.Draw());
 }
Example #32
0
 public void DrawRectangle()
 {
     m_rectangle.Draw();
 }