public ToolBar() { InitializeComponent(); ToolBarViewModel.GetInstance().UI = this; Border selectedToolButton = null; viewModel = ToolBarViewModel.GetInstance(); viewModel.AddButton(eraserButton, SpriteEditor.Tools.Eraser); viewModel.AddButton(pencilButton, SpriteEditor.Tools.Pencil); viewModel.AddButton(editButton, SpriteEditor.Tools.Edit); viewModel.AddButton(zoomButton, SpriteEditor.Tools.Zoom); viewModel.AddButton(colorPickerButton, SpriteEditor.Tools.ColorPicker); viewModel.EditButton = (EditButton)editButton.Child; switch (SpriteEditor.GetInstance().SelectedToolType) { case SpriteEditor.Tools.Eraser: selectedToolButton = eraserButton; break; case SpriteEditor.Tools.Pencil: selectedToolButton = pencilButton; break; case SpriteEditor.Tools.Edit: selectedToolButton = editButton; break; case SpriteEditor.Tools.Zoom: selectedToolButton = zoomButton; break; } viewModel.SelectTool(selectedToolButton); }
private void SelectTool(object sender, MouseButtonEventArgs e) { viewModel.SelectTool(sender); }