public MainWindow()
        {
            InitializeComponent();

            string[] blocksFile = System.IO.File.ReadAllLines(Directory.GetParent(Environment.CurrentDirectory).Parent.FullName + @"\Resources\UCD\Blocks.txt");
            string[] namesFile  = System.IO.File.ReadAllLines(Directory.GetParent(Environment.CurrentDirectory).Parent.FullName + @"\Resources\UCD\extracted\DerivedName.txt");

            //Regex rx = new Regex(@"\;[A-Z\s\-]+\;");
            //Regex n = new Regex(@"N;[A-Z\s\-]+;{4,}");
            //Create block from each line in Blocks.txt
            foreach (string s in blocksFile)
            {
                if (s.Contains(';'))
                {
                    string[] split   = s.Split(';');
                    string[] blSplit = split[0].Split("..");

                    blocks.Add(new Block
                    {
                        begin = blSplit[0].Trim(),
                        end   = blSplit[1].Trim(),
                        block = split[1].Trim()
                    });
                }
            }
            //Assign begin and end for each block in delimiter dictionary
            foreach (string s in namesFile)
            {
                if (s.Contains(';') && !s.Contains(".."))
                {
                    string[] split = s.Split(';');
                    delimiter.Add(int.Parse(split[0].Trim(), NumberStyles.HexNumber), split[1].Trim());
                }
            }
            //Assign individual unicodes from each block
            foreach (Block b in blocks)
            {
                int beginInt = int.Parse(b.begin, NumberStyles.HexNumber);
                int endInt   = int.Parse(b.end, NumberStyles.HexNumber);
                for (int i = beginInt; i <= endInt; i++)
                {
                    if (delimiter.ContainsKey(i))
                    {
                        Unicode u = new Unicode
                        {
                            Integer          = i,
                            Hex              = i.ToString("X"),
                            Block            = b.block,
                            Name             = delimiter[i],
                            DisplayCharacter = char.ConvertFromUtf32(i)
                        };
                        b.unicodes.Add(u);
                        names.Add(u);
                    }
                }
            }
        }
        void dataSelection(object sender, SelectedCellsChangedEventArgs e)
        {
            DataGrid d = sender as DataGrid;
            Unicode  b = d.SelectedItem as Unicode;

            integerText.Text = b.Integer.ToString();
            hexText.Text     = b.Hex;
            blockN.Text      = b.Block;
            name.Text        = b.Name;
            format.Text      = b.DisplayCharacter;
            display.Text     = b.DisplayCharacter;
        }
Example #3
0
        void fillWrap(Block block, FontFamily fontFamily)
        {
            Unicodes.Clear();
            wrapPanel.Children.Clear();

            try
            {
                int d  = int.Parse(block.begin, System.Globalization.NumberStyles.HexNumber);
                int du = int.Parse(block.end, System.Globalization.NumberStyles.HexNumber);
                for (int i = d; i <= du; i++)
                {
                    Unicode btn = new Unicode();
                    if (codes.ContainsKey(i))
                    {
                        btn.Background = new SolidColorBrush(new Color
                        {
                            A = 255,
                            R = 230,
                            G = 230,
                            B = 230
                        });
                        btn.Id         = i;
                        btn.hex        = String.Format("{0:X}", i);
                        btn.Content    = Char.ConvertFromUtf32(i);
                        btn.ToolTip    = codes[i];
                        btn.FontFamily = fontFamily;
                    }
                    else
                    {
                        btn.Content    = "";
                        btn.ToolTip    = "Empty";
                        btn.Background = Brushes.Red;
                    }

                    btn.Click += btnClick;

                    Unicodes.Add(btn);
                    wrapPanel.Children.Add(btn);
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }