public void PrepareShutdownEventHandler(object sender, PrepareShutdownEventArgs e) { var services = from m in ShellModuleService.Modules select ShellModuleService.GetWorkItem(m).Services.Get <IShellInteractionService>() as ShellInteractionService; foreach (ShellInteractionService service in services) { service.OnShellTerminating(e); if (e.Cancel) { return; } } if (e.Logout) { AppDomain.CurrentDomain.SetData("Logout", new object()); } _shellView.ShowProgress(); try { SettingsService.SaveSettings(); IFavoritesService favoritesServices = WorkItem.RootWorkItem.Services.Get <IFavoritesService>(); favoritesServices.SaveFavorites(); } catch { } finally { _shellView.HideProgress(); try { foreach (ShellInteractionService service in services) { service.OnShellTerminated(new EventArgs()); } } finally { //WorkItem.Services.Get<IChannelFactoryService>().Dispose(); } } }
public void StartMenuItemExecutedEventHandler(object sender, StartMenuItemExecutedEventArgs e) { ShellMenuItem shellMenuItem = new ShellMenuItem(); shellMenuItem.Id = e.MenuItem.Id; shellMenuItem.EventTopic = e.MenuItem.EventTopic; shellMenuItem.Caption = e.MenuItem.Caption; shellMenuItem.IsAuthorized = e.MenuItem.IsAuthorized; shellMenuItem.IsEnabled = e.MenuItem.IsEnabled; shellMenuItem.Parameters = e.MenuItem.Parameters; shellMenuItem.Operation = e.MenuItem.Operation; shellMenuItem.AssemblyFile = e.MenuItem.AssemblyFile; if (!shellMenuItem.IsAuthorized) { IMessageBoxView messageBoxView = WorkItem.SmartParts.AddNew <MessageBoxView>(); messageBoxView.Show(StringResources.Authorization_NotAuhtorized , StringResources.Authorization_Message , null , Infrastructure.MessageBoxButton.Ok , Infrastructure.MessageBoxImage.Warning); return; } try { _shellView.ShowProgress(); try { if (!string.IsNullOrEmpty(shellMenuItem.AssemblyFile)) { ModuleInfo info = new ModuleInfo(shellMenuItem.AssemblyFile); ModuleLoaderService.Load(ShellModuleService.GetWorkItem(e.Module), info); } MenuItemExecutedEventArgs mappedEventArgs = new MenuItemExecutedEventArgs(); mappedEventArgs.MenuItem = shellMenuItem; mappedEventArgs.OpenInNewWindow = (e.StartOption == StartOption.NewWindow || e.StartOption == StartOption.Dashboard); ShellInteractionService interactionService = ShellModuleService.GetWorkItem(e.Module).Services.Get <IShellInteractionService>() as ShellInteractionService; interactionService.OnMenuItemExecuted(mappedEventArgs); if (!string.IsNullOrEmpty(shellMenuItem.EventTopic)) { EventTopic itemTopic = WorkItem.RootWorkItem.EventTopics.Get(shellMenuItem.EventTopic); if (itemTopic != null) { itemTopic.Fire(this, mappedEventArgs, WorkItem.RootWorkItem, PublicationScope.Global); } } } finally { _shellView.HideProgress(); } } catch (Exception ex) { IMessageBoxView messageBoxView = WorkItem.SmartParts.AddNew <MessageBoxView>(); messageBoxView.Show(StringResources.ActionException_Text, ex.Message, ex.ToString(), Infrastructure.MessageBoxButton.Ok, Infrastructure.MessageBoxImage.Error); } }
public void HelpEventHandler(object sender, EventArgs e) { ShellInteractionService shellInteractionService = ShellModuleService.GetWorkItem(ShellModuleService.ActiveModule).Services.Get <IShellInteractionService>() as ShellInteractionService; shellInteractionService.OnHelpRequested(e); }