public WindowCommands GetRightWindowCommands() { var windowCommands = new WindowCommands(); var refreshButton = WindowCommandHelper.CreateWindowCommandButton("appbar_refresh_counterclockwise_down", "refresh"); refreshButton.SetCurrentValue(System.Windows.Controls.Primitives.ButtonBase.CommandProperty, _commandManager.GetCommand("File.Refresh")); _commandManager.RegisterAction("File.Refresh", () => _messageService.ShowAsync("Refresh")); windowCommands.Items.Add(refreshButton); var saveButton = WindowCommandHelper.CreateWindowCommandButton("appbar_save", "save"); saveButton.SetCurrentValue(System.Windows.Controls.Primitives.ButtonBase.CommandProperty, _commandManager.GetCommand("File.Save")); _commandManager.RegisterAction("File.Save", () => _messageService.ShowAsync("Save")); windowCommands.Items.Add(saveButton); var showWindowButton = WindowCommandHelper.CreateWindowCommandButton("appbar_new_window", "show dialog window"); showWindowButton.SetCurrentValue(System.Windows.Controls.Primitives.ButtonBase.CommandProperty, new TaskCommand(() => _uiVisualizerService.ShowDialogAsync <ExampleDialogViewModel>())); windowCommands.Items.Add(showWindowButton); var showDataWindowButton = WindowCommandHelper.CreateWindowCommandButton("appbar_new_window", "show data window"); showDataWindowButton.SetCurrentValue(System.Windows.Controls.Primitives.ButtonBase.CommandProperty, new TaskCommand(() => _uiVisualizerService.ShowDialogAsync <ExampleDataViewModel>())); windowCommands.Items.Add(showDataWindowButton); return(windowCommands); }
public WindowCommands GetRightWindowCommands() { var windowCommands = new WindowCommands(); var refreshButton = WindowCommandHelper.CreateWindowCommandButton("appbar_refresh_counterclockwise_down", "refresh"); refreshButton.Command = _commandManager.GetCommand("File.Refresh"); _commandManager.RegisterAction("File.Refresh", () => _messageService.ShowAsync("Refresh")); windowCommands.Items.Add(refreshButton); var saveButton = WindowCommandHelper.CreateWindowCommandButton("appbar_save", "save"); saveButton.Command = _commandManager.GetCommand("File.Save"); _commandManager.RegisterAction("File.Save", () => _messageService.ShowAsync("Save")); windowCommands.Items.Add(saveButton); var showWindowButton = WindowCommandHelper.CreateWindowCommandButton("appbar_new_window", "show dialog window"); showWindowButton.Command = new Command(() => _uiVisualizerService.ShowDialog <ExampleDialogViewModel>()); windowCommands.Items.Add(showWindowButton); var showDataWindowButton = WindowCommandHelper.CreateWindowCommandButton("appbar_new_window", "show data window"); showDataWindowButton.Command = new Command(() => _uiVisualizerService.ShowDialog <ExampleDataViewModel>()); windowCommands.Items.Add(showDataWindowButton); return(windowCommands); }
/// <summary> /// Initializes a new instance of the <see cref="ShellWindow"/> class. /// </summary> public ShellWindow() { ThemeHelper.EnsureApplicationThemes(GetType().Assembly, true); MahAppsHelper.ApplyTheme(); InitializeComponent(); var accentColorBrush = ThemeHelper.GetAccentColorBrush(); border.BorderBrush = accentColorBrush; var serviceLocator = ServiceLocator.Default; var statusService = serviceLocator.ResolveType <IStatusService>(); statusService.Initialize(statusTextBlock); var commandManager = serviceLocator.ResolveType <ICommandManager>(); var flyoutService = serviceLocator.ResolveType <IFlyoutService>(); var mahAppsService = serviceLocator.ResolveType <IMahAppsService>(); serviceLocator.RegisterInstance <IAboutInfoService>(mahAppsService); var flyouts = new FlyoutsControl(); foreach (var flyout in flyoutService.GetFlyouts()) { flyouts.Items.Add(flyout); } Flyouts = flyouts; var windowCommands = mahAppsService.GetRightWindowCommands(); if (mahAppsService.GetAboutInfo() != null) { var aboutWindowCommand = WindowCommandHelper.CreateWindowCommandButton("appbar_information", "about"); var aboutService = serviceLocator.ResolveType <IAboutService>(); commandManager.RegisterAction("Help.About", aboutService.ShowAbout); aboutWindowCommand.Command = commandManager.GetCommand("Help.About"); windowCommands.Items.Add(aboutWindowCommand); } RightWindowCommands = windowCommands; var mainView = mahAppsService.GetMainView(); contentControl.Content = mainView; SetBinding(TitleProperty, new Binding("ViewModel.Title") { Source = mainView }); }
private void SetupRightCommands( IServiceLocator serviceLocator, IMahAppsService mahAppsService, ICommandManager commandManager) { var windowCommands = mahAppsService.GetRightWindowCommands(); if (mahAppsService.GetAboutInfo() != null) { var aboutWindowCommand = WindowCommandHelper.CreateWindowCommandButton("appbar_information", "about"); var aboutService = serviceLocator.ResolveType <IAboutService>(); commandManager.RegisterAction("Help.About", aboutService.ShowAbout); aboutWindowCommand.Command = commandManager.GetCommand("Help.About"); windowCommands.Items.Add(aboutWindowCommand); } RightWindowCommands = windowCommands; }
public WindowCommands GetRightWindowCommands() { var windowCommands = new WindowCommands(); var refreshButton = WindowCommandHelper.CreateWindowCommandButton(new PackIconMaterial { Kind = PackIconMaterialKind.Refresh }, "Refresh"); refreshButton.SetCurrentValue(System.Windows.Controls.Primitives.ButtonBase.CommandProperty, _commandManager.GetCommand("File.Refresh")); _commandManager.RegisterAction("File.Refresh", () => _messageService.ShowAsync("Refresh")); windowCommands.Items.Add(refreshButton); var saveButton = WindowCommandHelper.CreateWindowCommandButton(new PackIconMaterial { Kind = PackIconMaterialKind.ContentSave }, "Save"); saveButton.SetCurrentValue(System.Windows.Controls.Primitives.ButtonBase.CommandProperty, _commandManager.GetCommand("File.Save")); _commandManager.RegisterAction("File.Save", () => _messageService.ShowAsync("Save")); windowCommands.Items.Add(saveButton); var showWindowButton = WindowCommandHelper.CreateWindowCommandButton(new PackIconMaterial { Kind = PackIconMaterialKind.OpenInNew }, "Show dialog window"); showWindowButton.SetCurrentValue(System.Windows.Controls.Primitives.ButtonBase.CommandProperty, new TaskCommand(() => _uiVisualizerService.ShowDialogAsync <ExampleDialogViewModel>())); windowCommands.Items.Add(showWindowButton); var showDataWindowButton = WindowCommandHelper.CreateWindowCommandButton(new PackIconMaterial { Kind = PackIconMaterialKind.OpenInNew }, "Show data window"); showDataWindowButton.SetCurrentValue(System.Windows.Controls.Primitives.ButtonBase.CommandProperty, new TaskCommand(() => _uiVisualizerService.ShowDialogAsync <ExampleDataViewModel>())); windowCommands.Items.Add(showDataWindowButton); return(windowCommands); }
/// <summary> /// Initializes a new instance of the <see cref="ShellWindow"/> class. /// </summary> public ShellWindow() : base(DataWindowMode.Custom, setOwnerAndFocus: false) { var serviceLocator = ServiceLocator.Default; InitializeComponent(); statusBar.Background = Orc.Controls.ThemeHelper.GetAccentColorBrush(Orc.Controls.AccentColorStyle.AccentColor4); serviceLocator.RegisterInstance(pleaseWaitProgressBar, "pleaseWaitService"); var statusService = serviceLocator.ResolveType <IStatusService>(); statusService.Initialize(statusTextBlock); var commandManager = serviceLocator.ResolveType <ICommandManager>(); var flyoutService = serviceLocator.ResolveType <IFlyoutService>(); var mahAppsService = serviceLocator.ResolveType <IMahAppsService>(); serviceLocator.RegisterInstance <IAboutInfoService>(mahAppsService); var flyouts = new FlyoutsControl(); foreach (var flyout in flyoutService.GetFlyouts()) { flyouts.Items.Add(flyout); } Flyouts = flyouts; var windowCommands = mahAppsService.GetRightWindowCommands(); if (mahAppsService.GetAboutInfo() != null) { var aboutWindowCommand = WindowCommandHelper.CreateWindowCommandButton("appbar_information", "about"); var aboutService = serviceLocator.ResolveType <IAboutService>(); #pragma warning disable AvoidAsyncVoid // Avoid async void commandManager.RegisterAction("Help.About", async() => await aboutService.ShowAboutAsync()); #pragma warning restore AvoidAsyncVoid // Avoid async void aboutWindowCommand.SetCurrentValue(System.Windows.Controls.Primitives.ButtonBase.CommandProperty, commandManager.GetCommand("Help.About")); windowCommands.Items.Add(aboutWindowCommand); } RightWindowCommands = windowCommands; var statusBarContent = mahAppsService.GetStatusBar(); if (statusBarContent != null) { customStatusBarItem.SetCurrentValue(ContentProperty, statusBarContent); } var mainView = mahAppsService.GetMainView(); contentControl.Content = mainView; ShellDimensionsHelper.ApplyDimensions(this, mainView); SetBinding(TitleProperty, new Binding("ViewModel.Title") { Source = mainView }); }
/// <summary> /// Initializes a new instance of the <see cref="ShellWindow"/> class. /// </summary> public ShellWindow() : base(DataWindowMode.Custom, setOwnerAndFocus: false) { var serviceLocator = ServiceLocator.Default; InitializeComponent(); statusBar.Background = ThemeHelper.GetAccentColorBrush(AccentColorStyle.AccentColor4); serviceLocator.RegisterInstance(pleaseWaitProgressBar, "pleaseWaitService"); var statusService = serviceLocator.ResolveType <IStatusService>(); statusService.Initialize(statusTextBlock); var commandManager = serviceLocator.ResolveType <ICommandManager>(); var flyoutService = serviceLocator.ResolveType <IFlyoutService>(); var mahAppsService = serviceLocator.ResolveType <IMahAppsService>(); serviceLocator.RegisterInstance <IAboutInfoService>(mahAppsService); var flyouts = new FlyoutsControl(); foreach (var flyout in flyoutService.GetFlyouts()) { flyouts.Items.Add(flyout); } Flyouts = flyouts; var windowCommands = mahAppsService.GetRightWindowCommands(); if (mahAppsService.GetAboutInfo() != null) { var aboutWindowCommand = WindowCommandHelper.CreateWindowCommandButton("appbar_information", "about"); var aboutService = serviceLocator.ResolveType <IAboutService>(); commandManager.RegisterAction("Help.About", aboutService.ShowAbout); aboutWindowCommand.Command = commandManager.GetCommand("Help.About"); windowCommands.Items.Add(aboutWindowCommand); } RightWindowCommands = windowCommands; var statusBarContent = mahAppsService.GetStatusBar(); if (statusBarContent != null) { customStatusBarItem.Content = statusBarContent; } var mainView = mahAppsService.GetMainView(); contentControl.Content = mainView; SetBinding(TitleProperty, new Binding("ViewModel.Title") { Source = mainView }); }