public static void UpdateChildLayoutData(ContentControl item) { switch (item.Tag as string) { case "Text": MyText myText = item as MyText; myText.updateLayoutDate(); break; case "Image": MyImage myImage = item as MyImage; myImage.updateLayoutDate(); break; case "Media": MyMedia myMedia = item as MyMedia; myMedia.updateLayoutDate(); break; case "Office": MyOffice myOffice = item as MyOffice; myOffice.updateLayoutDate(); break; } }
public static void CreateControlByTag(string tag, DragEventArgs e, MyContainer canvas, MainWindow mWindow) { Point position = e.GetPosition(canvas); //MyContainer canvas = new MyContainer(); switch (tag) { case "Text": MyText myText = new MyText(); Canvas.SetLeft(myText, Math.Max(0, position.X - myText.Width / 2)); Canvas.SetTop(myText, Math.Max(0, position.Y - myText.Height / 2)); canvas.Children.Add(myText); myText.updateLayoutDate(); AttributeLayout.SetAttrTree(myText, mWindow); break; case "Media": MyMedia myMedia = new MyMedia(); Canvas.SetLeft(myMedia, Math.Max(0, position.X - myMedia.Width / 2)); Canvas.SetTop(myMedia, Math.Max(0, position.Y - myMedia.Height / 2)); canvas.Children.Add(myMedia); myMedia.updateLayoutDate(); AttributeLayout.SetAttrTree(myMedia, mWindow); break; case "Image": MyImage myImage = new MyImage(); Canvas.SetLeft(myImage, Math.Max(0, position.X - myImage.Width / 2)); Canvas.SetTop(myImage, Math.Max(0, position.Y - myImage.Height / 2)); canvas.Children.Add(myImage); myImage.updateLayoutDate(); AttributeLayout.SetAttrTree(myImage, mWindow); break; case "Word": MyOffice myOffice = new MyOffice(); Canvas.SetLeft(myOffice, Math.Max(0, position.X - myOffice.Width / 2)); Canvas.SetTop(myOffice, Math.Max(0, position.Y - myOffice.Height / 2)); canvas.Children.Add(myOffice); myOffice.updateLayoutDate(); AttributeLayout.SetAttrTree(myOffice, mWindow); break; } //return canvas; }