示例#1
0
        /// <summary>
        /// Загрузка дизайна конкретной формы из БД
        /// </summary>
        public static void GetFormDesignFromDb(ref Control c)
        {
            List <String> uniqueDesign = SQLClass.Select("SELECT design FROM " + Tables.Unique +
                                                         " WHERE FormFrom = '" + c.Name + "' and Type = 'Form'");

            if (uniqueDesign.Count == 0)
            {
                return;
            }
            String[] words = uniqueDesign[0].Split(new string[] { ":", ",", " = ", "=" }, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < words.Length; i++)
            {
                if (words[i] == "MinimizeBox")
                {
                    ((Form)c).MinimizeBox = (words[i + 1].Trim() == "True");
                }

                if (words[i] == "Color")
                {
                    foreach (String colorName in Enum.GetNames(typeof(KnownColor)))
                    {
                        String colorFromDB = words[i + 1];
                        if (colorFromDB.Trim().StartsWith("Color"))
                        {
                            colorFromDB = colorFromDB.Trim().Replace("Color [", "").Replace("]", "");
                        }

                        if (colorName == colorFromDB.Trim())
                        {
                            Color knownColor = Color.FromKnownColor((KnownColor)Enum.Parse(typeof(KnownColor), colorName));
                            c.BackColor = knownColor;
                        }
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        /// Чтение дизайна для Panel
        /// </summary>
        public void ReadPanelDefault()
        {
            List <String> Auths        = SQLClass.Select("SELECT design FROM " + Tables.Default + " WHERE type = 'panel'");
            String        designKnopki = Auths[0];

            String[] words = designKnopki.Split(new char[] { ':', ',', ' ', '\"' }, StringSplitOptions.RemoveEmptyEntries);

            for (int index = 0; index < words.Length; index++)
            {
                if (words[index] == "BackColor")
                {
                    foreach (String colorName in Enum.GetNames(typeof(KnownColor)))
                    {
                        if (colorName == words[index + 1])
                        {
                            Color knownColor = Color.FromKnownColor((KnownColor)Enum.Parse(typeof(KnownColor), colorName));
                            DesignClass.PANEL_COLOR = knownColor;
                        }
                    }
                }

                if (words[index] == "Transparency")
                {
                    DesignClass.PANEL_TRANSPARENCY = Convert.ToBoolean(words[index + 1]);
                }
                if (words[index] == "BackGroundImageAddress")
                {
                    DesignClass.PANEL_BACKGROUND_ADDRESS = words[index + 1] + ":" + words[index + 2];

                    PictureBox pb1 = new PictureBox();
                    pb1.Load(DesignClass.PANEL_BACKGROUND_ADDRESS);
                    DesignClass.PANEL_BACKGROUND_IMG = pb1.Image;
                    pb1.Dispose();
                }
            }
        }
示例#3
0
        /// <summary>
        /// Чтение дефолтного дизайна Button
        /// </summary>
        public static void ReadButtonDefault()
        {
            List <String> Auths = SQLClass.Select("SELECT design FROM " + Tables.Default + " WHERE type = 'Button'");

            if (Auths.Count == 0)
            {
                return;
            }

            String[] words = Auths[0].Split(new char[] { ':', ',', ' ', '\"' }, StringSplitOptions.RemoveEmptyEntries);

            for (int index = 0; index < words.Length; index++)
            {
                if (words[index] == "BackColor")
                {
                    foreach (String colorName in Enum.GetNames(typeof(KnownColor)))
                    {
                        if (colorName == words[index + 1])
                        {
                            Color knownColor = Color.FromKnownColor((KnownColor)Enum.Parse(typeof(KnownColor), colorName));
                            DesignClass.BUTTON_COLOR = knownColor;
                        }
                    }
                }

                if (words[index] == "ForeColor")
                {
                    foreach (String colorName in Enum.GetNames(typeof(KnownColor)))
                    {
                        if (colorName == words[index + 1])
                        {
                            Color knownColor = Color.FromKnownColor((KnownColor)Enum.Parse(typeof(KnownColor), colorName));
                            DesignClass.BUTTON_TEXT_COLOR = knownColor;
                        }
                    }
                }

                if (words[index] == "Font")
                {
                    foreach (FontFamily item in FontFamily.Families)
                    {
                        if (item.ToString() == words[index + 1])
                        {
                            DesignClass.BUTTON_FONT = new Font(item, 14);
                        }
                    }
                }

                if (words[index].Trim() == "BackgroundImage")
                {
                    DesignClass.BUTTON_BACKGROUND_IMG_ADRESS = words[index + 1] + ":" + words[index + 2];
                    PictureBox pb = new PictureBox();
                    pb.Load(DesignClass.BUTTON_BACKGROUND_IMG_ADRESS);
                    DesignClass.BUTTON_BACKGROUND_IMG = pb.Image;
                }

                if (words[index] == "FlatStyle")
                {
                    if (words[index + 1] == "Popup")
                    {
                        DesignClass.FLAT_OF_BUTTON = FlatStyle.Popup;
                    }
                    else if (words[index + 1] == "System")
                    {
                        DesignClass.FLAT_OF_BUTTON = FlatStyle.System;
                    }
                    else if (words[index + 1] == "Standard")
                    {
                        DesignClass.FLAT_OF_BUTTON = FlatStyle.Popup;
                    }
                    else if (words[index + 1] == "Flat")
                    {
                        DesignClass.FLAT_OF_BUTTON = FlatStyle.System;
                    }
                }

                #region ImageAlign
                if (words[index].Trim() == "ImageAlign")
                {
                    //DesignClass.BUTTONIMAGE_ALLINE = (ContentAlignment)(words[index + 1]);
                    if (words[index + 1] == "TopLeft")
                    {
                        DesignClass.BUTTONIMAGE_ALLINE = ContentAlignment.TopLeft;
                    }
                    else if (words[index + 1] == "TopCenter")
                    {
                        DesignClass.BUTTONIMAGE_ALLINE = ContentAlignment.TopCenter;
                    }
                    else if (words[index + 1] == "TopRight")
                    {
                        DesignClass.BUTTONIMAGE_ALLINE = ContentAlignment.TopRight;
                    }
                    else if (words[index + 1] == "MiddleLeft")
                    {
                        DesignClass.BUTTONIMAGE_ALLINE = ContentAlignment.MiddleLeft;
                    }
                    else if (words[index + 1] == "MiddleCenter")
                    {
                        DesignClass.BUTTONIMAGE_ALLINE = ContentAlignment.MiddleCenter;
                    }
                    else if (words[index + 1] == "MiddleRight")
                    {
                        DesignClass.BUTTONIMAGE_ALLINE = ContentAlignment.MiddleRight;
                    }
                    else if (words[index + 1] == "BottomLeft")
                    {
                        DesignClass.BUTTONIMAGE_ALLINE = ContentAlignment.BottomLeft;
                    }
                    else if (words[index + 1] == "BottomCenter")
                    {
                        DesignClass.BUTTONIMAGE_ALLINE = ContentAlignment.BottomCenter;
                    }
                    else if (words[index + 1] == "BottomRight")
                    {
                        DesignClass.BUTTONIMAGE_ALLINE = ContentAlignment.BottomRight;
                    }
                }
                #endregion
            }
        }
示例#4
0
        /// <summary>
        /// ЧТение дефолтного дизайна для Label
        /// </summary>
        public void ReadLabelDefault()
        {
            List <String> Auths        = SQLClass.Select("SELECT design FROM " + Tables.Default + " WHERE type = 'label'");
            String        designKnopki = Auths[0];

            String[] words = designKnopki.Split(new char[] { ':', ',', ' ', '\"' }, StringSplitOptions.RemoveEmptyEntries);

            for (int index = 0; index < words.Length; index++)
            {
                if (words[index] == "BackColor")
                {
                    String colorFromDB = words[index + 1].Trim();
                    if (colorFromDB.StartsWith("Color"))
                    {
                        colorFromDB = colorFromDB.Replace("Color [", "").Replace("]", "");
                    }

                    foreach (String colorName in Enum.GetNames(typeof(KnownColor)))
                    {
                        if (colorName == colorFromDB)
                        {
                            Color knownColor = Color.FromKnownColor((KnownColor)Enum.Parse(typeof(KnownColor), colorName));
                            DesignClass.LABEL_COLOR = knownColor;
                        }
                    }
                }

                if (words[index] == "ForeColor")
                {
                    String colorFromDB = words[index + 1].Trim();
                    if (colorFromDB.StartsWith("Color"))
                    {
                        colorFromDB = colorFromDB.Replace("Color [", "").Replace("]", "");
                    }

                    foreach (String colorName in Enum.GetNames(typeof(KnownColor)))
                    {
                        if (colorName == colorFromDB)
                        {
                            Color knownColor = Color.FromKnownColor((KnownColor)Enum.Parse(typeof(KnownColor), colorName));
                            DesignClass.LABEL_TEXT_COLOR = knownColor;
                        }
                    }
                }

                if (words[index].Trim() == "FontName")
                {
                    DesignClass.NAME_FONT_OF_LABEL = words[index + 1];
                }

                if (words[index].Trim() == "FontSize")
                {
                    DesignClass.SIZE_FONT_OF_LABEL = (int)(Convert.ToDecimal(words[index + 1]));
                }
                if (words[index].Trim() == "TextAlign")
                {
                    DesignClass.LABEL_AUTO_SIZE = false;
                    switch (words[index + 1])
                    {
                    case "BottomCenter":
                        DesignClass.LABEL_TEXT_ALIGN = System.Drawing.ContentAlignment.BottomCenter;
                        break;

                    case "BottomLeft":
                        DesignClass.LABEL_TEXT_ALIGN = System.Drawing.ContentAlignment.BottomLeft;
                        break;

                    case "BottomRight":
                        DesignClass.LABEL_TEXT_ALIGN = System.Drawing.ContentAlignment.BottomRight;
                        break;

                    case "MiddleCenter":
                        DesignClass.LABEL_TEXT_ALIGN = System.Drawing.ContentAlignment.MiddleCenter;
                        break;

                    case "MiddleLeft":
                        DesignClass.LABEL_TEXT_ALIGN = System.Drawing.ContentAlignment.MiddleLeft;
                        break;

                    case "MiddleRight":
                        DesignClass.LABEL_TEXT_ALIGN = System.Drawing.ContentAlignment.MiddleRight;
                        break;

                    case "TopCenter":
                        DesignClass.LABEL_TEXT_ALIGN = System.Drawing.ContentAlignment.TopCenter;
                        break;

                    case "TopLeft":
                        DesignClass.LABEL_TEXT_ALIGN = System.Drawing.ContentAlignment.TopLeft;
                        break;

                    case "TopRight":
                        DesignClass.LABEL_TEXT_ALIGN = System.Drawing.ContentAlignment.TopRight;
                        break;

                    default:
                        DesignClass.LABEL_AUTO_SIZE = true;
                        break;
                    }
                }
            }

            if (DesignClass.NAME_FONT_OF_LABEL != null && DesignClass.SIZE_FONT_OF_LABEL != 0)
            {
                DesignClass.FONT_OF_LABEL = new Font(DesignClass.NAME_FONT_OF_LABEL, DesignClass.SIZE_FONT_OF_LABEL);
            }
        }
示例#5
0
        /// <summary>
        /// Получение уникального дизайна кнопки из базы данных
        /// </summary>
        /// <param name="name">Имя кнопки</param>
        /// <param name="words">Массив слов (что-то связанное с JSON)</param>
        /// <returns>
        /// Новая кнопка со свойствами уникальной кнопки с названием <paramref name="name"/> из базы
        /// Её НЕЛЬЗЯ использовать как <code>ctr = GetUniqueDesignFromDB(...)</code>
        /// Нужно по отдельности задавать её свойства вашей кнопке.
        /// </returns>
        public static Button GetUniqueDesignFromDB(string name)
        {
            Button temp        = new Button();
            string temp_design = "";

            try
            {
                temp_design = SQLClass.Select(string.Format("SELECT design FROM `{1}` WHERE `name`='{0}'", name, Tables.Unique))[0];
            } catch (ArgumentOutOfRangeException)
            {
                return(new Button());
            }
            string[] words = temp_design.Split(new string[] { ":", ",", " = ", "=", "[", "]" }, StringSplitOptions.RemoveEmptyEntries);

            var FontName = "";
            var FontSize = 0;

            #region Код декодировки temp_design
            for (int i = 0; i < words.Length; i++)
            {
                #region Задаём цвет
                if (words[i].Trim() == "Color")
                {
                    try
                    {
                        temp.BackColor = Color.FromArgb(
                            Convert.ToInt32(words[i + 1]),
                            Convert.ToInt32(words[i + 2]),
                            Convert.ToInt32(words[i + 3]), Convert.ToInt32(words[i + 4]));
                    }
                    catch (Exception)
                    {
                        foreach (String colorName in Enum.GetNames(typeof(KnownColor)))
                        {
                            String colorFromDB = words[i + 1].Trim();
                            if (colorFromDB.StartsWith("Color"))
                            {
                                colorFromDB = colorFromDB.Replace("Color [", "").Replace("]", "");
                            }

                            if (colorName == colorFromDB)
                            {
                                Color knownColor = Color.FromKnownColor((KnownColor)Enum.Parse(typeof(KnownColor), colorName));
                                temp.BackColor = knownColor;
                            }
                        }
                    }
                }

                if (words[i].Trim() == "ForeColor")
                {
                    try
                    {
                        temp.ForeColor = Color.FromArgb(
                            Convert.ToInt32(words[i + 1]),
                            Convert.ToInt32(words[i + 2]),
                            Convert.ToInt32(words[i + 3]), Convert.ToInt32(words[i + 4]));
                    }
                    catch (Exception)
                    {
                        foreach (String colorName in Enum.GetNames(typeof(KnownColor)))
                        {
                            String colorFromDB = words[i + 1].Trim();
                            if (colorFromDB.StartsWith("Color"))
                            {
                                colorFromDB = colorFromDB.Replace("Color [", "").Replace("]", "");
                            }

                            if (colorName == colorFromDB)
                            {
                                Color knownColor = Color.FromKnownColor((KnownColor)Enum.Parse(typeof(KnownColor), colorName));
                                temp.ForeColor = knownColor;
                            }
                        }
                    }
                }
                #endregion

                #region Задаём видимость
                if (words[i].Trim() == "Visible")
                {
                    temp.Visible = (words[i + 1] == "True");
                }
                #endregion

                #region Задаём шрифт
                if (words[i].Trim() == "FontName")
                {
                    FontName = words[i + 1];
                }
                #endregion

                #region Задаём размер шрифта
                if (words[i].Trim() == "FontSize")
                {
                    FontSize = (int)(Convert.ToDecimal(words[i + 1]));
                }
                #endregion

                #region Задаем стиль кнопки
                if (words[i].Trim() == "FlatStyle")
                {
                    if (words[i + 1] == "Popup")
                    {
                        ((Button)temp).FlatStyle = FlatStyle.Popup;
                    }
                    else if (words[i + 1] == "System")
                    {
                        ((Button)temp).FlatStyle = FlatStyle.System;
                    }
                    else if (words[i + 1] == "Standard")
                    {
                        ((Button)temp).FlatStyle = FlatStyle.Standard;
                    }
                    else if (words[i + 1] == "Flat")
                    {
                        ((Button)temp).FlatStyle = FlatStyle.Flat;
                    }
                }
                #endregion
            }

            if (FontName != "" && FontSize > 0)
            {
                temp.Font = new Font(FontName, FontSize);
            }
            #endregion

            return(temp);
        }