Пример #1
0
        private void ResizeThumb_DragStarted(object sender, DragStartedEventArgs e)
        {
            this.designerItem = this.DataContext as MyBaseControl;

            if (this.designerItem != null)
            {
                this.canvas = VisualTreeHelper.GetParent(this.designerItem) as Canvas;

                if (this.canvas != null)
                {
                    this.transformOrigin = this.designerItem.RenderTransformOrigin;

                    this.rotateTransform = this.designerItem.RenderTransform as RotateTransform;
                    if (this.rotateTransform != null)
                    {
                        this.angle = this.rotateTransform.Angle * Math.PI / 180.0;
                    }
                    else
                    {
                        this.angle = 0.0d;
                    }

                    AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this.canvas);
                    if (adornerLayer != null)
                    {
                        this.adorner = new SizeAdorner(this.designerItem);
                        adornerLayer.Add(this.adorner);
                    }
                }
            }
        }
Пример #2
0
        public static void setControlSource(MyBaseControl currentControl, String content)
        {
            string tag = currentControl.Tag as string;

            switch (tag)
            {
            case "Text":
                MyText myText = currentControl as MyText;
                myText.setContentSource(content);
                break;

            case "Image":
                MyImage myImage = currentControl as MyImage;
                myImage.setContentSource(content);
                break;

            case "Media":
                MyMedia myMedia = currentControl as MyMedia;
                myMedia.setContentSource(content);
                break;

            case "Office":
                MyOffice myOffice = currentControl as MyOffice;
                myOffice.setContentSource(content);
                break;
            }
        }
Пример #3
0
        public static void SetAttrTree(MyBaseControl myBaseControl, MainWindow window)
        {
            window.currentControl = myBaseControl;
            string tag = myBaseControl.Tag as string;

            window.ControlAttrTree.Visibility = System.Windows.Visibility.Visible;
            switch (tag)
            {
            case "Text":
                MyText myText = myBaseControl as MyText;
                showTextAttrGird(myText, window);
                break;

            case "Image":
                MyImage myImage = myBaseControl as MyImage;
                showImageAttrGrid(myImage, window);
                break;

            case "Media":
                MyMedia myMedia = myBaseControl as MyMedia;
                showMediaAttrGrid(myMedia, window);
                break;

            case "Office":
                MyOffice myOffice = myBaseControl as MyOffice;
                showOfficeAttrGrid(myOffice, window);
                break;
            }
        }
Пример #4
0
        public static void setLayoutAttrbute(object sender, MyBaseControl currentControl)
        {
            if (currentControl == null)
            {
                return;
            }
            TextBox txb = sender as TextBox;

            if (!txb.IsFocused)
            {
                return;
            }
            string tag = txb.Tag as string;

            switch (tag)
            {
            case "ControlHeight":
                String height = txb.Text;
                if (height == "")
                {
                    break;
                }
                currentControl.Height = Convert.ToDouble(height);
                break;

            case "ControlWidth":
                String width = txb.Text;
                if (width == "")
                {
                    break;
                }
                ;
                currentControl.Width = Convert.ToDouble(width);
                break;
            }
            UpdateChildLayoutData(currentControl);
        }
Пример #5
0
        private static void appendChildToXml(XmlDocument doc, XmlNode element, MyContainer canvas, XmlNode sourceList)
        {
            string        appPath       = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            int           count         = canvas.Children.Count;
            MyBaseControl myBaseControl = null;
            LayoutData    layoutData    = null;

            for (int i = 0; i < count; i++)
            {
                myBaseControl = canvas.Children[i] as MyBaseControl;
                layoutData    = myBaseControl.layoutData;

                XmlNode      canvasElement = doc.CreateElement(layoutData.tag);
                XmlAttribute canvasTag     = doc.CreateAttribute("tag");
                canvasTag.Value = layoutData.tag;
                canvasElement.Attributes.Append(canvasTag);

                XmlAttribute canvasHeight = doc.CreateAttribute("height");
                canvasHeight.Value = layoutData.height.ToString();
                canvasElement.Attributes.Append(canvasHeight);

                XmlAttribute canvasWidth = doc.CreateAttribute("width");
                canvasWidth.Value = layoutData.width.ToString();
                canvasElement.Attributes.Append(canvasWidth);

                XmlAttribute canvasSourcePath = doc.CreateAttribute("sourcePath");
                canvasSourcePath.Value = copyFileToSourceFoler(layoutData.sourcePath, appPath);

                canvasElement.Attributes.Append(canvasSourcePath);

                XmlAttribute canvasRotateTransform = doc.CreateAttribute("rotateTransform");
                canvasRotateTransform.Value = layoutData.angle.ToString();
                canvasElement.Attributes.Append(canvasRotateTransform);

                XmlAttribute canvasText = doc.CreateAttribute("text");
                canvasText.Value = layoutData.text;
                canvasElement.Attributes.Append(canvasText);

                XmlAttribute canvasLeft = doc.CreateAttribute("canvasLeft");
                canvasLeft.Value = layoutData.canvasLeft.ToString();
                canvasElement.Attributes.Append(canvasLeft);

                XmlAttribute canvasTop = doc.CreateAttribute("canvasTop");
                canvasTop.Value = layoutData.canvasTop.ToString();
                canvasElement.Attributes.Append(canvasTop);

                XmlAttribute imageSwitch = doc.CreateAttribute("imageSwitch");
                imageSwitch.Value = layoutData.imageSwitch.ToString();
                canvasElement.Attributes.Append(imageSwitch);

                XmlAttribute stretchModel = doc.CreateAttribute("stretchModel");
                stretchModel.Value = layoutData.stretchModel.ToString();
                canvasElement.Attributes.Append(stretchModel);

                XmlAttribute sceneTime = doc.CreateAttribute("sceneTime");
                sceneTime.Value = layoutData.sceneTime.ToString();
                canvasElement.Attributes.Append(sceneTime);

                XmlAttribute backgroundColor = doc.CreateAttribute("backgroundColor");
                backgroundColor.Value = layoutData.backgroundColor.ToString();
                canvasElement.Attributes.Append(backgroundColor);

                XmlAttribute textSize = doc.CreateAttribute("textSize");
                textSize.Value = layoutData.textSize.ToString();
                canvasElement.Attributes.Append(textSize);

                XmlAttribute textColor = doc.CreateAttribute("textColor");
                textColor.Value = layoutData.textColor.ToString();
                canvasElement.Attributes.Append(textColor);

                XmlAttribute textBackground = doc.CreateAttribute("textBackground");
                textBackground.Value = layoutData.textBackground.ToString();
                canvasElement.Attributes.Append(textBackground);

                XmlNode sourceElement = doc.CreateElement("sourceElement");
                sourceElement.InnerText = canvasSourcePath.Value;
                sourceList.AppendChild(sourceElement);
                element.AppendChild(canvasElement);
            }
        }