private void OnAddComponentChoosed(Component choosedComponent, SceneObject target) { try { target.AttachComponent(choosedComponent); } catch (ArgumentException e) { MessageBox.Show("Вы не можете добавить этот компонент, так как он уже установлен на этот объект"); } }
public RainPresenter(IScene model, IView view) { this.model = model; this.view = view; this.view.MouseDownEvent += view_MouseDownEvent; this.view.MouseUpEvent += view_MouseUpEvent; this.view.MouseMoveEvent += view_MouseMoveEvent; this.view.PressedMouseMoveEvent += view_PressedMouseMoveEvent; this.view.ClearClick += view_ClearClick; this.view.OpenFromXMLClick += view_OpenFromXMLClick; this.view.SaveToXMLClick += view_SaveToXMLClick; this.view.ListBoxSelectedIndexChanged += view_ListBoxSelectedIndexChanged; this.view.ListViewSelectedIndexChanged += view_ListViewSelectedIndexChanged; this.view.PropertyValueChanged += view_PropertyValueChanged; this.view.OpenProjectClick += view_OpenProjectClick; this.view.MouseUpRightClick += view_MouseUpRightClick; this.view.DeleteClick += view_DeleteObjectClick; this.view.DuplicateClick += view_DuplicateObjectClick; this.view.SearchTextBox.TextChanged += view_SearchBoxTextChanged; this.view.TabControlTabSwithed += view_TabConrolTabSwitched; this.view.ComponentAddClick += view_ComponentAddClick; this.view.ComponentDeleteClick += view_ComponentDeleteClick; this.view.PropertyGrid.SelectedObjectsChanged += view_PropertyGridValueChanged; var circleBrush = new SceneObject("Circle", 0, 0, 100, 100); var circleDrawer = circleBrush.AttachComponent <Drawer>(); circleDrawer.UseBrush = true; circleDrawer.Shape = Shapes.Circle; scenabs.Add(circleBrush); var squareBrush = new SceneObject("Square", 0, 0, 100, 100); var squareDrawer = squareBrush.AttachComponent <Drawer>(); squareDrawer.UseBrush = true; squareDrawer.Shape = Shapes.Square; scenabs.Add(squareBrush); var arrowVerticalBrush = new SceneObject("Arrow_Vertical", 0, 0, 100, 100); var arrowVerticalDrawer = arrowVerticalBrush.AttachComponent <Drawer>(); arrowVerticalDrawer.UseBrush = true; arrowVerticalDrawer.Shape = Shapes.Arrow_Vertical; scenabs.Add(arrowVerticalBrush); var arrowHorizontalBrush = new SceneObject("Arrow_Horizontal", 0, 0, 100, 100); var arrowHorizontalDrawer = arrowHorizontalBrush.AttachComponent <Drawer>(); arrowHorizontalDrawer.UseBrush = true; arrowHorizontalDrawer.Shape = Shapes.Arrow_Horizontal; scenabs.Add(arrowHorizontalBrush); var stickmanBrush = new SceneObject("Stickman", 0, 0, 100, 100); var stickmanDrawer = stickmanBrush.AttachComponent <Drawer>(); stickmanDrawer.UseBrush = true; stickmanDrawer.Shape = Shapes.StickMan; scenabs.Add(stickmanBrush); using (Graphics gr = Graphics.FromImage(emptyImage)) { gr.Clear(Color.White); } for (int i = 0; i < scenabimgs.Length; i++) { scenabimgs[i] = emptyImage; } this.view.UpdateScenabsData(scenabs, scenabimgs); mouseInteraction = interactions[0]; this.view.SceneBox.Scene = model; }