private void FullViewViewModel_Loaded(object sender, System.Windows.RoutedEventArgs e) { IStateService state = _container.Get().Resolve <IStateService>(); if (state != null && !string.IsNullOrEmpty(state.GetCurrentDocument())) { DocumentPath = state.GetCurrentDocument(); } }
public void Initialize() { if (_weak.IsAlive && _weak.Get() != null) { var mapper = _weak.Get().Resolve <IWindowMapper>(); if (mapper.Get(_windowScope) == null) { mapper.Map(_windowScope, typeof(FullViewWindow)); } _weak.Get().RegisterType <IFullView, FullViewWindow>(); _weak.Get().RegisterType <IToolbarViewModel, ToolbarViewModel>(); _weak.Get().RegisterType <IFullViewViewModel, FullViewViewModel>(); var vm = _weak.Get().Resolve <IFullViewViewModel>(); IWindow wind = (vm.View as IWindow); //_weak.Get().Resolve<IWindowProvider>().Generate(_windowScope); if (wind != null) { wind.Owner = System.Windows.Application.Current.MainWindow; wind.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner; wind.Title = "Full view"; wind.WindowStyle = System.Windows.WindowStyle.ToolWindow; wind.Show(); } } }
public RecentMenuItemViewModel(string header, int priority, IUnityContainer container = null, ImageSource icon = null, ICommand command = null, KeyGesture gesture = null, bool isCheckable = false) : base(header, priority, icon, command, gesture, isCheckable) { if (container != null) { _containerWeak = new GenericWeakReference <IUnityContainer>(container); IFileHistoryService service = _containerWeak.Get().Resolve <IFileHistoryService>(); if (service != null) { _historyServWeak = new GenericWeakReference <IFileHistoryService>(service); _historyServWeak.Get().RecentChanged += RecentMenuItemViewModel_RecentChanged; } } }
public FullViewViewModel(IFullView view, IUnityContainer cont) : base(view) { _container = new GenericWeakReference<IUnityContainer>(cont); _resourcePath = "FullViewModule.Highlightings.Default.xshd"; if (_container.IsAlive) ToolbarViewModel = _container.Get().Resolve<IToolbarViewModel>(); if ((this.View as IWindow) != null) { (View as IWindow).Loaded += FullViewViewModel_Loaded; (View as IWindow).Closing += FullViewViewModel_Closing; } }
public RecentMenuItemViewModel(string header, int priority, IUnityContainer container = null, ImageSource icon = null, ICommand command = null, KeyGesture gesture = null, bool isCheckable = false) : base(header, priority, icon, command, gesture, isCheckable) { if (container != null) { _containerWeak = new GenericWeakReference<IUnityContainer>(container); IFileHistoryService service = _containerWeak.Get().Resolve<IFileHistoryService>(); if (service != null) { _historyServWeak = new GenericWeakReference<IFileHistoryService>(service); _historyServWeak.Get().RecentChanged += RecentMenuItemViewModel_RecentChanged; } } }
public FullViewViewModel(IFullView view, IUnityContainer cont) : base(view) { _container = new GenericWeakReference <IUnityContainer>(cont); _resourcePath = "FullViewModule.Highlightings.Default.xshd"; if (_container.IsAlive) { ToolbarViewModel = _container.Get().Resolve <IToolbarViewModel>(); } if ((this.View as IWindow) != null) { (View as IWindow).Loaded += FullViewViewModel_Loaded; (View as IWindow).Closing += FullViewViewModel_Closing; } }
private void RecentMenuItemViewModel_RecentChanged(object sender, RecentEventArgs e) { ICommandManager commands = _containerWeak.Get().Resolve <ICommandManager>(); switch (e.Action) { case RecentAction.Added: ICommand openRecentCmd = commands.GetCommand("OPENRECENT"); var newVM = new MenuItemViewModel(e.Item, Children.Count + 1, null, openRecentCmd); newVM.CommandParameter = newVM.Header; Add(newVM); break; case RecentAction.Removed: Remove(e.Item); break; case RecentAction.None: default: break; } commands = null; }
private void InitializeCoreServices() { _weakCont.Get().RegisterType <IFileHistoryService, FileHistoryService>(new ContainerControlledLifetimeManager()); _weakCont.Get().RegisterType <IStateService, ApplicationStateService>(new ContainerControlledLifetimeManager()); _weakCont.Get().RegisterType <IThemeManager, ThemeManager>(new ContainerControlledLifetimeManager()); _weakCont.Get().RegisterType <ICommandManager, Core.Infrastructure.CommandManager>(new ContainerControlledLifetimeManager()); _weakCont.Get().RegisterType <AbstractMenuItem, MenuItemViewModel>(new ContainerControlledLifetimeManager(), new InjectionConstructor(new InjectionParameter(typeof(string), "$MAIN$"), new InjectionParameter(typeof(int), 1), new InjectionParameter(typeof(ImageSource), null), new InjectionParameter(typeof(ICommand), null), new InjectionParameter(typeof(KeyGesture), null), new InjectionParameter(typeof(bool), false), new InjectionParameter(typeof(IUnityContainer), this._weakCont.Get()))); _weakCont.Get().RegisterType <IWindowMapper, WindowMapper>(new ContainerControlledLifetimeManager()); _weakCont.Get().RegisterType <IWindowProvider, WindowProviderService>(new ContainerControlledLifetimeManager()); }