コード例 #1
0
        private void AddViews(List <UserControl> views, List <FrameworkElement> list_N, DelegateCreateDockPane createDockPane)
        {
            List <FrameworkElement> list_N_plus_1 = new List <FrameworkElement>();
            bool isHorizontal = false;
            int  viewIndex    = 1;

            while (viewIndex < views.Count)
            {
                for (int i = 0; (i < list_N.Count) && (viewIndex < views.Count); ++i)
                {
                    SplitterPane splitterPane = ILayoutFactory.MakeSplitterPane(isHorizontal);

                    var node = list_N[i];
                    System.Windows.Markup.IAddChild parentElement = (System.Windows.Markup.IAddChild)node.Parent;
                    (node.Parent as Grid).Children.Remove(node);

                    parentElement.AddChild(splitterPane);
                    Grid.SetRow(splitterPane, Grid.GetRow(node));
                    Grid.SetColumn(splitterPane, Grid.GetColumn(node));

                    splitterPane.AddChild(node, true);

                    list_N_plus_1.Add(node);

                    node = views[viewIndex];
                    DockPane dockPane = createDockPane();
                    dockPane.IViewContainer.AddUserControl(node as UserControl);

                    list_N_plus_1.Add(dockPane);

                    splitterPane.AddChild(dockPane, false);

                    ++viewIndex;
                }

                isHorizontal  = !isHorizontal;
                list_N        = list_N_plus_1;
                list_N_plus_1 = new List <FrameworkElement>();
            }
        }
コード例 #2
0
        private void startcamera(Window w) //初始化相机动画
        {
            w.Width  = 300;
            w.Height = 100;
            w.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            w.ResizeMode            = ResizeMode.NoResize;
            w.WindowStyle           = WindowStyle.None;
            var bc = new BrushConverter();

            w.Background = (Brush)bc.ConvertFrom("#8B5F65");
            System.Windows.Controls.Label BT = new System.Windows.Controls.Label();
            BT.Content    = "正在初始化相机,请稍后.......................";
            BT.Foreground = Brushes.White;
            BT.FontSize   = 15; BT.FontWeight = FontWeights.Bold;
            BT.Margin     = new Thickness(0, 30, 0, 0);

            System.Windows.Controls.Grid    panel     = new System.Windows.Controls.Grid();
            System.Windows.Markup.IAddChild container = panel;
            container.AddChild(BT);
            container = w;
            container.AddChild(panel);
            w.Show();
        }
コード例 #3
0
ファイル: LayoutReader.cs プロジェクト: dbinev/WpfDockManager
        public static void LoadNode(ILayoutFactory iLayoutFactory, Dictionary <string, UserControl> viewsMap, FrameworkElement rootFrameworkElement, FrameworkElement parentFrameworkElement, XmlNode xmlParentElement, bool isParentHorizontal)
        {
            int row             = 0;
            int rowIncrement    = isParentHorizontal ? 2 : 0;
            int column          = 0;
            int columnIncrement = isParentHorizontal ? 0 : 2;

            foreach (var xmlChildNode in xmlParentElement.ChildNodes)
            {
                if (xmlChildNode is XmlElement)
                {
                    if ((xmlChildNode as XmlElement).Name == "SplitterPane")
                    {
                        XmlElement xmlSplitterPane = xmlChildNode as XmlElement;

                        XmlAttribute xmlAttribute = xmlSplitterPane.Attributes.GetNamedItem("Orientation") as XmlAttribute;

                        System.Diagnostics.Trace.Assert(xmlAttribute != null, "SplitterPane element does not have an orientation attribute");

                        bool isChildHorizontal = xmlAttribute.Value == "Horizontal";

                        SplitterPane newGrid = iLayoutFactory.MakeSplitterPane(isChildHorizontal);
                        newGrid.Tag = GetGuid(xmlSplitterPane);

                        if (parentFrameworkElement == rootFrameworkElement)
                        {
                            iLayoutFactory.SetRootPane(newGrid, out row, out column);
                        }
                        else
                        {
                            System.Windows.Markup.IAddChild parentElement = (System.Windows.Markup.IAddChild)parentFrameworkElement;
                            parentElement.AddChild(newGrid);
                            Grid.SetRow(newGrid, row);
                            Grid.SetColumn(newGrid, column);
                        }
                        SetWidthOrHeight(xmlSplitterPane, parentFrameworkElement, isParentHorizontal, row, column);

                        row    += rowIncrement;
                        column += columnIncrement;

                        LoadNode(iLayoutFactory, viewsMap, rootFrameworkElement, newGrid, xmlSplitterPane, isChildHorizontal);
                    }
                    else if ((xmlChildNode as XmlElement).Name == "DocumentPanel")
                    {
                        DocumentPanel documentPanel = iLayoutFactory.MakeDocumentPanel();

                        if (parentFrameworkElement == rootFrameworkElement)
                        {
                            iLayoutFactory.SetRootPane(documentPanel, out row, out column);
                        }
                        else
                        {
                            System.Windows.Markup.IAddChild parentElement = (System.Windows.Markup.IAddChild)parentFrameworkElement;
                            parentElement.AddChild(documentPanel);
                            Grid.SetRow(documentPanel, row);
                            Grid.SetColumn(documentPanel, column);
                        }

                        XmlElement xmlDocumentPanel = xmlChildNode as XmlElement;
                        SetWidthOrHeight(xmlDocumentPanel, parentFrameworkElement, isParentHorizontal, row, column);

                        row    += rowIncrement;
                        column += columnIncrement;

                        LoadNode(iLayoutFactory, viewsMap, rootFrameworkElement, documentPanel, xmlDocumentPanel, true);
                    }
                    else if ((xmlChildNode as XmlElement).Name == "DocumentPaneGroup")
                    {
                        DocumentPaneGroup documentPaneGroup = iLayoutFactory.MakeDocumentPaneGroup();

                        System.Windows.Markup.IAddChild parentElement = (System.Windows.Markup.IAddChild)parentFrameworkElement;
                        parentElement.AddChild(documentPaneGroup);

                        XmlElement xmlDocumentGroup = xmlChildNode as XmlElement;

                        documentPaneGroup.Tag = GetGuid(xmlDocumentGroup);;
                        SetWidthOrHeight(xmlDocumentGroup, parentFrameworkElement, isParentHorizontal, row, column);

                        LoadDocuments(iLayoutFactory, viewsMap, xmlDocumentGroup, documentPaneGroup.IViewContainer);
                        Grid.SetRow(documentPaneGroup, row);
                        Grid.SetColumn(documentPaneGroup, column);
                        row    += rowIncrement;
                        column += columnIncrement;
                    }
                    else if ((xmlChildNode as XmlElement).Name == "ToolPaneGroup")
                    {
                        ToolPaneGroup toolPaneGroup = iLayoutFactory.MakeToolPaneGroup();

                        System.Windows.Markup.IAddChild parentElement = (System.Windows.Markup.IAddChild)parentFrameworkElement;
                        parentElement.AddChild(toolPaneGroup);

                        XmlElement xmlToolPaneGroup = xmlChildNode as XmlElement;

                        toolPaneGroup.Tag = GetGuid(xmlToolPaneGroup);
                        SetWidthOrHeight(xmlToolPaneGroup, parentFrameworkElement, isParentHorizontal, row, column);

                        LoadTools(viewsMap, xmlToolPaneGroup, toolPaneGroup.IViewContainer);
                        Grid.SetRow(toolPaneGroup, row);
                        Grid.SetColumn(toolPaneGroup, column);
                        row    += rowIncrement;
                        column += columnIncrement;
                    }
                    else if ((xmlChildNode as XmlElement).Name == "FloatingToolPaneGroup")
                    {
                        FloatingToolPaneGroup floatingToolPaneGroup = iLayoutFactory.MakeFloatingToolPaneGroup();
                        XmlElement            xmlfloatingTool       = xmlChildNode as XmlElement;
                        floatingToolPaneGroup.Tag = GetGuid(xmlfloatingTool);
                        SetLocationAndSize(xmlfloatingTool, floatingToolPaneGroup);
                        LoadTools(viewsMap, xmlfloatingTool, floatingToolPaneGroup.IViewContainer);
                    }
                    else if ((xmlChildNode as XmlElement).Name == "FloatingDocumentPaneGroup")
                    {
                        FloatingDocumentPaneGroup floatingDocumentPaneGroup = iLayoutFactory.MakeFloatingDocumentPaneGroup();
                        XmlElement xmlfloatingDocument = xmlChildNode as XmlElement;
                        floatingDocumentPaneGroup.Tag = GetGuid(xmlfloatingDocument);
                        SetLocationAndSize(xmlfloatingDocument, floatingDocumentPaneGroup);
                        LoadDocuments(iLayoutFactory, viewsMap, xmlfloatingDocument, floatingDocumentPaneGroup.IViewContainer);
                    }
                    else if ((xmlChildNode as XmlElement).Name == "LeftSide")
                    {
                        XmlElement xmlLeftSide = xmlChildNode as XmlElement;
                        LoadUnPinnedToolDataNodes(iLayoutFactory, viewsMap, WindowLocation.LeftSide, xmlLeftSide);
                    }
                    else if ((xmlChildNode as XmlElement).Name == "TopSide")
                    {
                        XmlElement xmlTopSide = xmlChildNode as XmlElement;
                        LoadUnPinnedToolDataNodes(iLayoutFactory, viewsMap, WindowLocation.TopSide, xmlTopSide);
                    }
                    else if ((xmlChildNode as XmlElement).Name == "RightSide")
                    {
                        XmlElement xmlRightSide = xmlChildNode as XmlElement;
                        LoadUnPinnedToolDataNodes(iLayoutFactory, viewsMap, WindowLocation.RightSide, xmlRightSide);
                    }
                    else if ((xmlChildNode as XmlElement).Name == "BottomSide")
                    {
                        XmlElement xmlBottomSide = xmlChildNode as XmlElement;
                        LoadUnPinnedToolDataNodes(iLayoutFactory, viewsMap, WindowLocation.BottomSide, xmlBottomSide);
                    }
                }

                if (parentFrameworkElement != rootFrameworkElement)
                {
                    if ((row > 2) || (column > 2))
                    {
                        // we can only have two child elements (plus a splitter) in each grid
                        break;
                    }
                }
            }
        }