private async void UpdateClipboard() { Indicator.IsBusy = true; if (ProfileComboBox.IsLoaded && ProfileComboBox.SelectedValue != null && ProfileComboBox.SelectedValue as string != "Default") { if (ProfileComboBox.Items.Contains("Default")) { UpdateProfileComboBox(false, ProfileComboBox.SelectedValue as string); } Clipboard.ClearHistory(); using (LiteDatabase db = new LiteDatabase($"Filename={Path.Combine(documents, "Auto Paste Clipboard", "data.db")}; Connection=shared")) { ILiteCollection <ClipboardProfile> collection = db.GetCollection <ClipboardProfile>("clipboard"); ClipboardProfile clipboardProfile = collection.FindOne(x => x.Profile == ProfileComboBox.SelectedValue as string); foreach (string item in clipboardProfile.Clipboard) { DataPackage data = new DataPackage(); data.SetText(item); Clipboard.SetContent(data); await Task.Delay(450); } DelimiterComboBox.SelectedIndex = clipboardProfile.Delimeter; DelayUpDownBox.Value = clipboardProfile.Delay; ProfileNameTextBox.Text = ProfileComboBox.SelectedValue as string; } } UndoChangesBtn.IsEnabled = false; Indicator.IsBusy = false; }
static Task PlatformSetTextAsync(string text) { var dataPackage = new DataPackage(); dataPackage.SetText(text); WindowsClipboard.SetContent(dataPackage); return(Task.CompletedTask); }
public void Copy(DataPackage data, bool flush = true) { data.RequestedOperation = DataPackageOperation.Copy; Clip.SetContent(data); if (flush) { Clip.Flush(); } }
static Func <string, CancellationToken, Task> CreateAsyncSet() { return((text, cancellation) => { var dataPackage = new DataPackage(); dataPackage.SetText(text); var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; return dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => UapClipboard.SetContent(dataPackage)) .AsTask(cancellation); }); }