public ClipboardHistoryList(ClipboardHistory history) { DataContext = new ViewModel(history); InitializeComponent(); _inputter = new Inputter(); this.OnActualUnload(Dispose); }
public ClipboardView(string location) { Location = location; Title = "<custom>"; PreviewText = "<Custom Data>"; try { Timestamp = ClipboardHistory.ToTimestamp(location); byte[] data = null; if ((data = ClipboardHistory.ReadFormatData(location, (int)ViewFormat.Image)) != null) { MainFormat = ViewFormat.Image; Title = "<Image>"; PreviewImage = data; PreviewText = "<Image>"; } else if ((data = ClipboardHistory.ReadFormatData(location, (int)ViewFormat.Files)) != null) { MainFormat = ViewFormat.Files; string[] files = Clipboard.GetDropFiles(data); Title = files.FirstOrDefault() ?? "<File/Directory>"; PreviewText = string.Join("\n", files); } else if ((data = ClipboardHistory.ReadFormatData(location, (int)ViewFormat.UnicodeText)) != null) { MainFormat = ViewFormat.UnicodeText; Title = PreviewText = data.ToUnicodeTitle(); } else if ((data = ClipboardHistory.ReadFormatData(location, (int)ViewFormat.PlainText)) != null) { MainFormat = ViewFormat.PlainText; Title = PreviewText = data.ToAsciiTitle(); } } catch { } Title = Title.Replace("\r\n", " ") .Replace("\r\n", " ") .Trim(); int titleMaxLength = 100; if (Title.Length > titleMaxLength) { Title = Title.Substring(0, titleMaxLength) + "..."; } }
public ViewModel(ClipboardHistory history) { History = history; Pinned = new BetterListCollectionView(History.Items) { Filter = x => (x as ClipboardEntry)?.IsPinned == true }; Recent = new BetterListCollectionView(History.Items) { Filter = x => (x as ClipboardEntry)?.IsPinned != true }; }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; // Debug.Assert(false); if (args.Contains("-start")) { Start(); } if (args.Contains("-purge")) { ClipboardHistory.Purge(); } if (args.Contains("-showdup")) { ClipboardHistory.Purge(showOnly: true); } if (args.Contains("-capture")) { new ClipboardHistory().MakeSnapshot(); } if (args.Contains("-toplaintext")) { Win32.Clipboard.ToPlainText(); } if (args.Contains("-clearall")) { ClearAll(); } var loadBuffer = args.FirstOrDefault(x => x.StartsWith("-load:")); if (loadBuffer.IsNotEmpty()) { // Debug.Assert(false); LoadSnapshot(loadBuffer.Replace("-load:", "")); } }
static void Start() { try { Log.WriteLine("================== Started =================="); var monitor = new ClipboardHistory(); var closeRequest = new EventWaitHandle(false, EventResetMode.ManualReset, Globals.CloseRequestName); ClipboardWatcher.OnClipboardChanged = () => { var p = new Process(); p.StartInfo.FileName = Assembly.GetExecutingAssembly().Location; p.StartInfo.Arguments = "-capture"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.CreateNoWindow = true; p.Start(); }; ClipboardWatcher.Enabled = true; Task.Factory.StartNew(() => { Console.WriteLine("Press 'Enter' to exit"); Console.ReadLine(); closeRequest.Set(); }); closeRequest.WaitOne(); } finally { ClipboardWatcher.Enabled = false; } }
public ClipboardPopup(ClipboardHistory history) { _history = history; }
static void LoadSnapshot(string bufferLocation) { ClipboardHistory.LoadSnapshot(bufferLocation); }
static void ClearAll() { ClipboardHistory.ClearAll(); }