Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="contrl">лист объектов которые надо сохрнить. обычно равно this</param>
        /// <param name="json">json к которому надо добавить ещё больше json-а</param>
        /// <returns></returns>
        public JArray formSerialize(Control contrl, JArray json = null)
        {
            if (json == null)
            {
                json = new JArray();
            }
            foreach (Control ctr in contrl.Controls)
            {
                if (ctr.GetType().ToString() == "System.Windows.Forms.Button")
                {
                    Dictionary <string, string> button = new Dictionary <string, string>();
                    //button.Add("BackgroundImage", imageText(ctr.BackgroundImage));
                    button.Add("Name", ctr.Name);
                    button.Add("Enabled", ctr.Enabled.ToString());
                    button.Add("Visible", ctr.Visible.ToString());
                    button.Add("BackgroundImageLayout", ctr.BackgroundImageLayout.ToString());
                    button.Add("FontSize", ctr.Font.Size.ToString());
                    button.Add("BackColor", ButtonUniqueForm.ColorToJSON(ctr.BackColor)); //ctr.BackColor.Name);
                    button.Add("Type", "Button");
                    button.Add("ForeColor", ButtonUniqueForm.ColorToJSON(ctr.ForeColor)); //ctr.ForeColor.Name);
                    button.Add("Font", ctr.Font.Name);
                    button.Add("FlatStyle", Convert.ToString(DesignClass.FLAT_OF_BUTTON));
                    json.Add(JObject.FromObject(button));
                }
                else if (ctr.GetType().ToString() == "System.Windows.Forms.Label")
                {
                    Dictionary <string, string> label = new Dictionary <string, string>();

                    label.Add("Name", ctr.Name);
                    label.Add("BackColor", ButtonUniqueForm.ColorToJSON(ctr.BackColor));//((Label)ctr).BackColor.Name);
                    label.Add("Enabled", ctr.Enabled.ToString());
                    label.Add("Visible", ctr.Visible.ToString());
                    label.Add("Type", "Label");
                    label.Add("FontSize", ctr.Font.Size.ToString());
                    label.Add("Font", ctr.Font.Name);
                    label.Add("ForeColor", ((Label)ctr).ForeColor.Name);
                    json.Add(JObject.FromObject(label));
                }
                else if (ctr.GetType().ToString() == "System.Windows.Forms.Panel")
                {
                    json.Add(formSerialize(ctr, json));
                    Dictionary <string, string> panel = new Dictionary <string, string>();
                    panel.Add("Name", ctr.Name);
                    panel.Add("Enabled", ctr.Enabled.ToString());
                    panel.Add("Visible", ctr.Visible.ToString());
                    panel.Add("Type", "panel");
                    panel.Add("Form", ctr.FindForm().Name);
                    json.Add(JObject.FromObject(panel));
                }
            }
            return(json);
        }
Example #2
0
        private void changeUniqueBtnMenuItem_Click(object sender, EventArgs e)
        {
            Button           pb = (Button)((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl;
            ButtonUniqueForm f  = new ButtonUniqueForm(pb);

            f.ShowDialog();
            pb = f.newButton;
            if (!f.ReturnToDefault)
            {
                ButtonUniqueForm.UpdateButtonDesignInDb(pb);
            }

            pic(this);
        }
Example #3
0
 public static void UpdateLabelDesignInDb(Control pb)
 {
     SQLClass.Delete("DELETE FROM " + Tables.Unique +
                     " WHERE type = 'Label'" +
                     " AND name = '" + pb.Name +
                     "' AND FormFrom = '" + pb.FindForm().Name + "'");
     SQLClass.Insert("INSERT INTO " + Tables.Unique +
                     " (type, design, author, name, FormFrom) VALUES " +
                     "('Label', " +
                     "'ForeColor = " + ButtonUniqueForm.ColorToJSON(pb.ForeColor) +
                     ", FontName = " + pb.Font.Name +
                     ", FontSize = " + pb.Font.Size +
                     ", Text = " + pb.Text +
                     "', 'admin', '" + pb.Name + "', '" + pb.FindForm().Name + "')");
 }
Example #4
0
        public static void pic(Control c)
        {
            //Фон формы FIXME!!!
            if (c.GetType().ToString().Contains("WindowsFormsApplication1"))
            {
                c.BackgroundImage  = DesignClass.FORM_BACKGROUND_IMG;
                c.Cursor           = DesignClass.FORM_CURSOR;
                c.BackColor        = DesignClass.FORM_COLOR;
                c.ContextMenuStrip = DesignClass.FORM_MENU;

                FormUniqueForm.GetFormDesignFromDb(ref c);
            }

            //Дизайн кнопок
            foreach (Control ctr in c.Controls)
            {
                #region DesignClass дефалт
                string ctr_type = ctr.GetType().ToString();
                if (ctr_type == "System.Windows.Forms.Button")
                {
                    ((Button)ctr).FlatStyle             = DesignClass.FLAT_OF_BUTTON;
                    ((Button)ctr).BackgroundImage       = DesignClass.BUTTON_BACKGROUND_IMG;
                    ((Button)ctr).BackgroundImageLayout = ImageLayout.Stretch;
                    ((Button)ctr).ForeColor             = DesignClass.BUTTON_TEXT_COLOR;
                    ((Button)ctr).TextAlign             = DesignClass.BUTTONIMAGE_ALLINE;
                    ((Button)ctr).Font      = DesignClass.BUTTON_FONT;
                    ((Button)ctr).BackColor = DesignClass.BUTTON_COLOR;
                    ctr.ContextMenuStrip    = DesignClass.BUTTON_MENU;
                }
                else if (ctr_type == "System.Windows.Forms.Label")
                {
                    ((Label)ctr).BackColor = Color.Transparent;
                    ((Label)ctr).ForeColor = DesignClass.LABEL_TEXT_COLOR;
                    ((Label)ctr).Font      = DesignClass.FONT_OF_LABEL;
                    if (!DesignClass.LABEL_AUTO_SIZE)
                    {
                        ((Label)ctr).TextAlign = DesignClass.LABEL_TEXT_ALIGN;
                    }
                    else
                    {
                        ((Label)ctr).AutoSize = true;
                    }
                    ctr.ContextMenuStrip = DesignClass.LABEL_MENU;
                }
                else if (ctr_type == "System.Windows.Forms.PictureBox")
                {
                    ctr.ContextMenuStrip = DesignClass.PICTURE_SAVE_MENU;
                }
                else if (ctr_type == "System.Windows.Forms.Panel")
                {
                    ((Panel)ctr).BackgroundImage = DesignClass.PANEL_BACKGROUND_IMG;
                    ((Panel)ctr).BackColor       = DesignClass.PANEL_COLOR;
                    ctr.ContextMenuStrip         = DesignClass.PANEL_MENU;
                    if (DesignClass.PANEL_TRANSPARENCY)
                    {
                        ((Panel)ctr).BackColor = Color.Transparent;
                    }
                }
                #endregion

                var temp = ButtonUniqueForm.GetUniqueDesignFromDB(ctr.Name);

                ctr.BackColor = temp.BackColor;
                ctr.ForeColor = temp.ForeColor;
                ctr.Font      = temp.Font;
                ctr.Visible   = temp.Visible;

                pic(ctr);
            }
        }
Example #5
0
        /// <summary>
        /// Сохранение дефолтного дизайна в базу
        /// </summary>
        /// <returns></returns>
        public static Dictionary <string, JObject> typeSerialize()
        {
            Dictionary <string, JObject> AllTypesData = new Dictionary <string, JObject>();

            #region Button
            Dictionary <string, string> ButtonData = new Dictionary <string, string>();
            if (DesignClass.BUTTON_BACKGROUND_IMG_ADRESS != null)
            {
                ButtonData.Add("BackgroundImage", DesignClass.BUTTON_BACKGROUND_IMG_ADRESS.ToString());
            }

            //ButtonData.Add("BackgroundImageLayout", button1.BackgroundImageLayout.ToString());

            if (DesignClass.BUTTON_TEXT_COLOR != null)
            {
                ButtonData.Add("ForeColor", ButtonUniqueForm.ColorToJSON(DesignClass.BUTTON_TEXT_COLOR));//DesignClass.BUTTON_TEXT_COLOR.ToString());
            }
            if (DesignClass.BUTTON_FONT != null)
            {
                ButtonData.Add("Font", DesignClass.BUTTON_FONT.ToString());
            }
            if (DesignClass.BUTTON_COLOR != null)
            {
                ButtonData.Add("Color", ButtonUniqueForm.ColorToJSON(DesignClass.BUTTON_COLOR));//.ToString());
            }

            ButtonData.Add("ImageAlign", DesignClass.BUTTONIMAGE_ALLINE.ToString());   //.ToString());
            ButtonData.Add("FlatStyle", Convert.ToString(DesignClass.FLAT_OF_BUTTON)); //.ToString());

            #endregion

            #region Panel
            Dictionary <string, string> PanelData = new Dictionary <string, string>();
            if (DesignClass.PANEL_COLOR != null)
            {
                PanelData.Add("BackColor", ButtonUniqueForm.ColorToJSON(DesignClass.PANEL_COLOR));// DesignClass.PANEL_COLOR.ToString());
            }
            if (DesignClass.PANEL_BACKGROUND_ADDRESS != null)
            {
                PanelData.Add("BackGroundImageAddress", DesignClass.PANEL_BACKGROUND_ADDRESS);
            }
            if (DesignClass.PANEL_TRANSPARENCY != false)
            {
                PanelData.Add("Transparency", "true");
            }
            #endregion

            #region Label
            Dictionary <string, string> labelData = new Dictionary <string, string>();
            if (DesignClass.LABEL_COLOR != null)
            {
                labelData.Add("BackColor", ButtonUniqueForm.ColorToJSON(DesignClass.LABEL_COLOR));//DesignClass.LABEL_COLOR.ToString());
            }
            if (DesignClass.LABEL_TEXT_COLOR != null)
            {
                labelData.Add("ForeColor", ButtonUniqueForm.ColorToJSON(DesignClass.LABEL_TEXT_COLOR));//DesignClass.LABEL_TEXT_COLOR.ToString());
            }
            if (DesignClass.FONT_OF_LABEL != null)
            {
                labelData.Add("FontSize", DesignClass.FONT_OF_LABEL.Size.ToString());
                labelData.Add("FontName", DesignClass.FONT_OF_LABEL.Name);
            }

            if (!DesignClass.LABEL_AUTO_SIZE)
            {
                labelData.Add("TextAlign", DesignClass.LABEL_TEXT_ALIGN.ToString());
            }
            else
            {
                labelData.Add("TextAlign", "null");
            }
            #endregion

            AllTypesData.Add("button", JObject.FromObject(ButtonData));
            AllTypesData.Add("label", JObject.FromObject(labelData));
            AllTypesData.Add("panel", JObject.FromObject(PanelData));

            foreach (string type in AllTypesData.Keys)
            {
                SQLClass.Delete("DELETE FROM " + Tables.Default + " WHERE type = '" + type + "'");
                SQLClass.Insert(String.Format("INSERT INTO " + Tables.Default + "(type, design, author) VALUES ('{0}','{1}','{2}')",
                                              type, AllTypesData[type].ToString(), "test"));
            }

            return(AllTypesData);
        }