Ejemplo n.º 1
0
            //---------------------------------------------------------------------------------------------------------
            /// <summary>
            /// Активация определённой вкладки
            /// </summary>
            /// <param name="layout">Вкладка</param>
            /// <param name="pane">Панель</param>
            /// <param name="pane_group">Группа панелей</param>
            /// <param name="layout_panel">Панель макета</param>
            //---------------------------------------------------------------------------------------------------------
            private void ActivePane(LayoutAnchorable layout, LayoutAnchorablePane pane, LayoutAnchorablePaneGroup pane_group,
                                    LayoutPanel layout_panel)
            {
                if (!layout.IsVisible)
                {
                    if (!pane.IsVisible)
                    {
                        if (!pane_group.IsVisible)
                        {
                            if (pane_group.Parent == null)
                            {
                                layout_panel.Children.Add(pane_group);
                            }
                        }

                        if (pane.Parent == null)
                        {
                            pane_group.Children.Add(pane);
                        }
                    }

                    if (layout.Parent == null)
                    {
                        pane.Children.Add(layout);
                    }
                    layout.IsVisible = true;
                }
            }
        private void ShowPluginWindow(xBimXplorerPluginWindow PluginWindow)
        {
            if (PluginWindow is UserControl)
            {
                // preparing user control
                UserControl uc = PluginWindow as UserControl;
                uc.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                uc.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
                //set data binding
                PluginWindow.BindUI(MainWindow);

                // add into UI
                if (PluginWindow.DefaultUIContainer == PluginWindowDefaultUIContainerEnum.LayoutDoc)
                {
                    // layout document mode
                    LayoutDocument ld = new LayoutDocument();
                    ld.Title   = PluginWindow.WindowTitle;
                    ld.Content = uc;
                    MainDocPane.Children.Add(ld);
                }
                else if (PluginWindow.DefaultUIContainer == PluginWindowDefaultUIContainerEnum.LayoutAnchorable)
                {
                    LayoutAnchorablePaneGroup pg  = GetRightPane();
                    LayoutAnchorablePane      lap = new LayoutAnchorablePane();
                    pg.Children.Add(lap);
                    LayoutAnchorable ld = new LayoutAnchorable();
                    ld.Title   = PluginWindow.WindowTitle;
                    ld.Content = uc;
                    lap.Children.Add(ld);
                }
            }
        }
Ejemplo n.º 3
0
        public Boolean BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
        {
            if (anchorableToShow.Content is ITool tool)
            {
                PaneLocation         preferredLocation = tool.PreferredLocation;
                String               paneName          = GetPaneName(preferredLocation);
                LayoutAnchorablePane toolsPane         = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name == paneName);
                if (toolsPane == null)
                {
                    switch (preferredLocation)
                    {
                    case PaneLocation.Left:
                        toolsPane = CreateAnchorablePane(layout, Orientation.Horizontal, paneName, InsertPosition.Start);
                        break;

                    case PaneLocation.Right:
                        toolsPane = CreateAnchorablePane(layout, Orientation.Horizontal, paneName, InsertPosition.End);
                        break;

                    case PaneLocation.Bottom:
                        toolsPane = CreateAnchorablePane(layout, Orientation.Vertical, paneName, InsertPosition.End);
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
                toolsPane.Children.Add(anchorableToShow);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 4
0
        protected override void UserInitialisation()
        {
            this.DesignLayoutAnchorable             = new LayoutAnchorable();
            this.DesignLayoutAnchorable.Title       = "Grid Properties";
            this.DesignLayoutAnchorable.CanClose    = false;
            this.DesignLayoutAnchorable.CanFloat    = false;
            this.DesignLayoutAnchorable.CanAutoHide = false;
            this.DesignLayoutAnchorable.CanHide     = false;

            this.FilterLayoutAnchorable             = new LayoutAnchorable();
            this.FilterLayoutAnchorable.Title       = "Filter";
            this.FilterLayoutAnchorable.CanClose    = false;
            this.FilterLayoutAnchorable.CanFloat    = false;
            this.FilterLayoutAnchorable.CanAutoHide = false;
            this.FilterLayoutAnchorable.CanHide     = false;

            if (ApplicationManager.Instance.User.IsAdmin())
            {
                this.AdministratorLayoutAnchorable             = new LayoutAnchorable();
                this.AdministratorLayoutAnchorable.Title       = "Administration";
                this.AdministratorLayoutAnchorable.CanAutoHide = false;
                this.AdministratorLayoutAnchorable.CanClose    = false;
                this.AdministratorLayoutAnchorable.CanFloat    = false;
                this.AdministratorLayoutAnchorable.CanHide     = false;
            }

            Pane = new LayoutAnchorablePane();
            Pane.Children.Add(DesignLayoutAnchorable);
            Pane.Children.Add(FilterLayoutAnchorable);
            if (AdministratorLayoutAnchorable != null)
            {
                Pane.Children.Add(AdministratorLayoutAnchorable);
            }
            this.Panes.Add(Pane);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Ensure that tool panes are initially docked to their default positions.
        /// </summary>
        /// <param name="layout">The root of the docking layout.</param>
        /// <param name="anchorableToShow">The anchorable to show.</param>
        /// <param name="destinationContainer">The destination container.</param>
        /// <returns></returns>
        public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
        {
            if (anchorableToShow.Content is IPadContent padContent)
            {
                if (destinationContainer?.FindParent <LayoutFloatingWindow>() != null)
                {
                    return(false); // we do not handle bringing pads in a floating layout
                }
                var defaultPosition = padContent.DefaultPosition;

                if (defaultPosition == DefaultPadPositions.Hidden)
                {
                    layout.Hidden.Add(anchorableToShow); // Pads hidden by default are added to the hidden collection
                    return(true);
                }

                // search for the appropriate LayoutAnchorablePane
                LayoutAnchorablePane destinationPane = null;

                AnchorSide?anchorSide = DefaultPadPosition_To_AnchorSide(defaultPosition);
                if (anchorSide.HasValue && (null != (destinationPane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(p => p.GetSide() == anchorSide.Value))))
                {
                    destinationPane.Children.Add(anchorableToShow);
                    return(true);
                }
            }

            return(false); // no special strategy here
        }
Ejemplo n.º 6
0
        private static LayoutAnchorablePane CreateAnchorablePane(LayoutRoot layout, Orientation orientation, string paneName, InsertPosition position)
        {
            var parent    = layout.Descendents().OfType <LayoutPanel>().FirstOrDefault(d => d.Orientation == orientation);
            var toolsPane = new LayoutAnchorablePane {
                Name = paneName
            };

            if (parent == null && layout.Root != null)
            {
                parent = layout.Root.RootPanel;
            }
            if (parent == null)
            {
                return(toolsPane);
            }
            if (position == InsertPosition.Start)
            {
                parent.InsertChildAt(0, toolsPane);
            }
            else
            {
                parent.Children.Add(toolsPane);
            }
            return(toolsPane);
        }
Ejemplo n.º 7
0
        public void AfterInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableShown)
        {
            // If this is the first anchorable added to this pane, then use the preferred size.
            if (anchorableShown.Content is IToolWindow)
            {
                IToolWindow tool = anchorableShown.Content as IToolWindow;
                if (anchorableShown.Parent is LayoutAnchorablePane)
                {
                    LayoutAnchorablePane anchorablePane = anchorableShown.Parent as LayoutAnchorablePane;

                    if (anchorablePane.ChildrenCount == 1)
                    {
                        switch (tool.PreferredLocation)
                        {
                        case PaneLocation.Left:
                        case PaneLocation.Right:
                            anchorablePane.DockWidth = new GridLength(tool.PreferredWidth, GridUnitType.Pixel);
                            break;

                        case PaneLocation.Bottom:
                            anchorablePane.DockHeight = new GridLength(tool.PreferredHeight, GridUnitType.Pixel);
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
0
        private void OnLayoutUpdated(object sender, EventArgs e)
        {
            LayoutAnchorablePane actualWidth = this._model;

            ((ILayoutPositionableElementWithActualSize)actualWidth).ActualWidth  = base.ActualWidth;
            ((ILayoutPositionableElementWithActualSize)actualWidth).ActualHeight = base.ActualHeight;
        }
Ejemplo n.º 9
0
        public void AddExteralControl(IBaseView view)
        {
            if ((view.ViewPos == ViewLocation.Center) || (view.ViewPos == ViewLocation.Bottom))
            {
                LayoutDocumentPane docPane = GetControlObject <LayoutDocumentPane>(Enum.GetName(typeof(ViewLocation), view.ViewPos));
                if (docPane == null)
                {
                    docPane = Center;
                }

                LayoutDocument LayoutDoc = new LayoutDocument();
                LayoutDoc.ContentId = view.ViewID;
                LayoutDoc.Title     = view.ViewName;
                LayoutDoc.CanClose  = true;
                LayoutDoc.Closed   += LayoutDoc_Closed;
                LayoutDoc.Content   = view as UserControl;
                docPane.Children.Add(LayoutDoc);
            }
            else
            {
                LayoutAnchorablePane docPane = GetControlObject <LayoutAnchorablePane>(Enum.GetName(typeof(ViewLocation), view.ViewPos));

                LayoutAnchorable LayoutDoc = new LayoutAnchorable();
                LayoutDoc.ContentId = view.ViewID;
                LayoutDoc.Title     = view.ViewName;
                LayoutDoc.CanClose  = true;
                LayoutDoc.Closed   += LayoutDoc_Closed;
                LayoutDoc.Content   = view as UserControl;
                docPane.Children.Add(LayoutDoc);
            }
        }
Ejemplo n.º 10
0
        public bool BeforeInsertAnchorable(LayoutRoot layout,
                                           LayoutAnchorable anchorableToShow,
                                           ILayoutContainer destinationContainer)
        {
            // AD wants to add the anchorable into destinationContainer
            // just for test provide a new anchorablepane
            // if the pane is floating let the manager go ahead
            LayoutAnchorablePane destPane = destinationContainer as LayoutAnchorablePane;

            if (destinationContainer != null &&
                destinationContainer.FindParent <LayoutFloatingWindow>() != null)
            {
                return(false);
            }

            var toolsPane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "ToolsPane");

            if (toolsPane != null)
            {
                // do not allow this as Tabbed Document
                anchorableToShow.CanDockAsTabbedDocument = false;
                toolsPane.Children.Add(anchorableToShow);
                return(true);
            }

            return(false);
        }
        private static LayoutAnchorablePane CreateAnchorablePane(LayoutRoot layout, Orientation orientation,
            string paneName, InsertPosition position)
        {
            var layoutPanels = layout.Descendents().OfType<LayoutPanel>().ToArray();
            var parent = layoutPanels.FirstOrDefault(d => d != null && d.Orientation == orientation);
            if (parent == null)
            {
                parent = layoutPanels.FirstOrDefault();
                position = InsertPosition.Start;
            }
            var toolsPane = new LayoutAnchorablePane { Name = paneName };
            if (parent != null)
            {
                if (position == InsertPosition.Start)
                    parent.InsertChildAt(0, toolsPane);
                else
                    parent.Children.Add(toolsPane);
            }
            else
            {
                var layoutAnchorableFloatingWindow = new LayoutAnchorableFloatingWindow();
                toolsPane.Parent = layoutAnchorableFloatingWindow;

            }
            return toolsPane;
        }
        private void SetPropertyWindowVisibility(bool isVisible,
                                                 LayoutAnchorable window, LayoutAnchorablePane container)
        {
            if (isVisible && window.Parent == null)
            {
                if (propertyWindowGroup.Parent == null)
                {
                    windowPanel.Children.Insert(0, propertyWindowGroup);
                }

                if (window == taskPanel)
                {
                    propertyWindowGroup.Children.Insert(0, container);
                }
                else
                {
                    propertyWindowGroup.Children.Add(container);
                }
                container.Children.Add(window);
                window.Show();
            }
            else if (!isVisible && window.Parent != null)
            {
                window.Close();
            }
        }
Ejemplo n.º 13
0
        internal IEnumerable <ILayoutPanelElement> GetInitializedViews()
        {
            IEnumerable <string> enabledWidgets = GetEnabledWidgets();

            foreach (ExportedType export in ExportedTypeLibrary.GetExports(typeof(IUIWidget)).Where(j => enabledWidgets.Contains(j.Attribute.Alias)))
            {
                IUIWidget widget = export.CreateInstance <IUIWidget>();

                string widgetName = widget.GetType().Name;
                Logger.Instance.LogFormat(LogType.Trace, this, Properties.Resources.BeginInitialization, widgetName);

                try
                {
                    if (!widget.Initialize())
                    {
                        Logger.Instance.LogFormat(LogType.Warning, this, Properties.Resources.InitializationFailure, widgetName);
                        continue;
                    }

                    LayoutAnchorablePane pane = CreatePaneFromWidget(widget);
                    _panelElements.Add(pane);

                    Widgets.Add(widget);

                    Logger.Instance.LogFormat(LogType.Trace, this, Properties.Resources.InitializationSuccess, widgetName);
                }
                catch (Exception ex)
                {
                    Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.InitializationError, widgetName);
                    Logger.Instance.LogException(this, ex);
                }
            }

            return(_panelElements);
        }
        /// <summary>
        /// 添加一个可移动窗口
        /// </summary>
        /// <param name="pane"></param>
        /// <param name="title"></param>
        internal LayoutAnchorable AddLayoutAnchorable(LayoutAnchorablePane pane, string title)
        {
            LayoutAnchorable anchorable = new LayoutAnchorable();

            anchorable.Title = title;
            pane.Children.Add(anchorable);
            return(anchorable);
        }
        /// <summary>
        /// 获取一个布局可抛锚窗格
        /// </summary>
        /// <param name="Title">标题</param>
        /// <param name="FatherLayout">父布局</param>
        /// <returns></returns>
        internal LayoutAnchorable AddLayoutAnchorablePane(LayoutAnchorablePaneGroup FatherLayout, string title)
        {
            LayoutAnchorablePane pane       = new LayoutAnchorablePane();
            LayoutAnchorable     anchorable = new LayoutAnchorable();

            anchorable.Title = title;
            pane.Children.Add(anchorable);
            FatherLayout.Children.Add(pane);
            return(anchorable);
        }
Ejemplo n.º 16
0
        public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
        {
            //AD wants to add the anchorable into destinationContainer
            //just for test provide a new anchorablepane
            //if the pane is floating let the manager go ahead



            LayoutAnchorablePane destPane = destinationContainer as LayoutAnchorablePane;

            if (destinationContainer != null &&
                destinationContainer.FindParent <LayoutFloatingWindow>() != null)
            {
                return(false);
            }

            //var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "ToolsPane");

            Type toolType = anchorableToShow.Content.GetType();

            var docData = _dockViewmodel.Data.DocumentTypeData.FirstOrDefault(a => a.DocType == _dockViewmodel.Data.ActiveDocument.GetType());

            var pos = docData.DicToolDockPosition[toolType];

            LayoutAnchorSide side = GetAnchorSide(pos, layout);


            if (side.Children.Count == 0)
            {
                var group = new LayoutAnchorGroup();



                group.Children.Add(anchorableToShow);


                side.Children.Add(group);
                SetToolPaneProperties(anchorableToShow);

                return(true);
            }
            else
            {
                side.Children[0].Children.Add(anchorableToShow);

                SetToolPaneProperties(anchorableToShow);
                return(true);
            }



            return(false);

            //return true;
        }
Ejemplo n.º 17
0
        public void ProcessDefinition()
        {
            LayoutAnchorablePane container = GetDefaultLayoutContainer();

            foreach (var viewModel in ViewModelSelection.SelectedObject)
            {
                CreateAndAddDynamicPanel(viewModel);
            }

            EventAggregator.Subscribe(Definition.GetSelectionBindingType(), OnSelectionBindingChanged, ThreadOption.UIThread, true);
        }
        public LayoutAnchorablePaneControl(LayoutAnchorablePane model)
        {
            if (model == null)
                throw new ArgumentNullException("model");

            _model = model;

            SetBinding(ItemsSourceProperty, new Binding("Model.Children") { Source = this });
            SetBinding(FlowDirectionProperty, new Binding("Model.Root.Manager.FlowDirection") { Source = this });

            this.LayoutUpdated += new EventHandler(OnLayoutUpdated);
        }
Ejemplo n.º 19
0
 protected override void UserInitialisation()
 {
     this.UserLayoutAnchorable             = new LayoutAnchorable();
     this.UserLayoutAnchorable.Title       = "Properties";
     this.UserLayoutAnchorable.CanClose    = false;
     this.UserLayoutAnchorable.CanFloat    = false;
     this.UserLayoutAnchorable.CanAutoHide = false;
     this.UserLayoutAnchorable.CanHide     = false;
     Pane = new LayoutAnchorablePane();
     Pane.Children.Add(UserLayoutAnchorable);
     this.Panes.Add(Pane);
 }
        private LayoutAnchorablePane GetRightPane()
        {
            if (_rightPane != null)
            {
                return(_rightPane);
            }
            var rigthPanel = GetRightPaneGroup();

            _rightPane = new LayoutAnchorablePane();
            rigthPanel.Children.Add(_rightPane);
            return(_rightPane);
        }
Ejemplo n.º 21
0
        public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
        {
            var tool = anchorableToShow.Content as ITool;

            if (tool != null)
            {
                var    preferredLocation = tool.PreferredLocation;
                string paneName          = GetPaneName(preferredLocation);
                var    toolsPane         = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name == paneName);
                if (toolsPane == null)
                {
                    switch (preferredLocation)
                    {
                    case PaneLocation.Left:
                    {
                        var parent = layout.Descendents().OfType <LayoutPanel>().First(d => d.Orientation == Orientation.Horizontal);
                        toolsPane = new LayoutAnchorablePane {
                            DockWidth = new GridLength(tool.PreferredWidth, GridUnitType.Pixel), Name = paneName
                        };
                        parent.InsertChildAt(0, toolsPane);
                    }
                    break;

                    case PaneLocation.Right:
                    {
                        var parent = layout.Descendents().OfType <LayoutPanel>().First(d => d.Orientation == Orientation.Horizontal);
                        toolsPane = new LayoutAnchorablePane {
                            DockWidth = new GridLength(tool.PreferredWidth, GridUnitType.Pixel), Name = paneName
                        };
                        parent.Children.Add(toolsPane);
                    }
                    break;

                    case PaneLocation.Bottom:
                    {
                        var parent = layout.Descendents().OfType <LayoutPanel>().First(d => d.Orientation == Orientation.Vertical);
                        toolsPane = new LayoutAnchorablePane {
                            DockHeight = new GridLength(tool.PreferredHeight, GridUnitType.Pixel), Name = paneName
                        };
                        parent.Children.Add(toolsPane);
                    }
                    break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
                toolsPane.Children.Add(anchorableToShow);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 22
0
        //http://avalondock.codeplex.com/wikipage?title=AvalonDock%202.0%20Getting%20Start%20Guide&referringTitle=Documentation
		public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
		{
            if (anchorableToShow.Content is ITool)
            {
                var preferredLocation = ((ITool) anchorableToShow.Content).PreferredLocation;
                string paneName = GetPaneName(preferredLocation);
                var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == paneName);
                if (toolsPane == null)
                {
                    switch (preferredLocation)
                    {
                        case PaneLocation.Left:
                        {
                            //TODO: this should use two steps: first, try to add to existing "LayoutAnchorablePane" if not create layoutAnchorGroup like below
                            var layoutAnchorSide = layout.Descendents().OfType<LayoutAnchorSide>().First(side => side.Side == AnchorSide.Left);
                            var layoutAnchorGroup = new LayoutAnchorGroup();
                            layoutAnchorGroup.InsertChildAt(0, anchorableToShow);
                            layoutAnchorSide.InsertChildAt(0, layoutAnchorGroup);
                            anchorableToShow.AutoHideWidth = 200;

                            //var parent = layout.Descendents().OfType<LayoutPanel>().First(d => d.Orientation == Orientation.Horizontal);
                            //toolsPane = new LayoutAnchorablePane { DockWidth = new GridLength(200, GridUnitType.Pixel) };
                        }
                            break;
                        case PaneLocation.Right:
                        {
                            var parent = layout.Descendents().OfType<LayoutPanel>().First(d => d.Orientation == Orientation.Horizontal);
                            toolsPane = new LayoutAnchorablePane { DockWidth = new GridLength(200, GridUnitType.Pixel) };
                            parent.Children.Add(toolsPane);
                        }
                            break;
                        case PaneLocation.Bottom:
                        {
                            var ds = layout.Descendents().ToList();
                            var items = layout.Descendents().OfType<LayoutPanel>().ToList();
                            var items2 = layout.Descendents().OfType<LayoutAnchorGroup>().ToList();
                            //var parent = items2.First();
                            var parent = layout.Descendents().OfType<LayoutPanel>().First(d => d.Orientation == Orientation.Vertical);
                            toolsPane = new LayoutAnchorablePane { DockHeight = new GridLength(300, GridUnitType.Pixel) };
                            parent.Children.Add(toolsPane);
                        }
                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }
                }
                if(toolsPane != null)
                    toolsPane.Children.Add(anchorableToShow);
                return true;
            }

			return false;
		}
        private void SetDockWidthForPane(LayoutAnchorablePane propertiesPane, DockingSettings dockingSettings)
        {
            Argument.IsNotNull(() => propertiesPane);
            Argument.IsNotNull(() => dockingSettings);

            var paneGroup = propertiesPane.Parent as LayoutAnchorablePaneGroup;

            if (paneGroup != null && paneGroup.DockWidth.Value < dockingSettings.Width)
            {
                paneGroup.DockWidth = new GridLength(dockingSettings.Width);
            }
        }
Ejemplo n.º 24
0
        public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
        {
            if (anchorableToShow.Content is TerminalViewModel)
            {
                var panel_horizontal      = layout.Children.OfType <LayoutPanel>().FirstOrDefault();
                var panel_vertical        = panel_horizontal.Children.OfType <LayoutPanel>().FirstOrDefault();
                var anchorable_pane_group = panel_vertical.Children.OfType <LayoutAnchorablePaneGroup>().FirstOrDefault();

                if (anchorable_pane_group == null)
                {
                    anchorable_pane_group = new LayoutAnchorablePaneGroup();
                    panel_vertical.Children.Add(anchorable_pane_group);
                }

                var anchorable_pane = anchorable_pane_group.Children.OfType <LayoutAnchorablePane>().FirstOrDefault();

                if (anchorable_pane == null)
                {
                    anchorable_pane = new LayoutAnchorablePane();
                    anchorable_pane_group.Children.Add(anchorable_pane);
                }

                anchorable_pane.Children.Add(anchorableToShow);

                return(true);
            }
            else if (anchorableToShow.Content is SpiffsViewModel)
            {
                var panel_horizontal      = layout.Children.OfType <LayoutPanel>().FirstOrDefault();
                var anchorable_pane_group = panel_horizontal.Children.OfType <LayoutAnchorablePaneGroup>().FirstOrDefault();

                if (anchorable_pane_group == null)
                {
                    anchorable_pane_group = new LayoutAnchorablePaneGroup();
                    panel_horizontal.Children.Insert(0, anchorable_pane_group);
                }

                var anchorable_pane = anchorable_pane_group.Children.OfType <LayoutAnchorablePane>().FirstOrDefault();

                if (anchorable_pane == null)
                {
                    anchorable_pane = new LayoutAnchorablePane();
                    anchorable_pane_group.Children.Add(anchorable_pane);
                }

                anchorable_pane.Children.Add(anchorableToShow);

                return(true);
            }

            return(false);
        }
Ejemplo n.º 25
0
    public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
    {
        // AD wants to add the anchorable into destinationContainer
        // just for test provide a new anchorablepane
        // if the pane is floating let the manager go ahead
        LayoutAnchorablePane destPane = destinationContainer as LayoutAnchorablePane;

        if (destinationContainer != null &&
            destinationContainer.FindParent <LayoutFloatingWindow>() != null)
        {
            return(false);
        }

        var projectPane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "ProjectPane");

        if (projectPane != null && anchorableToShow.Content is ProjectTreeViewModel)
        {
            projectPane.Children.Add(anchorableToShow);
            return(true);
        }
        else if (anchorableToShow.Content is ProjectTreeViewModel)
        {
            var pane = new LayoutAnchorablePane(anchorableToShow)
            {
                DockWidth = new System.Windows.GridLength(300)
            };

            layout.RootPanel.Children.Insert(0, pane);
            return(true);
        }

        var pixelPane = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(x => x.Name == "PixelPane");

        if (pixelPane != null && anchorableToShow.Content is ArrangerEditorViewModel)
        {
            pixelPane.Children.Add(anchorableToShow);
            return(true);
        }
        else if (anchorableToShow.Content is ArrangerEditorViewModel)
        {
            var pane = new LayoutAnchorablePane(anchorableToShow)
            {
                DockWidth = new System.Windows.GridLength(400)
            };

            layout.RootPanel.Children.Add(pane);
            return(true);
        }

        return(false);
    }
Ejemplo n.º 26
0
        /// <summary>
        /// 将信息窗口添加到信息面板
        /// </summary>
        /// <param name="infoControl">信息窗口控件</param>
        public void AddToInfoPanel(UserControl infoControl, string title, bool canClose, bool canHide, bool canFloat, bool isUnique)
        {
            if (RightDockPanel != null && RightDockPanel is LayoutAnchorablePane)
            {
                LayoutAnchorablePane anchorPane = (LayoutAnchorablePane)RightDockPanel;

                LayoutAnchorable anchor = null;
                try
                {
                    anchor = FindUserControl(infoControl.Tag.ToString());
                }
                catch (Exception)
                {
                    anchor = null;
                }

                /*
                 * if (anchor != null && !anchor.IsActive)
                 * {
                 *  m_anchors.Remove(anchor);
                 *  anchor.Close();
                 *  anchor = null;
                 * }
                 */
                if (anchor == null)
                {
                    anchor                  = new LayoutAnchorable();
                    anchor.Title            = title;
                    anchor.CanClose         = canClose;
                    anchor.CanHide          = canHide;
                    anchor.CanFloat         = canFloat;
                    anchor.CanAutoHide      = true;
                    anchor.Content          = infoControl;
                    anchor.AutoHideWidth    = 280;
                    anchor.AutoHideMinWidth = 280;

                    (RightDockPanel as LayoutAnchorablePane).Children.Add(anchor);

                    m_anchors.Add(anchor);
                }
                else
                {
                    if (anchor.IsAutoHidden)
                    {
                        anchor.ToggleAutoHide();
                    }

                    anchor.Show();
                }
            }
        }
Ejemplo n.º 27
0
        public MainWindow()
        {
            main = this;
            InitializeComponent();
            //

            OpenOutputWindow();
            var g = new LayoutAnchorablePane();

            g.Children.Add(new LayoutAnchorable {
                Title = "资源"
            });
            //BottomGroup.Children.Add();
        }
Ejemplo n.º 28
0
        public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow,
                                           ILayoutContainer destinationContainer)
        {
            if (anchorableToShow?.Content is ITool tool)
            {
                var pane = layout.Descendents().OfType <LayoutAnchorablePane>()
                           .FirstOrDefault(p => p.Name == $"{tool.InitialPosition}Pane");

                if (pane == null)
                {
                    Orientation orientation = Orientation.Horizontal;
                    if (tool.InitialPosition == ToolPosition.Top || tool.InitialPosition == ToolPosition.Bottom)
                    {
                        orientation = Orientation.Vertical;
                    }

                    LayoutPanel parent = layout.Descendents().OfType <LayoutPanel>()
                                         .First(p => p.Orientation == orientation);

                    pane = new LayoutAnchorablePane()
                    {
                        Name = $"{tool.InitialPosition}Pane"
                    };

                    if (tool.InitialPosition == ToolPosition.Left || tool.InitialPosition == ToolPosition.Top)
                    {
                        parent.InsertChildAt(0, pane);
                    }
                    else
                    {
                        parent.Children.Add(pane);
                    }
                }

                pane.Children.Add(anchorableToShow);

                if (pane.DockMinWidth < tool.MinWidth)
                {
                    pane.DockMinWidth = tool.MinWidth;
                }
                if (pane.DockMinHeight < tool.MinHeight)
                {
                    pane.DockMinHeight = tool.MinHeight;
                }

                return(true);
            }

            return(false);
        }
Ejemplo n.º 29
0
        public void AttachDockingManager(DockingManager dockingManager)
        {
            DockingManager = dockingManager;

            var layoutRoot = new LayoutRoot();

            DockingManager.Layout = layoutRoot;

            DocumentPane = layoutRoot.RootPanel.Children[0] as LayoutDocumentPane;

            ToolsPane = new LayoutAnchorablePane();
            layoutRoot.RootPanel.Children.Insert(0, ToolsPane);
            ToolsPane.DockWidth = new GridLength(ToolPaneWidth.GetValueOrDefault(410));
        }
Ejemplo n.º 30
0
        private static LayoutAnchorablePane CreatePaneFromWidget(IUIWidget widget)
        {
            LayoutAnchorable anchorable = new LayoutAnchorable();

            anchorable.Content   = widget.UIElement;
            anchorable.ContentId = widget.ContentGuid;
            anchorable.Title     = widget.Title;
            anchorable.CanClose  = false;
            anchorable.CanHide   = false;

            LayoutAnchorablePane pane = new LayoutAnchorablePane(anchorable);

            return(pane);
        }
Ejemplo n.º 31
0
 protected override void OnMouseLeave(MouseEventArgs e)
 {
     base.OnMouseLeave(e);
     if (this._isMouseDown && e.LeftButton == MouseButtonState.Pressed)
     {
         LayoutAnchorablePaneControl layoutAnchorablePaneControl = this.FindVisualAncestor <LayoutAnchorablePaneControl>();
         if (layoutAnchorablePaneControl != null)
         {
             LayoutAnchorablePane model = layoutAnchorablePaneControl.Model as LayoutAnchorablePane;
             model.Root.Manager.StartDraggingFloatingWindowForPane(model);
         }
     }
     this._isMouseDown = false;
 }
Ejemplo n.º 32
0
        public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
        {
            if (anchorableToShow.Content is ITool)
            {
                var preferredLocation = ((ITool)anchorableToShow.Content).PreferredLocation;
                string paneName = GetPaneName(preferredLocation);
                var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == paneName);
                if (toolsPane == null)
                {
                    switch (preferredLocation)
                    {
                        case Dock.Left:
                            {
                                var parent = layout.Descendents().OfType<LayoutPanel>().First(d => d.Orientation == Orientation.Horizontal);
                                toolsPane = new LayoutAnchorablePane { DockWidth = new GridLength(200, GridUnitType.Pixel) };
                                parent.InsertChildAt(0, toolsPane);
                            }
                            break;
                        case Dock.Right:
                            {
                                var parent = layout.Descendents().OfType<LayoutPanel>().First(d => d.Orientation == Orientation.Horizontal);
                                toolsPane = new LayoutAnchorablePane { DockWidth = new GridLength(200, GridUnitType.Pixel) };
                                parent.Children.Add(toolsPane);
                            }
                            break;
                        case Dock.Bottom:
                            {
                                var parent = layout.Descendents().OfType<LayoutPanel>().First(d => d.Orientation == Orientation.Vertical);
                                toolsPane = new LayoutAnchorablePane { DockHeight = new GridLength(200, GridUnitType.Pixel) };
                                parent.Children.Add(toolsPane);
                            }
                            break;
                        case Dock.Top:
                            {
                                var parent = layout.Descendents().OfType<LayoutPanel>().First(d => d.Orientation == Orientation.Vertical);
                                toolsPane = new LayoutAnchorablePane { DockHeight = new GridLength(200, GridUnitType.Pixel) };
                                parent.InsertChildAt(0, toolsPane);
                            }
                            break;
                        default:
                            throw new ArgumentOutOfRangeException();
                    }
                }
                toolsPane.Children.Add(anchorableToShow);
                return true;
            }

            return false;
        }
Ejemplo n.º 33
0
 /// <summary>
 /// 获取一个布局可抛锚窗格
 /// </summary>
 /// <param name="Title">标题</param>
 /// <param name="FatherLayout">父布局</param>
 /// <returns></returns>
 public void AddLayoutAnchorablePane(LayoutAnchorablePaneGroup FatherLayout, string Title = "属性")
 {
     try
     {
         LayoutAnchorablePane pane       = new LayoutAnchorablePane();
         LayoutAnchorable     anchorable = new LayoutAnchorable();
         anchorable.Title = Title;
         pane.Children.Add(anchorable);
         FatherLayout.Children.Add(pane);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "[MainWindow][miAnchorVerticalPane_Click_1]");
     }
 }
Ejemplo n.º 34
0
        public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
        {
            //AD wants to add the anchorable into destinationContainer
            //just for test provide a new anchorablepane
            //if the pane is floating let the manager go ahead
            LayoutAnchorablePane destPane = destinationContainer as LayoutAnchorablePane;

            if (destinationContainer != null &&
                destinationContainer.FindParent <LayoutFloatingWindow>() != null)
            {
                return(false);
            }

            return(false);
        }
Ejemplo n.º 35
0
        private void AddAreaPlaceholder(string key,
                                        LayoutAnchorablePane thePlaceHolder)
        {
            if ( m_DisplayMap == null )
            {
                throw new NullReferenceException("display map not initialized yet");
            }

            if ( m_DisplayMap.Keys.Contains(key) )
            {
                throw new Exception("area placeholder already exists in dictionary");
            }

            m_DisplayMap.Add(key,
                             thePlaceHolder);
        }
Ejemplo n.º 36
0
        internal List<ILayoutPanelElement> InitializeViews()
        {
            ReadOnlyCollection<string> enabledWidgets = new ReadOnlyCollection<string>(SettingsManager.Instance.GetSetting("CustomOperationViewer", "WidgetConfiguration").GetValue<ExportConfiguration>().GetEnabledExports());
            foreach (ExportedType export in ExportedTypeLibrary.GetExports(typeof(IUIWidget)).Where(j => enabledWidgets.Contains(j.Attribute.Alias)))
            {
                var iuiWidget = export.CreateInstance<IUIWidget>();

                string jobName = iuiWidget.GetType().Name;
                Logger.Instance.LogFormat(LogType.Info, this, "Initializing ViewPlugin type '{0}'...", jobName);

                try
                {
                    if (!iuiWidget.Initialize())
                    {
                        Logger.Instance.LogFormat(LogType.Warning, this, "ViewPlugin type '{0}' initialization failed. The ViewPlugin will not be executed.", jobName);
                        continue;
                    }
                    var pane =
                        new LayoutAnchorablePane(new LayoutAnchorable
                                                     {
                                                         Content = iuiWidget.UIElement,
                                                         ContentId = iuiWidget.ContentGuid,
                                                         Title = iuiWidget.Title,
                                                         CanClose = false,
                                                         CanHide = false
                                                     });

                    _PanelElements.Add(pane);
                    _Widgets.Add(iuiWidget);
                    Logger.Instance.LogFormat(LogType.Info, this, "ViewPlugin type '{0}' initialization successful.", jobName);
                }
                catch (Exception ex)
                {
                    Logger.Instance.LogFormat(LogType.Error, this, "An error occurred while initializing ViewPlugin type '{0}'. The error message was: {1}", jobName, ex.Message);
                }
            }
            return _PanelElements;
        }
Ejemplo n.º 37
0
        private static LayoutAnchorablePane CreatePaneFromWidget(IUIWidget widget)
        {
            LayoutAnchorable anchorable = new LayoutAnchorable();
            anchorable.Content = widget.UIElement;
            anchorable.ContentId = widget.ContentGuid;
            anchorable.Title = widget.Title;
            anchorable.CanClose = false;
            anchorable.CanHide = false;

            LayoutAnchorablePane pane = new LayoutAnchorablePane(anchorable);
            return pane;
        }
 private void ShowPropertyGrid_OnClick(object sender, RoutedEventArgs e)
 {
     if (anchorablePane == null)
     {
         anchorablePane = new LayoutAnchorablePane();
         if (layoutAnchorable == null)
         {
             layoutAnchorable = new LayoutAnchorable
             {
                 Title = "PropertyGrid",
                 Content = propertyGrid
             };
             anchorablePane.Children.Add(layoutAnchorable);
         }
     }
     layoutAnchorable.AddToLayout(myDockingManager, AnchorableShowStrategy.Left);
 }
		public void AddControl(string controlName)
		{
			Type controlType = null;

			if (!_controls.TryGetValue(controlName, out controlType))
				return;

			var control = Activator.CreateInstance(controlType);
			var anchor = new LayoutAnchorable()
			{
				Title = controlName,
				CanClose = false
			};
			var pane = new LayoutAnchorablePane();

			anchor.Content = control;
			pane.Children.Add(anchor);

			DockingManagerGroup.Children.Add(pane);
		}
Ejemplo n.º 40
0
        void AttachAnchorablesSource(LayoutRoot layout, IEnumerable anchorablesSource)
        {
            if (anchorablesSource == null)
                return;

            if (layout == null)
                return;

            //if (layout.Descendents().OfType<LayoutAnchorable>().Any())
            //    throw new InvalidOperationException("Unable to set the AnchorablesSource property if LayoutAnchorable objects are already present in the model");
            var anchorablesImported = layout.Descendents().OfType<LayoutAnchorable>().Select(d => d.Content).ToArray();
            var anchorables = anchorablesSource as IEnumerable;
            var listOfAnchorablesToImport = new List<object>(anchorables.OfType<object>());

            foreach (var document in listOfAnchorablesToImport.ToArray())
            {
                if (anchorablesImported.Contains(document))
                    listOfAnchorablesToImport.Remove(document);
            }

            LayoutAnchorablePane anchorablePane = null;
            if (layout.ActiveContent != null)
            {
                //look for active content parent pane
                anchorablePane = layout.ActiveContent.Parent as LayoutAnchorablePane;
            }

            if (anchorablePane == null)
            {
                //look for a pane on the right side
                anchorablePane = layout.Descendents().OfType<LayoutAnchorablePane>().Where(pane => !pane.IsHostedInFloatingWindow && pane.GetSide() == AnchorSide.Right).FirstOrDefault();
            }

            if (anchorablePane == null)
            {
                //look for an available pane
                anchorablePane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault();
            }

            _suspendLayoutItemCreation = true;
            foreach (var anchorableContentToImport in listOfAnchorablesToImport)
            {
                var anchorableToImport = new LayoutAnchorable()
                {
                    Content = anchorableContentToImport
                };

                bool added = false;
                if (LayoutUpdateStrategy != null)
                {
                    added = LayoutUpdateStrategy.BeforeInsertAnchorable(layout, anchorableToImport, anchorablePane);
                }

                if (!added)
                {
                    if (anchorablePane == null)
                    {
                        var mainLayoutPanel = new LayoutPanel() { Orientation = Orientation.Horizontal };
                        if (layout.RootPanel != null)
                        {
                            mainLayoutPanel.Children.Add(layout.RootPanel);
                        }

                        layout.RootPanel = mainLayoutPanel;
                        anchorablePane = new LayoutAnchorablePane() { DockWidth = new GridLength(200.0, GridUnitType.Pixel) };
                        mainLayoutPanel.Children.Add(anchorablePane);
                    }

                    anchorablePane.Children.Add(anchorableToImport);
                    added = true;
                }

                if (LayoutUpdateStrategy != null)
                    LayoutUpdateStrategy.AfterInsertAnchorable(layout, anchorableToImport);

                CreateAnchorableLayoutItem(anchorableToImport);

            }

            _suspendLayoutItemCreation = false;

            var anchorablesSourceAsNotifier = anchorablesSource as INotifyCollectionChanged;
            if (anchorablesSourceAsNotifier != null)
                anchorablesSourceAsNotifier.CollectionChanged += new NotifyCollectionChangedEventHandler(anchorablesSourceElementsChanged);
        }
Ejemplo n.º 41
0
        void anchorablesSourceElementsChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (Layout == null)
                return;

            //When deserializing documents are created automatically by the deserializer
            if (SuspendAnchorablesSourceBinding)
                return;

            //handle remove
            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove ||
                e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace)
            {
                if (e.OldItems != null)
                {
                    var anchorablesToRemove = Layout.Descendents().OfType<LayoutAnchorable>().Where(d => e.OldItems.Contains(d.Content)).ToArray();
                    foreach (var anchorableToRemove in anchorablesToRemove)
                    {
                        (anchorableToRemove.Parent as ILayoutContainer).RemoveChild(
                            anchorableToRemove);
                    }
                }
            }

            //handle add
            if (e.NewItems != null &&
                (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add ||
                e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Replace))
            {
                if (e.NewItems != null)
                {
                    LayoutAnchorablePane anchorablePane = null;

                    if (Layout.ActiveContent != null)
                    {
                        //look for active content parent pane
                        anchorablePane = Layout.ActiveContent.Parent as LayoutAnchorablePane;
                    }

                    if (anchorablePane == null)
                    {
                        //look for a pane on the right side
                        anchorablePane = Layout.Descendents().OfType<LayoutAnchorablePane>().Where(pane => !pane.IsHostedInFloatingWindow && pane.GetSide() == AnchorSide.Right).FirstOrDefault();
                    }

                    if (anchorablePane == null)
                    {
                        //look for an available pane
                        anchorablePane = Layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault();
                    }

                    _suspendLayoutItemCreation = true;
                    foreach (var anchorableContentToImport in e.NewItems)
                    {
                        var anchorableToImport = new LayoutAnchorable()
                        {
                            Content = anchorableContentToImport
                        };

                        bool added = false;
                        if (LayoutUpdateStrategy != null)
                        {
                            added = LayoutUpdateStrategy.BeforeInsertAnchorable(Layout, anchorableToImport, anchorablePane);
                        }

                        if (!added)
                        {
                            if (anchorablePane == null)
                            {
                                var mainLayoutPanel = new LayoutPanel() { Orientation = Orientation.Horizontal };
                                if (Layout.RootPanel != null)
                                {
                                    mainLayoutPanel.Children.Add(Layout.RootPanel);
                                }

                                Layout.RootPanel = mainLayoutPanel;
                                anchorablePane = new LayoutAnchorablePane() { DockWidth = new GridLength(200.0, GridUnitType.Pixel) };
                                mainLayoutPanel.Children.Add(anchorablePane);
                            }

                            anchorablePane.Children.Add(anchorableToImport);
                            added = true;
                        }

                        if (LayoutUpdateStrategy != null)
                        {
                            LayoutUpdateStrategy.AfterInsertAnchorable(Layout, anchorableToImport);
                        }

                        var root = anchorableToImport.Root;

                        if (root != null && root.Manager == this)
                        {
                            CreateAnchorableLayoutItem(anchorableToImport);
                        }

                    }
                    _suspendLayoutItemCreation = false;
                }
            }

            if (e.Action == NotifyCollectionChangedAction.Reset)
            {
                //NOTE: I'm going to clear every anchorable present in layout but
                //some anchorable may have been added directly to the layout, for now I clear them too
                var anchorablesToRemove = Layout.Descendents().OfType<LayoutAnchorable>().ToArray();
                foreach (var anchorableToRemove in anchorablesToRemove)
                {
                    (anchorableToRemove.Parent as ILayoutContainer).RemoveChild(
                        anchorableToRemove);
                }
            }

            if (Layout != null)
                Layout.CollectGarbage();
        }
Ejemplo n.º 42
0
        internal void StartDraggingFloatingWindowForPane(LayoutAnchorablePane paneModel)
        {
            if (paneModel.Children.Any(c => !c.CanFloat))
                return;
            var paneAsPositionableElement = paneModel as ILayoutPositionableElement;
            var paneAsWithActualSize = paneModel as ILayoutPositionableElementWithActualSize;

            double fwWidth = paneAsPositionableElement.FloatingWidth;
            double fwHeight = paneAsPositionableElement.FloatingHeight;
            double fwLeft = paneAsPositionableElement.FloatingLeft;
            double fwTop = paneAsPositionableElement.FloatingTop;

            if (fwWidth == 0.0)
                fwWidth = paneAsWithActualSize.ActualWidth;
            if (fwHeight == 0.0)
                fwHeight = paneAsWithActualSize.ActualHeight;

            var destPane = new LayoutAnchorablePane()
            {
                DockWidth = paneAsPositionableElement.DockWidth,
                DockHeight = paneAsPositionableElement.DockHeight,
                DockMinHeight = paneAsPositionableElement.DockMinHeight,
                DockMinWidth = paneAsPositionableElement.DockMinWidth,
                FloatingLeft = paneAsPositionableElement.FloatingLeft,
                FloatingTop = paneAsPositionableElement.FloatingTop,
                FloatingWidth = paneAsPositionableElement.FloatingWidth,
                FloatingHeight = paneAsPositionableElement.FloatingHeight,
            };

            bool savePreviousContainer = paneModel.FindParent<LayoutFloatingWindow>() == null;
            int currentSelectedContentIndex = paneModel.SelectedContentIndex;
            while (paneModel.Children.Count > 0)
            {
                var contentModel = paneModel.Children[paneModel.Children.Count - 1] as LayoutAnchorable;

                if (savePreviousContainer)
                {
                    var contentModelAsPreviousContainer = contentModel as ILayoutPreviousContainer;
                    contentModelAsPreviousContainer.PreviousContainer = paneModel;
                    contentModel.PreviousContainerIndex = paneModel.Children.Count - 1;
                }

                paneModel.RemoveChildAt(paneModel.Children.Count - 1);
                destPane.Children.Insert(0, contentModel);
            }

            if (destPane.Children.Count > 0)
            {
                destPane.SelectedContentIndex = currentSelectedContentIndex;
            }

            LayoutFloatingWindow fw;
            LayoutFloatingWindowControl fwc;
            fw = new LayoutAnchorableFloatingWindow()
            {
                RootPanel = new LayoutAnchorablePaneGroup(
                    destPane)
                    {
                        DockHeight = destPane.DockHeight,
                        DockWidth = destPane.DockWidth,
                        DockMinHeight = destPane.DockMinHeight,
                        DockMinWidth = destPane.DockMinWidth,
                    }
            };

            Layout.FloatingWindows.Add(fw);

            fwc = new LayoutAnchorableFloatingWindowControl(
                fw as LayoutAnchorableFloatingWindow)
            {
                Width = fwWidth,
                Height = fwHeight
            };

            //fwc.Owner = Window.GetWindow(this);
            //fwc.SetParentToMainWindowOf(this);

            _fwList.Add(fwc);

            Layout.CollectGarbage();

            InvalidateArrange();

            fwc.AttachDrag();
            fwc.Show();
        }
Ejemplo n.º 43
0
        internal List<ILayoutPanelElement> InitializeViews()
        {
            ReadOnlyCollection<string> enabledWidgets = GetEnabledWidgets();

            foreach (ExportedType export in ExportedTypeLibrary.GetExports(typeof(IUIWidget)).Where(j => enabledWidgets.Contains(j.Attribute.Alias)))
            {
                var iuiWidget = export.CreateInstance<IUIWidget>();

                string iuiWidgetName = iuiWidget.GetType().Name;
                Logger.Instance.LogFormat(LogType.Info, this, Properties.Resources.Init, iuiWidgetName);

                try
                {
                    if (!iuiWidget.Initialize())
                    {
                        Logger.Instance.LogFormat(LogType.Warning, this, Properties.Resources.InitFailed, iuiWidgetName);
                        continue;
                    }
                    var pane =
                        new LayoutAnchorablePane(new LayoutAnchorable
                                                     {
                                                         Content = iuiWidget.UIElement,
                                                         ContentId = iuiWidget.ContentGuid,
                                                         Title = iuiWidget.Title,
                                                         CanClose = false,
                                                         CanHide = false
                                                     });

                    _panelElements.Add(pane);
                    _widgets.Add(iuiWidget);
                    Logger.Instance.LogFormat(LogType.Info, this, Properties.Resources.InitSuccessful, iuiWidgetName);
                }
                catch (Exception ex)
                {
                    Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.InitError, iuiWidgetName, ex.Message);
                }
            }
            return _panelElements;
        }
Ejemplo n.º 44
0
		protected override void InternalDock()
		{
			var root = Root as LayoutRoot;
			LayoutAnchorablePane anchorablePane = null;

			if (root.ActiveContent != null &&
				root.ActiveContent != this)
			{
				//look for active content parent pane
				anchorablePane = root.ActiveContent.Parent as LayoutAnchorablePane;
			}

			if (anchorablePane == null)
			{
				//look for a pane on the right side
				anchorablePane = root.Descendents().OfType<LayoutAnchorablePane>().Where(pane => !pane.IsHostedInFloatingWindow && pane.GetSide() == AnchorSide.Right).FirstOrDefault();
			}

			if (anchorablePane == null)
			{
				//look for an available pane
				anchorablePane = root.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault();
			}


			bool added = false;
			if (root.Manager.LayoutUpdateStrategy != null)
			{
				added = root.Manager.LayoutUpdateStrategy.BeforeInsertAnchorable(root, this, anchorablePane);
			}

			if (!added)
			{
				if (anchorablePane == null)
				{
					var mainLayoutPanel = new LayoutPanel() { Orientation = Orientation.Horizontal };
					if (root.RootPanel != null)
					{
						mainLayoutPanel.Children.Add(root.RootPanel);
					}

					root.RootPanel = mainLayoutPanel;
					anchorablePane = new LayoutAnchorablePane() { DockWidth = new GridLength(200.0, GridUnitType.Pixel) };
					mainLayoutPanel.Children.Add(anchorablePane);
				}

				anchorablePane.Children.Add(this);
				added = true;
			}

			if (root.Manager.LayoutUpdateStrategy != null)
			{
				root.Manager.LayoutUpdateStrategy.AfterInsertAnchorable(root, this);
			}

			base.InternalDock();
		}
Ejemplo n.º 45
0
        /// <summary>
        /// Add the anchorable to a DockingManager layout
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="strategy"></param>
        public void AddToLayout(DockingManager manager, AnchorableShowStrategy strategy)
        {
            if (IsVisible ||
                IsHidden)
                throw new InvalidOperationException();

            bool most = (strategy & AnchorableShowStrategy.Most) == AnchorableShowStrategy.Most;
            bool left = (strategy & AnchorableShowStrategy.Left) == AnchorableShowStrategy.Left;
            bool right = (strategy & AnchorableShowStrategy.Right) == AnchorableShowStrategy.Right;
            bool top = (strategy & AnchorableShowStrategy.Top) == AnchorableShowStrategy.Top;
            bool bottom = (strategy & AnchorableShowStrategy.Bottom) == AnchorableShowStrategy.Bottom;

            if (!most)
            {
                var side = AnchorSide.Left;
                if (left)
                    side = AnchorSide.Left;
                if (right)
                    side = AnchorSide.Right;
                if (top)
                    side = AnchorSide.Top;
                if (bottom)
                    side = AnchorSide.Bottom;

                var anchorablePane = manager.Layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(p => p.GetSide() == side);
                if (anchorablePane != null)
                    anchorablePane.Children.Add(this);
                else
                    most = true;
            }

            if (most)
            {
                if (manager.Layout.RootPanel == null)
                    manager.Layout.RootPanel = new LayoutPanel() { Orientation = (left || right ? Orientation.Horizontal : Orientation.Vertical) };

                if (left || right)
                {
                    if (manager.Layout.RootPanel.Orientation == Orientation.Vertical &&
                        manager.Layout.RootPanel.ChildrenCount > 1)
                    {
                        manager.Layout.RootPanel = new LayoutPanel(manager.Layout.RootPanel);
                    }

                    manager.Layout.RootPanel.Orientation = Orientation.Horizontal;

                    var pane = new LayoutAnchorablePane(this) { DockWidth =  new GridLength(AutoHideWidth) };

                    if (left)
                        manager.Layout.RootPanel.Children.Insert(0, pane);
                    else
                        manager.Layout.RootPanel.Children.Add(pane);
                }
                else
                {
                    if (manager.Layout.RootPanel.Orientation == Orientation.Horizontal &&
                        manager.Layout.RootPanel.ChildrenCount > 1)
                    {
                        manager.Layout.RootPanel = new LayoutPanel(manager.Layout.RootPanel);
                    }

                    manager.Layout.RootPanel.Orientation = Orientation.Vertical;

                    var pane = new LayoutAnchorablePane(this) { DockHeight = new GridLength(AutoHideHeight) };

                    if (top)
                        manager.Layout.RootPanel.Children.Insert(0, pane);
                    else
                        manager.Layout.RootPanel.Children.Add(pane);
                }

            }
        }
Ejemplo n.º 46
0
        internal LayoutAnchorablePane GetLayoutAnchorablePane()
        {
            if (layoutanchpanegroup == null)
            {
                layoutanchpanegroup = new LayoutAnchorablePaneGroup();
                layoutanchpanegroup.DockWidth = new GridLength(250);
            }

            if (layoutanchpane == null)
                layoutanchpane = new LayoutAnchorablePane();

            if (!layoutanchpanegroup.Children.Contains(layoutanchpane))
                layoutanchpanegroup.Children.Add(layoutanchpane);

            if (!LayoutPane.Children.Contains(layoutanchpanegroup))
            LayoutPane.Children.Add(layoutanchpanegroup);

            return layoutanchpane;
        }
Ejemplo n.º 47
0
 private static LayoutAnchorablePane CreateAnchorablePane(LayoutRoot layout, Orientation orientation,
     string paneName, InsertPosition position)
 {
     var parent = layout.Descendents().OfType<LayoutPanel>().First(d => d.Orientation == orientation);
     var toolsPane = new LayoutAnchorablePane { Name = paneName };
     if (position == InsertPosition.Start)
         parent.InsertChildAt(0, toolsPane);
     else
         parent.Children.Add(toolsPane);
     return toolsPane;
 }
Ejemplo n.º 48
0
        private static LayoutAnchorablePane CreateAnchorablePane(
            LayoutRoot layout,
            Orientation orientation,
            string paneName,
            InsertPosition position)
        {
            var parent = layout.Descendents().OfType<LayoutPanel>().First();
            foreach (var panel in layout.Descendents().OfType<LayoutPanel>())
            {
                if (panel.Orientation == orientation)
                {
                    parent = panel;
                    break;
                }
            }

            var toolsPane = new LayoutAnchorablePane { Name = paneName };
            if (position == InsertPosition.Start)
            {
                parent.InsertChildAt(0, toolsPane);
            }
            else
            {
                parent.Children.Add(toolsPane);
            }

            return toolsPane;
        }
Ejemplo n.º 49
0
		public void ToggleAutoHide()
		{
			#region Anchorable is already auto hidden
			if (IsAutoHidden)
			{
				var parentGroup = Parent as LayoutAnchorGroup;
				var parentSide = parentGroup.Parent as LayoutAnchorSide;
				var previousContainer = ((ILayoutPreviousContainer)parentGroup).PreviousContainer as LayoutAnchorablePane;

				if (previousContainer == null)
				{
					AnchorSide side = (parentGroup.Parent as LayoutAnchorSide).Side;
					switch (side)
					{
						case AnchorSide.Right:
							if (parentGroup.Root.RootPanel.Orientation == Orientation.Horizontal)
							{
								previousContainer = new LayoutAnchorablePane();
								parentGroup.Root.RootPanel.Children.Add(previousContainer);
							}
							else
							{
								previousContainer = new LayoutAnchorablePane();
								LayoutPanel panel = new LayoutPanel() { Orientation = Orientation.Horizontal };
								LayoutRoot root = parentGroup.Root as LayoutRoot;
								LayoutPanel oldRootPanel = parentGroup.Root.RootPanel as LayoutPanel;
								root.RootPanel = panel;
								panel.Children.Add(oldRootPanel);
								panel.Children.Add(previousContainer);
							}
							break;
						case AnchorSide.Left:
							if (parentGroup.Root.RootPanel.Orientation == Orientation.Horizontal)
							{
								previousContainer = new LayoutAnchorablePane();
								parentGroup.Root.RootPanel.Children.Insert(0, previousContainer);
							}
							else
							{
								previousContainer = new LayoutAnchorablePane();
								LayoutPanel panel = new LayoutPanel() { Orientation = Orientation.Horizontal };
								LayoutRoot root = parentGroup.Root as LayoutRoot;
								LayoutPanel oldRootPanel = parentGroup.Root.RootPanel as LayoutPanel;
								root.RootPanel = panel;
								panel.Children.Add(previousContainer);
								panel.Children.Add(oldRootPanel);
							}
							break;
						case AnchorSide.Top:
							if (parentGroup.Root.RootPanel.Orientation == Orientation.Vertical)
							{
								previousContainer = new LayoutAnchorablePane();
								parentGroup.Root.RootPanel.Children.Insert(0, previousContainer);
							}
							else
							{
								previousContainer = new LayoutAnchorablePane();
								LayoutPanel panel = new LayoutPanel() { Orientation = Orientation.Vertical };
								LayoutRoot root = parentGroup.Root as LayoutRoot;
								LayoutPanel oldRootPanel = parentGroup.Root.RootPanel as LayoutPanel;
								root.RootPanel = panel;
								panel.Children.Add(previousContainer);
								panel.Children.Add(oldRootPanel);
							}
							break;
						case AnchorSide.Bottom:
							if (parentGroup.Root.RootPanel.Orientation == Orientation.Vertical)
							{
								previousContainer = new LayoutAnchorablePane();
								parentGroup.Root.RootPanel.Children.Add(previousContainer);
							}
							else
							{
								previousContainer = new LayoutAnchorablePane();
								LayoutPanel panel = new LayoutPanel() { Orientation = Orientation.Vertical };
								LayoutRoot root = parentGroup.Root as LayoutRoot;
								LayoutPanel oldRootPanel = parentGroup.Root.RootPanel as LayoutPanel;
								root.RootPanel = panel;
								panel.Children.Add(oldRootPanel);
								panel.Children.Add(previousContainer);
							}
							break;
					}
				}
				else
				{
					//I'm about to remove parentGroup, redirect any content (ie hidden contents) that point to it
					//to previousContainer
					LayoutRoot root = parentGroup.Root as LayoutRoot;
					foreach (var cnt in root.Descendents().OfType<ILayoutPreviousContainer>().Where(c => c.PreviousContainer == parentGroup))
					{
						cnt.PreviousContainer = previousContainer;
					}
				}


				foreach (var anchorableToToggle in parentGroup.Children.ToArray())
				{
					previousContainer.Children.Add(anchorableToToggle);
				}

				parentSide.Children.Remove(parentGroup);
			}
			#endregion
			#region Anchorable is docked
			else if (Parent is LayoutAnchorablePane)
			{
				var root = Root;
				var parentPane = Parent as LayoutAnchorablePane;

				var newAnchorGroup = new LayoutAnchorGroup();

				((ILayoutPreviousContainer)newAnchorGroup).PreviousContainer = parentPane;

				foreach (var anchorableToImport in parentPane.Children.ToArray())
					newAnchorGroup.Children.Add(anchorableToImport);

				//detect anchor side for the pane
				var anchorSide = parentPane.GetSide();

				switch (anchorSide)
				{
					case AnchorSide.Right:
						root.RightSide.Children.Add(newAnchorGroup);
						break;
					case AnchorSide.Left:
						root.LeftSide.Children.Add(newAnchorGroup);
						break;
					case AnchorSide.Top:
						root.TopSide.Children.Add(newAnchorGroup);
						break;
					case AnchorSide.Bottom:
						root.BottomSide.Children.Add(newAnchorGroup);
						break;
				}
			}
			#endregion
		}