public void DeleteWidget(object parameter) { if (SelectedWidget != null) { string widgetName = SelectedWidget.Name; MessageBoxResult result = MessageBox.Show($"Are you sure you want to delete the {widgetName} widgets from inventory?", "Delete Widgets", MessageBoxButton.YesNo); switch (result) { case MessageBoxResult.Yes: Widgets.Remove(SelectedWidget); MessageBox.Show($"{widgetName} Widgets Deleted", "Delete Widgets"); if (Widgets.Any()) { SelectedWidget = Widgets[0]; } break; case MessageBoxResult.No: MessageBox.Show($"{widgetName} Widgets Deletion Canceled", "Delete Widgets"); break; } } }
public void DeleteWidget(object parameter) { if (SelectedWidget != null) { string widgetName = SelectedWidget.Name; MessageBoxResult result = MessageBox.Show($"Are you sure you want to delete the {widgetName} widgets from inventory?", "Delete Widgets", MessageBoxButton.YesNo); switch (result) { case MessageBoxResult.Yes: // TODO - handle I/O Errors _widgetBusiness.DeleteWidget(SelectedWidget.Id); Widgets.Remove(SelectedWidget); WidgetOperationFeedback = "Widget Deleted"; if (Widgets.Any()) { SelectedWidget = Widgets[0]; } break; case MessageBoxResult.No: WidgetOperationFeedback = "Widget Deletion Canceled"; break; } } }
public MainViewModel( IWidgetFactory widgetFactory, IWidgetRegistry widgetRegistry, ILogger logger, INavigationManager navigationManager, IEventAggregator eventAggregator, ISettingsService settingsService, IDialogService dialogService, ModulesApiClient modulesApiClient, ModuleConnectionsApiClient connectionsApiClient, ModulesSerializer modulesSerializer) { _widgetRegistry = widgetRegistry; _logger = logger; _navigationManager = navigationManager; _eventAggregator = eventAggregator; _settingsService = settingsService; _dialogService = dialogService; _modulesApiClient = modulesApiClient; _connectionsApiClient = connectionsApiClient; _modulesSerializer = modulesSerializer; _widgets = new ObservableCollection <WidgetViewModel>(); _widgets.CollectionChanged += OnWidgetsCollectionChanged; _connections = new ObservableCollection <ConnectionViewModel>(); _connections.CollectionChanged += OnConnectionsCollectionChanged; _savingBuffer = new List <WidgetViewModel>(); WidgetFactory = widgetFactory; RefreshCommand = new DelegateCommand(async() => await LoadDataAsync(), () => !IsBusy); AddCommandBinding(CustomApplicationCommands.Refresh, RefreshCommand); DeleteCommand = new DelegateCommand(Delete, () => !IsBusy && Widgets.Any(w => w.IsSelected)); AddCommandBinding(CustomApplicationCommands.Delete, DeleteCommand); ImportFileCommand = new DelegateCommand(ImportFile, () => !IsBusy); AddCommandBinding(CustomApplicationCommands.Import, ImportFileCommand); ExportFileCommand = new DelegateCommand(ExportFile, () => !IsBusy); AddCommandBinding(CustomApplicationCommands.Export, ExportFileCommand); }
public bool HasUnlitIndicator(string label) => Widgets.Any(e => e.Indicator != null && e.Indicator.Value.Type == IndicatorType.Unlit && e.Indicator.Value.Label == label);
public bool HasIndicator(string label) => Widgets.Any(e => e.Indicator != null && e.Indicator.Value.Label == label);
public override string ToString() { return($"#={SerialNumber}{(Widgets.Any() ? "; " : "")}{Widgets.GroupBy(w => w.Type).Select(g => g.JoinString(", ")).JoinString("; ")}"); }