private async Task <bool> ProcessMenuButtonClick(UniversalCommands command, object data) { var button = BaseMenuElement.CreatedUIElements.Find( element => element is MenuButtonItem && ((IButtonOperation)element).Parameter == (object)command); var parent = BaseMenuElement.CreatedUIElements.Find(element => element is MenuSubItem && ((BaseExpanderItem)element).SubItems .ToList().Contains(button)) as BaseExpanderItem; if (parent != null) { string tmp; tmp = button.Image; button.Image = parent.Image; parent.Image = tmp; tmp = button.HintText; button.HintText = parent.HintText; parent.HintText = tmp; tmp = button.Description; button.Description = parent.Description; parent.Description = tmp; var brush = button.Color; button.Color = parent.Color; parent.Color = brush; parent.IsExpanded = false; } ProcessControllerRaiseDialog(command); try { IsActive = false; await Task.Run(delegate { if ((int)command < (int)UniversalOperations.Count) { ApplicationController.Operation((int)command); } }); return(true); } catch (Exception e) { MessageBox.Show(e.Message, "Exception"); return(false); } finally { IsActive = true; } }
private async void ProcessControllerRaiseDialog(object obj) { foreach (var element in BaseMenuElement.CreatedUIElements.OfType <MenuSubItem>()) { element.IsExpanded = false; } if (!(obj is UniversalCommands)) { } else { UniversalCommands buttonCommand = (UniversalCommands)obj; switch (buttonCommand) { case UniversalCommands.NewDocument: CreateDocument(); break; case UniversalCommands.OpenDocument: new Microsoft.Win32.OpenFileDialog().ShowDialog(); break; case UniversalCommands.SaveDocument: new Microsoft.Win32.SaveFileDialog().ShowDialog(); break; case UniversalCommands.StepBackward: break; case UniversalCommands.StepForward: break; case UniversalCommands.Pen: break; case UniversalCommands.Line1: break; case UniversalCommands.Line2: break; case UniversalCommands.Line3: break; case UniversalCommands.Line4: break; case UniversalCommands.Arc1: break; case UniversalCommands.Arc2: break; case UniversalCommands.Circle1: break; case UniversalCommands.Circle2: break; case UniversalCommands.BrokenLine: break; case UniversalCommands.Spline: break; case UniversalCommands.MoveView: break; case UniversalCommands.EnlargeView: break; case UniversalCommands.DiminishView: break; case UniversalCommands.ShowAll: break; case UniversalCommands.ShowNodes: break; case UniversalCommands.ShowGrid: break; case UniversalCommands.SetTheme: break; case UniversalCommands.Eraser: break; case UniversalCommands.Trimming: break; case UniversalCommands.EnlargeElement: break; case UniversalCommands.LinkLines: break; case UniversalCommands.DestroyLine: break; case UniversalCommands.Correct: break; case UniversalCommands.CreateNode: break; case UniversalCommands.DeleteNode: break; case UniversalCommands.Measure: break; case UniversalCommands.Protractor: break; case UniversalCommands.AddLayer: new LayersAdd { Owner = _owner }.ShowDialog(); break; case UniversalCommands.DeleteLayer: new LayersDelete { Owner = _owner }.ShowDialog(); break; case UniversalCommands.LayersManager: new LayersManager { Owner = _owner }.ShowDialog(); break; case UniversalCommands.Help: break; case UniversalCommands.Console: ConsoleVisible = ConsoleVisible == Visibility.Visible ? Visibility.Collapsed : Visibility.Visible; break; case UniversalCommands.Statistics: new Statistics { Owner = _owner }.ShowDialog(); break; case UniversalCommands.Properties: new Dialogs.Properties { Owner = _owner }.ShowDialog(); break; default: throw new ArgumentOutOfRangeException(); } } }
public MenuTextButtonItem(string hintText, UniversalCommands operationType, int width = DefaultWidth, int height = DefaultHeight) : this(hintText, (object)operationType, width, height) { }
public MenuSubItem(string image, string hintText, UniversalCommands operationType, IEnumerable <BaseMenuElement> subItems, int width = DefaultWidth, int height = DefaultHeight) : this(image, hintText, (object)operationType, subItems, width, height) { }