示例#1
0
        /// <summary>
        /// Convert a Avalondock ContentId into a viewmodel instance
        /// that represents a document or tool window. The re-load of
        /// this component is cancelled if the Id cannot be resolved.
        ///
        /// The result is (viewmodel Id or Cancel) is returned in <paramref name="args"/>.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void UpdateLayout(object sender, LayoutSerializationCallbackEventArgs args)
        {
            try
            {
                Core.Interfaces.IViewModelResolver resolver = null;

                resolver = DataContext as Core.Interfaces.IViewModelResolver;

                if (resolver == null)
                {
                    return;
                }

                // Get a matching viewmodel for a view through DataContext of this view
                var contentViewModel = resolver.ContentViewModelFromId(args.Model.ContentId);

                if (contentViewModel == null)
                {
                    args.Cancel = true;
                }

                // found a match - return it
                args.Content = contentViewModel;
            }
            catch (Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
示例#2
0
        private void ReloadContentOnStartUp(LayoutSerializationCallbackEventArgs args)
        {
            string cId = args.Model.ContentId;

            logger.DebugFormat("ReloadContentOnStartUp, {0}", cId);

            var pane = Tools.Union <PaneViewModel>(Screens).FirstOrDefault(p => p.ContentId == cId);

            if (pane != null)
            {
                args.Content = pane;
            }
            else
            {
                args.Content =
                    ReloadTool(args.Model) as PaneViewModel ??
                    ReloadDocument(args.Model) as PaneViewModel;
            }

            // убираем пустую панель
            if (args.Content == null)
            {
                args.Cancel = true;
            }
        }
        private void LayoutDeserialization(object sender, LayoutSerializationCallbackEventArgs args)
        {
            try
            {
                Type t = Type.GetType(args.Model.ContentId);
                DockWindowViewModel vm = null;
                foreach (var anchorable in dockMgr.AnchorablesSource)
                {
                    if (anchorable.GetType() == t)
                    {
                        vm           = anchorable as DockWindowViewModel;
                        vm.IsVisible = args.Model.IsEnabled;
                    }
                }

                // found a match - return it
                if (vm != null)
                {
                    args.Content = vm;
                }
                else
                {
                    args.Cancel = true;
                }
            }
            catch (Exception exp)
            {
                Console.WriteLine(exp.Message);
            }
        }
示例#4
0
        private void LayoutSerializer_LayoutSerializationCallback(object sender, LayoutSerializationCallbackEventArgs e)
        {
            var mvm = this.DataContext as MainWindowViewModel;

            if (e.Model.ContentId == null)
            {
                e.Cancel = true;
                return;
            }

            if (e.Model.ContentId.Equals(Korduene.UI.WPF.Constants.ContentIds.TOOLBOX, StringComparison.OrdinalIgnoreCase))
            {
                var vm = new ToolBoxViewModel();
                e.Content = vm;
                mvm.AddToolsInternal(vm);
            }
            else if (e.Model.ContentId.Equals(Korduene.UI.WPF.Constants.ContentIds.PROPERTIES, StringComparison.OrdinalIgnoreCase))
            {
                var vm = new PropertiesViewModel();
                e.Content = vm;
                mvm.AddToolsInternal(vm);
            }
            else if (e.Model.ContentId.Equals(Korduene.UI.WPF.Constants.ContentIds.SOLUTION_EXPLORER, StringComparison.OrdinalIgnoreCase))
            {
                var vm = new SolutionExplorerViewModel();
                e.Content = vm;
                mvm.AddToolsInternal(vm);
            }
            else if (e.Model.ContentId.Equals(Korduene.UI.WPF.Constants.ContentIds.OUTPUT, StringComparison.OrdinalIgnoreCase))
            {
                var vm = new OutputViewModel();
                e.Content = vm;
                mvm.AddToolsInternal(vm);
            }
        }
示例#5
0
 void LayoutDeserialization(object sender, LayoutSerializationCallbackEventArgs e)
 {
     if (e.Content == null)
     {
         e.Content = FindContent(e.Model.ContentId);
     }
 }
示例#6
0
        /// <summary>
        /// Method is called via interface from <seealso cref="AvalonDockLayoutViewModel"/>
        /// when the application loads layout.
        /// </summary>
        /// <param name="args"></param>
        public void ReloadContentOnStartUp(LayoutSerializationCallbackEventArgs args)
        {
            string sId = args.Model.ContentId;

            // Empty Ids are invalid but possible if aaplication is closed with File>New without edits.
            if (string.IsNullOrWhiteSpace(sId) == true)
            {
                args.Cancel = true;
                return;
            }

            if (args.Model.ContentId == FileStatsViewModel.ToolContentId)
            {
                args.Content = this.FileStats;
            }
            else
            {
                args.Content = this.ReloadDocument(args.Model.ContentId);

                if (args.Content == null)
                {
                    args.Cancel = true;
                }
            }
        }
示例#7
0
 void LayoutSerializer_LayoutSerializationCallback(object sender, LayoutSerializationCallbackEventArgs e)
 {
     if (Profile != null && e.Model is LayoutDocument)
     {
         HeliosObject         profileObject = HeliosSerializer.ResolveReferenceName(Profile, e.Model.ContentId);
         HeliosEditorDocument editor        = CreateDocumentEditor(profileObject);
         profileObject.PropertyChanged += DocumentObject_PropertyChanged;
         e.Content       = CreateDocumentContent(editor);
         e.Model.Closed += Document_Closed;
         AddDocumentMeta(profileObject, (LayoutDocument)e.Model, editor);
     }
 }
示例#8
0
        void MatchLayoutContent(object o, LayoutSerializationCallbackEventArgs e)
        {
            var contentId = e.Model.ContentId;

            if (e.Model is LayoutAnchorable)
            {
                foreach (var tool in this.AnchorContents)
                {
                    if (tool.ContentId == contentId)
                    {
                        e.Content = tool;
                        return;
                    }
                }

                // Unknown
                //ErrorDialog(new Exception("unknown ContentID: " + contentId));
                e.Cancel = true;                 // 未実装のペインは表示しない
                return;
            }

            if (e.Model is LayoutDocument)
            {
                // Documentは復帰しない
                // load済みを探す
                e.Cancel = true;                 // ドキュメントは読み込まない
                return;

                foreach (var document in this.Contents)
                {
                    if (document.ContentId == contentId)
                    {
                        e.Content = document;
                        return;
                    }
                }

                // Document
                {
                    //var document = NewDocument();
                    //Documents.Add(document);
                    //document.ContentId = contentId;
                    //e.Content = document;
                }

                return;
            }

            //ErrorDialog(new Exception("Unknown Model: " + e.Model.GetType()));
            return;
        }
示例#9
0
        private void LayoutSerializationCallback(object sender, LayoutSerializationCallbackEventArgs args)
        {
            if (args.Model.ContentId.StartsWith("Plugin"))
            {
                args.Cancel = true;
            }
            else
            {
                var outputWindow = new OutputWindow(this, args.Model.Title, _allRootModels)
                {
                    Uid         = args.Model.ContentId,
                    DockContent = args.Model
                };

                _outputWindows.Add(outputWindow);
                args.Content = outputWindow.VisibleControl;

                args.Model.Closed += OnOutputWindowClosed;

                var menuItem = new MenuItem
                {
                    Header = outputWindow.Name,
                    Name   = outputWindow.Uid,
                };

                menuItem.Click += (s, e) => { ShowOutputWindow((string)((MenuItem)s).Header); };

                if (_windowMenuItem.Items.Count > 0)
                {
                    _windowMenuItem.Items.Insert(0, menuItem);
                }
                else
                {
                    _windowMenuItem.Items.Add(menuItem);
                }

                if (_windowSeparator.Visibility != Visibility.Visible)
                {
                    _windowSeparator.Visibility = Visibility.Visible;
                }

                PluginHost.Instance.OutputWindowCreated(outputWindow.RootModel);

                if (SettingsHolder.Instance.Settings.AutoConnect)
                {
                    outputWindow.RootModel.PushCommandToConveyor(
                        new ConnectCommand(SettingsHolder.Instance.Settings.ConnectHostName, SettingsHolder.Instance.Settings.ConnectPort));
                }
            }
        }
示例#10
0
        private void LayoutSerializer_LayoutSerializationCallback(object sender, LayoutSerializationCallbackEventArgs e)
        {
            var vm = DataContext as MainWindowViewModel;

            switch (e.Model.ContentId)
            {
            case "FileExplorer":
                e.Content = vm.DockManager._fileexpl;
                break;

            case "CommandConsole":
                e.Content = vm.DockManager._console;
                break;

            case "PowerShell":
                e.Content = vm.DockManager._powerShell;
                break;

            case "Output":
                e.Content = vm.DockManager._output;
                break;

            case "Project":
                e.Content = vm.DockManager._project;
                break;

            case "Properties":
                e.Content = vm.DockManager._properties;
                break;

            default:
                if (e.Model.ContentId == null)
                {
                    e.Cancel = true;
                    break;
                }
                if (e.Model.ContentId.StartsWith("file://"))
                {
                    var path = e.Model.ContentId.Substring(7);
                    e.Content = new CodeEditorViewModel(path);
                    DockManagerViewModel.DocumentManager.Documents.Add(e.Content as CodeEditorViewModel);
                }
                else
                {
                    e.Cancel = true;
                }
                break;
            }
        }
示例#11
0
        private void OnLayoutDeserialized(object sender, LayoutSerializationCallbackEventArgs e)
        {
            foreach (UiMenuItem item in _mainMenuView.Items)
            {
                if (e.Model.Title != (string)item.Header)
                {
                    continue;
                }

                e.Content = item.CommandParameter;
                //e.Model.Content = item.CommandParameter;
                e.Cancel = false;
                return;
            }
        }
示例#12
0
        void MatchLayoutContent(object o, LayoutSerializationCallbackEventArgs e)
        {
            var contentId = e.Model.ContentId;

            if (e.Model is LayoutAnchorable)
            {
                // Tool Windows
                foreach (var tool in Tools)
                {
                    if (tool.ContentId == contentId)
                    {
                        e.Content = tool;
                        return;
                    }
                }

                // Unknown
                ErrorDialog(new Exception("unknown ContentID: " + contentId));
                return;
            }

            if (e.Model is LayoutDocument)
            {
                // load済みを探す
                foreach (var document in Documents)
                {
                    if (document.ContentId == contentId)
                    {
                        e.Content = document;
                        return;
                    }
                }

                // Document
                {
                    var document = NewDocument();
                    Documents.Add(document);
                    document.ContentId = contentId;
                    e.Content          = document;
                }

                return;
            }

            ErrorDialog(new Exception("Unknown Model: " + e.Model.GetType()));
            return;
        }
示例#13
0
        void MatchLayoutContent(object o, LayoutSerializationCallbackEventArgs e)
        {
            //var contentId = e.Model.ContentId;

            //if (e.Model is LayoutAnchorable)
            //{
            //    // Tool Windows
            //    foreach (var tool in Tools)
            //    {
            //        if (tool.ContentId == contentId)
            //        {
            //            e.Content = tool;
            //            return;
            //        }
            //    }

            //    // Unknown
            //    ErrorDialog(new Exception("unknown ContentID: " + contentId));
            //    return;
            //}

            //if (e.Model is LayoutDocument)
            //{
            //    // load済みを探す
            //    foreach (var document in Documents)
            //    {
            //        if (document.ContentId == contentId)
            //        {
            //            e.Content = document;
            //            return;
            //        }
            //    }

            //    // Document
            //    {
            //        var document = NewDocument();
            //        Documents.Add(document);
            //        document.ContentId = contentId;
            //        e.Content = document;
            //    }

            //    return;
            //}

            //ErrorDialog(new Exception("Unknown Model: " + e.Model.GetType()));
            //return;
        }
示例#14
0
        private void UpdateLayout(object sender, LayoutSerializationCallbackEventArgs args)
        {
            //var resolver = DataContext as IDocumentViewModelResolver;

            //if (resolver == null)
            //    return;

            //// Get a matching viewmodel for that view via DataContext property of this view
            //var contentViewModel = resolver
            //    .GetContentViewModelFromId(args.Model.ContentId);

            //if (contentViewModel == null)
            //    args.Cancel = true;

            //// found a match - return it
            //args.Content = contentViewModel;
        }
示例#15
0
 void LayoutSerializer_LayoutSerializationCallback(object sender, LayoutSerializationCallbackEventArgs e)
 {
     if (Profile != null && e.Model is LayoutDocument)
     {
         HeliosObject profileObject = HeliosSerializer.ResolveReferenceName(Profile, e.Model.ContentId);
         if (profileObject != null)
         {
             HeliosEditorDocument editor = CreateDocumentEditor(profileObject);
             profileObject.PropertyChanged += DocumentObject_PropertyChanged;
             e.Content = CreateDocumentContent(editor);
             //DocumentPane.Children.Add((LayoutDocument)e.Model);
             e.Model.Closed += Document_Closed;
             AddDocumentMeta(profileObject, (LayoutDocument)e.Model, editor);
         }
         else
         {
             ConfigManager.LogManager.LogDebug("Layout Serializer: Unable to resolve Layout Document " + e.Model.ContentId);
         }
     }
 }
示例#16
0
        /// <summary>
        /// Convert a Avalondock ContentId into a viewmodel instance
        /// that represents a document or tool window. The re-load of
        /// this component is cancelled if the Id cannot be resolved.
        ///
        /// The result is (viewmodel Id or Cancel) is returned in <paramref name="args"/>.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void UpdateLayout(object sender, LayoutSerializationCallbackEventArgs args)
        {
            var resolver = this.DataContext as IDockpanelContentViewmodelResolver;

            if (resolver == null)
            {
                return;
            }

            // Get a matching viewmodel for that view via DataContext property of this view
            INotifyPropertyChanged content_view_model = resolver.ContentViewModelFromID(args.Model.ContentId);

            if (content_view_model == null)
            {
                args.Cancel = true;
            }

            // found a match - return it
            args.Content = content_view_model;
        }
示例#17
0
        void LayoutSerializationCallback(object sender, LayoutSerializationCallbackEventArgs e)
        {
            switch (e.Model)
            {
            case LayoutAnchorable la:
                e.Content = ToolPanes.FirstOrDefault(p => p.ContentId == la.ContentId);
                e.Cancel  = e.Content == null;
                la.CanDockAsTabbedDocument = false;
                if (!e.Cancel)
                {
                    e.Cancel = ((ToolPaneModel)e.Content).IsVisible;
                    ((ToolPaneModel)e.Content).IsVisible = true;
                }
                break;

            default:
                e.Cancel = true;
                break;
            }
        }
示例#18
0
        private void Deserializer_LayoutSerializationCallback(object sender, LayoutSerializationCallbackEventArgs e)
        {
            switch (e.Model.ContentId)
            {
            case "home":
                break;

            case "author":
                AuthorPane = (LayoutAnchorable)e.Model;
                break;

            case "tag":
                TagPane = (LayoutAnchorable)e.Model;
                break;

            case "information":
                InformationPane = (LayoutAnchorable)e.Model;
                break;
            }
        }
示例#19
0
        void LayoutSerializationCallback(object sender, LayoutSerializationCallbackEventArgs e)
        {
            switch (e.Model)
            {
            case LayoutAnchorable la:
                switch (la.ContentId)
                {
                case AssemblyListPaneModel.PaneContentId:
                    e.Content = AssemblyListPaneModel.Instance;
                    break;

                case SearchPaneModel.PaneContentId:
                    e.Content = SearchPaneModel.Instance;
                    break;

                case AnalyzerPaneModel.PaneContentId:
                    e.Content = AnalyzerPaneModel.Instance;
                    break;

#if DEBUG
                case DebugStepsPaneModel.PaneContentId:
                    e.Content = DebugStepsPaneModel.Instance;
                    break;
#endif
                default:
                    e.Cancel = true;
                    break;
                }
                la.CanDockAsTabbedDocument = false;
                if (!e.Cancel)
                {
                    e.Cancel = ((ToolPaneModel)e.Content).IsVisible;
                    ((ToolPaneModel)e.Content).IsVisible = true;
                }
                break;

            default:
                e.Cancel = true;
                break;
            }
        }
示例#20
0
        private static void ReloadContentOnStartUp(LayoutSerializationCallbackEventArgs args)
        {
            string sId = args.Model.ContentId;

            // Empty Ids are invalid but possible if aaplication is closed with File>New without edits.
            if (string.IsNullOrWhiteSpace(sId) == true)
            {
                //args.Cancel = true;
                return;
            }

            //if (args.Model.ContentId == FileStatsViewModel.ToolContentId)
            //    args.Content = Workspace.This.FileStats;
            //else
            //{
            //    args.Content = AvalonDockLayoutViewModel.ReloadDocument(args.Model.ContentId);

            //    if (args.Content == null)
            //        args.Cancel = true;
            //}
        }
示例#21
0
        /// <summary>
        /// Convert a Avalondock ContentId into a viewmodel instance
        /// that represents a document or tool window. The re-load of
        /// this component is cancelled if the Id cannot be resolved.
        ///
        /// The result is (viewmodel Id or Cancel) is returned in <paramref name="args"/>.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void UpdateLayout(object sender, LayoutSerializationCallbackEventArgs args)
        {
            var resolver = DataContext as Interfaces.IViewModelResolver;

            if (resolver == null)
            {
                return;
            }

            // Get a matching viewmodel for that view via DataContext property of this view
            var contentViewModel = resolver
                                   .GetContentViewModelFromId(args.Model.ContentId);

            if (contentViewModel == null)
            {
                args.Cancel = true;
            }

            // found a match - return it
            args.Content = contentViewModel;
        }
示例#22
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;
            }
        }
示例#23
0
        internal void LayoutSerializationCallback(object sender, LayoutSerializationCallbackEventArgs e)
        {
            switch (e.Model)
            {
            case LayoutAnchorable la:
                switch (la.ContentId)
                {
                case AssemblyListPaneModel.PaneContentId:
                    e.Content = AssemblyListPaneModel.Instance;
                    break;

                case SearchPaneModel.PaneContentId:
                    e.Content = SearchPaneModel.Instance;
                    break;

                case AnalyzerPaneModel.PaneContentId:
                    e.Content = AnalyzerPaneModel.Instance;
                    break;

#if DEBUG
                case DebugStepsPaneModel.PaneContentId:
                    e.Content = DebugStepsPaneModel.Instance;
                    break;
#endif
                default:
                    e.Cancel = true;
                    break;
                }
                if (!e.Cancel)
                {
                    ToolPanes.Add((ToolPaneModel)e.Content);
                }
                break;

            default:
                e.Cancel = true;
                break;
            }
        }
示例#24
0
        /// <summary>
        /// Обработчик события загрузки
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void LayoutSerializationCallbackHandler(object sender, LayoutSerializationCallbackEventArgs e)
        {
            if (string.IsNullOrEmpty(e.Model.ContentId))
            {
                e.Cancel = true;
                return;
            }

            var panel = PanelManager.Instance.GetNamedPanel(e.Model.ContentId);

            if (panel == null)
            {
                panel = PanelManager.Instance.CreateNamedPanel(e.Model.ContentId, e.Model is LayoutAnchorable);
            }

            if (panel == null)
            {
                e.Cancel = true;
            }
            else
            {
                e.Content = panel;
            }
        }
示例#25
0
        private async void Serializer_LayoutSerializationCallback(object sender, LayoutSerializationCallbackEventArgs e)
        {
            switch (e.Model)
            {
            case LayoutAnchorable anchorable:
                switch (anchorable.ContentId)
                {
                case ToolExplorerViewModel.Identifier:
                    _workspace.Docking.ExplorerViewModel.IsVisible = anchorable.IsVisible;
                    e.Content = _workspace.Docking.ExplorerViewModel;
                    break;

                case ToolDetailViewModel.Identifier:
                    _workspace.Docking.DetailViewModel.IsVisible = anchorable.IsVisible;
                    e.Content = _workspace.Docking.DetailViewModel;
                    break;

                case ToolPreviewViewModel.Identifier:
                    _workspace.Docking.PreviewViewModel.IsVisible = anchorable.IsVisible;
                    e.Content = _workspace.Docking.PreviewViewModel;
                    break;
                }

                break;

            case LayoutDocument document:
            {
                var lister = KexContainer.Resolve <FileLister>();
                e.Content   = _workspace.Open(lister, document.IsLastFocusedDocument, document.IsSelected);
                lister.Path = document.ContentId;
                await lister.Refresh();

                break;
            }
            }
        }
 void LayoutSerializationCallback(object sender, LayoutSerializationCallbackEventArgs e)
 {
     // do not delete me
 }