示例#1
0
        public static void AddLabel(zeus.HelperClass.zLabel lbl, ref Label label, System.Windows.Forms.Form f)
        {
            string location  = lbl.location;
            string text      = lbl.text;
            string size      = lbl.size;
            string font      = lbl.fontFamily;
            string font_size = lbl.fontSize;
            string color     = lbl.color;
            string textalign = lbl.textAlign;
            string style     = lbl.fontStyle;

            withProviderName = lbl.withProviderName;

            int X = int.Parse(location.Split(';')[0]);
            int Y = int.Parse(location.Split(';')[1]);

            //label = new Label();
            //labels[label_count].Parent = img[1];
            if (text.Length != 0)
            {
                label.Text = text;
            }

            label.BackColor = Color.Transparent;
            label.Location  = new Point(X, Y);

            if (size.Length != 0)
            {
                label.Size = new Size(int.Parse(size.Split(';')[0]), int.Parse(size.Split(';')[1]));
            }
            else
            {
                label.AutoSize = true;
            }
            // Цвет
            int red   = 0;
            int green = 0;
            int blue  = 0;

            if (color.Length > 5)
            {
                red   = int.Parse(color.Split(';')[0]);
                green = int.Parse(color.Split(';')[1]);
                blue  = int.Parse(color.Split(';')[2]);
            }

            label.ForeColor = Color.FromArgb(red, green, blue);

            if (font.Length != 0 && font_size.Length != 0)
            {
                switch (style)
                {
                case "bold": label.Font = new Font(font, float.Parse(font_size), FontStyle.Bold); break;

                case "italic": label.Font = new Font(font, float.Parse(font_size), FontStyle.Italic); break;

                case "strikeout": label.Font = new Font(font, float.Parse(font_size), FontStyle.Strikeout); break;

                case "underline": label.Font = new Font(font, float.Parse(font_size), FontStyle.Underline); break;

                default:
                    label.Font = new Font(font, float.Parse(font_size), FontStyle.Regular);
                    break;
                }
            }

            if (textalign.Length != 0)
            {
                switch (textalign.ToLower())
                {
                case "middleright": label.TextAlign = ContentAlignment.MiddleRight; break;

                case "middleleft": label.TextAlign = ContentAlignment.MiddleLeft; break;

                case "middlecenter": label.TextAlign = ContentAlignment.MiddleCenter; break;

                case "topleft": label.TextAlign = ContentAlignment.TopLeft; break;

                case "topright": label.TextAlign = ContentAlignment.TopRight; break;

                case "topcenter": label.TextAlign = ContentAlignment.TopCenter; break;

                default:
                    label.TextAlign = ContentAlignment.TopLeft; break;
                }
            }

            //f.Controls.Add(label);
        }
示例#2
0
        /// <summary>
        /// Добавление надписи на форму. ver. 2.0
        /// </summary>
        /// <param name="lbl"></param>
        /// <param name="label"></param>
        /// <param name="f"></param>
        public static void AddLabel(zeus.HelperClass.zLabel lbl, ref Label label, System.Windows.Forms.Form f)
        {
            string location      = lbl.location;
            string text          = lbl.text;
            string size          = lbl.size;
            string font          = lbl.fontFamily;
            string style         = lbl.fontStyle;
            string font_size     = lbl.fontSize;
            string color         = lbl.color;
            string textalign     = lbl.textAlign;
            string textTransform = lbl.textTransform;

            if (lbl.value != null && lbl.value != string.Empty)
            {
                text = lbl.value;
            }

            int X = int.Parse(location.Split(';')[0]);
            int Y = int.Parse(location.Split(';')[1]);

            label = new Label();
            //labels[label_count].Parent = img[1];
            label.Text = text;

            if (lbl.bgcolor.ToLower() == "transparent")
            {
                label.BackColor = Color.Transparent;
            }
            else
            {
                label.BackColor = Color.FromName(lbl.bgcolor);
            }

            label.Location = new Point(X, Y);

            if (size.Length != 0)
            {
                label.Size = new Size(int.Parse(size.Split(';')[0]), int.Parse(size.Split(';')[1]));
            }
            else
            {
                label.AutoSize = true;
            }
            // Цвет
            int red   = 0;
            int green = 0;
            int blue  = 0;

            if (color.Length > 5)
            {
                red   = int.Parse(color.Split(';')[0]);
                green = int.Parse(color.Split(';')[1]);
                blue  = int.Parse(color.Split(';')[2]);

                label.ForeColor = Color.FromArgb(red, green, blue);
            }
            if (font.Length != 0 && font_size.Length != 0)
            {
                FontStyle style1 = FontStyle.Regular;

                if (!string.IsNullOrEmpty(style))
                {
                    style1 = (FontStyle)Enum.Parse(typeof(FontStyle), style, true);
                }

                label.Font = new Font(font, float.Parse(font_size), style1);
            }

            if (!string.IsNullOrEmpty(textalign))
            {
                switch (textalign.ToLower())
                {
                case "middleright": label.TextAlign = ContentAlignment.MiddleRight; break;

                case "middleleft": label.TextAlign = ContentAlignment.MiddleLeft; break;

                case "middlecenter": label.TextAlign = ContentAlignment.MiddleCenter; break;

                case "topleft": label.TextAlign = ContentAlignment.TopLeft; break;

                case "topright": label.TextAlign = ContentAlignment.TopRight; break;

                case "topcenter": label.TextAlign = ContentAlignment.TopCenter; break;

                default:
                    label.TextAlign = ContentAlignment.TopLeft; break;
                }
            }
            f.Controls.Add(label);
        }