private static void createChild(XmlNode canvas, MyContainer myContainer) { int count = canvas.ChildNodes.Count; for (int i = 0; i < count; i++) { LayoutData layoutData = new LayoutData(); XmlNode element = canvas.ChildNodes.Item(i); layoutData.textBackground = Convert.ToInt32(element.Attributes[14].Value); layoutData.textColor = Convert.ToInt32(element.Attributes[13].Value); layoutData.textSize = Convert.ToInt32(element.Attributes[12].Value); layoutData.backgroundColor = Convert.ToInt32(element.Attributes[11].Value); layoutData.sceneTime = Convert.ToInt32(element.Attributes[10].Value); layoutData.stretchModel = Convert.ToInt32(element.Attributes[9].Value); layoutData.imageSwitch = Convert.ToInt32(element.Attributes[8].Value); layoutData.canvasTop = double.Parse(element.Attributes[7].Value); layoutData.canvasLeft = double.Parse(element.Attributes[6].Value); layoutData.text = element.Attributes[5].Value; layoutData.angle = double.Parse(element.Attributes[4].Value); layoutData.sourcePath = element.Attributes[3].Value; layoutData.width = double.Parse(element.Attributes[2].Value); layoutData.height = double.Parse(element.Attributes[1].Value); layoutData.tag = element.Attributes[0].Value; switch (layoutData.tag) { case "Text": MyText myText = new MyText(); myText.initLayout(layoutData); myContainer.Children.Add(myText); break; case "Media": MyMedia myMedia = new MyMedia(); myMedia.initLayout(layoutData); myContainer.Children.Add(myMedia); break; case "Image": MyImage myImage = new MyImage(); myImage.initLayout(layoutData); myContainer.Children.Add(myImage); break; case "Office": MyOffice myOffice = new MyOffice(); myOffice.initLayout(layoutData); myContainer.Children.Add(myOffice); break; } layoutData = null; } }
public static MyContainer previewCanvasContent(MyContainer myContainer) { MyContainer previewCanvas = new MyContainer(); previewCanvas.initLayout(myContainer.layoutData); int count = myContainer.Children.Count; for (int i = 0; i < count; i++) { ContentControl temp = myContainer.Children[i] as ContentControl; switch (temp.Tag as string) { case "Text": MyText text = new MyText(); MyText tempText = (MyText)temp; text.Tag = "preview"; text.initLayout(tempText.layoutData); previewCanvas.Children.Add(text); //AttributeLayout.SetAttrTree(tag, this); break; case "Image": MyImage image = new MyImage(); MyImage tempImage = (MyImage)temp; image.Tag = "preview"; image.initLayout(tempImage.layoutData); previewCanvas.Children.Add(image); //AttributeLayout.SetAttrTree(tag, this); break; case "Media": MyMedia media = new MyMedia(); MyMedia tempMedia = (MyMedia)temp; media.Tag = "preview"; media.initLayout(tempMedia.layoutData); previewCanvas.Children.Add(media); //AttributeLayout.SetAttrTree(tag, this); break; case "Office": MyOffice myOffice = new MyOffice(); MyOffice tempOffice = (MyOffice)temp; myOffice.Tag = "preview"; myOffice.initLayout(tempOffice.layoutData); previewCanvas.Children.Add(myOffice); //AttributeLayout.SetAttrTree(tag, this); break; } } return(previewCanvas); }