Exemplo n.º 1
0
        public void LoadAvalonDockLayout(object o)
        {
            lock (lockObj) {
                if (!_dockloaded)
                {
                    _dockmanager = (Xceed.Wpf.AvalonDock.DockingManager)o;

                    var serializer = new Xceed.Wpf.AvalonDock.Layout.Serialization.XmlLayoutSerializer(_dockmanager);
                    serializer.LayoutSerializationCallback += (s, args) => {
                        args.Content = args.Content;
                    };

                    if (System.IO.File.Exists(Utility.AvalonDock.LayoutInitializer.LAYOUTFILEPATH))
                    {
                        try {
                            serializer.Deserialize(Utility.AvalonDock.LayoutInitializer.LAYOUTFILEPATH);
                            _dockloaded = true;
                        } catch (Exception ex) {
                            Logger.Error("Failed to load AvalonDock Layout. Loading default Layout!", ex);
                            using (var stream = new StringReader(Properties.Resources.avalondock)) {
                                serializer.Deserialize(stream);
                            }
                        }
                    }
                    else
                    {
                        LoadDefaultLayout(serializer);
                    }
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 ///		Inicializa los datos globales
 /// </summary>
 internal static void Initialize(MainWindow mainWindow, Xceed.Wpf.AvalonDock.DockingManager dockManager)
 {
     HostController = new HostPluginsController(ApplicationName,
                                                new Controllers.HostViewsController(ApplicationName, mainWindow),
                                                new Controllers.HostViewModelController(ApplicationName),
                                                mainWindow, dockManager);
 }
Exemplo n.º 3
0
        public void InitializeLayout(Xceed.Wpf.AvalonDock.DockingManager manager)
        {
            XmlLayoutSerializer serializer = new XmlLayoutSerializer(manager);

            serializer.LayoutSerializationCallback += LayoutSerializationCallback;
            try {
                sessionSettings.DockLayout.Deserialize(serializer);
            } finally {
                serializer.LayoutSerializationCallback -= LayoutSerializationCallback;
            }
        }
Exemplo n.º 4
0
 public MDIMainViewModel(Xceed.Wpf.AvalonDock.DockingManager dockManager) : base(false)
 {
     // Inicializa las propiedades
     DockingController = new AvalonLayout.LayoutDockingController(dockManager);
     DockingController.ActiveDocumentChanged += (sender, args) => ActiveDocument = args.ActiveDocument;
     // Inicializa los comandos
     ConfigurationCommand = new BaseCommand("Configuración", parameter => OpenWindowConfigurate());
     PathPluginsCommand   = new BaseCommand("Plugins", parameter => OpenWindowPathPlugins());
     SaveAllCommand       = new BaseCommand("SaveAll", parameter => ExecuteAction(nameof(SaveAllCommand), parameter),
                                            parameter => CanExecuteAction(nameof(SaveAllCommand), parameter));
     CloseAllWindowsCommand = new BaseCommand("CloseAll", parameter => ExecuteAction(nameof(CloseAllWindowsCommand), parameter),
                                              parameter => CanExecuteAction(nameof(CloseAllWindowsCommand), parameter));
     HelpIndexCommand = new BaseCommand("HelpIndex", parameter => ExecuteAction(nameof(HelpIndexCommand), parameter));
 }
Exemplo n.º 5
0
 public LayoutDockingController(Xceed.Wpf.AvalonDock.DockingManager dockManager)
 {
     DockManager = dockManager;
     DockManager.ActiveContentChanged += (sender, evntArgs) =>
     {
         if (DockManager.ActiveContent != null && DockManager.Layout != null && DockManager.Layout.ActiveContent != null)
         {
             ActiveDocument = GetPaneViewModel(DockManager.Layout.ActiveContent.ContentId);
         }
         else
         {
             ActiveDocument = null;
         }
     };
 }
Exemplo n.º 6
0
        private void OpenOrFocusPluginWindow(Type tp)
        {
            bool             pluginWindowIsInitialized = false;
            SinglePluginItem v = null;

            _retainedControls.TryGetValue(tp, out v);
            if (v != null)
            {
                var anchorableTest = v.UiObject as LayoutContent;
                // The plugin is already loaded in the memory. We need to figure out whether it is already loaded in the UI. There are a few things to check before it is certain that the plugin is still there
                // 1. From the Plugin itself whether it is Loaded and Visible
                var plgInW = anchorableTest.Content as Window;
                if (plgInW != null)
                {
                    if (plgInW.IsLoaded && plgInW.IsVisible)
                    {
                        return;  // It is already Loaded and Visible
                    }
                }

                var plgInUC = anchorableTest.Content as UserControl;
                if (plgInUC != null)
                {
                    if (plgInUC.IsLoaded && plgInUC.IsVisible)
                    {
                        return;  // It is already Loaded and Visible, or it is AutoHidden
                    }
                    if (anchorableTest.Parent is LayoutDocumentPane || anchorableTest.Parent is LayoutAnchorablePane)
                    {
                        // If it is docked under the LayoutDocumentPane or another LayoutAnchorablePane, it should be active there even though it might be Unloaded (e.g. when the Tab is not in focus)
                        return;
                    }

                    // Item might be not in focus as a tab item to any of the possible panel. Search whether it is there
                    if (plgInUC.Parent is Xceed.Wpf.AvalonDock.DockingManager)
                    {
                        Xceed.Wpf.AvalonDock.DockingManager dockMgr = plgInUC.Parent as Xceed.Wpf.AvalonDock.DockingManager;
                        if (dockMgr.Layout.Children.Count() > 0)
                        {
                            foreach (LayoutElement layoutElem in dockMgr.Layout.Children)
                            {
                                // Layout Panel may be recursive
                                if (layoutElem is LayoutPanel)
                                {
                                    if (LocateControlInLayoutPanel(layoutElem as LayoutPanel, plgInUC))
                                    {
                                        return;
                                    }
                                }

                                if (layoutElem is LayoutAnchorSide)
                                {
                                    foreach (LayoutAnchorGroup lyG in (layoutElem as LayoutAnchorSide).Children)
                                    {
                                        foreach (LayoutAnchorable lyGA in lyG.Children)
                                        {
                                            if (lyGA.Content == plgInUC)
                                            {
                                                return; // The item is already in a LayoutAnchorGroup, probably is AutoHidden
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                // If the status is not any of the above, show the plugin again
                ShowPluginWindow(v.PluginInterface, true);
            }
            else
            {
                IXbimXplorerPluginWindow instance;
                if (_retainedControls.ContainsKey(tp))
                {
                    instance = _retainedControls[tp].PluginInterface;
                }
                else
                {
                    try
                    {
                        instance = (IXbimXplorerPluginWindow)Activator.CreateInstance(tp);
                    }
                    catch (Exception ex)
                    {
                        var msg = $"Error creating instance of type '{tp}'";
                        Log.Error(msg, ex);
                        return;
                    }
                }
                var menuWindow = ShowPluginWindow(instance, true);
                if (menuWindow == null)
                {
                    return;
                }
                // if returned the window must be retained.
                var item = new SinglePluginItem()
                {
                    PluginInterface = instance,
                    UiObject        = menuWindow
                };
                if (!_retainedControls.ContainsKey(tp))
                {
                    _retainedControls.Add(tp, item);
                }
                if ((_retainedControls[tp].UiObject as LayoutAnchorable) != null)
                {
                    (_retainedControls[tp].UiObject as LayoutAnchorable).IsActive = true;
                }
                return;
            }
        }