Пример #1
0
        public Boolean BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer)
        {
            if (anchorableToShow.Content is IMesTool tool)
            {
                MesPaneLocation      preferredLocation = tool.PreferredLocation;
                String               paneName          = GetPaneName(preferredLocation);
                LayoutAnchorablePane toolsPane         = layout.Descendents().OfType <LayoutAnchorablePane>().FirstOrDefault(d => d.Name == paneName);
                if (toolsPane == null)
                {
                    switch (preferredLocation)
                    {
                    case MesPaneLocation.Left:
                        toolsPane = CreateAnchorablePane(layout, Orientation.Horizontal, paneName, InsertPosition.Start);
                        break;

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

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

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

            return(false);
        }
Пример #2
0
        private static String GetPaneName(MesPaneLocation location)
        {
            switch (location)
            {
            case MesPaneLocation.Left:
                return("LeftPane");

            case MesPaneLocation.Right:
                return("RightPane");

            case MesPaneLocation.Bottom:
                return("BottomPane");

            default:
                throw new ArgumentOutOfRangeException("location");
            }
        }