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); }
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; } }