public MainWindow() { InitializeComponent(); HexProcessor = new HexProcessor(); BinaryProcessor = new BinaryProcessor(); IntegerProcessor = new IntegerProcessor(); HistoryProcessor = new HistoryProcessor(); ReadFromClipboard(); }
private void ReadFromClipboard() { if (Clipboard.ContainsText(TextDataFormat.Text)) { string copiedText = Clipboard.GetText(TextDataFormat.Text).Trim(); if (BinaryProcessor.IsBinaryNumber(copiedText)) { BinaryTextBox.Text = copiedText; } else if (HexProcessor.IsHexNumber(copiedText)) { HexTextBox.Text = copiedText; } else if (IntegerProcessor.IsInteger(copiedText, out int intNumber)) { IntegerTextBox.Text = copiedText; } } }
private void HexTextBox_TextChanged(object sender, TextChangedEventArgs e) { var input = HexTextBox.Text.Trim(); if (!string.IsNullOrEmpty(input)) { if (HexProcessor.IsHexNumber(input)) { var hexValue = HexProcessor.ConvertToHex(input); IntegerTextBox.Text = hexValue.ToString(); BinaryTextBox.Text = hexValue.ToBinaryString(); PostConvertion(input); } else { ErrorMessage.Text = ERROR_MESSAGE; } } else { RefreshExecute(null, null); } }