private void ViewChanged() { if (PlainTextSelected) { _formatter = new PlainTextFormatter(SettingsUtils.GetEncoding()); ApplyFormatter(_formatter); } else if (HexSelected) { _formatter = new HexFormatter(); ApplyFormatter(_formatter); } }
private void Send() { if (FileSelected) { var filePath = Message; if (!File.Exists(filePath)) { DialogUtils.ShowErrorDialog("The file does not exist."); return; } if (new FileInfo(filePath).Length > 4096) { DialogUtils.ShowErrorDialog("The file is to large to send, maximum size is 16 KB."); return; } try { byte[] file = File.ReadAllBytes(filePath); SendData?.Invoke(file); } catch (Exception ex) { DialogUtils.ShowErrorDialog("Error while reading file. " + ex.Message); return; } } else { byte[] data = new byte[0]; try { data = _parser.Parse(Message, SettingsUtils.GetEncoding()); SendData?.Invoke(data); } catch (FormatException ex) { DialogUtils.ShowErrorDialog(ex.Message); return; } } }