コード例 #1
0
        /// <inheritdoc />
        public IPerspective OpenPerspective(string perspectiveId)
        {
            if (string.IsNullOrEmpty(perspectiveId))
            {
                return(null);
            }

            IPerspective    newPerspective = PerspectiveFactory.Instance.GetPerspective(perspectiveId);
            IWidgetCompound widgetCompound = newPerspective.GetPanel();

            MainWindow.SetContent(widgetCompound);

            IPerspective oldPerspective = ActivePerspective;

            if (oldPerspective != null)
            {
                // Currently nothing to do
            }

            ActivePerspective = newPerspective;
            _workbenchEventManager.Dispatch(lstnr => lstnr.OnPerspectiveChanged(oldPerspective, newPerspective), OnPerspectiveChangedException);

            if (newPerspective != null)
            {
                // Currently nothing to do
            }

            return(newPerspective);
        }
コード例 #2
0
        public static void AddOrSelectTool <T>(this IPerspective me, Func <T> factory) where T : IToolViewModel
        {
            var currentTool = me.Tools.FirstOrDefault(t => t is T);

            if (currentTool != default)
            {
                me.SelectedTool = currentTool;
            }
            else
            {
                me.AddTool(factory());
            }
        }
コード例 #3
0
        public static void AddOrSelectTool <T>(this IPerspective me, T tool) where T : IToolViewModel
        {
            var currentTool = me.Tools.FirstOrDefault(t => t.Equals(tool));

            if (currentTool != null)
            {
                me.SelectedTool = currentTool;
            }
            else
            {
                me.AddTool(tool);
            }
        }
コード例 #4
0
        public void ApplyPerspective(IPerspective perspective)
        {
            m_StatusService.HandleStatus(Status.Debug(string.Format("Loading perspective: {0}", perspective.Name))); /// @todo: remove
            m_CurrentPerspective = perspective;                                                                      /// @todo: check if this should be placed at the end of the loading process

            WidgetConfiguration pageConfig = GetPageConfiguration(perspective);

            DetachToolbars();
            CreateToolbars(pageConfig);
            ConfigurePage(pageConfig);
            CreatePanes(pageConfig);
            m_Page.PerformLayout();
        }
コード例 #5
0
        private static WidgetConfiguration GetPageConfiguration(IPerspective perspective)
        {
            WidgetConfiguration pageConfig = new WidgetConfiguration();

            if (perspective.Configuration.PageConfiguration != null)
            {
                return(perspective.Configuration.PageConfiguration as WidgetConfiguration);
            }

            if (string.IsNullOrEmpty(perspective.Configuration.PageConfigurationXml))
            {
                throw new InvalidOperationException(string.Format("The Perspective ({0}) wasn't created correctly. Its PageConfiguration and PageConfigurationXml are both null or empty", perspective.Id));
            }

            using (StringReader input = new StringReader(perspective.Configuration.PageConfigurationXml))
                using (XmlReader reader = XmlReader.Create(input))
                {
                    pageConfig.ReadXml(reader);
                }
            return(pageConfig);
        }
コード例 #6
0
ファイル: FileMenuSaveHandler.cs プロジェクト: astorch/motoi
 /// <inheritdoc />
 public void OnPerspectiveChanged(IPerspective oldPerspective, IPerspective newPerspective)
 {
     oldPerspective?.RemovePerspectiveListener(this);
     newPerspective?.AddPerspectiveListener(this);
 }