예제 #1
0
        static void SetColorStyle(Control control, StyleInfo info)
        {
            if (control is TableLayoutPanel)
            {
                foreach (Control othercontrol in ((TableLayoutPanel)control).Controls)
                {
                    SetColorStyle(othercontrol,info);
                }
            }
            else if (control is FlowLayoutPanel)
            {
                foreach (Control othercontrol in ((FlowLayoutPanel)control).Controls)
                {
                    SetColorStyle(othercontrol,info);
                }
            }
            else if (control is Label)
            {
                //apply changes to control here
                Label text = (Label)control;
                text.ForeColor = info.LabelTextColor;
                text.BackColor = info.LabelBackColor;
            }
            else if (control is Button)
            {

            }
            else if (control is CheckBox)
            {
                CheckBox checkbox = (CheckBox)control;
                checkbox.ForeColor = info.FormTextColor;
                checkbox.BackColor = info.FormColor;
            }
        }
예제 #2
0
        public static void ApplyStlye(Form form,StyleInfo info)
        {
            foreach (Control control in form.Controls)
            {
                if (control is TableLayoutPanel)
                {
                    foreach (Control secondarycontrol in ((TableLayoutPanel)control).Controls)
                    {
                        SetColorStyle(secondarycontrol,info);
                    }
                }
            }

            form.BackColor = info.FormColor;
        }
예제 #3
0
 public static void Save(string filepath,StyleInfo info)
 {
     if (!Directory.Exists(filepath))
         Directory.CreateDirectory(filepath);
     try
     {
         XmlSerializer serializer = new XmlSerializer(typeof(StyleInfo));
         TextWriter textWriter = new StreamWriter(filepath);
         serializer.Serialize(textWriter, info);
         textWriter.Close();
     }
     catch (Exception)
     {
         MessageBox.Show("Error Saving " + filepath);
     }
 }