Exemplo n.º 1
0
 /// <summary>
 /// Общая функция для отображения панели
 /// </summary>
 /// <param name="panel"></param>
 /// <param name="showSrtrategy"></param>
 private void ShowPanel(Schematix.Panels.SchematixPanelBase panel, AnchorableShowStrategy showSrtrategy)
 {
     if (panel != null)
     {
         if ((panel.IsVisible == false) && (panel.IsHidden == false))
         {
             panel.AddToLayout(mainWindow.dockManager, showSrtrategy);
         }
         panel.Show();
     }
 }
        private static AnchorableShowStrategy GetContentAnchorableStrategy(LayoutAnchorable anchorable)
        {
            var anchorableStrategy = AnchorableStrategy.Most;

            if (anchorable != null)
            {
                if (anchorable.IsAnchorable())
                {
                    anchorableStrategy = anchorable.GetAnchorableStrategy();
                }
                else if (anchorable.Content.IsAnchorable())
                {
                    anchorableStrategy = anchorable.Content.GetAnchorableStrategy();
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }

            AnchorableShowStrategy flag = 0;

            foreach (AnchorableStrategy strategyFlag in SplitAnchorableStrategies(anchorableStrategy))
            {
                var strategy = AnchorableShowStrategy.Most;
                strategyFlag.ValueSwitchOn()
                .Case(AnchorableStrategy.Most,
                      x => strategy = AnchorableShowStrategy.Most)
                .Case(AnchorableStrategy.Left,
                      x => strategy = AnchorableShowStrategy.Left)
                .Case(AnchorableStrategy.Right,
                      x => strategy = AnchorableShowStrategy.Right)
                .Case(AnchorableStrategy.Top,
                      x => strategy = AnchorableShowStrategy.Top)
                .Case(AnchorableStrategy.Bottom,
                      x => strategy = AnchorableShowStrategy.Bottom)
                .Default(x =>
                {
                    throw new InvalidEnumArgumentException("Unknown AnchorableStrategy value");
                });
                flag |= strategy;
            }
            if (flag == 0)
            {
                flag = AnchorableShowStrategy.Most;
            }
            return(flag);
        }
Exemplo n.º 3
0
        private void ShowAnchorable(string id, AnchorableShowStrategy strategy)
        {
            var anchorable = DockManager.Layout.Descendents().OfType <LayoutAnchorable>().Single(a => a.ContentId == id);

            if (anchorable.IsHidden)
            {
                anchorable.Show();
            }
            else if (anchorable.IsVisible)
            {
                anchorable.IsActive = true;
            }
            else
            {
                anchorable.AddToLayout(DockManager, strategy | AnchorableShowStrategy.Most);
            }
        }
Exemplo n.º 4
0
        private void ShowAnchorable(LayoutAnchorable item, AnchorableShowStrategy strategy)
        {
            var obj = DockManager.Layout.Descendents().OfType <LayoutAnchorable>().Single(a => a.ContentId == item.ContentId);

            if (obj.IsHidden)
            {
                obj.Show();
            }
            else if (obj.IsVisible)
            {
                obj.IsActive = true;
            }
            else
            {
                obj.AddToLayout(DockManager, strategy | AnchorableShowStrategy.Most);
            }
        }
Exemplo n.º 5
0
        private static AnchorableShowStrategy GetContentAnchorableStrategy(LayoutAnchorable anchorable)
        {
            var anchorableStrategy = AnchorableStrategies.Most;

            if (anchorable != null)
            {
                if (anchorable.IsAnchorable())
                {
                    anchorableStrategy = anchorable.GetAnchorableStrategy();
                }
                else if (anchorable.Content.IsAnchorable())
                {
                    anchorableStrategy = anchorable.Content.GetAnchorableStrategy();
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }

            AnchorableShowStrategy flag = 0;

            foreach (AnchorableStrategies strategyFlag in SplitAnchorableStrategies(anchorableStrategy))
            {
                var strategy = AnchorableShowStrategy.Most;

                strategy = strategyFlag switch
                {
                    AnchorableStrategies.Most => AnchorableShowStrategy.Most,
                    AnchorableStrategies.Left => AnchorableShowStrategy.Left,
                    AnchorableStrategies.Right => AnchorableShowStrategy.Right,
                    AnchorableStrategies.Top => AnchorableShowStrategy.Top,
                    AnchorableStrategies.Bottom => AnchorableShowStrategy.Bottom,
                    _ => throw new InvalidOperationException($@"Unknown AnchorableStrategy value {strategyFlag}"),
                };
                flag |= strategy;
            }
            if (flag == 0)
            {
                flag = AnchorableShowStrategy.Most;
            }
            return(flag);
        }
Exemplo n.º 6
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;

                    if (left)
                    {
                        manager.Layout.RootPanel.Children.Insert(0, new LayoutAnchorablePane(this));
                    }
                    else
                    {
                        manager.Layout.RootPanel.Children.Add(new LayoutAnchorablePane(this));
                    }
                }
                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;

                    if (top)
                    {
                        manager.Layout.RootPanel.Children.Insert(0, new LayoutAnchorablePane(this));
                    }
                    else
                    {
                        manager.Layout.RootPanel.Children.Add(new LayoutAnchorablePane(this));
                    }
                }
            }
        }
Exemplo n.º 7
0
        private void ShowAnchorable(LayoutAnchorable item, AnchorableShowStrategy strategy)
        {
            var obj = DockManager.Layout.Descendents().OfType<LayoutAnchorable>().Single(a => a.ContentId == item.ContentId);

            if (obj.IsHidden)
            {
                obj.Show();
            }
            else if (obj.IsVisible)
            {
                obj.IsActive = true;
            }
            else
            {
                obj.AddToLayout(DockManager, strategy | AnchorableShowStrategy.Most);
            }
        }
Exemplo n.º 8
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;

					if (left)
						manager.Layout.RootPanel.Children.Insert(0, new LayoutAnchorablePane(this));
					else
						manager.Layout.RootPanel.Children.Add(new LayoutAnchorablePane(this));
				}
				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;

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

			}
		}
Exemplo n.º 9
0
        public void AddToLayout(DockingManager manager, AnchorableShowStrategy strategy)
        {
            if (this.IsVisible || this.IsHidden)
            {
                throw new InvalidOperationException();
            }
            bool flag  = (strategy & AnchorableShowStrategy.Most) == AnchorableShowStrategy.Most;
            bool flag1 = (strategy & AnchorableShowStrategy.Left) == AnchorableShowStrategy.Left;
            bool flag2 = (strategy & AnchorableShowStrategy.Right) == AnchorableShowStrategy.Right;
            bool flag3 = (strategy & AnchorableShowStrategy.Top) == AnchorableShowStrategy.Top;
            bool flag4 = (strategy & AnchorableShowStrategy.Bottom) == AnchorableShowStrategy.Bottom;

            if (!flag)
            {
                AnchorSide anchorSide = AnchorSide.Left;
                if (flag1)
                {
                    anchorSide = AnchorSide.Left;
                }
                if (flag2)
                {
                    anchorSide = AnchorSide.Right;
                }
                if (flag3)
                {
                    anchorSide = AnchorSide.Top;
                }
                if (flag4)
                {
                    anchorSide = AnchorSide.Bottom;
                }
                LayoutAnchorablePane layoutAnchorablePane = manager.Layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault <LayoutAnchorablePane>((LayoutAnchorablePane p) => p.GetSide() == anchorSide);
                if (layoutAnchorablePane == null)
                {
                    flag = true;
                }
                else
                {
                    layoutAnchorablePane.Children.Add(this);
                }
            }
            if (flag)
            {
                if (manager.Layout.RootPanel == null)
                {
                    manager.Layout.RootPanel = new LayoutPanel()
                    {
                        Orientation = (flag1 | flag2 ? Orientation.Horizontal : Orientation.Vertical)
                    };
                }
                if (flag1 | flag2)
                {
                    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;
                    if (!flag1)
                    {
                        manager.Layout.RootPanel.Children.Add(new LayoutAnchorablePane(this));
                        return;
                    }
                    manager.Layout.RootPanel.Children.Insert(0, new LayoutAnchorablePane(this));
                    return;
                }
                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;
                if (flag3)
                {
                    manager.Layout.RootPanel.Children.Insert(0, new LayoutAnchorablePane(this));
                    return;
                }
                manager.Layout.RootPanel.Children.Add(new LayoutAnchorablePane(this));
            }
        }