public static bool GetUnicodeBlocks(bool TryWeb, bool WebOnly) { if (!GetUnicodeBlocksFile(TryWeb, WebOnly)) { return(false); } string[] BlocksStrings = null; try { BlocksStrings = File.ReadAllLines(BlocksFileName); } catch { return(false); } foreach (string s in BlocksStrings) { if (s.Trim() == string.Empty) { continue; //empty string } if (s.Trim().StartsWith("#")) { continue; //comment } string[] splitbuf = s.Split(';'); if (splitbuf.Length < 2) { return(false); //format error } string blockname = splitbuf[1].Trim(); splitbuf = splitbuf[0].Split(new string[] { ".." }, StringSplitOptions.None); if (splitbuf.Length < 2) { return(false); //format error } string start = splitbuf[0].Trim(); string end = splitbuf[1].Trim(); UnicodeBlock ub = new UnicodeBlock( Convert.ToInt32(start, 16), Convert.ToInt32(end, 16), blockname); UnicodeBlocks.Add(ub); } try { File.Delete(BlocksFileName); } catch { } return(true); }
private void cmbBlocks_SelectedIndexChanged(object sender, EventArgs e) { if (cmbBlocks.Items.Count == 0) { return; } if (cmbBlocks.SelectedIndex == -1) { cmbBlocks.SelectedIndex = 0; } UBN = cmbBlocks.SelectedIndex; UB = EncodingHelper.UnicodeBlocks[UBN]; ScrPG = 0; FillUnicodeTable(ScrPG); SetUnicLabelText(); }
private void frmMain_Load(object sender, EventArgs e) { ttMain.SetToolTip(btnNext, "Next page (CTRL+N)"); ttMain.SetToolTip(btnPrev, "Previous page (CTRL+P)"); //создание контролов для таблицы for (int i = 0; i < 256; i++) { TableItems[i] = new TableItem(); TableItems[i].Name = "TableItem" + i.ToString(); TableItems[i].Location = new Point(1, 1); TableItems[i].AutoSize = true; TableItems[i].Size = new System.Drawing.Size(51, 35); TableItems[i].TabIndex = i; Controls.Add(TableItems[i]); } //TableItems[255].Resize += new EventHandler(LastItemResize); PosTableItems(StartX, StartY); //получение списка кодировок EncodingInfo[] ei = Encoding.GetEncodings(); foreach (EncodingInfo einfo in ei) { int cp = einfo.CodePage; string name = einfo.Name; if ((Encoding.GetEncoding(cp).IsSingleByte) || (EncodingHelper.IsUnicode(cp))) { CPs.Add(cp); cmbCP.Items.Add(name); } } //получение блоков юникода if (!EncodingHelper.GetUnicodeBlocks(true, false)) //через сеть не получилось { if (!EncodingHelper.GetUnicodeBlocks(false, false)) //вообще не получилось { MessageBox.Show("GetUnicodeBlocks falied", "Error"); } } if (EncodingHelper.UnicodeBlocks.Count != 0) { //заполнение combobox с блоками foreach (UnicodeBlock ub in EncodingHelper.UnicodeBlocks) { cmbBlocks.Items.Add(ub.Desription + " [" + ub.StartHex + ".." + ub.EndHex + "]"); } //установка начального блока и данных UBN = 0; UB = EncodingHelper.UnicodeBlocks[UBN]; SetUnicLabelText(); } //установка начальных значений CP = 1251; lblCPName.Text = Encoding.GetEncoding(CP).EncodingName + " [" + Encoding.GetEncoding(CP).CodePage.ToString() + "]"; FillTableOneByte(); PosTableItems(StartX, StartY); this.Location = new Point((Screen.PrimaryScreen.Bounds.Width - this.Width) / 2, (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2); }