예제 #1
0
        public override object Clone()
        {
            var ctl = new wQRCoder();

            ctl.Name       = Name;
            ctl.Rectangle  = Rectangle;
            ctl.Level      = Level;
            ctl.Text       = Text;
            ctl.ShowBorder = ShowBorder;
            ctl.Parent     = Parent;
            return(ctl);
        }
예제 #2
0
        public void Init(System.Xml.XmlDocument doc)
        {
            Controls.Clear();
            var layout = doc.SelectSingleNode("/layout");

            if (layout == null)
            {
                throw new Exception("无效参数");
            }
            if (layout.Attributes["version"].Value != version)
            {
                throw new Exception("文件版本不一致");
            }
            var author = layout.SelectSingleNode("property/author");

            this.Author = author.Attributes["name"].Value;

            var canvas = layout.SelectSingleNode("property/canvas");

            this.SizeF = new SizeF(float.Parse(canvas.Attributes["width"].Value), float.Parse(canvas.Attributes["height"].Value));

            var background = layout.SelectSingleNode("property/background");

            if (background != null)
            {
                this.BackgroundRect = new Rectangle(
                    int.Parse(background.Attributes["left"].Value),
                    int.Parse(background.Attributes["top"].Value),
                    int.Parse(background.Attributes["width"].Value),
                    int.Parse(background.Attributes["height"].Value)
                    );
                this.BackgroundPath = background.Attributes["src"].Value;
                this.ShowBackground = bool.Parse(background.Attributes["visible"].Value);
            }
            else
            {
                this.BackgroundPath = string.Empty;
            }

            var datetime = layout.SelectSingleNode("property/datetime");

            this.CreateTime = DateTime.Parse(datetime.Attributes["createtime"].Value);

            var items = layout.SelectSingleNode("items");

            foreach (System.Xml.XmlNode item in items.ChildNodes)
            {
                Controls.wControl ctl = null;
                switch (item.Name)
                {
                case "label":
                    ctl = new Controls.wLabel(item);
                    break;

                case "image":
                    ctl = new Controls.wImage(item);
                    break;

                case "barcode":
                    ctl = new Controls.wBarcode(item);
                    break;

                case "qrcoder":
                    ctl = new Controls.wQRCoder(item);
                    break;

                case "table":
                    ctl = new Controls.wTable(item);
                    break;
                }
                if (ctl != null)
                {
                    this.Controls.Add(ctl);
                }
            }
            SelectControl = null;
            Refresh();
        }