public DocumentationLink(DocumentationLinkType type, string url, string?label) { Label = label ?? type.ToString(); Url = url; Type = type; Open = new AnotherCommandImplementation(Execute); }
public DialogsViewModel() { //Sample 4 OpenSample4DialogCommand = new AnotherCommandImplementation(OpenSample4Dialog); AcceptSample4DialogCommand = new AnotherCommandImplementation(AcceptSample4Dialog); CancelSample4DialogCommand = new AnotherCommandImplementation(CancelSample4Dialog); }
public MainWindowViewModel(ISnackbarMessageQueue snackbarMessageQueue) { DemoItems = new ObservableCollection <DemoItem>(new[] { new DemoItem( "Home", typeof(Home), new[] { new DocumentationLink( DocumentationLinkType.Wiki, $"{ConfigurationManager.AppSettings["GitHub"]}/wiki", "WIKI"), DocumentationLink.DemoPageLink <Home>() } ) }); foreach (var item in GenerateDemoItems(snackbarMessageQueue).OrderBy(i => i.Name)) { DemoItems.Add(item); } _demoItemsView = CollectionViewSource.GetDefaultView(DemoItems); _demoItemsView.Filter = DemoItemsFilter; HomeCommand = new AnotherCommandImplementation( _ => { SearchKeyword = string.Empty; SelectedIndex = 0; }); MovePrevCommand = new AnotherCommandImplementation( _ => { if (!string.IsNullOrWhiteSpace(SearchKeyword)) { SearchKeyword = string.Empty; } SelectedIndex--; }, _ => SelectedIndex > 0); MoveNextCommand = new AnotherCommandImplementation( _ => { if (!string.IsNullOrWhiteSpace(SearchKeyword)) { SearchKeyword = string.Empty; } SelectedIndex++; }, _ => SelectedIndex < DemoItems.Count - 1); }
public IconPackViewModel(ISnackbarMessageQueue snackbarMessageQueue) { _snackbarMessageQueue = snackbarMessageQueue ?? throw new ArgumentNullException(nameof(snackbarMessageQueue)); OpenDotComCommand = new AnotherCommandImplementation(OpenDotCom); SearchCommand = new AnotherCommandImplementation(Search); CopyToClipboardCommand = new AnotherCommandImplementation(CopyToClipboard); _packIconKinds = new Lazy <IEnumerable <PackIconKindGroup> >(() => Enum.GetNames(typeof(PackIconKind)) .GroupBy(k => (PackIconKind)Enum.Parse(typeof(PackIconKind), k)) .Select(g => new PackIconKindGroup(g)) .OrderBy(x => x.Kind) .ToList()); var helper = new PaletteHelper(); if (helper.GetThemeManager() is { } themeManager) { themeManager.ThemeChanged += ThemeManager_ThemeChanged; } SetDefaultIconColors(); }
public ButtonsViewModel() { FloatingActionDemoCommand = new AnotherCommandImplementation(FloatingActionDemo); var autoStartingActionCountdownStart = DateTime.Now; var demoRestartCountdownComplete = DateTime.Now; var dismissRequested = false; DismissCommand = new AnotherCommandImplementation(_ => dismissRequested = true); ShowDismissButton = true; #region DISMISS button demo control //just some demo code for the DISMISS button...it's up to you to set //up the progress on the button as it would be with a progress bar. //and then hide the button, do whatever action you want to do new DispatcherTimer( TimeSpan.FromMilliseconds(100), DispatcherPriority.Normal, new EventHandler((o, e) => { if (dismissRequested) { ShowDismissButton = false; dismissRequested = false; demoRestartCountdownComplete = DateTime.Now.AddSeconds(3); DismissButtonProgress = 0; } if (ShowDismissButton) { var totalDuration = autoStartingActionCountdownStart.AddSeconds(5).Ticks - autoStartingActionCountdownStart.Ticks; var currentDuration = DateTime.Now.Ticks - autoStartingActionCountdownStart.Ticks; var autoCountdownPercentComplete = 100.0 / totalDuration * currentDuration; DismissButtonProgress = autoCountdownPercentComplete; if (DismissButtonProgress >= 100) { demoRestartCountdownComplete = DateTime.Now.AddSeconds(3); ShowDismissButton = false; UpdateDemoRestartCountdownText(demoRestartCountdownComplete, out _); } } else { UpdateDemoRestartCountdownText(demoRestartCountdownComplete, out bool isComplete); if (isComplete) { autoStartingActionCountdownStart = DateTime.Now; ShowDismissButton = true; } } }), Dispatcher.CurrentDispatcher); #endregion IncrementOrClickMeCountCommand = new AnotherCommandImplementation(_ => OrClickMeCount += 1); OrClickMeCount = 0; //just some demo code for the SAVE button SaveCommand = new AnotherCommandImplementation(_ => { if (IsSaveComplete == true) { IsSaveComplete = false; return; } if (SaveProgress != 0) { return; } var started = DateTime.Now; IsSaving = true; new DispatcherTimer( TimeSpan.FromMilliseconds(50), DispatcherPriority.Normal, new EventHandler((o, e) => { var totalDuration = started.AddSeconds(3).Ticks - started.Ticks; var currentProgress = DateTime.Now.Ticks - started.Ticks; var currentProgressPercent = 100.0 / totalDuration * currentProgress; SaveProgress = currentProgressPercent; if (SaveProgress >= 100) { IsSaveComplete = true; IsSaving = false; SaveProgress = 0; if (o is DispatcherTimer timer) { timer.Stop(); } } }), Dispatcher.CurrentDispatcher); }); }
public MainWindowViewModel(ISnackbarMessageQueue snackbarMessageQueue) { DemoItems = new ObservableCollection <DemoItem> { new DemoItem( "Home", typeof(Home), new[] { new DocumentationLink( DocumentationLinkType.Wiki, $"{ConfigurationManager.AppSettings["GitHub"]}/wiki", "WIKI"), DocumentationLink.DemoPageLink <Home>() }, selectedIcon: PackIconKind.Home, unselectedIcon: PackIconKind.HomeOutline) }; foreach (var item in GenerateDemoItems(snackbarMessageQueue).OrderBy(i => i.Name)) { DemoItems.Add(item); } MainDemoItems = new ObservableCollection <DemoItem> { DemoItems.First(x => x.Name == "Home"), DemoItems.First(x => x.Name == "Buttons"), DemoItems.First(x => x.Name == "Toggles"), DemoItems.First(x => x.Name == "Fields"), DemoItems.First(x => x.Name == "Pickers") }; _demoItemsView = CollectionViewSource.GetDefaultView(DemoItems); _demoItemsView.Filter = DemoItemsFilter; HomeCommand = new AnotherCommandImplementation( _ => { SearchKeyword = string.Empty; SelectedIndex = 0; }); MovePrevCommand = new AnotherCommandImplementation( _ => { if (!string.IsNullOrWhiteSpace(SearchKeyword)) { SearchKeyword = string.Empty; } SelectedIndex--; }, _ => SelectedIndex > 0); MoveNextCommand = new AnotherCommandImplementation( _ => { if (!string.IsNullOrWhiteSpace(SearchKeyword)) { SearchKeyword = string.Empty; } SelectedIndex++; }, _ => SelectedIndex < DemoItems.Count - 1); DismissAllNotificationsCommand = new AnotherCommandImplementation( _ => DemoItems[0].DismissAllNotifications(), _ => DemoItems[0].Notifications != null); AddNewNotificationCommand = new AnotherCommandImplementation( _ => DemoItems[0].AddNewNotification()); AddNewNotificationCommand.Execute(new object()); }