Esempio n. 1
0
 public void Dock()
 {
     if (this.PreviousContainer == null)
     {
         this.InternalDock();
     }
     else
     {
         ILayoutContainer parent        = base.Parent;
         int          num               = (parent is ILayoutGroup ? (parent as ILayoutGroup).IndexOfChild(this) : -1);
         ILayoutGroup previousContainer = this.PreviousContainer as ILayoutGroup;
         if (this.PreviousContainerIndex >= previousContainer.ChildrenCount)
         {
             previousContainer.InsertChildAt(previousContainer.ChildrenCount, this);
         }
         else
         {
             previousContainer.InsertChildAt(this.PreviousContainerIndex, this);
         }
         if (num <= -1)
         {
             this.PreviousContainer      = null;
             this.PreviousContainerIndex = 0;
         }
         else
         {
             this.PreviousContainer      = parent;
             this.PreviousContainerIndex = num;
         }
         this.IsSelected = true;
         this.IsActive   = true;
     }
     base.Root.CollectGarbage();
 }
Esempio n. 2
0
        public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
        {
            if (destinationContainer != null &&
                destinationContainer.FindParent<LayoutFloatingWindow>() != null)
            {
                return false;
            }

            foreach (var viewModelPane in ViewModelPanes)
            {
                if (viewModelPane.Item1.IsInstanceOfType(anchorableToShow.Content))
                {
                    var pane = layout
                        .Descendents()
                        .OfType<LayoutAnchorablePane>()
                        .SingleOrDefault(p => p.Name == viewModelPane.Item2);

                    if (pane != null)
                    {
                        pane.Children.Add(anchorableToShow);

                        if (viewModelPane.Item3)
                        {
                            anchorableToShow.ToggleAutoHide();
                        }

                        return true;
                    }
                }
            }

            return false;
        }
Esempio n. 3
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:
                            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;
        }
Esempio n. 4
0
 public static T FindByViewId <T>(this ILayoutContainer root, string viewId)
     where T : LayoutContent
 {
     return(root?.Descendents()
            .OfType <T>()
            .FirstOrDefault(x => x.ContentId == viewId));
 }
Esempio n. 5
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);
        }
Esempio n. 6
0
        public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
        {           
            //Determine panel name for given view model type
            string destPaneName = string.Empty;
            if (anchorableToShow.Content is JadeControls.Workspace.ViewModel.WorkspaceViewModel ||
                anchorableToShow.Content is JadeControls.SymbolInspector.SymbolInspectorPaneViewModel ||
                anchorableToShow.Content is JadeControls.CursorInspector.CursorInspectorPaneViewModel)
            {
                destPaneName = "LeftToolPanel";
            }
            else if (anchorableToShow.Content is JadeControls.OutputControl.ViewModel.OutputViewModel ||
                    anchorableToShow.Content is JadeControls.SearchResultsControl.ViewModel.SearchResultsPaneViewModel)
            {
                destPaneName = "LowerToolPanel";
            }
            else if (anchorableToShow.Content is JadeControls.ContextTool.ContextPaneViewModel)
            {
                destPaneName = "RightToolPanel";
            }
            else
            {
                return false;
            }

            //Find pane
            var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == destPaneName);
            if (toolsPane != null)
            {
                //Add
                toolsPane.Children.Add(anchorableToShow);
                return true;
            } 
            return false;
        }
Esempio n. 7
0
 public static bool IsOfType <T, S>(this ILayoutContainer container)
 {
     if (container is T)
     {
         return(true);
     }
     return(container is S);
 }
Esempio n. 8
0
 protected override void OnParentChanged(ILayoutContainer oldValue, ILayoutContainer newValue)
 {
     UpdateParentVisibility();
     RaisePropertyChanged("IsVisible");
     NotifyIsVisibleChanged();
     RaisePropertyChanged("IsHidden");
     RaisePropertyChanged("IsAutoHidden");
     base.OnParentChanged(oldValue, newValue);
 }
Esempio n. 9
0
		protected override void OnParentChanged(ILayoutContainer oldValue, ILayoutContainer newValue)
		{
			UpdateParentVisibility();
			RaisePropertyChanged("IsVisible");
			NotifyIsVisibleChanged();
			RaisePropertyChanged("IsHidden");
			RaisePropertyChanged("IsAutoHidden");
			base.OnParentChanged(oldValue, newValue);
		}
Esempio n. 10
0
 protected override void OnParentChanged(ILayoutContainer oldValue, ILayoutContainer newValue)
 {
     if (this.IsSelected && base.Parent != null && base.Parent is ILayoutContentSelector)
     {
         ILayoutContentSelector parent = base.Parent as ILayoutContentSelector;
         parent.SelectedContentIndex = parent.IndexOf(this);
     }
     base.OnParentChanged(oldValue, newValue);
 }
Esempio n. 11
0
        private UIElement UIElementFromModel(ILayoutContainer model)
        {
            if (model is LayoutPanel)
            {
                return(new FloatPanelControl(model as LayoutPanel));
            }

            return(null);
        }
Esempio n. 12
0
        protected override void OnParentChanging(ILayoutContainer oldValue, ILayoutContainer newValue)
        {
            ILayoutRoot root = base.Root;

            if (oldValue != null)
            {
                this.IsSelected = false;
            }
            base.OnParentChanging(oldValue, newValue);
        }
Esempio n. 13
0
        public static T FindParent <T>(this ILayoutElement element)
        {
            ILayoutContainer parent = element.Parent;

            while (parent != null && !(parent is T))
            {
                parent = parent.Parent;
            }
            return((T)parent);
        }
Esempio n. 14
0
 public TableLayoutManager(ILayoutContainer container, int gutterHeight, int gutterWidth, int marginHeight,
                           int marginWidth, int rows, int cols)
 {
     Container    = container;
     GutterHeight = gutterHeight;
     GutterWidth  = gutterWidth;
     MarginHeight = marginHeight;
     MarginWidth  = marginWidth;
     Rows         = rows;
     Cols         = cols;
 }
Esempio n. 15
0
 public static bool ContainsChildOfType <T, S>(this ILayoutContainer container)
 {
     foreach (var childElement in container.Descendents())
     {
         if (childElement is T || childElement is S)
         {
             return(true);
         }
     }
     return(false);
 }
 public TableLayoutManager(ILayoutContainer container, int gutterHeight, int gutterWidth, int marginHeight,
     int marginWidth, int rows, int cols)
 {
     Container = container;
     GutterHeight = gutterHeight;
     GutterWidth = gutterWidth;
     MarginHeight = marginHeight;
     MarginWidth = marginWidth;
     Rows = rows;
     Cols = cols;
 }
Esempio n. 17
0
 public static bool ContainsChildOfType <T>(this ILayoutContainer element)
 {
     foreach (var childElement in element.Descendents())
     {
         if (childElement is T)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 18
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;
		}
Esempio n. 19
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            Size desiredSize;
            IEnumerable <UIElement> uIElements = base.Children.Cast <UIElement>();
            double right = 0;
            bool   flag  = false;

            using (IEnumerator <UIElement> enumerator = (
                       from ch in uIElements
                       where ch.Visibility != System.Windows.Visibility.Collapsed
                       select ch).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    TabItem       current = (TabItem)enumerator.Current;
                    LayoutContent content = current.Content as LayoutContent;
                    if (!flag)
                    {
                        desiredSize = current.DesiredSize;
                        if (right + desiredSize.Width <= finalSize.Width)
                        {
                            current.Visibility = System.Windows.Visibility.Visible;
                            Size size = current.DesiredSize;
                            current.Arrange(new Rect(right, 0, size.Width, finalSize.Height));
                            double    actualWidth = current.ActualWidth;
                            Thickness margin      = current.Margin;
                            double    left        = actualWidth + margin.Left;
                            margin = current.Margin;
                            right  = right + (left + margin.Right);
                            continue;
                        }
                    }
                    if (content.IsSelected && !current.IsVisible)
                    {
                        ILayoutContainer       parent = content.Parent;
                        ILayoutContentSelector layoutContentSelector = content.Parent as ILayoutContentSelector;
                        ILayoutPane            layoutPane            = content.Parent as ILayoutPane;
                        int num = layoutContentSelector.IndexOf(content);
                        if (num > 0 && parent.ChildrenCount > 1)
                        {
                            layoutPane.MoveChild(num, 0);
                            layoutContentSelector.SelectedContentIndex = 0;
                            desiredSize = this.ArrangeOverride(finalSize);
                            return(desiredSize);
                        }
                    }
                    current.Visibility = System.Windows.Visibility.Hidden;
                    flag = true;
                }
                return(finalSize);
            }
            return(desiredSize);
        }
Esempio n. 20
0
        protected override void OnParentChanging(ILayoutContainer oldValue, ILayoutContainer newValue)
        {
            if (oldValue != null)
            {
                IsSelected = false;
            }

            //if (root != null && _isActive && newValue == null)
            //    root.ActiveContent = null;

            base.OnParentChanging(oldValue, newValue);
        }
Esempio n. 21
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
            var destPane = destinationContainer as LayoutAnchorablePane;

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

            var tool = anchorableToShow.Content as ToolViewModel;

            if (tool != null)
            {
                var preferredLocation = tool.PreferredLocation;
                var paneName          = GetPaneName(preferredLocation);
                var toolsPane         = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name == paneName);
                if (toolsPane == null)
                {
                    switch (preferredLocation)
                    {
                    case ToolLocation.Left:
                        toolsPane = CreateAnchorablePane(layout, Orientation.Horizontal, paneName,
                                                         InsertPosition.Start);
                        break;

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

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

                    case ToolLocation.Top:
                        toolsPane = CreateAnchorablePane(layout, Orientation.Vertical, paneName, InsertPosition.Start);
                        break;

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

            return(false);
        }
Esempio n. 22
0
        protected override void OnParentChanged(ILayoutContainer oldValue, ILayoutContainer newValue)
        {
            if (IsSelected && Parent != null && Parent is ILayoutContentSelector)
            {
                var parentSelector = (Parent as ILayoutContentSelector);
                parentSelector.SelectedContentIndex = parentSelector.IndexOf(this);
            }

            //var root = Root;
            //if (root != null && _isActive)
            //    root.ActiveContent = this;

            base.OnParentChanged(oldValue, newValue);
        }
Esempio n. 23
0
        protected override void OnParentChanged(ILayoutContainer oldValue, ILayoutContainer newValue)
        {
            var oldGroup = oldValue as ILayoutGroup;
            if (oldGroup != null)
                oldGroup.ChildrenCollectionChanged -= new EventHandler(OnParentChildrenCollectionChanged);

            RaisePropertyChanged("IsDirectlyHostedInFloatingWindow");

            var newGroup = newValue as ILayoutGroup;
            if (newGroup != null)
                newGroup.ChildrenCollectionChanged += new EventHandler(OnParentChildrenCollectionChanged);

            base.OnParentChanged(oldValue, newValue);
        }
Esempio n. 24
0
        public static ILayoutRoot GetRoot(this ILayoutElement element)
        {
            if (element is ILayoutRoot)
            {
                return(element as ILayoutRoot);
            }
            ILayoutContainer parent = element.Parent;

            while (parent != null && !(parent is ILayoutRoot))
            {
                parent = parent.Parent;
            }
            return((ILayoutRoot)parent);
        }
Esempio n. 25
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);
        }
Esempio n. 26
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;
        }
Esempio n. 27
0
        public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
        {
            if (destinationContainer != null &&
                destinationContainer.FindParent<LayoutFloatingWindow>() != null)
                return false;

            var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "ToolsPane");
            if (toolsPane != null)
            {
                toolsPane.Children.Add(anchorableToShow);
                return true;
            }

            return false;
        }
Esempio n. 28
0
        public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorable, ILayoutContainer destination)
        {
            LayoutAnchorablePane pane = destination as LayoutAnchorablePane;
            if (destination != null && destination.FindParent<LayoutFloatingWindow>() != null)
            {
                return false;
            }

            LayoutAnchorablePane files = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "pnFiles");
            if (files != null)
            {
                files.Children.Add(anchorable);
                return true;
            }
            return false;
        }
        public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
        {
            var myViewModel = anchorableToShow.Content as IToolWindow;
            if (myViewModel != null)
            {
                var lap = layout.Descendents();
                var pane = lap.OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == myViewModel.DefaultDockingPane);
                if (pane != null)
                {
                    pane.Children.Add(anchorableToShow);
                    return true;
                }
            }

            return false;
        }
Esempio n. 30
0
        protected override void OnParentChanged(ILayoutContainer oldValue, ILayoutContainer newValue)
        {
            ILayoutGroup layoutGroup = oldValue as ILayoutGroup;

            if (layoutGroup != null)
            {
                layoutGroup.ChildrenCollectionChanged -= new EventHandler(this.OnParentChildrenCollectionChanged);
            }
            this.RaisePropertyChanged("IsDirectlyHostedInFloatingWindow");
            ILayoutGroup layoutGroup1 = newValue as ILayoutGroup;

            if (layoutGroup1 != null)
            {
                layoutGroup1.ChildrenCollectionChanged += new EventHandler(this.OnParentChildrenCollectionChanged);
            }
            base.OnParentChanged(oldValue, newValue);
        }
Esempio n. 31
0
        public static IEnumerable <ILayoutElement> Descendents(this ILayoutElement element)
        {
            ILayoutContainer layoutContainer = element as ILayoutContainer;

            if (layoutContainer != null)
            {
                foreach (ILayoutElement child in layoutContainer.Children)
                {
                    yield return(child);

                    foreach (ILayoutElement layoutElement in child.Descendents())
                    {
                        yield return(layoutElement);
                    }
                }
            }
        }
Esempio n. 32
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;

            if (anchorableToShow.Content is SectionBrowserViewModel)
            {
                var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "SectionBrowserPane");
                if (toolsPane != null)
                {
                   // anchorableToShow.CanHide = false;
                    toolsPane.Children.Add(anchorableToShow);
                    return true;
                }
            }

            if (anchorableToShow.Content is BlockGroupBrowserViewModel)
            {
                var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "BlockGroupBrowserPane");
                if (toolsPane != null)
                {
                   // anchorableToShow.CanHide = false;
                    toolsPane.Children.Add(anchorableToShow);
                    return true;
                }
            }

            if (anchorableToShow.Content is BlockOutputPreviewViewModel)
            {
                var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == "BlockOutputPreviewPane");
                if (toolsPane != null)
                {
                    toolsPane.Children.Add(anchorableToShow);
                    return true;
                }
            }

            return false;
        }
Esempio n. 33
0
 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (this._isMouseDown)
     {
         Point position = e.GetPosition(this);
         if (Math.Abs(position.X - this._mouseDownPoint.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(position.Y - this._mouseDownPoint.Y) > SystemParameters.MinimumVerticalDragDistance)
         {
             this.UpdateDragDetails();
             base.CaptureMouse();
             this._isMouseDown = false;
         }
     }
     if (base.IsMouseCaptured)
     {
         Point screenDPI = this.PointToScreenDPI(e.GetPosition(this));
         if (!this._parentDocumentTabPanelScreenArea.Contains(screenDPI))
         {
             base.ReleaseMouseCapture();
             this.Model.Root.Manager.StartDraggingFloatingWindowForContent(this.Model, true);
             return;
         }
         int num = this._otherTabsScreenArea.FindIndex((Rect r) => r.Contains(screenDPI));
         if (num >= 0)
         {
             LayoutContent    content    = this._otherTabs[num].Content as LayoutContent;
             ILayoutContainer parent     = this.Model.Parent;
             ILayoutPane      layoutPane = this.Model.Parent as ILayoutPane;
             if (layoutPane is LayoutDocumentPane && !((LayoutDocumentPane)layoutPane).CanRepositionItems)
             {
                 return;
             }
             if (layoutPane.Parent != null && layoutPane.Parent is LayoutDocumentPaneGroup && !((LayoutDocumentPaneGroup)layoutPane.Parent).CanRepositionItems)
             {
                 return;
             }
             List <ILayoutElement> list = parent.Children.ToList <ILayoutElement>();
             layoutPane.MoveChild(list.IndexOf(this.Model), list.IndexOf(content));
             this.Model.IsActive = true;
             this._parentDocumentTabPanel.UpdateLayout();
             this.UpdateDragDetails();
         }
     }
 }
Esempio 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
            if (destinationContainer != null &&
                destinationContainer.FindParent <LayoutFloatingWindow>() != null)
            {
                return(false);
            }

            if (anchorableToShow.Content is IAnchorableWindow)
            {
                string paneToSearch = "";
                switch ((anchorableToShow.Content as IAnchorableWindow).AnchorableDefaultPlacementEnum)
                {
                case PlacementEnum.Top:

                    break;

                case PlacementEnum.Left:
                    paneToSearch = "LeftAnchorablePane";
                    break;

                case PlacementEnum.Right:
                    break;

                case PlacementEnum.Bottom:
                    paneToSearch = "BottomAnchorablePane";
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                var anchorablePaneToAddChild = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name == paneToSearch);
                if (anchorablePaneToAddChild != null)
                {
                    anchorablePaneToAddChild.Children.Add(anchorableToShow);
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 35
0
        public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow,
                                           ILayoutContainer destinationContainer)
        {
            var destPane = destinationContainer as LayoutAnchorablePane;
            if (destinationContainer != null &&
                destinationContainer.FindParent<LayoutFloatingWindow>() != null)
                return false;

            LayoutAnchorablePane toolsPane =
                layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(
                    d => d.GetType() == typeof (IContentView));
            if (toolsPane != null)
            {
                toolsPane.Children.Add(anchorableToShow);
                return true;
            }

            return false;
        }
Esempio n. 36
0
        public static bool ContainsChildOfType <T>(this ILayoutContainer element)
        {
            bool flag;

            using (IEnumerator <ILayoutElement> enumerator = element.Descendents().GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    if (!(enumerator.Current is T))
                    {
                        continue;
                    }
                    flag = true;
                    return(flag);
                }
                return(false);
            }
            return(flag);
        }
Esempio n. 37
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)
            //{
            //    toolsPane.Children.Add(anchorableToShow);
            //    return true;
            //}

            return false;
        }
        public bool BeforeInsertAnchorable(LayoutRoot layout,
                                           LayoutAnchorable anchorableToShow,
                                           ILayoutContainer destinationContainer)
        {
            LayoutAnchorablePane pane = null;

            if (anchorableToShow.Content is DebugLogViewModel)
            {
                pane = layout.Descendents().OfType <LayoutAnchorablePane>()
                       .FirstOrDefault(d => d.Name == "bottom");
            }
            if (pane != null)
            {
                //anchorableToShow.CanHide = false;
                anchorableToShow.CanClose = false;
                pane.Children.Add(anchorableToShow);
                return(true);
            }
            return(false);
        }
Esempio n. 39
0
 protected override void OnMouseEnter(MouseEventArgs e)
 {
     base.OnMouseEnter(e);
     if (LayoutAnchorableTabItem._draggingItem != null && LayoutAnchorableTabItem._draggingItem != this && e.LeftButton == MouseButtonState.Pressed)
     {
         LayoutContent    model      = this.Model;
         ILayoutContainer parent     = model.Parent;
         ILayoutPane      layoutPane = model.Parent as ILayoutPane;
         if (layoutPane is LayoutAnchorablePane && !((LayoutAnchorablePane)layoutPane).CanRepositionItems)
         {
             return;
         }
         if (layoutPane.Parent != null && layoutPane.Parent is LayoutAnchorablePaneGroup && !((LayoutAnchorablePaneGroup)layoutPane.Parent).CanRepositionItems)
         {
             return;
         }
         List <ILayoutElement> list = parent.Children.ToList <ILayoutElement>();
         layoutPane.MoveChild(list.IndexOf(LayoutAnchorableTabItem._draggingItem.Model), list.IndexOf(model));
     }
 }
Esempio n. 40
0
        public static bool ContainsChildOfType <T, S>(this ILayoutContainer container)
        {
            bool flag;

            using (IEnumerator <ILayoutElement> enumerator = container.Descendents().GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ILayoutElement current = enumerator.Current;
                    if (!(current is T) && !(current is S))
                    {
                        continue;
                    }
                    flag = true;
                    return(flag);
                }
                return(false);
            }
            return(flag);
        }
Esempio n. 41
0
        /// <summary>
        /// Method is called when a completely new layout item is
        /// to be inserted into the current avalondock layout.
        /// </summary>
        /// <param name="layout"></param>
        /// <param name="anchorableToShow"></param>
        /// <param name="destinationContainer"></param>
        /// <returns></returns>
        public bool BeforeInsertAnchorable(LayoutRoot layout,
                                           LayoutAnchorable anchorableToShow,
                                           ILayoutContainer destinationContainer)
        {
            if (anchorableToShow.Content is IToolWindow)
            {
                IToolWindow tool = anchorableToShow.Content as IToolWindow;

                var preferredLocation = tool.PreferredLocation;

                LayoutAnchorGroup layoutGroup = null;

                switch (preferredLocation)
                {
                case PaneLocation.Left:
                    layoutGroup = FindAnchorableGroup(layout, preferredLocation);
                    break;

                case PaneLocation.Right:
                    layoutGroup = FindAnchorableGroup(layout, preferredLocation);
                    break;

                case PaneLocation.Bottom:
                    layoutGroup = FindAnchorableGroup(layout, preferredLocation);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                if (layoutGroup != null)
                {
                    ////group.InsertChildAt(0, anchorableToShow);
                    layoutGroup.Children.Add(anchorableToShow);
                }

                return(true);
            }

            return(false);
        }
Esempio n. 42
0
        public void AnchorablePaneHideCloseTest()
        {
            TestHost.SwitchToAppThread();

            Task <AnchorablePaneTestWindow> taskResult = WindowHelpers.CreateInvisibleWindowAsync <AnchorablePaneTestWindow>();

            taskResult.Wait();

            AnchorablePaneTestWindow windows = taskResult.Result;

            ILayoutContainer expectedContainer = windows.Screen3.Parent;

            windows.Screen3.Hide();
            Assert.IsTrue(windows.Screen3.IsHidden);
            windows.Screen2.Close();
            windows.Screen3.Show();
            Assert.IsFalse(windows.Screen3.IsHidden);
            ILayoutContainer actualContainer = windows.Screen3.Parent;

            Assert.AreEqual(expectedContainer, actualContainer);
        }
Esempio n. 43
0
 protected override void OnParentChanged(ILayoutContainer oldValue, ILayoutContainer newValue)
 {
     base.OnParentChanged(oldValue, newValue);
     Task.Run(async delegate
     {
         await Task.Delay(100);
         Dispatcher.Invoke((Action)(() =>
         {
             _valueInternallySetToUpdateHandle = true;
             IsPaneFloating = IsFloating;
             IsPaneFloatingMinimized = IsFloating;
             _valueInternallySetToUpdateHandle = false;
             if (!IsFloating)
             {
                 FloatingHeight = FloaterHeight;
                 FloatingWidth = FloaterWidth;
             }
         }));
     });
     this.IsMaximized = false;
 }
 public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
 {
     bool result = false;
     if (layout != null
        && anchorableToShow != null)
     {
         var destPane = destinationContainer as LayoutAnchorablePane;
         if (anchorableToShow.Root == null)
         {
             anchorableToShow.AddToLayout(layout.Manager, GetContentAnchorableStrategy(anchorableToShow));
             bool isHidden = GetContentAnchorableIsHidden(anchorableToShow);
             if (isHidden)
             {
                 anchorableToShow.CanHide = true;
                 anchorableToShow.Hide();
             }
             result = true;
         }
         else if (destPane != null && anchorableToShow.IsHidden)
         {
             // Show a hidden Anchorable.
             if (anchorableToShow.PreviousContainerIndex < 0)
             {
                 destPane.Children.Add(anchorableToShow);
             }
             else
             {
                 int insertIndex = anchorableToShow.PreviousContainerIndex;
                 if (insertIndex > destPane.ChildrenCount)
                 {
                     insertIndex = destPane.ChildrenCount;
                 }
                 destPane.Children.Insert(insertIndex, anchorableToShow);
             }
             result = true;
         }
     }
     return result || m_WrappedStrategy.BeforeInsertAnchorable(layout, anchorableToShow, destinationContainer);
 }
 public bool BeforeInsertDocument(LayoutRoot layout, LayoutDocument anchorableToShow, ILayoutContainer destinationContainer)
 {
     return m_WrappedStrategy.BeforeInsertDocument(layout, anchorableToShow, destinationContainer);
 }
 public bool BeforeInsertDocument(LayoutRoot layout, LayoutDocument anchorableToShow, ILayoutContainer destinationContainer)
 {
     return false;
 }
Esempio n. 47
0
        public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow,
            ILayoutContainer destinationContainer)
        {
            var destPane = destinationContainer as LayoutAnchorablePane;

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

            var content = anchorableToShow.Content;
            bool result;
            if (destinationContainer != null && destinationContainer.FindParent<LayoutFloatingWindow>() != null)
            {
                result = false;
            }
            else
            {
                var layoutAnchorablePane =
                    layout.Descendents()
                        .OfType<LayoutAnchorablePane>()
                        .FirstOrDefault(d => d.Name == "BottomPane");
                var layoutAnchorablePane2 =
                    layout.Descendents()
                        .OfType<LayoutAnchorablePane>()
                        .FirstOrDefault(d => d.Name == "LeftPane");
                var layoutAnchorablePane3 =
                    layout.Descendents()
                        .OfType<LayoutAnchorablePane>()
                        .FirstOrDefault(d => d.Name == "RightPane");
                switch (((ToolViewModel) content).DefaultPane)
                {
                    case DefaultToolPane.Left:
                        if (layoutAnchorablePane2 != null)
                        {
                            layoutAnchorablePane2.Children.Add(anchorableToShow);
                            result = true;
                            return result;
                        }
                        break;
                    case DefaultToolPane.Right:
                        if (layoutAnchorablePane3 != null)
                        {
                            layoutAnchorablePane3.Children.Add(anchorableToShow);
                            result = true;
                            return result;
                        }
                        break;
                    case DefaultToolPane.Bottom:
                        if (layoutAnchorablePane != null)
                        {
                            layoutAnchorablePane.Children.Add(anchorableToShow);
                            result = true;
                            return result;
                        }
                        break;
                }
                var layoutAnchorablePane4 =
                    layout.Descendents()
                        .OfType<LayoutAnchorablePane>()
                        .FirstOrDefault((LayoutAnchorablePane d) => d.Name == "ToolsPane");
                if (layoutAnchorablePane4 != null)
                {
                    layoutAnchorablePane4.Children.Add(anchorableToShow);
                    result = true;
                }
                else
                {
                    result = false;
                }
            }
            return result;
        }
 public bool BeforeInsertDocument(LayoutRoot layout, LayoutDocument anchorableToShow, ILayoutContainer destinationContainer)
 {
     throw new NotImplementedException();
 }
Esempio n. 49
0
 public bool BeforeInsertDocument(LayoutRoot layout, LayoutDocument document, ILayoutContainer destination)
 {
     return false;
 }
 public TableLayoutManager(ILayoutContainer container)
 {
     Container = container;
 }
 public TableLayoutManager(ILayoutContainer container, int rows, int cols)
 {
     Container = container;
     Rows = rows;
     Cols = cols;
 }
Esempio n. 52
0
 public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
 {
     return BeforeInsertContent(layout, anchorableToShow);
 }
 public bool InsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
 {
     return false;
 }
 public bool BeforeInsertDocument(LayoutRoot layout, LayoutDocument anchorableToShow, ILayoutContainer destinationContainer)
 {
     //TODO - can I stop anchorables being docked?
     return false;
 }
Esempio n. 55
0
 /// <summary>
 /// Provides derived classes an opportunity to handle changes to the Parent property.
 /// </summary>
 protected virtual void OnParentChanged(ILayoutContainer oldValue, ILayoutContainer newValue)
 {
     
 }
Esempio n. 56
-1
        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 content = anchorableToShow.Content;
            string destPaneName = "";
            if(content is IdInfoTablePane2ViewModel)
            {
                destPaneName = "IdInfoTablePane";
                ////layout.BottomSide.InsertChildAt(0, anchorableToShow);
                //layout.BottomSide.Children[0].Children.Add(anchorableToShow);
                //return true;
            }
            else if(content is CategoryTreePaneViewModel)
            {
                destPaneName = "CategoryTreePane";
            }
            else if (content is WpfApplication1.Workspace.ParameterFileTreePaneViewModel)
            {
                destPaneName = "ParameterFileTreePane";
            }
            else if(content is FileSharePaneViewModel)
            {
                destPaneName = "FileSharePane";
            }
            else if(content is ParameterTab2ViewModel)
            {
                destPaneName = "ParameterTabPane";
            }
            else
            { return false; }

            foreach(var pane in layout.Descendents().OfType<LayoutAnchorablePane>().Where(p=>p.ChildrenCount  >= 1))
            {
                for (int i = 0; i < pane.ChildrenCount; ++i)
                {
                    var child = pane.Children[i];
                    if (child.Content == null)
                    {
                        child.IsVisible = false;
                        --i;
                    }
                }
            }

            var toolsPane = layout.Descendents().OfType<LayoutAnchorablePane>().FirstOrDefault(d => d.Name == destPaneName);
            if (toolsPane != null)
            {
                toolsPane.Children.Add(anchorableToShow);
                return true;
            }

            return false;
        }