public style_class set_style(style_class s) { style_class ss = get_style(s.name); if (ss == null) { styles.Add(s); } return(s); }
public void set_style(Control c, Color?bc = null) { // base style if (c is base_combo) { if (c is line_cmd) { this.set_style("line-cmd", this.font_family_light, this.font_size_normal + 2 , this.back_color_page, ctrls.ctrls.change_light(this.fore_color, 0.8f)).apply(c); } style_class sc = get_style("cmb-sugg-fnt"); if (sc == null) { set_style("cmb-sugg-fnt", this.font_family_light, this.font_size_normal - 2); set_style("cmb-sugg-des-fnt", this.font_family_light, this.font_size_normal - 3); set_style("cmb-sugg-sel-fnt", this.font_family_semibold, this.font_size_normal - 2); } ((base_combo)c).sugg_fnt = get_style("cmb-sugg-fnt").font; ((base_combo)c).sugg_des_fnt = get_style("cmb-sugg-des-fnt").font; ((base_combo)c).sugg_sel_fnt = get_style("cmb-sugg-sel-fnt").font; ((base_combo)c).sel_bc = Color.Yellow; ((base_combo)c).sel_bc_2 = Color.LightYellow; } else if (c is DataGridView) { this.init_grid((DataGridView)c, bc.Value); return; } else { if (c is Label || c is TextBox || c is CheckBox || c is ComboBox || c is DateTimePicker) { this.set_style("normal", this.font_family_light, this.font_size_normal + 2 , this.back_color_page, this.fore_color).apply(c); } else if (c is Button) { this.set_style("normal", this.font_family, this.font_size_normal + 2 , this.back_color_page, this.fore_color, FontStyle.Underline).apply(c); ((Button)c).FlatAppearance.BorderSize = 0; ((Button)c).FlatStyle = System.Windows.Forms.FlatStyle.Flat; c.Cursor = Cursors.Hand; } c.BackColor = bc.Value; } // class List <string> ss = tag_infos.get_styles(c); if (ss != null) { foreach (string s in ss) { if (s == "h1") { this.set_style("h1", this.font_family_light, this.fs1 + 4, this.back_color_page, this.fc1).apply(c); } else if (s == "h2") { this.set_style("h2", this.font_family_light, this.fs2 + 3, this.back_color_page, this.fc1).apply(c); } else if (s == "h3") { this.set_style("h3", this.font_family_light, this.fs3 + 2, this.back_color_page, this.fc1).apply(c); } else if (s == "h4") { this.set_style("h4", this.font_family_light, this.fs4 + 1, this.back_color_page, this.fc1).apply(c); } else if (s == "p1") { this.set_style("p1", this.font_family_light, this.fs1, this.back_color_page, this.fc1).apply(c); } else if (s == "p2") { this.set_style("p2", this.font_family_light, this.fs2, this.back_color_page, this.fc2).apply(c); } else if (s == "p3") { this.set_style("p3", this.font_family_light, this.fs3, this.back_color_page, this.fc3).apply(c); } else if (s == "p4") { this.set_style("p4", this.font_family_light, this.fs4, this.back_color_page, this.fc4).apply(c); } else if (s == "sb") { string sn = $"sb-{(int)c.Font.Size}"; this.set_style(sn, this.font_family_semibold, (int)c.Font.Size).apply(c); } else if (s == "link1") { this.set_style("link1", this.font_family, this.fs1, this.back_color_page, this.fore_color_link, FontStyle.Underline).apply(c); } else if (s == "link2") { this.set_style("link2", this.font_family, this.fs2, this.back_color_page, this.fore_color_link, FontStyle.Underline).apply(c); } else if (s == "link3") { this.set_style("link3", this.font_family, this.fs3, this.back_color_page, this.fore_color_link, FontStyle.Underline).apply(c); } else if (s == "link4") { this.set_style("link4", this.font_family, this.fs4, this.back_color_page, this.fore_color_link, FontStyle.Underline).apply(c); } else if (s == "linkc1") { this.set_style("linkc1", this.font_family, this.fs1, this.back_color_page, this.fore_color_cancel_link, FontStyle.Underline).apply(c); } else if (s == "linkc2") { this.set_style("linkc2", this.font_family, this.fs2, this.back_color_page, this.fore_color_cancel_link, FontStyle.Underline).apply(c); } else if (s == "linkc3") { this.set_style("linkc3", this.font_family, this.fs3, this.back_color_page, this.fore_color_cancel_link, FontStyle.Underline).apply(c); } else if (s == "linkc4") { this.set_style("linkc4", this.font_family, this.fs4, this.back_color_page, this.fore_color_cancel_link, FontStyle.Underline).apply(c); } else if (s == "title") { set_style("title", this.font_family_light, this.font_size_normal + 7, this.back_color_page, Color.DodgerBlue).apply(c); } else if (s == "sub_title") { set_style("sub-title", this.font_family_semibold, this.font_size_normal + 2 , this.back_color_page, ctrls.ctrls.change_light(Color.DodgerBlue, 1.5f)).apply(c); } else if (s == "c-err") { set_style(s, fc: this.fore_color_error).apply(c); } else if (s == "c-war") { set_style(s, fc: this.fore_color_warning).apply(c); } else if (s == "c-link") { set_style(s, fc: this.fore_color_link).apply(c); } else if (s == "c-light") { set_style(s, fc: this.fore_color_light).apply(c); } else if (s == "c-light2") { set_style(s, fc: this.fore_color_light2).apply(c); } else if (s == "c-cancel") { set_style(s, fc: this.fore_color_cancel_link).apply(c); } else if (s == "c1") { set_style(s, fc: this.fc1).apply(c); } else if (s == "c2") { set_style(s, fc: this.fc2).apply(c); } else if (s == "c3") { set_style(s, fc: this.fc3).apply(c); } else if (s == "c4") { set_style(s, fc: this.fc4).apply(c); } else if (s == "bi") { c.BackColor = this.back_color_page; } else { throw new Exception($"lo stile {s} non viene gestito."); } } } // childs if (c is FlowLayoutPanel || c is TableLayoutPanel || c is Panel) { foreach (Control c2 in c.Controls) { set_style(c2, bc); } } }
public style_class set_style(string name, Color?bc = null, Color?fc = null) { style_class ss = get_style(name); return(ss != null ? ss : this.set_style(new style_class(name, bc, fc))); }
public style_class set_style(string name, string font_family, int fs, Color?bc = null, Color?fc = null, FontStyle?fstyle = null) { style_class ss = get_style(name); return(ss != null ? ss : this.set_style(new style_class(name, font_family, fs, bc, fc, fstyle))); }