Exemplo n.º 1
0
        private void ToolStripMenuItem_setbaseline_Click(object sender, EventArgs e)
        {
            if (listView_charmap.SelectedItems.Count > 0)
            {
                string tOut;
                if (DialogResult.OK == Dialog_InputBox.OpenDialog("请输入基线值, 前缀@表示相对量:", "设置字体基线", "0", out tOut))
                {
                    bool tOffset = false;
                    if (tOut.Length > 0 && tOut[0] == '@')
                    {
                        tOffset = true;
                        tOut    = tOut.Remove(0, 1);
                    }

                    int tValue;
                    try
                    {
                        tValue = Convert.ToInt32(tOut);
                    }
                    catch (Exception Expt)
                    {
                        Helper.ShowErr("格式不正确: " + Expt.Message);
                        return;
                    }

                    foreach (ListViewItem x in listView_charmap.SelectedItems)
                    {
                        FontDef.CharDef tDef = (FontDef.CharDef)x.Tag;

                        if (tOffset)
                        {
                            tDef.Baseline += tValue;
                        }
                        else
                        {
                            tDef.Baseline = tValue;
                        }
                    }
                }
            }

            Repaint();
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            // 收集所有字符
            HashSet<char> tList = new HashSet<char>();

            // 统计文本
            foreach (char x in textBox1.Text)
            {
                if (Char.IsControl(x))
                    continue;

                if (!tList.Contains(x))
                {
                    bool tAddable = true;
                    if (checkBox2.Checked)
                    {
                        foreach (FontDef.CharDef y in _Def.CharList)
                        {
                            if (y.Character == x)
                            {
                                tAddable = false;
                                break;
                            }
                        }
                    }

                    if (tAddable)
                        tList.Add(x);
                }
            }

            // 填充字符
            foreach (char x in tList)
            {
                if (_SelectedChars.Count > 0 && !checkBox3.Checked)
                {
                    _SelectedChars[0].SrcFont = fontDialog1.Font;
                    _SelectedChars[0].FontColor = colorDialog1.Color;
                    _SelectedChars[0].Character = x;
                    if (_SelectedChars[0].Character == ' ')
                        _SelectedChars[0].Advance = (int)(fontDialog1.Font.SizeInPoints * 0.8);

                    _SelectedChars.RemoveAt(0);
                }
                else
                {
                    if (checkBox1.Checked || checkBox3.Checked)
                    {
                        FontDef.CharDef tDef = new FontDef.CharDef();
                        tDef.SrcFont = fontDialog1.Font;
                        tDef.FontColor = colorDialog1.Color;
                        tDef.Character = x;
                        if (tDef.Character == ' ')
                            tDef.Advance = (int)(fontDialog1.Font.SizeInPoints * 0.8);

                        _Def.CharList.Add(tDef);
                    }
                    else
                        break;
                }
            }

            DialogResult = DialogResult.OK;
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            // 收集所有字符
            HashSet <char> tList = new HashSet <char>();

            // 统计文本
            foreach (char x in textBox1.Text)
            {
                if (Char.IsControl(x))
                {
                    continue;
                }

                if (!tList.Contains(x))
                {
                    bool tAddable = true;
                    if (checkBox2.Checked)
                    {
                        foreach (FontDef.CharDef y in _Def.CharList)
                        {
                            if (y.Character == x)
                            {
                                tAddable = false;
                                break;
                            }
                        }
                    }

                    if (tAddable)
                    {
                        tList.Add(x);
                    }
                }
            }

            // 填充字符
            foreach (char x in tList)
            {
                if (_SelectedChars.Count > 0 && !checkBox3.Checked)
                {
                    _SelectedChars[0].SrcFont   = fontDialog1.Font;
                    _SelectedChars[0].FontColor = colorDialog1.Color;
                    _SelectedChars[0].Character = x;
                    if (_SelectedChars[0].Character == ' ')
                    {
                        _SelectedChars[0].Advance = (int)(fontDialog1.Font.SizeInPoints * 0.8);
                    }

                    _SelectedChars.RemoveAt(0);
                }
                else
                {
                    if (checkBox1.Checked || checkBox3.Checked)
                    {
                        FontDef.CharDef tDef = new FontDef.CharDef();
                        tDef.SrcFont   = fontDialog1.Font;
                        tDef.FontColor = colorDialog1.Color;
                        tDef.Character = x;
                        if (tDef.Character == ' ')
                        {
                            tDef.Advance = (int)(fontDialog1.Font.SizeInPoints * 0.8);
                        }

                        _Def.CharList.Add(tDef);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            DialogResult = DialogResult.OK;
        }