예제 #1
0
        public int Delete()
        {
            string membre = SessionState.MemberInfo.NomUtilisateur;
            int    status = XmlStyleWebProvider.Delete(membre, this);

            return(status);
        }
예제 #2
0
        private void Construire()
        {
            string   membre = HttpContext.Current.User.Identity.Name;
            StyleWeb sw     = XmlStyleWebProvider.GetStyleWeb(membre, StyleWeb, TypeStyleWeb.Label);
            Style    st     = Sql.Web.Data.StyleWeb.StyleWebToStyle(sw);

            this.ApplyStyle(st);
        }
예제 #3
0
    protected void ButtonSupprimer_Click(object sender, EventArgs e)
    {
        styleWebObjet.Applicable = false;
        string membre = HttpContext.Current.User.Identity.Name;

        XmlStyleWebProvider.Update(membre, styleWebObjet);

        Response.Redirect(returnUrl);
    }
예제 #4
0
    protected void ButtonSauver_Click(object sender, EventArgs e)
    {
        StyleWeb.StyleToStyleWeb(styleWebObjet, primaryStyle);
        string membre = HttpContext.Current.User.Identity.Name;

        styleWebObjet.Applicable = true;

        XmlStyleWebProvider.Update(membre, styleWebObjet);

        Response.Redirect(returnUrl);
    }
예제 #5
0
        /* TextAlign sera dans chaque reponse donc pas dans le XML mais dans la BD
         * sinon cela n'a pas de sens pour l'utilisateur
         * TextAlign n'existe pas dans le Style
         */
        public static void ApplyStyleWeb(string nomStyle, string typeStyle, WebControl webControl)
        {
            // C'est un peu loufoque mais comme le boulot de lier un nom de membre a un
            // questionnaire etait deja fait il est repris ici
            // une reflexion plus global devrait etre mene pour par exemple
            // configurer une nouvelle variable SessionState.Membre dans login.cs
            // par exemple
            string membre = WebContent.GetUtilisateur();

            StyleWeb sw = new StyleWeb();
            Style    st = new Style();

            try
            {
                sw = XmlStyleWebProvider.GetStyleWeb(membre, nomStyle, typeStyle);
                st = StyleWeb.StyleWebToStyle(sw);
                if (sw.Applicable)
                {
                    webControl.ApplyStyle(st);

                    if (typeStyle == TypeStyleWeb.Table)
                    {
                        // On aurait bien aimé utiliser Unit() ici mais CellPadding et CellSpacing sont des int !
                        // Tandis que Height et Width sont des Unit()
                        if (sw.Padding != "")
                        {
                            (( Table )webControl).CellPadding = int.Parse(sw.Padding);
                        }
                        if (sw.Spacing != "")
                        {
                            (( Table )webControl).CellSpacing = int.Parse(sw.Spacing);
                        }
                    }
                }
            }
            catch
            {
                // Mettre un break point pour detecter les erreurs Xml
                int i = 3;
            }
        }
예제 #6
0
    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
    }