protected void Page_Load(object sender, System.EventArgs e) { if (Page.IsPostBack == false) { LabelTitre.Text = "Edition d'un StyleWeb"; if (Request.QueryString["Style"] != null && Request.QueryString["Type"] != null) { string styleNom = Request.QueryString["Style"].ToString(); string type = Request.QueryString["Type"].ToString(); if (type == TypeStyleWeb.Table) { PanelTypeTable.Visible = true; } string membre = HttpContext.Current.User.Identity.Name; styleWebObjet = XmlStyleWebProvider.GetStyleWeb(membre, styleNom, type); primaryStyle = StyleWeb.StyleWebToStyle(styleWebObjet); LabelTitre.Text += " : " + styleNom + " : " + type; LabelApplicable.Visible = styleWebObjet.Applicable == false; } if (Request.QueryString["ReturnUrl"] != null) { returnUrl = Request.QueryString["ReturnUrl"].ToString(); } TextBoxPadding.Text = styleWebObjet.Padding.ToString(); TextBoxSpacing.Text = styleWebObjet.Spacing.ToString(); TextBoxWidth.Text = /*styleWebObjet.Width == 0 ? "" :*/ styleWebObjet.Width.ToString(); TextBoxHeight.Text = /*styleWebObjet.Height == 0 ? "" :*/ styleWebObjet.Height.ToString(); TextBoxBorderWidth.Text = styleWebObjet.BorderWidth == 0 ? "" : styleWebObjet.BorderWidth.ToString(); TextBoxFontSize.Text = styleWebObjet.FontSize.ToString(); ColorsList colors = new ColorsList(); DropDownListBorderColor.DataSource = colors; DropDownListBorderColor.DataBind(); if (styleWebObjet.BorderColor != "none") { TextBoxBorderColor.Text = styleWebObjet.BorderColor; DropDownListBorderColor.SelectedValue = ColorTranslator.FromHtml(styleWebObjet.BorderColor).Name; ColorPickerBorderColor.SelectedColor = ColorTranslator.FromHtml(styleWebObjet.BorderColor); } DropDownListBackColor.DataSource = colors; DropDownListBackColor.DataBind(); if (styleWebObjet.BackColor != "none") { TextBoxBackColor.Text = styleWebObjet.BackColor; DropDownListBackColor.SelectedValue = ColorTranslator.FromHtml(styleWebObjet.BackColor).Name; ColorPickerBackColor.SelectedColor = ColorTranslator.FromHtml(styleWebObjet.BackColor); } DropDownListForegroundColor.DataSource = colors; DropDownListForegroundColor.DataBind(); if (styleWebObjet.ForeColor != "none") { TextBoxForegroundColor.Text = styleWebObjet.ForeColor; DropDownListForegroundColor.SelectedValue = ColorTranslator.FromHtml(styleWebObjet.ForeColor).Name; ColorPickerForegroundColor.SelectedColor = ColorTranslator.FromHtml(styleWebObjet.ForeColor); } // Add data to the borderStyleList control. ListItemCollection styles = new ListItemCollection(); Type styleType = typeof(BorderStyle); foreach (string s in Enum.GetNames(styleType)) { styles.Add(s); } DropDownListBorderStyle.DataSource = styles; DropDownListBorderStyle.DataBind(); DropDownListBorderStyle.SelectedIndex = styleWebObjet.BorderStyle; // Add data to the borderWidthList control. ListItemCollection widths = new ListItemCollection(); for (int i = 0; i < 46; i++) { widths.Add(i.ToString() + "px"); } DropDownListBorderWidthList.DataSource = widths; DropDownListBorderWidthList.DataBind(); // Add data to the fontNameList control. ListItemCollection names = new ListItemCollection(); foreach (FontFamily oneFontFamily in FontFamily.Families) { names.Add(oneFontFamily.Name); } DropDownListFontName.DataSource = names; DropDownListFontName.DataBind(); // ca ne marche surement pas ListItem li = new ListItem(styleWebObjet.FontName); if (DropDownListFontName.Items.Contains(li)) { DropDownListFontName.SelectedValue = styleWebObjet.FontName; } // Add data to the fontSizeList control. ListItemCollection fontSizes = new ListItemCollection(); fontSizes.Add("Small"); fontSizes.Add("Medium"); fontSizes.Add("Large"); fontSizes.Add("8pt"); fontSizes.Add("10pt"); fontSizes.Add("12pt"); fontSizes.Add("14pt"); fontSizes.Add("16pt"); fontSizes.Add("18pt"); fontSizes.Add("20pt"); fontSizes.Add("24pt"); fontSizes.Add("48pt"); DropDownListFontSize.DataSource = fontSizes; DropDownListFontSize.DataBind(); // Font Style ListItemCollection stylesF = new ListItemCollection(); Type styleTypeF = typeof(FontStyle); foreach (string s in Enum.GetNames(styleTypeF)) { stylesF.Add(s); } stylesF.Add("Overline"); // qui n'est pas dans FontStyle ???!! CheckBoxListFontStyle.DataSource = stylesF; CheckBoxListFontStyle.DataBind(); CheckBoxListFontStyle.Items[1].Selected = styleWebObjet.Bold; CheckBoxListFontStyle.Items[2].Selected = styleWebObjet.Italic; CheckBoxListFontStyle.Items[3].Selected = styleWebObjet.Underline; CheckBoxListFontStyle.Items[4].Selected = styleWebObjet.Strikeout; CheckBoxListFontStyle.Items[5].Selected = styleWebObjet.Overline; } // Construire l'objet a chaque fois switch (styleWebObjet.Type) { case "Label": Label lbl = new Label(); lbl.ID = "ObjetID"; lbl.Text = Texte; PanelObjet.Controls.Add(lbl); break; case "TextBox": TextBox txb = new TextBox(); txb.ID = "ObjetID"; txb.Text = Texte; PanelObjet.Controls.Add(txb); break; case "RadioButtonList": RadioButtonListStyle rbl = new RadioButtonListStyle(); rbl.ID = "ObjetID"; rbl.Items.Add("article 1"); rbl.Items.Add("article 2"); rbl.Items.Add("article 3"); PanelObjet.Controls.Add(rbl); break; case "CheckBoxList": CheckBoxListStyle cbl = new CheckBoxListStyle(); cbl.ID = "ObjetID"; cbl.Items.Add("article 1"); cbl.Items.Add("article 2"); cbl.Items.Add("article 3"); PanelObjet.Controls.Add(cbl); break; case "Table": Table tbl = new Table(); if (IsPostBack == false) { int padding = 0; try { padding = int.Parse(styleWebObjet.Padding); tbl.CellPadding = padding; } catch { } int spacing = 0; try { spacing = int.Parse(styleWebObjet.Padding); tbl.CellSpacing = spacing; } catch { } } else { int padding = 0; try { padding = int.Parse(TextBoxPadding.Text); tbl.CellPadding = padding; } catch { } int spacing = 0; try { spacing = int.Parse(TextBoxSpacing.Text); tbl.CellSpacing = spacing; } catch { } } TableRow row = new TableRow(); TableCell cell = new TableCell(); cell.Controls.Add(new LiteralControl(Texte)); row.Cells.Add(cell); tbl.Rows.Add(row); this.Controls.Add(tbl); tbl.ID = "ObjetID"; PanelObjet.Controls.Add(tbl); break; } Page.Form.DefaultButton = ButtonWidthOk.UniqueID; // Pour donner le focus }
protected void Page_Load(object sender, System.EventArgs e) { if (Page.IsPostBack == false) { DrawColors(); // Add data to the borderColorList, // backColorList, and foreColorList controls. //ListItemCollection colors = new ListItemCollection(); //colors.Add( Color.Black.Name ); //colors.Add( Color.Blue.Name ); //colors.Add( Color.Green.Name ); //colors.Add( Color.Orange.Name ); //colors.Add( Color.Purple.Name ); //colors.Add( Color.Red.Name ); //colors.Add( Color.White.Name ); //colors.Add( Color.Yellow.Name ); Colors colors = new Colors(); DropDownListBorderColor.DataSource = colors; DropDownListBorderColor.DataBind(); DropDownListBackColor.DataSource = colors; DropDownListBackColor.DataBind(); DropDownListForegroundColor.DataSource = colors; DropDownListForegroundColor.DataBind(); // Add data to the borderStyleList control. ListItemCollection styles = new ListItemCollection(); Type styleType = typeof(BorderStyle); foreach (string s in Enum.GetNames(styleType)) { styles.Add(s); } borderStyleList.DataSource = styles; borderStyleList.DataBind(); // Add data to the borderWidthList control. ListItemCollection widths = new ListItemCollection(); for (int i = 0; i < 46; i++) { widths.Add(i.ToString() + "px"); } borderWidthList.DataSource = widths; borderWidthList.DataBind(); // Add data to the fontNameList control. ListItemCollection names = new ListItemCollection(); names.Add("Arial"); names.Add("Courier"); names.Add("Garamond"); names.Add("Time New Roman"); names.Add("Verdana"); fontNameList.DataSource = names; fontNameList.DataBind(); // Add data to the fontSizeList control. ListItemCollection fontSizes = new ListItemCollection(); fontSizes.Add("Small"); fontSizes.Add("Medium"); fontSizes.Add("Large"); fontSizes.Add("10pt"); fontSizes.Add("14pt"); fontSizes.Add("20pt"); fontSizeList.DataSource = fontSizes; fontSizeList.DataBind(); // Font Style ListItemCollection stylesF = new ListItemCollection(); Type styleTypeF = typeof(FontStyle); foreach (string s in Enum.GetNames(styleTypeF)) { stylesF.Add(s); } DropDownListStyle.DataSource = stylesF; DropDownListStyle.DataBind(); CheckBoxListFontStyle.DataSource = stylesF; CheckBoxListFontStyle.DataBind(); // Set primaryStyle as the style for each control. applyStyle(); } string pageIsCallBack = ""; if (Page.IsCallback) { pageIsCallBack = "Page.IsCallback == true"; } else { pageIsCallBack = "Page.IsCallback == false"; } string pageIsPostBack = ""; if (Page.IsPostBack) { pageIsPostBack = "Page.IsPostBack == true"; } else { pageIsPostBack = "Page.IsPostBack == false"; } Trace.Warn("Page_Load : " + pageIsCallBack); Trace.Warn("Page_Load : " + pageIsPostBack); }