예제 #1
0
 BaseInfo ConvertLayoutElement(ILayoutElement e)
 {
     if (e is LayoutPanel)
     {
         var panel = e as LayoutPanel;
         var sp    = new LayoutPanelInfo
         {
             Width = new GridLengthInfo {
                 Unit = panel.DockWidth.GridUnitType, Value = panel.DockWidth.Value
             },
             Height = new GridLengthInfo {
                 Unit = panel.DockHeight.GridUnitType, Value = panel.DockHeight.Value
             }
         };
         foreach (var x in panel.Children)
         {
             sp.Children.Add(ConvertLayoutElement(x));
         }
         return(sp);
     }
     else if (e is LayoutRoot)
     {
         var root = e as LayoutRoot;
         var sp   = new LayoutRootInfo {
             Center = (LayoutPanelInfo)ConvertLayoutElement(root.RootPanel)
         };
         return(sp);
     }
     else if (e is LayoutDocumentPane)
     {
         var doc = e as LayoutDocumentPane;
         var sp  = new DocumentPaneInfo
         {
             Width = new GridLengthInfo {
                 Unit = doc.DockWidth.GridUnitType, Value = doc.DockWidth.Value
             },
             Height = new GridLengthInfo {
                 Unit = doc.DockHeight.GridUnitType, Value = doc.DockHeight.Value
             }
         };
         sp.Content.AddRange(ConvertViews(doc.Children));
         return(sp);
     }
     else if (e is LayoutDocumentPaneGroup)
     {
         var doc = e as LayoutDocumentPaneGroup;
         var sp  = new LayoutDocumentPaneGroupInfo
         {
             Width = new GridLengthInfo {
                 Unit = doc.DockWidth.GridUnitType, Value = doc.DockWidth.Value
             },
             Height = new GridLengthInfo {
                 Unit = doc.DockHeight.GridUnitType, Value = doc.DockHeight.Value
             },
             Orientation = doc.Orientation
         };
         foreach (var x in doc.Children)
         {
             sp.Children.Add(ConvertLayoutElement(x));
         }
         return(sp);
     }
     else
     {
         throw new NotSupportedException();
     }
 }
예제 #2
0
 BaseInfo ConvertLayoutElement(ILayoutElement e)
 {
     if (e is LayoutPanel)
     {
         var panel = e as LayoutPanel;
         var sp = new LayoutPanelInfo
         {
             Width = new GridLengthInfo {Unit = panel.DockWidth.GridUnitType, Value = panel.DockWidth.Value},
             Height = new GridLengthInfo {Unit = panel.DockHeight.GridUnitType, Value = panel.DockHeight.Value}
         };
         foreach (var x in panel.Children)
         {
             sp.Children.Add(ConvertLayoutElement(x));
         }
         return sp;
     }
     else if (e is LayoutRoot)
     {
         var root = e as LayoutRoot;
         var sp = new LayoutRootInfo {Center = (LayoutPanelInfo) ConvertLayoutElement(root.RootPanel)};
         return sp;
     }
     else if (e is LayoutDocumentPane)
     {
         var doc = e as LayoutDocumentPane;
         var sp = new DocumentPaneInfo
         {
             Width = new GridLengthInfo {Unit = doc.DockWidth.GridUnitType, Value = doc.DockWidth.Value},
             Height = new GridLengthInfo {Unit = doc.DockHeight.GridUnitType, Value = doc.DockHeight.Value}
         };
         sp.Content.AddRange(ConvertViews(doc.Children));
         return sp;
     }
     else if (e is LayoutDocumentPaneGroup)
     {
         var doc = e as LayoutDocumentPaneGroup;
         var sp = new LayoutDocumentPaneGroupInfo
         {
             Width = new GridLengthInfo {Unit = doc.DockWidth.GridUnitType, Value = doc.DockWidth.Value},
             Height = new GridLengthInfo {Unit = doc.DockHeight.GridUnitType, Value = doc.DockHeight.Value},
             Orientation = doc.Orientation
         };
         foreach (var x in doc.Children)
         {
             sp.Children.Add(ConvertLayoutElement(x));
         }
         return sp;
     }
     else
         throw new NotSupportedException();
 }