Beispiel #1
0
        public RawLayout(StructField[] fields, CreateControlDelegate createControlDelegate)
        {
            this.AutoScroll = true;
            this.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
            this.Dock = System.Windows.Forms.DockStyle.Fill;

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            foreach (StructField item in fields)
            {
                System.Windows.Forms.Label lbl = new UI.LynnLabel();
                lbl.Text = string.Format("{0} {1}", item.ID, item.Name);
                lbl.Width = 200;
                this.Controls.Add(lbl);

                System.Xml.XmlElement node = doc.CreateElement("Control");
                node.SetAttribute("ID", item.ID);
                node.SetAttribute("Editor", EditorFactory.CreateFromDefaultValue(item.DefaultValue));

                System.Windows.Forms.Control con = createControlDelegate(node);
                con.Width = 200;
                this.Controls.Add(con);
            }
        }
Beispiel #2
0
        public RawLayout(StructField[] fields, CreateControlDelegate createControlDelegate)
        {
            this.AutoScroll    = true;
            this.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
            this.Dock          = System.Windows.Forms.DockStyle.Fill;

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            foreach (StructField item in fields)
            {
                System.Windows.Forms.Label lbl = new UI.LynnLabel();
                lbl.Text  = string.Format("{0} {1}", item.ID, item.Name);
                lbl.Width = 200;
                this.Controls.Add(lbl);

                System.Xml.XmlElement node = doc.CreateElement("Control");
                node.SetAttribute("ID", item.ID);
                node.SetAttribute("Editor", EditorFactory.CreateFromDefaultValue(item.DefaultValue));

                System.Windows.Forms.Control con = createControlDelegate(node);
                con.Width = 200;
                this.Controls.Add(con);
            }
        }
Beispiel #3
0
        public TableLayout(System.Xml.XmlNode param, CreateControlDelegate createControlDelegate)
        {
            this.Margin = new System.Windows.Forms.Padding(0);
            this.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.None;
            this.Dock = System.Windows.Forms.DockStyle.Fill;
            this.RowCount = Int32.Parse(param.Attributes["RowCount"].Value);
            this.ColumnCount = Int32.Parse(param.Attributes["ColumnCount"].Value);
            this.AutoScroll = true;

            for (int i = 0; i < this.RowCount; i++)
                this.RowStyles.Add(new System.Windows.Forms.RowStyle());

            for (int i = 0; i < this.ColumnCount; i++)
                this.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());

            foreach (System.Xml.XmlNode item in param.ChildNodes)
            {
                if (item.Name != "TableCell") continue;
                int x, y;
                x = Int32.Parse(item.Attributes["X"].Value);
                y = Int32.Parse(item.Attributes["Y"].Value);

                if (item.Attributes["Width"] != null)
                {
                    string str = item.Attributes["Width"].Value;

                    if (str.Contains("/"))
                    {
                        float up = float.Parse(str.Substring(0, str.IndexOf('/')));
                        float down = float.Parse(str.Substring(str.IndexOf('/') + 1));
                        this.ColumnStyles[x - 1].SizeType = System.Windows.Forms.SizeType.Percent;
                        this.ColumnStyles[x - 1].Width = up / down;
                    }
                    else
                    {
                        this.ColumnStyles[x - 1].SizeType = System.Windows.Forms.SizeType.Absolute;
                        this.ColumnStyles[x - 1].Width = Int32.Parse(str);
                    }
                }

                if (item.Attributes["Height"] != null)
                {
                    string str = item.Attributes["Height"].Value;
                    if (str.StartsWith("1/"))
                    {
                        this.RowStyles[y - 1].SizeType = System.Windows.Forms.SizeType.Percent;
                        this.RowStyles[y - 1].Height = 1.0f / Int32.Parse(str.Substring(2));
                    }
                    else
                    {
                        this.RowStyles[y - 1].SizeType = System.Windows.Forms.SizeType.Absolute;
                        this.RowStyles[y - 1].Height = Int32.Parse(str);
                    }
                }

                System.Windows.Forms.Control con = null;
                if (item.FirstChild is System.Xml.XmlText)
                {
                    con = new UI.LynnLabel();
                    con.Text = item.FirstChild.Value;
                }
                else if (item.FirstChild.Name == "Control" || item.FirstChild.Name == "Layout")
                {
                    con = createControlDelegate(item.FirstChild);
                }

                if (con != null)
                {
                    //con.Margin = new System.Windows.Forms.Padding(5);
                    con.Dock = System.Windows.Forms.DockStyle.Fill;
                    this.Controls.Add(con, x - 1, y - 1);

                    if (item.Attributes["ColumnSpan"] != null)
                    {
                        this.SetColumnSpan(con, Int32.Parse(item.Attributes["ColumnSpan"].Value));
                    }

                    if (item.Attributes["RowSpan"] != null)
                    {
                        this.SetRowSpan(con, Int32.Parse(item.Attributes["RowSpan"].Value));
                    }
                }
            }
        }
Beispiel #4
0
        public TableLayout(System.Xml.XmlNode param, CreateControlDelegate createControlDelegate)
        {
            this.Margin          = new System.Windows.Forms.Padding(0);
            this.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.None;
            this.Dock            = System.Windows.Forms.DockStyle.Fill;
            this.RowCount        = Int32.Parse(param.Attributes["RowCount"].Value);
            this.ColumnCount     = Int32.Parse(param.Attributes["ColumnCount"].Value);
            this.AutoScroll      = true;

            for (int i = 0; i < this.RowCount; i++)
            {
                this.RowStyles.Add(new System.Windows.Forms.RowStyle());
            }

            for (int i = 0; i < this.ColumnCount; i++)
            {
                this.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
            }

            foreach (System.Xml.XmlNode item in param.ChildNodes)
            {
                if (item.Name != "TableCell")
                {
                    continue;
                }
                int x, y;
                x = Int32.Parse(item.Attributes["X"].Value);
                y = Int32.Parse(item.Attributes["Y"].Value);

                if (item.Attributes["Width"] != null)
                {
                    string str = item.Attributes["Width"].Value;

                    if (str.Contains("/"))
                    {
                        float up   = float.Parse(str.Substring(0, str.IndexOf('/')));
                        float down = float.Parse(str.Substring(str.IndexOf('/') + 1));
                        this.ColumnStyles[x - 1].SizeType = System.Windows.Forms.SizeType.Percent;
                        this.ColumnStyles[x - 1].Width    = up / down;
                    }
                    else
                    {
                        this.ColumnStyles[x - 1].SizeType = System.Windows.Forms.SizeType.Absolute;
                        this.ColumnStyles[x - 1].Width    = Int32.Parse(str);
                    }
                }

                if (item.Attributes["Height"] != null)
                {
                    string str = item.Attributes["Height"].Value;
                    if (str.StartsWith("1/"))
                    {
                        this.RowStyles[y - 1].SizeType = System.Windows.Forms.SizeType.Percent;
                        this.RowStyles[y - 1].Height   = 1.0f / Int32.Parse(str.Substring(2));
                    }
                    else
                    {
                        this.RowStyles[y - 1].SizeType = System.Windows.Forms.SizeType.Absolute;
                        this.RowStyles[y - 1].Height   = Int32.Parse(str);
                    }
                }

                System.Windows.Forms.Control con = null;
                if (item.FirstChild is System.Xml.XmlText)
                {
                    con      = new UI.LynnLabel();
                    con.Text = item.FirstChild.Value;
                }
                else if (item.FirstChild.Name == "Control" || item.FirstChild.Name == "Layout")
                {
                    con = createControlDelegate(item.FirstChild);
                }

                if (con != null)
                {
                    //con.Margin = new System.Windows.Forms.Padding(5);
                    con.Dock = System.Windows.Forms.DockStyle.Fill;
                    this.Controls.Add(con, x - 1, y - 1);

                    if (item.Attributes["ColumnSpan"] != null)
                    {
                        this.SetColumnSpan(con, Int32.Parse(item.Attributes["ColumnSpan"].Value));
                    }

                    if (item.Attributes["RowSpan"] != null)
                    {
                        this.SetRowSpan(con, Int32.Parse(item.Attributes["RowSpan"].Value));
                    }
                }
            }
        }