コード例 #1
0
 private void AddDockViewModel(DockViewModelTemplate dockViewModel)
 {
     dockViewModel.IsVisible.Value = true;
     if (dockViewModel is DockToolViewModelTemplate)
     {
         this.Anchorables.Add(dockViewModel);
         this.ActiveDock.Value = dockViewModel;
     }
     else if (dockViewModel is EditorViewModelTemplate)
     {
         this.Documents.Add(dockViewModel as EditorViewModelTemplate);
         this.ActiveDocument.Value = dockViewModel as EditorViewModelTemplate;
     }
 }
コード例 #2
0
        private void UpdateLayout(object sender, LayoutSerializationCallbackEventArgs args)
        {
            Type registeredType = null;

            foreach (Type dockType in this.dockTemplateTypes)
            {
                if (dockType.Name == args.Model.ContentId)
                {
                    registeredType = dockType;
                    break;
                }
            }
            if (registeredType != null)
            {
                DockViewModelTemplate dockViewModel = this.dockCreator.CreateDock(registeredType);
                if (!(dockViewModel is MapEditorViewModel))
                {
                    AddDockViewModel(dockViewModel);
                }
                args.Content = dockViewModel;
            }
        }
コード例 #3
0
 public CloseDockMessage(DockViewModelTemplate dock)
 {
     this.Dock = dock;
 }
コード例 #4
0
        public WindowManagerViewModel(IEventAggregator eventAggregator, IConstants constants, IAmeSession session, IActionHandler actionHandler, DockingManager dockManager)
        {
            this.eventAggregator = eventAggregator ?? throw new ArgumentNullException("eventAggregator");
            this.constants       = constants ?? throw new ArgumentNullException("constants");
            this.session         = session ?? throw new ArgumentNullException("constants");
            this.actionHandler   = actionHandler ?? throw new ArgumentNullException("actionHandler");

            this.WindowManager = dockManager;
            this.DockLayout    = new DockLayoutViewModel(this, constants, eventAggregator);

            this.Documents   = new ObservableCollection <EditorViewModelTemplate>();
            this.Anchorables = new ObservableCollection <DockViewModelTemplate>();

            foreach (Map map in session.Maps)
            {
                MapEditorCreator      mapEditorCreator = new MapEditorCreator(this.eventAggregator, constants, this.session, map);
                DockViewModelTemplate dockViewModel    = mapEditorCreator.CreateDock();
                AddDockViewModel(dockViewModel);
            }
            if (this.Documents.Count > 0)
            {
                this.ActiveDocument.Value = this.Documents[0];
            }

            DockCreatorTemplate[] dockCreators = new DockCreatorTemplate[]
            {
                new ClipboardCreator(this.eventAggregator),
                new ItemEditorCreator(this.eventAggregator, constants, this.session),
                new ItemListCreator(this.eventAggregator, this.session),
                new LayerListCreator(this.eventAggregator, this.session, this.actionHandler),
                new MinimapCreator(this.eventAggregator, this.session),
                new SelectedBrushCreator(this.eventAggregator, constants),
                new ProjectExplorerCreator(this.eventAggregator, this.actionHandler, this.session),
                new SessionViewerCreator(this.eventAggregator, this.session),
                new ToolboxCreator(this.eventAggregator, this.session),
                new MapEditorCreator(this.eventAggregator, constants, this.session)
            };
            this.dockCreator = new DockCreator(dockCreators);

            Type dockTemplateType = typeof(DockViewModelTemplate);

            this.dockTemplateTypes = (from domainAssembly in AppDomain.CurrentDomain.GetAssemblies()
                                      from assemblyType in domainAssembly.GetTypes()
                                      where typeof(DockViewModelTemplate).IsAssignableFrom(assemblyType)
                                      select assemblyType).ToArray();

            this.IsBusy.PropertyChanged            += IsBusyChanged;
            this.ActiveDock.PropertyChanged        += ActiveDockPropertyChanged;
            this.ActiveDocument.PropertyChanged    += ActiveDocumentPropertyChanged;
            this.session.Maps.CollectionChanged    += MapsChanged;
            Application.Current.MainWindow.Closing += CloseApplication;

            this.NewProjectCommand     = new DelegateCommand(() => NewProject());
            this.NewMapCommand         = new DelegateCommand(() => NewMap());
            this.OpenProjectCommand    = new DelegateCommand(() => OpenProject());
            this.OpenMapCommand        = new DelegateCommand(() => OpenMap());
            this.SaveFileCommand       = new DelegateCommand(() => SaveCurrentMap());
            this.SaveAsFileCommand     = new DelegateCommand(() => SaveAsMap());
            this.ExportFileCommand     = new DelegateCommand(() => this.actionHandler.ExportFile());
            this.ExportAsFileCommand   = new DelegateCommand(() => ExportAsMap());
            this.CloseFileCommand      = new DelegateCommand(() => this.actionHandler.CloseFile());
            this.UndoCommand           = new DelegateCommand(() => this.actionHandler.Undo());
            this.RedoCommand           = new DelegateCommand(() => this.actionHandler.Redo());
            this.CutCommand            = new DelegateCommand(() => this.actionHandler.CutSelection());
            this.CopyCommand           = new DelegateCommand(() => this.actionHandler.CopySelection());
            this.PasteCommand          = new DelegateCommand(() => this.actionHandler.PasteClipboard());
            this.SampleViewCommand     = new DelegateCommand(() => this.actionHandler.SampleView());
            this.ZoomInCommand         = new DelegateCommand(() => this.actionHandler.ZoomIn());
            this.ZoomOutCommand        = new DelegateCommand(() => this.actionHandler.ZoomOut());
            this.FitMapToWindowCommand = new DelegateCommand(() => this.actionHandler.FitMapToWindow());

            this.eventAggregator.GetEvent <OpenDockEvent>().Subscribe((message) =>
            {
                OpenDock(message);
            }, ThreadOption.PublisherThread);
            this.eventAggregator.GetEvent <CloseDockEvent>().Subscribe((message) =>
            {
                CloseDock(message);
            }, ThreadOption.PublisherThread);
            this.eventAggregator.GetEvent <CloseApplicationEvent>().Subscribe((message) =>
            {
                CloseApplication();
            }, ThreadOption.PublisherThread);
            this.eventAggregator.GetEvent <OpenWindowEvent>().Subscribe((message) =>
            {
                OpenWindow(message);
            }, ThreadOption.PublisherThread);
            this.eventAggregator.GetEvent <NotificationActionEvent <string> >().Subscribe(
                SaveLayoutMessageReceived,
                ThreadOption.PublisherThread,
                false,
                (filter) => filter.Notification.Contains(MessageIds.SaveWorkspaceLayout));
            this.eventAggregator.GetEvent <NotificationEvent <string> >().Subscribe(
                LoadLayoutMessageReceived,
                ThreadOption.PublisherThread,
                false,
                (filter) => filter.Notification.Contains(MessageIds.LoadWorkspaceLayout));
            this.eventAggregator.GetEvent <NotificationEvent <ViewNotification> >().Subscribe((message) =>
            {
                ViewNotificationReceived(message);
            }, ThreadOption.PublisherThread);
            this.eventAggregator.GetEvent <NotificationEvent <ZoomLevel> >().Subscribe((message) =>
            {
                SetZoomLevel(message);
            }, ThreadOption.PublisherThread);
            this.eventAggregator.GetEvent <NotificationEvent <SaveMessage> >().Subscribe((message) =>
            {
                SaveAs(message);
            }, ThreadOption.PublisherThread);
        }