コード例 #1
0
        /// <summary>
        /// Loads viewStyle from xml data.
        /// </summary>
        /// <param name="viewStyleXML">ViewStyle data.(This must be result of SaveToXml())</param>
        public void LoadFromXml(byte[] viewStyleXML)
        {
            try{
                MemoryStream strm = new MemoryStream(viewStyleXML);
                DataSet      ds   = new DataSet();
                ds.ReadXml(strm);
                strm.Close();

                DataRow dr = ds.Tables["ViewStyle"].Rows[0];

                if (dr.Table.Columns.Contains("BorderColor"))
                {
                    this.BorderColor = Color.FromArgb(Convert.ToInt32(dr["BorderColor"]));
                }
                if (dr.Table.Columns.Contains("BorderHotColor"))
                {
                    this.BorderHotColor = Color.FromArgb(Convert.ToInt32(dr["BorderHotColor"]));
                }
                if (dr.Table.Columns.Contains("ButtonColor"))
                {
                    this.ButtonColor = Color.FromArgb(Convert.ToInt32(dr["ButtonColor"]));
                }
                if (dr.Table.Columns.Contains("ButtonHotColor"))
                {
                    this.ButtonHotColor = Color.FromArgb(Convert.ToInt32(dr["ButtonHotColor"]));
                }
                if (dr.Table.Columns.Contains("ButtonPressedColor"))
                {
                    this.ButtonPressedColor = Color.FromArgb(Convert.ToInt32(dr["ButtonPressedColor"]));
                }
                if (dr.Table.Columns.Contains("ControlBackColor"))
                {
                    this.ControlBackColor = Color.FromArgb(Convert.ToInt32(dr["ControlBackColor"]));
                }
                if (dr.Table.Columns.Contains("EditColor"))
                {
                    this.EditColor = Color.FromArgb(Convert.ToInt32(dr["EditColor"]));
                }
                if (dr.Table.Columns.Contains("EditFocusedColor"))
                {
                    this.EditFocusedColor = Color.FromArgb(Convert.ToInt32(dr["EditFocusedColor"]));
                }
                if (dr.Table.Columns.Contains("EditReadOnlyColor"))
                {
                    this.EditReadOnlyColor = Color.FromArgb(Convert.ToInt32(dr["EditReadOnlyColor"]));
                }

                if (dr.Table.Columns.Contains("BarColor"))
                {
                    this.BarColor = Color.FromArgb(Convert.ToInt32(dr["BarColor"]));
                }
                if (dr.Table.Columns.Contains("BarHotColor"))
                {
                    this.BarHotColor = Color.FromArgb(Convert.ToInt32(dr["BarHotColor"]));
                }
                if (dr.Table.Columns.Contains("BarTextColor"))
                {
                    this.BarTextColor = Color.FromArgb(Convert.ToInt32(dr["BarTextColor"]));
                }
                if (dr.Table.Columns.Contains("BarHotTextColor"))
                {
                    this.BarHotTextColor = Color.FromArgb(Convert.ToInt32(dr["BarHotTextColor"]));
                }
                if (dr.Table.Columns.Contains("BarPressedColor"))
                {
                    this.BarPressedColor = Color.FromArgb(Convert.ToInt32(dr["BarPressedColor"]));
                }
                if (dr.Table.Columns.Contains("BarBorderColor"))
                {
                    this.BarBorderColor = Color.FromArgb(Convert.ToInt32(dr["BarBorderColor"]));
                }
                if (dr.Table.Columns.Contains("BarHotBorderColor"))
                {
                    this.BarHotBorderColor = Color.FromArgb(Convert.ToInt32(dr["BarHotBorderColor"]));
                }
                if (dr.Table.Columns.Contains("BarClientAreaColor"))
                {
                    this.BarClientAreaColor = Color.FromArgb(Convert.ToInt32(dr["BarClientAreaColor"]));
                }
                if (dr.Table.Columns.Contains("BarItemSelectedColor"))
                {
                    this.BarItemSelectedColor = Color.FromArgb(Convert.ToInt32(dr["BarItemSelectedColor"]));
                }
                if (dr.Table.Columns.Contains("BarItemSelectedTextColor"))
                {
                    this.BarItemSelectedTextColor = Color.FromArgb(Convert.ToInt32(dr["BarItemSelectedTextColor"]));
                }
                if (dr.Table.Columns.Contains("BarItemDisabledTextColor"))
                {
                    this.BarItemDisabledTextColor = Color.FromArgb(Convert.ToInt32(dr["BarItemDisabledTextColor"]));
                }
                if (dr.Table.Columns.Contains("BarItemHotColor"))
                {
                    this.BarItemHotColor = Color.FromArgb(Convert.ToInt32(dr["BarItemHotColor"]));
                }
                if (dr.Table.Columns.Contains("BarItemPressedColor"))
                {
                    this.BarItemPressedColor = Color.FromArgb(Convert.ToInt32(dr["BarItemPressedColor"]));
                }
                if (dr.Table.Columns.Contains("BarItemBorderHotColor"))
                {
                    this.BarItemBorderHotColor = Color.FromArgb(Convert.ToInt32(dr["BarItemBorderHotColor"]));
                }
                if (dr.Table.Columns.Contains("BarItemTextColor"))
                {
                    this.BarItemTextColor = Color.FromArgb(Convert.ToInt32(dr["BarItemTextColor"]));
                }
                if (dr.Table.Columns.Contains("BarItemHotTextColor"))
                {
                    this.BarItemHotTextColor = Color.FromArgb(Convert.ToInt32(dr["BarItemHotTextColor"]));
                }
                if (dr.Table.Columns.Contains("BarItemsStyle"))
                {
                    this.BarItemsStyle = (ItemsStyle)Convert.ToInt32(dr["BarItemsStyle"]);
                }
                if (dr.Table.Columns.Contains("FlashColor"))
                {
                    this.FlashColor = Color.FromArgb(Convert.ToInt32(dr["FlashColor"]));
                }
                if (dr.Table.Columns.Contains("TextColor"))
                {
                    this.TextColor = Color.FromArgb(Convert.ToInt32(dr["TextColor"]));
                }
                if (dr.Table.Columns.Contains("NegativeValueColor"))
                {
                    this.NegativeValueColor = Color.FromArgb(Convert.ToInt32(dr["NegativeValueColor"]));
                }

                if (dr.Table.Columns.Contains("GridCellsFont"))
                {
                    this.GridCellsFont = UI_Utils.ParseFont(dr["GridCellsFont"].ToString());
                }

                ds.Dispose();
            }
            catch (Exception x) {
                MessageBox.Show(x.Message);
                RestoreDefault();
            }
        }
コード例 #2
0
        /// <summary>
        /// Saves current viewStyle to xml.
        /// </summary>
        /// <returns>Returns byte xml data.</returns>
        public byte[] SaveToXml()
        {
            byte[] retVal = null;

            DataSet   ds = new DataSet("dsViewStyle");
            DataTable dt = ds.Tables.Add("ViewStyle");

            dt.Columns.Add("BorderColor", Type.GetType("System.String"));
            dt.Columns.Add("BorderHotColor", Type.GetType("System.String"));
            dt.Columns.Add("ButtonColor", Type.GetType("System.String"));
            dt.Columns.Add("ButtonHotColor", Type.GetType("System.String"));
            dt.Columns.Add("ButtonPressedColor", Type.GetType("System.String"));
            dt.Columns.Add("ControlBackColor", Type.GetType("System.String"));
            dt.Columns.Add("ControlForeColor", Type.GetType("System.String"));
            dt.Columns.Add("EditColor", Type.GetType("System.String"));
            dt.Columns.Add("EditFocusedColor", Type.GetType("System.String"));
            dt.Columns.Add("EditReadOnlyColor", Type.GetType("System.String"));
            //
            dt.Columns.Add("FlashColor", Type.GetType("System.String"));
            dt.Columns.Add("BarColor", Type.GetType("System.String"));
            dt.Columns.Add("BarHotColor", Type.GetType("System.String"));
            dt.Columns.Add("BarTextColor", Type.GetType("System.String"));
            dt.Columns.Add("BarHotTextColor", Type.GetType("System.String"));
            dt.Columns.Add("BarPressedColor", Type.GetType("System.String"));
            dt.Columns.Add("BarBorderColor", Type.GetType("System.String"));
            dt.Columns.Add("BarHotBorderColor", Type.GetType("System.String"));
            dt.Columns.Add("BarClientAreaColor", Type.GetType("System.String"));
            dt.Columns.Add("BarItemSelectedColor", Type.GetType("System.String"));
            dt.Columns.Add("BarItemSelectedTextColor", Type.GetType("System.String"));
            dt.Columns.Add("BarItemDisabledTextColor", Type.GetType("System.String"));
            dt.Columns.Add("BarItemSelectedBorder", Type.GetType("System.String"));
            dt.Columns.Add("BarItemHotColor", Type.GetType("System.String"));
            dt.Columns.Add("BarItemPressedColor", Type.GetType("System.String"));
            dt.Columns.Add("BarItemBorderHotColor", Type.GetType("System.String"));
            dt.Columns.Add("BarItemTextColor", Type.GetType("System.String"));
            dt.Columns.Add("BarItemHotTextColor", Type.GetType("System.String"));
            dt.Columns.Add("BarItemsStyle", Type.GetType("System.String"));
            dt.Columns.Add("TextColor", Type.GetType("System.String"));
            dt.Columns.Add("Text3DColor", Type.GetType("System.String"));
            dt.Columns.Add("TextShadowColor", Type.GetType("System.String"));
            //	dt.Columns.Add("TextStyle",Type.GetType("System.String"));
            dt.Columns.Add("NegativeValueColor", Type.GetType("System.String"));
            dt.Columns.Add("GridCellsFont", Type.GetType("System.String"));


            DataRow dr = dt.NewRow();

            dr["BorderColor"]        = this.BorderColor.ToArgb();
            dr["BorderHotColor"]     = this.BorderHotColor.ToArgb();
            dr["ButtonColor"]        = this.ButtonColor.ToArgb();
            dr["ButtonHotColor"]     = this.ButtonHotColor.ToArgb();
            dr["ButtonPressedColor"] = this.ButtonPressedColor.ToArgb();
            dr["ControlBackColor"]   = this.ControlBackColor.ToArgb();
            dr["ControlForeColor"]   = this.ControlForeColor.ToArgb();
            dr["EditColor"]          = this.EditColor.ToArgb();
            dr["EditFocusedColor"]   = this.EditFocusedColor.ToArgb();
            dr["EditReadOnlyColor"]  = this.EditReadOnlyColor.ToArgb();
            //
            dr["FlashColor"]               = this.FlashColor.ToArgb();
            dr["BarColor"]                 = this.BarColor.ToArgb();
            dr["BarHotColor"]              = this.BarHotColor.ToArgb();
            dr["BarTextColor"]             = this.BarTextColor.ToArgb();
            dr["BarHotTextColor"]          = this.BarHotTextColor.ToArgb();
            dr["BarPressedColor"]          = this.BarPressedColor.ToArgb();
            dr["BarBorderColor"]           = this.BarBorderColor.ToArgb();
            dr["BarHotBorderColor"]        = this.BarHotBorderColor.ToArgb();
            dr["BarClientAreaColor"]       = this.BarClientAreaColor.ToArgb();
            dr["BarItemSelectedColor"]     = this.BarItemSelectedColor.ToArgb();
            dr["BarItemSelectedTextColor"] = this.BarItemSelectedTextColor.ToArgb();
            dr["BarItemDisabledTextColor"] = this.BarItemDisabledTextColor.ToArgb();
            //		dr["BarItemSelectedBorder"]    = this.BarItemSelectedBorder.ToArgb();
            dr["BarItemHotColor"]       = this.BarItemHotColor.ToArgb();
            dr["BarItemPressedColor"]   = this.BarItemPressedColor.ToArgb();
            dr["BarItemBorderHotColor"] = this.BarItemBorderHotColor.ToArgb();
            dr["BarItemTextColor"]      = this.BarItemTextColor.ToArgb();
            dr["BarItemHotTextColor"]   = this.BarItemHotTextColor.ToArgb();
            dr["BarItemsStyle"]         = Convert.ToInt32(this.BarItemsStyle);
            dr["FlashColor"]            = this.FlashColor.ToArgb();
            dr["TextColor"]             = this.TextColor.ToArgb();
            dr["NegativeValueColor"]    = this.NegativeValueColor.ToArgb();
            //	dr["TextStyle"]                = this.TextStyle;
            //
            dr["GridCellsFont"] = UI_Utils.FontToString(this.GridCellsFont);

            dt.Rows.Add(dr);

            MemoryStream strm = new MemoryStream();

            ds.WriteXml(strm, XmlWriteMode.IgnoreSchema);
            retVal = strm.ToArray();
            strm.Close();

            ds.Dispose();

            return(retVal);
        }