Ejemplo n.º 1
0
        private void InitialClass(BaseDll.Shape shape, FactoryDll.MainFactory Factory)
        {
            var Paint = new PaintElem(shape, Factory);

            ListClass.Add(Paint);
            LBoxClass.Items.Add(Paint.shape.GetType().Name.ToString());
        }
Ejemplo n.º 2
0
 private void Initial()
 {
     InitialLang();
     DrawArrea          = new Bitmap(pct1.Width, pct1.Height);
     gObject            = Graphics.FromImage(DrawArrea);
     colorDialog1.Color = Color.Black;
     list             = new List <PaintElem>();
     ListClass        = new List <PaintElem>();
     Pcolor.BackColor = colorDialog1.Color;
     ispress          = false;
     Factory          = new Factories.LineFactory();
     shape            = Factory.FactoryMethod();
     InitialClass(shape, Factory);
     Factory = new Factories.EllipseFactory();
     shape   = Factory.FactoryMethod();
     InitialClass(shape, Factory);
     Factory = new Factories.CircleFactory();
     shape   = Factory.FactoryMethod();
     InitialClass(shape, Factory);
     Factory = new Factories.RectangleFactory();
     shape   = Factory.FactoryMethod();
     InitialClass(shape, Factory);
     Factory = new Factories.SquareFactory();
     shape   = Factory.FactoryMethod();
     InitialClass(shape, Factory);
     Factory = new Factories.TriangleFactory();
     shape   = Factory.FactoryMethod();
     InitialClass(shape, Factory);
     LBoxClass.SelectedIndex = LBoxClass.Items.Count - 1;
     SelectClass(LBoxClass.SelectedIndex);
 }
Ejemplo n.º 3
0
        private void SelectClass(int index)
        {
            switch (index)
            {
            case 0:
                Factory      = new Factories.LineFactory();
                shape        = Factory.FactoryMethod();
                shape.scolor = colorDialog1.Color;
                shape.Pwidth = trackBar1.Value;
                pen          = new Pen(shape.scolor, shape.Pwidth);
                break;

            case 1:
                Factory      = new Factories.EllipseFactory();
                shape        = Factory.FactoryMethod();
                shape.scolor = colorDialog1.Color;
                shape.Pwidth = trackBar1.Value;
                pen          = new Pen(shape.scolor, shape.Pwidth);
                break;

            case 2:
                Factory      = new Factories.CircleFactory();
                shape        = Factory.FactoryMethod();
                shape.scolor = colorDialog1.Color;
                shape.Pwidth = trackBar1.Value;
                pen          = new Pen(shape.scolor, shape.Pwidth);
                break;

            case 3:
                Factory      = new Factories.RectangleFactory();
                shape        = Factory.FactoryMethod();
                shape.scolor = colorDialog1.Color;
                shape.Pwidth = trackBar1.Value;
                pen          = new Pen(shape.scolor, shape.Pwidth);
                break;

            case 4:
                Factory      = new Factories.SquareFactory();
                shape        = Factory.FactoryMethod();
                shape.scolor = colorDialog1.Color;
                shape.Pwidth = trackBar1.Value;
                pen          = new Pen(shape.scolor, shape.Pwidth);
                break;

            case 5:
                Factory      = new Factories.TriangleFactory();
                shape        = Factory.FactoryMethod();
                shape.scolor = colorDialog1.Color;
                shape.Pwidth = trackBar1.Value;
                pen          = new Pen(shape.scolor, shape.Pwidth);
                break;

            default:
                foreach (var p in FactoryPlugins)
                {
                    if (LBoxClass.Text + "Factory" == p.Name.ToString())
                    {
                        Factory = (FactoryDll.MainFactory)Activator.CreateInstance(p);
                        //shape = (BaseDll.Shape)Activator.CreateInstance(p, "Line");
                        shape        = Factory.FactoryMethod();
                        shape.scolor = colorDialog1.Color;
                        shape.Pwidth = trackBar1.Value;
                        pen          = new Pen(shape.scolor, shape.Pwidth);
                        //IsOriginalShape = false;
                        break;
                    }
                }
                break;
            }
        }
Ejemplo n.º 4
0
 public PaintElem(BaseDll.Shape shape1, FactoryDll.MainFactory Factory1)
 {
     shape   = shape1;
     Factory = Factory1;
 }