コード例 #1
0
        public static void LoadLayout(DockingManager manager, ILayoutViewModelResolver layoutResolver)
        {
            var layoutSerializer      = new XmlLayoutSerializer(manager);
            HashSet <string> resolved = new HashSet <string>();

            layoutSerializer.LayoutSerializationCallback += (s, e) =>
            {
                if (e.Model?.ContentId != null && e.Model is LayoutAnchorable anchorable && !resolved.Contains(e.Model.ContentId))
                {
                    var tool = layoutResolver.ResolveViewModel(e.Model.ContentId);
                    resolved.Add(e.Model.ContentId);

                    if (tool != null)
                    {
                        e.Content       = tool;
                        tool.Visibility = anchorable.IsVisible ? Visibility.Visible : Visibility.Hidden;
                        return;
                    }
                }

                // Don't create any panels if something went wrong.
                e.Cancel = true;
            };

            if (File.Exists("dock.layout"))
            {
                layoutSerializer.Deserialize("dock.layout");
            }
            else
            {
                layoutResolver.LoadDefault();
            }
        }
コード例 #2
0
        public MainWindowWithDocking(IMainWindowHolder mainWindowHolder,
                                     IDocumentManager documentManager,
                                     ILayoutViewModelResolver layoutViewModelResolver,
                                     IFileSystem fileSystem)
        {
            this.fileSystem     = fileSystem;
            avaloniaDockAdapter = new AvaloniaDockAdapter(documentManager, layoutViewModelResolver);

            InitializeComponent();
            this.AttachDevTools();
            mainWindowHolder.Window = this;
            PersistentDockDataTemplate.DocumentManager = documentManager;
        }
コード例 #3
0
        public MainWindowWithDocking(IMainWindowHolder mainWindowHolder,
                                     IDocumentManager documentManager,
                                     ILayoutViewModelResolver layoutViewModelResolver,
                                     IFileSystem fileSystem)
        {
            this.fileSystem     = fileSystem;
            avaloniaDockAdapter = new AvaloniaDockAdapter(documentManager, layoutViewModelResolver);

            // we have to do it before InitializeComponent!
            var primaryScreen = Screens.Primary ?? Screens.All.FirstOrDefault();

            GlobalApplication.HighDpi = (primaryScreen?.PixelDensity ?? 1) > 1.5f;

            InitializeComponent();
            this.AttachDevTools();
            mainWindowHolder.Window = this;
            PersistentDockDataTemplate.DocumentManager = documentManager;
        }
コード例 #4
0
        public static void LoadLayout(DockingManager manager, ILayoutViewModelResolver layoutResolver, IFileSystem fileSystem)
        {
            var layoutSerializer      = new XmlLayoutSerializer(manager);
            HashSet <string> resolved = new HashSet <string>();

            layoutSerializer.LayoutSerializationCallback += (s, e) =>
            {
                if (e.Model?.ContentId != null && e.Model is LayoutAnchorable anchorable && !resolved.Contains(e.Model.ContentId))
                {
                    var tool = layoutResolver.ResolveViewModel(e.Model.ContentId);
                    resolved.Add(e.Model.ContentId);

                    if (tool != null)
                    {
                        e.Content       = tool;
                        tool.Visibility = anchorable.IsVisible;
                        return;
                    }
                }

                // Don't create any panels if something went wrong.
                e.Cancel = true;
            };

            if (fileSystem.Exists(DockSettingsFile))
            {
                try
                {
                    layoutSerializer.Deserialize(fileSystem.OpenRead(DockSettingsFile));
                }
                catch (System.Exception _)
                {
                    layoutResolver.LoadDefault();
                }
            }
            else
            {
                layoutResolver.LoadDefault();
            }
        }