Esempio n. 1
0
        public static int Update(string membre, StyleWeb o)
        {
            string _xmlFile = "StyleWeb/" + membre.Trim() + "/" + SessionState.Questionnaire.Style;

            DataSet   dataSet   = XmlUtil.ReadAndValidateXml(_xmlFile, _xsdFile);
            DataTable dataTable = dataSet.Tables[0];

            foreach (DataRow row in dataTable.Rows)
            {
                if (o.StyleWebGUID == new Guid(row["StyleWebGUID"].ToString()))
                {
                    DataRow r = row;
                    Fill(ref r, o);
                    break;
                }
            }

            try
            {
                XmlUtil.DataSetWriteXml(ref dataSet, _xmlFile);
            }
            catch
            {
                return(0);
            }

            return(1);
        }
Esempio n. 2
0
        public static int Delete(string membre, StyleWeb o)
        {
            string _xmlFile = "StyleWeb/" + membre.Trim() + "/" + SessionState.Questionnaire.Style;

            DataSet   dataSet   = XmlUtil.ReadAndValidateXml(_xmlFile, _xsdFile);
            DataTable dataTable = dataSet.Tables[0];

            foreach (DataRow row in dataTable.Rows)
            {
                if (o.StyleWebGUID == ( Guid )row["StyleWebGUID"])
                {
                    row.Delete();
                }
            }

            try
            {
                XmlUtil.DataSetWriteXml(ref dataSet, _xmlFile);
            }
            catch
            {
                return(0);
            }

            return(1);
        }
Esempio n. 3
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);
        }
Esempio n. 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);
    }
        private void CreateControls()
        {
            // Le Questionnaire
            Table tableLabel1 = CreateTableForLabel(SessionState.Questionnaire.Description, "TdStatQuestionnaireLabelStyle", "LabelQuestionnaireStyle");

            this.Controls.Add(tableLabel1);

            foreach (PollQuestion question in SessionState.Questions)
            {
                // Page
                if (question.SautPage != "")
                {
                    Table     tablePage = new Table();
                    TableCell cellPage  = new TableCell();
                    TableRow  rowPage   = new TableRow();

                    Label labelTitrePage = new Label();
                    StyleWeb.ApplyStyleWeb("TitrePage", TypeStyleWeb.Label, labelTitrePage);
                    labelTitrePage.Text = question.SautPage;

                    cellPage.Controls.Add(labelTitrePage);
                    rowPage.Cells.Add(cellPage);
                    tablePage.Rows.Add(rowPage);

                    this.Controls.Add(tablePage);
                }

                // Tableau
                if (question.Tableau != "")
                {
                    Table     tableTableau = new Table();
                    TableCell cellTableau  = new TableCell();
                    TableRow  rowTableau   = new TableRow();

                    Label labelTableau = new Label();
                    StyleWeb.ApplyStyleWeb("TitreTableau", TypeStyleWeb.Label, labelTableau);
                    labelTableau.Text = question.Tableau;

                    cellTableau.Controls.Add(labelTableau);
                    rowTableau.Cells.Add(cellTableau);
                    tableTableau.Rows.Add(rowTableau);

                    this.Controls.Add(tableTableau);
                }

                // Question
                Table tableLabel2 = CreateTableForQuestion(question);
                this.Controls.Add(tableLabel2);

                Table table = CreateReponseTable(question.PollQuestionId);
                table.CssClass = "TableStatAllStyle";
                this.Controls.Add(table);
            }
        }
Esempio n. 6
0
        // On en peut pas faire de create si le fichier du membre n'existe pas !!!
        //
        public static int Create(string membre, StyleWeb o)
        {
            string _xmlFile = "StyleWeb/" + membre.Trim() + "/" + SessionState.Questionnaire.Style;

            DataSet   dataSet   = XmlUtil.ReadAndValidateXml(_xmlFile, _xsdFile);
            DataTable dataTable = dataSet.Tables[0];
            DataRow   row       = dataTable.NewRow();

            row["StyleWebGUID"] = Guid.NewGuid();
            Fill(ref row, o);
            dataTable.Rows.Add(row);

            try
            {
                XmlUtil.DataSetWriteXml(ref dataSet, _xmlFile);
            }
            catch
            {
                return(0);
            }

            return(1);
        }
Esempio n. 7
0
 private static void Fill(ref DataRow row, StyleWeb sw)
 {
     row["NomStyleWeb"] = sw.NomStyleWeb;
     row["Type"]        = sw.Type;
     row["Applicable"]  = sw.Applicable;
     row["BackColor"]   = sw.BackColor;
     row["Bold"]        = sw.Bold;
     row["BorderColor"] = sw.BorderColor;
     row["BorderStyle"] = sw.BorderStyle;
     row["BorderWidth"] = sw.BorderWidth;
     row["FontName"]    = sw.FontName;
     row["FontSize"]    = sw.FontSize;
     row["ForeColor"]   = sw.ForeColor;
     row["Padding"]     = sw.Padding;
     row["Spacing"]     = sw.Spacing;
     row["Height"]      = sw.Height;
     row["Width"]       = sw.Width;
     row["Italic"]      = sw.Italic;
     row["Overline"]    = sw.Overline;
     row["Strikeout"]   = sw.Strikeout;
     row["Underline"]   = sw.Underline;
     row["TextAlign"]   = sw.TextAlign;
 }
Esempio n. 8
0
        //public static StyleWebCollection GetAll( string membre )
        //{
        //    string _xmlFile = "StyleWeb/" + membre.Trim() + ".xml";

        //    StyleWebCollection list = new StyleWebCollection();
        //    DataSet dataSet = XmlUtil.ReadAndValidateXml( _xmlFile, _xsdFile );

        //    DataTable dataTable = dataSet.Tables[ 0 ];
        //    foreach ( DataRow r in dataTable.Rows )
        //    {
        //        StyleWeb current = StyleWeb.Fill( r );
        //        list.Add( current );
        //    }
        //    return list;
        //}

        /// <summary>
        /// Aller chercher le StyleWeb pour l'utilisateur
        /// </summary>
        /// <param name="membre"></param>
        /// <param name="nomStyleWeb">Question, Réponse, etc ...</param>
        /// <param name="typeStyleWeb">TextBox, Label, RadioButtonLis, etc..</param>
        public static StyleWeb GetStyleWeb(string membre, string nomStyleWeb, string typeStyleWeb)
        {
            Reporter.Trace("GetStyleWeb()");

            string _xmlFile = "StyleWeb/" + membre.Trim() + "/" + SessionState.Questionnaire.Style;

            Reporter.Trace("  SessionState.Questionnaire.Style : {0}", SessionState.Questionnaire.Style);

            string fileName = HttpContext.Current.Request.MapPath("~/App_Data/" + _xmlFile);

            if (File.Exists(fileName) == false)
            {
                string path = HttpContext.Current.Request.MapPath("~/App_Data/StyleWeb/" + membre.Trim());
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                // Copie du fichier de l'intervieweur pour un membre qui n'a pas ce fichier de styles
                string dir = HttpContext.Current.Request.MapPath("~/App_Data/StyleWeb");
                File.Copy(dir + "/intervieweur/" + SessionState.Questionnaire.Style, dir + "/" + membre.Trim() + "/" + SessionState.Questionnaire.Style);
            }

            DataSet   dataSet   = XmlUtil.ReadAndValidateXml(_xmlFile, _xsdFile);
            DataTable dataTable = dataSet.Tables[0];

            foreach (DataRow r in dataTable.Rows)
            {
                if (nomStyleWeb == ( string )r["NomStyleWeb"] && typeStyleWeb == ( string )r["Type"])       // match found
                {
                    StyleWeb styleTrouve = StyleWeb.Fill(r);
                    return(styleTrouve);
                }
            }

            // Le style n'existe pas on le cree
            StyleWeb style = new StyleWeb();

            style.NomStyleWeb = nomStyleWeb;
            style.Type        = typeStyleWeb;
            style.Applicable  = true;
            style.BackColor   = "#FFFFFF";
            style.Bold        = false;
            style.BorderColor = "#000000";
            style.BorderStyle = 1;
            style.BorderWidth = 1;
            style.FontName    = "none";
            style.ForeColor   = "#000000";
            style.Padding     = "";
            style.Spacing     = "";
            style.Width       = "";
            style.Height      = "";
            style.Italic      = false;
            style.Overline    = false;
            style.Strikeout   = false;
            style.Underline   = false;
            style.TextAlign   = "left";

            Create(membre, style);

            return(style);
        }
Esempio n. 9
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 + "&nbsp;: " + 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
    }