コード例 #1
0
        /// <summary>
        /// Reads the panel data from the window save list.
        /// </summary>
        /// <param name="reader">The <see cref="XmlReader"/> object that reads from the source stream.</param>
        internal void ReadXml(XmlReader reader)
        {
            try
            {
                string s;

                switch (reader.GetAttribute("dock"))
                {
                case "Fill":
                    this.Dock = DockStyle.Fill;
                    break;

                case "Top":
                    this.Dock = DockStyle.Top;
                    break;

                case "Bottom":
                    this.Dock = DockStyle.Bottom;
                    break;

                case "Left":
                    this.Dock = DockStyle.Left;
                    break;

                case "Right":
                    this.Dock = DockStyle.Right;
                    break;

                default:
                    return;
                }

                s = reader.GetAttribute("width");
                if (s != null)
                {
                    this.Width = int.Parse(s);
                }

                s = reader.GetAttribute("height");
                if (s != null)
                {
                    this.Height = int.Parse(s);
                }

                s = reader.GetAttribute("type");
                if (s == null)
                {
                    return;
                }

                Type type = Type.GetType(s, true);

                if (type == null)
                {
                    return;
                }

                ConstructorInfo info = type.GetConstructor(Type.EmptyTypes);

                if (info == null)
                {
                    return;
                }

                DockWindow wnd = info.Invoke(new object[0]) as DockWindow;
                wnd.ControlContainer = this;
                this.form            = wnd;
                wnd.CreateContainer();
                wnd.ReadXml(reader);
            }
            catch (Exception ex)
            {
                Console.WriteLine("DockPanel.ReadXml: " + ex.Message);
            }
        }