private void LoadShapes() { DrawManager.AddDefaultDrawers(); foreach (var keyValuePair in PluginsManager.ShapePlugins.SelectMany(shapePlugin => shapePlugin.RegisterShape())) { DrawManager.AddDrawer(keyValuePair.Key, keyValuePair.Value); } var index = _shapesButtonsOffset; foreach (var shapeDrawer in DrawManager.Drawers) { var defaultShape = shapeDrawer.CreateShape(); var button = new ToolStripButton { Text = defaultShape.Name, DisplayStyle = ToolStripItemDisplayStyle.Text, }; button.Click += (o, args) => { CurrentDrawer = shapeDrawer; var shape = shapeDrawer.CreateShape(); ControllersManager.Set <DrawShapeController>(); ControllersManager.Current.CurrentShape = shape; foreach (var btn in toolStrip.Items.OfType <ToolStripButton>()) { btn.Checked = false; } button.Checked = true; }; toolStrip.Items.Insert(index++, button); _shapesButtonsCount++; } }
private void Form1_Load(object sender, EventArgs e) { ControllersManager.Add(new DrawShapeController(this)); ControllersManager.Add(new MoveShapeController(this)); PluginsManager.LoadPlugins(); G = panel1.CreateGraphics(); DrawManager.AddDefaultDrawers(); foreach (var keyValuePair in PluginsManager.ShapePlugins.SelectMany(shapePlugin => shapePlugin.RegisterShape())) { DrawManager.AddDrawer(keyValuePair.Key, keyValuePair.Value); } var index = 2; foreach (var shapeDrawer in DrawManager.Drawers) { var defaultShape = shapeDrawer.CreateShape(); var button = new ToolStripButton { Text = defaultShape.Name, DisplayStyle = ToolStripItemDisplayStyle.Text, }; button.Click += (o, args) => { CurrentDrawer = shapeDrawer; var shape = shapeDrawer.CreateShape(); ControllersManager.Set <DrawShapeController>(); ControllersManager.Current.CurrentShape = shape; foreach (var btn in toolStrip.Items.OfType <ToolStripButton>()) { btn.Checked = false; } button.Checked = true; }; toolStrip.Items.Insert(index++, button); } }