private void BtnSave_OnClick(object sender, RoutedEventArgs e) { var title = TxtTitle.Text; if (string.IsNullOrEmpty(title)) { const string msg = "Please specify a title for your snippet before saving it."; MessageBox.Show(msg, "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } var snippet = new TextSnippet(title, TxtContent.Text); if (_pluginEngine.PluginByType <SnippetsPlugin>().AddSnippet(this, snippet)) { snippet.SaveAsJson(); } Close(); }
private void ClipboardOnClipboardChanged([CanBeNull] object sender, SharpClipboard.ClipboardChangedEventArgs e) { IClipboardEntry entry = e.ContentType switch { SharpClipboard.ContentTypes.Text => new TextClipboardEntry { Title = _clipboard.ClipboardText.Trim().Replace("\n", "").Replace("\r", ""), Content = _clipboard.ClipboardText }, SharpClipboard.ContentTypes.Image => new ImageClipboardEntry { Title = $"Image - Copied {DateTime.Now.ToShortDateString()}", Content = _clipboard.ClipboardImage }, _ => null }; if (entry != null) { _pluginEngine.PluginByType <ClipboardManagerPlugin>().ClipboardHistory.AddFirst(entry); } }