示例#1
0
        public static List <CodeSection> ParseString(int codepage, string text)
        {
            List <UInt16>      chars = new List <UInt16>();
            List <CodeSection> list = new List <CodeSection>();
            int first = 0, last = 0;
            int i;

            for (i = 0; i < text.Length; i++)
            {
                chars.Add(MySource.EncodingGetUint16(codepage, text.Substring(i, 1)));
            }
            for (i = 0; i < chars.Count; i++)
            {
                if (i == 0)
                {
                    first = chars[i];
                }
                else
                {
                    if (chars[i] != chars[i - 1])
                    {
                        last = chars[i - 1];
                        list.Add(new CodeSection(first, last));
                        first = chars[i];
                    }
                }
            }
            last = chars[i - 1];
            list.Add(new CodeSection(first, last));

            return(list);
        }
示例#2
0
        public MySource(MySource source)
        {
            var type = typeof(MySource);

            foreach (var item in type.GetProperties())
            {
                item.SetValue(this, item.GetValue(source, null), null);
            }
        }
示例#3
0
        public frmSource(MySource source)
        {
            InitializeComponent();

            this.source   = source;
            this.codepage = CodePageConverter.GetCodePage(source.CodePage);

            comboBoxSourceType.Items.AddRange(new string[] { SourceTypeConverter.SourceTypeSection, SourceTypeConverter.SourceTypeString });
            comboBoxSourceType.Text = source.SourceType;
            textBoxEdit.Text        = source.Source;
        }
示例#4
0
        public static string CheckValid(string SourceType, int codepage, string text)
        {
            if (SourceType == SourceTypeConverter.SourceTypeSection)
            {
                List <CodeSection> list = CodeSection.Parse(text);
                text = "";
                for (int i = 0; i < list.Count; i++)
                {
                    if (i > 0)
                    {
                        text += ",";
                    }
                    if (list[i].range != null)
                    {
                        text += "0x" + list[i].range.first_hh.ToString("X2").ToUpper() + ":" + list[i].range.first_ll.ToString("X2").ToUpper()
                                + "-" + "0x" + list[i].range.last_hh.ToString("X2").ToUpper() + ":" + list[i].range.last_ll.ToString("X2").ToUpper();
                    }
                    else
                    {
                        text += "0x" + list[i].first.ToString("X4").ToUpper() + "-0x" + list[i].last.ToString("X4").ToUpper();
                    }
                }
            }
            else
            {
                List <UInt16> list = new List <UInt16>();

                for (int i = 0; i < text.Length; i++)
                {
                    string strTmp = text.Substring(i, 1);
                    if (strTmp.Length > 0)
                    {
                        list.Add(MySource.EncodingGetUint16(codepage, strTmp));
                    }
                }
                list.Sort();
                text = "";
                for (int i = 0; i < list.Count; i++)
                {
                    if (i > 0)
                    {
                        if (list[i] == list[i - 1])
                        {
                            continue;
                        }
                    }
                    text += MySource.EncodingGetString(codepage, list[i]);
                }
            }

            return(text);
        }
示例#5
0
        private void buttonOk_Click(object sender, EventArgs e)
        {
            string text = CheckValid(comboBoxSourceType.Text, codepage, textBoxEdit.Text);

            if (text.Length == 0)
            {
                MessageBoxEx.Show("请检查输入数据!!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            textBoxEdit.Text = text;

            MySource sourceTmp = new MySource(source);

            sourceTmp.SourceType = comboBoxSourceType.Text;
            sourceTmp.Source     = textBoxEdit.Text;

            source = sourceTmp;

            DialogResult = DialogResult.OK;
        }
示例#6
0
 public FontConfig()
 {
     _font         = def_font;
     _font.Padding = def_padding;
     _source       = def_source;
 }
示例#7
0
 public void ResetSource()
 {
     _source = def_source;
 }