Beispiel #1
0
        private void ShowAscii()
        {
            string hexString = BitConverter.ToString(bytesDataA).Replace("-", string.Empty);
            var    ascii     = hexString.HexStrToAscii();

            LinesA = Split(ascii, 32);
            int sector = (LinesA.Count - 4) / 4;

            for (int i = LinesA.Count - 4; i >= 0; i -= 4)
            {
                LinesA.Insert(i, $"+{Translate.Key(nameof(MifareWindowsTool.Properties.Resources.Sector))}: {sector--}\r");
            }
            txtOutput.Document = new System.Windows.Documents.FlowDocument();
            txtOutput.AppendText(new string(LinesA.SelectMany(c => c).ToArray()));
        }
Beispiel #2
0
        private void ShowHex()
        {
            txtOutput.Document = new System.Windows.Documents.FlowDocument();
            string hex       = BitConverter.ToString(bytesDataA).Replace("-", string.Empty);
            int    cptOffset = 0;

            LinesA = Split(hex, 32);
            int sector = (LinesA.Count - split) / split;

            for (int i = LinesA.Count - split; i >= 0; i -= split)
            {
                LinesA.Insert(i, $"+{Translate.Key(nameof(MifareWindowsTool.Properties.Resources.Sector))}: {sector--}\r");
            }

            for (int line = 0; line < LinesA.Count; line++)
            {
                if (line == 1)
                {
                    txtOutput.AppendText(LinesA[line], VioletBrush, false);
                }
                else if (line > 0 && (line % (split + (split + 1) * cptOffset)) == 0)
                {
                    for (int c = 0; c < LinesA[line].Length; c++)
                    {
                        if (c <= 11)
                        {
                            txtOutput.AppendText(LinesA[line][c].ToString(), Brushes.Lime);
                        }
                        else if (c > 11 && c <= 19)
                        {
                            txtOutput.AppendText(LinesA[line][c].ToString(), Brushes.Orange);
                        }
                        else
                        {
                            txtOutput.AppendText(LinesA[line][c].ToString(), Brushes.Green);
                        }
                    }
                    cptOffset += 1;
                }
                else
                {
                    txtOutput.AppendText(LinesA[line], Brushes.White, false);
                }
            }
        }
        private void ShowCompareDumps()
        {
            if (bytesDataA == null || bytesDataB == null)
            {
                return;
            }

            Mouse.OverrideCursor = Cursors.Wait;
            txtOutput.Document   = new System.Windows.Documents.FlowDocument();

            string hexA = BitConverter.ToString(bytesDataA).Replace("-", string.Empty);
            string hexB = BitConverter.ToString(bytesDataB).Replace("-", string.Empty);

            LinesA = Split(hexA, blocksize * 2);
            LinesB = Split(hexB, blocksize * 2);
            if (bytesDataA.Length == 1024)
            {
                split = 4;
            }

            int sectorA = (LinesA.Count - split) / split;

            for (int i = LinesA.Count - split; i >= 0; i -= split)
            {
                LinesA.Insert(i, $"\r+{Translate.Key(nameof(MifareWindowsTool.Properties.Resources.Sector))}:{sectorA--}\r");
            }

            int sectorB = (LinesB.Count - split) / split;

            for (int i = LinesB.Count - split; i >= 0; i -= split)
            {
                LinesB.Insert(i, "");
            }

            for (int i = 0; i < Math.Max(LinesA.Count, LinesB.Count); i++)
            {
                if (i < LinesA.Count && !LinesA[i].StartsWith("\r+") || i < LinesB.Count && !LinesB[i].StartsWith("\r+"))
                {
                    if (i < LinesA.Count && i < LinesB.Count && LinesA[i] == LinesB[i])
                    {
                        txtOutput.AppendText("____________"); txtOutput.AppendText(Translate.Key(nameof(MifareWindowsTool.Properties.Resources.Identical)), Brushes.Lime); txtOutput.AppendText("_____________\r", Brushes.White);
                    }
                    else if (i < LinesB.Count && !string.IsNullOrWhiteSpace(LinesB[i]))
                    {
                        txtOutput.AppendText("____________"); txtOutput.AppendText(Translate.Key(nameof(MifareWindowsTool.Properties.Resources.Different)), Brushes.Red); txtOutput.AppendText("_____________\r", Brushes.White);

                        for (int j = 0; j < LinesA[i].Count(); j++)
                        {
                            if (j == 0)
                            {
                                txtOutput.AppendText("  ");
                            }
                            if (LinesA[i][j] != LinesB[i][j])
                            {
                                txtOutput.AppendText("v", Brushes.Red);
                            }
                            else
                            {
                                txtOutput.AppendText(" ", Brushes.White);
                            }
                        }
                        txtOutput.AppendText("\r", Brushes.White);
                    }
                }
                if (i < LinesA.Count)
                {
                    txtOutput.AppendText((!string.IsNullOrWhiteSpace(LinesA[i]) && !LinesA[i].StartsWith("\r+") ? "A:" : "") + LinesA[i], LinesA[i].StartsWith("\r+") ? PaleBlueBrush : Brushes.White, LinesA[i].StartsWith("\r+") ? true : false);
                }
                if (i < LinesB.Count)
                {
                    txtOutput.AppendText((!string.IsNullOrWhiteSpace(LinesB[i]) && !LinesB[i].StartsWith("\r+") ? "B:" : "") + LinesB[i], LinesB[i].StartsWith("\r+") ? PaleBlueBrush : Brushes.White, LinesB[i].StartsWith("\r+") ? true : false);
                }
            }
            Mouse.OverrideCursor = null;
        }