コード例 #1
0
        private void generateFont()
        {
            btnGenerate.Enabled = false;
            try
            {
                if (cbBold.Checked)
                {
                    m_font.FontStyle = FontStyle.Bold;
                }
                else
                {
                    m_font.FontStyle = FontStyle.Regular;
                }

                int num = int.Parse(cbHeight.Text);
                pictureBoxC.Width  = num;
                pictureBoxC.Height = num;
                m_font.FontName    = cbChinese.Text;
                GdiFont.InfoGdiFont e_ = new GdiFont.InfoGdiFont();
                e_ = GdiFont.GetFontSize(
                    "S".Translate(),
                    m_font.FontName,
                    m_font.FontStyle,
                    pictureBoxC.Width,
                    pictureBoxC.Height,
                    (float)Utility.GetInt(cbHeight.Text),
                    true,
                    pictureBox
                    );
                if (e_.FontSize != 0f)
                {
                    m_font.FontSize = e_.FontSize;
                    m_font.Xpi      = ((pictureBoxC.Width - e_.Width) / 2) - e_.Xpi;
                    m_font.Ypi      = ((pictureBoxC.Height - e_.Height) / 2) - e_.Ypi;
                    Font font = new Font(m_font.FontName, m_font.FontSize, m_font.FontStyle);
                    m_image = new Bitmap(pictureBoxC.Width, pictureBoxC.Height);
                    Graphics graphics = Graphics.FromImage(m_image);
                    graphics.Clear(Color.FromArgb(0, 0, 0));
                    graphics.DrawString("S".Translate(), font, Brushes.Red, (PointF) new Point(m_font.Xpi, m_font.Ypi));
                    pictureBoxC.Image   = m_image;
                    btnGenerate.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
        private void refreshChars()
        {
            btnGenerate.Enabled = false;
            try
            {
                if (cbBold.Checked)
                {
                    m_char.FontStyle = FontStyle.Bold;
                }
                else
                {
                    m_char.FontStyle = FontStyle.Regular;
                }

                int num = int.Parse(cbHeight.Text);
                pictureBoxL.Width  = num / 2;
                pictureBoxL.Height = num;
                m_char.FontName    = cbLetter.Text;
                showFont           = GdiFont.GetFontSize(
                    "8",
                    m_char.FontName,
                    m_char.FontStyle,
                    pictureBoxL.Width,
                    pictureBoxL.Height,
                    (float)Utility.GetInt(cbHeight.Text),
                    true,
                    pictureBox
                    );
                if (showFont.FontSize != 0f)
                {
                    m_char.FontSize = showFont.FontSize;
                    m_char.Xpi      = ((pictureBoxL.Width - showFont.Width) / 2) - showFont.Xpi;
                    m_char.Ypi      = ((pictureBoxL.Height - showFont.Height) / 2) - showFont.Ypi;
                    Font font = new Font(m_char.FontName, m_char.FontSize, m_char.FontStyle);
                    m_image = new Bitmap(pictureBoxL.Width, pictureBoxL.Height);
                    adjustmentFont(m_image, m_char, Encoding.GetEncoding(cbEncode.Text), (byte)'X');
                    pictureBoxL.Image   = m_image;
                    btnGenerate.Enabled = true;
                }
            }
            catch { }
        }
コード例 #3
0
ファイル: FontCreator.cs プロジェクト: x893/NextionEditor
        private void generateFont()
        {
            btnGenerate.Enabled = false;
            try
            {
                if (cbBold.Checked)
                    m_font.FontStyle = FontStyle.Bold;
                else
                    m_font.FontStyle = FontStyle.Regular;

                int num = int.Parse(cbHeight.Text);
                pictureBoxC.Width = num;
                pictureBoxC.Height = num;
                m_font.FontName = cbChinese.Text;
                GdiFont.InfoGdiFont e_ = new GdiFont.InfoGdiFont();
                e_ = GdiFont.GetFontSize(
                                "S".Translate(),
                                m_font.FontName,
                                m_font.FontStyle,
                                pictureBoxC.Width,
                                pictureBoxC.Height,
                                (float)Utility.GetInt(cbHeight.Text),
                                true,
                                pictureBox
                            );
                if (e_.FontSize != 0f)
                {
                    m_font.FontSize = e_.FontSize;
                    m_font.Xpi = ((pictureBoxC.Width - e_.Width) / 2) - e_.Xpi;
                    m_font.Ypi = ((pictureBoxC.Height - e_.Height) / 2) - e_.Ypi;
                    Font font = new Font(m_font.FontName, m_font.FontSize, m_font.FontStyle);
                    m_image = new Bitmap(pictureBoxC.Width, pictureBoxC.Height);
                    Graphics graphics = Graphics.FromImage(m_image);
                    graphics.Clear(Color.FromArgb(0, 0, 0));
                    graphics.DrawString("S".Translate(), font, Brushes.Red, (PointF)new Point(m_font.Xpi, m_font.Ypi));
                    pictureBoxC.Image = m_image;
                    btnGenerate.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #4
0
ファイル: FontCreator.cs プロジェクト: x893/NextionEditor
        private void refreshChars()
        {
            btnGenerate.Enabled = false;
            try
            {
                if (cbBold.Checked)
                    m_char.FontStyle = FontStyle.Bold;
                else
                    m_char.FontStyle = FontStyle.Regular;

                int num = int.Parse(cbHeight.Text);
                pictureBoxL.Width = num / 2;
                pictureBoxL.Height = num;
                m_char.FontName = cbLetter.Text;
                showFont = GdiFont.GetFontSize(
                                "8",
                                m_char.FontName,
                                m_char.FontStyle,
                                pictureBoxL.Width,
                                pictureBoxL.Height,
                                (float)Utility.GetInt(cbHeight.Text),
                                true,
                                pictureBox
                            );
                if (showFont.FontSize != 0f)
                {
                    m_char.FontSize = showFont.FontSize;
                    m_char.Xpi = ((pictureBoxL.Width - showFont.Width) / 2) - showFont.Xpi;
                    m_char.Ypi = ((pictureBoxL.Height - showFont.Height) / 2) - showFont.Ypi;
                    Font font = new Font(m_char.FontName, m_char.FontSize, m_char.FontStyle);
                    m_image = new Bitmap(pictureBoxL.Width, pictureBoxL.Height);
                    adjustmentFont(m_image, m_char, Encoding.GetEncoding(cbEncode.Text), (byte)'X');
                    pictureBoxL.Image = m_image;
                    btnGenerate.Enabled = true;
                }
            }
            catch { }
        }