public void ExecuteHyperlink(ShellHyperlink hyperlink) { IShellModule module = (from m in _shellModuleService.Modules where m.Id == hyperlink.ModuleId select m).LastOrDefault(); if (module != null) { ShellInteractionService interactionService = _shellModuleService.GetWorkItem(module).Services.Get <IShellInteractionService>() as ShellInteractionService; interactionService.OnHyperlinkExecuted(new HyperlinkExecutedEventArgs(hyperlink)); _shellHyperlink = null; //Clean up saved shellhyperlink from activation uri at application startup, See ShellApplication.cs function AddServices while (_workItem.RootWorkItem.Items.FindByType <ShellHyperlink>().Count > 0) { _workItem.RootWorkItem.Items.Remove(_workItem.RootWorkItem.Items.FindByType <ShellHyperlink>().FirstOrDefault()); } } }
private void OnModuleActivated() { ShellInteractionService interactionService = null; var modules = from m in Modules where m != _activeModule select m; foreach (IShellModule module in modules) { interactionService = GetWorkItem(module).Services.Get <IShellInteractionService>() as ShellInteractionService; interactionService.OnModuleDeactivated(new EventArgs()); } interactionService = GetWorkItem(_activeModule).Services.Get <IShellInteractionService>() as ShellInteractionService; interactionService.OnModuleActivated(new EventArgs()); EventHandler <DataEventArgs <IShellModule> > temp = ModuleActivated; if (temp != null) { temp(this, new DataEventArgs <IShellModule>(_activeModule)); } }
private void InitializeModelThread(object state) { IShellPresentationModel model = state as IShellPresentationModel; try { ShellDrillDownMenuItem favoritesMenu = null; ShellDrillDownMenuItem startMenu = null; List <AuthOperation> operations = new List <AuthOperation>(); XmlDocument favoritesDoc = _favoritesService.GetFavorites(model.Module.Id); Application.Current.Dispatcher.Invoke(new Action(() => { startMenu = XmlToShellDrillDownMenuItemTransformer.Transform(model.Module.GetMenu()); if (favoritesDoc != null) { favoritesMenu = XmlToShellDrillDownMenuItemTransformer.Transform(favoritesDoc); } else { favoritesMenu = new ShellDrillDownMenuItem() { Caption = StringResources.FavoritesMenu_Header, IsFolder = true }; } AddOperations(startMenu, operations); AddOperations(favoritesMenu, operations); })); bool isAuthorizationEnabled = true; if (operations.Count > 0) { isAuthorizationEnabled = _authorizationService.CheckAuthorization(model.Module.Id, operations); } Application.Current.Dispatcher.Invoke(new Action(() => { foreach (AuthOperation operation in operations) { operation.MenuItem.IsAuthorized = operation.IsAuthorized; } model.FavoritesMenuTopItem = favoritesMenu; if (model.FavoritesMenuTopItem != null) { model.FavoritesMenuTopItem.TreeChanged += (s, e) => { _favoritesService.QueueForUpdate(model.Module.Id, model.FavoritesMenuTopItem); }; } if (_config.HideUnauthorizedMenuItems) { HideUnauthorizedMenuItems(startMenu); } model.StartMenuTopItem = startMenu; OnModuleActivated(); if (!isAuthorizationEnabled) { ShellInteractionService interactionService = GetWorkItem(model.Module).Services.Get <IShellInteractionService>() as ShellInteractionService; interactionService.ShowNotification(new ShellNotification(StringResources.Authorization_Notification, null)); } })); } catch (Exception ex) { Application.Current.Dispatcher.Invoke(new Action(() => { model.StartMenuTopItem = new ShellDrillDownMenuItem() { Caption = "", IsEnabled = false }; throw ex; })); } }