示例#1
0
文件: Form1.cs 项目: Mikita98/OOP
        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());
        }
示例#2
0
文件: Form1.cs 项目: Mikita98/OOP
 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);
 }
示例#3
0
 public override void Draw(BaseDll.Shape shape, Graphics gObject, Pen pen)
 {
     gObject.DrawLine(pen, shape.x1, shape.y1, shape.x2, shape.y2);
 }
示例#4
0
文件: Form1.cs 项目: Mikita98/OOP
        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;
            }
        }
示例#5
0
文件: Form1.cs 项目: Mikita98/OOP
 public PaintElem(BaseDll.Shape shape1, FactoryDll.MainFactory Factory1)
 {
     shape   = shape1;
     Factory = Factory1;
 }
示例#6
0
 public virtual void Draw(BaseDll.Shape shape, Graphics gObject, Pen pen)
 {
 }