예제 #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            // создание выбранного шрифта
            string name = cbFontName.Text.Trim();
            int    size;

            if (name == "")
            {
                SelectedFont = null;
                DialogResult = DialogResult.OK;
            }
            else if (int.TryParse(cbFontSize.Text, out size))
            {
                SelectedFont           = new SchemeView.Font();
                SelectedFont.Name      = name;
                SelectedFont.Size      = size;
                SelectedFont.Bold      = chkBold.Checked;
                SelectedFont.Italic    = chkItalic.Checked;
                SelectedFont.Underline = chkUnderline.Checked;
                DialogResult           = DialogResult.OK;
            }
            else
            {
                ScadaUtils.ShowError(SchemePhrases.SizeInteger);
            }
        }
예제 #2
0
            public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
            {
                if (destinationType == typeof(string))
                {
                    SchemeView.Font font = value as SchemeView.Font;

                    if (font == null)
                    {
                        return("");
                    }
                    else
                    {
                        StringBuilder sb = new StringBuilder();
                        if (!string.IsNullOrEmpty(font.Name))
                        {
                            sb.Append(font.Name);
                        }
                        if (sb.Length > 0)
                        {
                            sb.Append("; ");
                        }
                        sb.Append(font.Size);
                        if (font.Bold)
                        {
                            sb.Append(Localization.UseRussian ? "; Ж" : "; B");
                        }
                        if (font.Italic)
                        {
                            sb.Append(Localization.UseRussian ? "; К" : "; I");
                        }
                        if (font.Underline)
                        {
                            sb.Append(Localization.UseRussian ? "; П" : "; U");
                        }
                        return(sb.ToString());
                    }
                }
                else
                {
                    return(base.ConvertTo(context, culture, value, destinationType));
                }
            }