private void textBoxCommand_TextPasted(object sender, ClipboardEventArgs e) { if (e.ClipboardText.Contains("\n")) { e.Handled = true; // Get current text, insert at caret and process, leave any trailing line unpasted StringBuilder currText = new StringBuilder(textBoxCommand.Text); currText.Insert(textBoxCommand.SelectionStart, e.ClipboardText); string[] parts = Regex.Split(currText.ToString(), @"(?<=[\n])"); foreach (string line in parts) { if (line.EndsWith("\n")) { WriteOutputString(lblPrompt.Text + " " + line.TrimEnd('\r', '\n') + Environment.NewLine); _input.Enqueue(line.TrimEnd('\r', '\n')); } else { if (String.IsNullOrWhiteSpace(line)) { _input.Enqueue(String.Empty); textBoxCommand.Text = String.Empty; } else { textBoxCommand.Text = line; textBoxCommand.SelectionStart = line.Length; } } } } }
private void ClipboardWatcher_OnClipboardModified(object sender, ClipboardEventArgs e) { Invoke((Action)(() => { Clips.Add(new KeyValuePair <Guid, string>(Guid.NewGuid(), (string)e.Data)); })); }
/// <summary> /// Handles the TextPasted event of the ClipboardTextBox controls. /// Prevents the pasting of text that cannot be converted to a number. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="ClipboardEventArgs"/> instance containing the event data.</param> private void ClipboardTextBox_TextPasted(object sender, ClipboardEventArgs e) { if (!int.TryParse(e.ClipboardText, out int result)) { // Pasted text is not a integer number e.Handled = true; } }
private static JsonElement GetJsonElement(ClipboardEventArgs args) { var json = JsonSerializer.SerializeToUtf8Bytes(args, JsonSerializerOptionsProvider.Options); var jsonReader = new Utf8JsonReader(json); var jsonElement = JsonElement.ParseValue(ref jsonReader); return(jsonElement); }
public void onGetClipboard(object o, ClipboardEventArgs e) { if (e.RemoteIP != RemoteIP) { return; } textBox1.Text = e.data; }
private void ClipboardOpen(object sender, ClipboardEventArgs e) { if (copied) { return; } copied = true; Thread.Sleep(150); ClipboardWatcher.Stop(); callback.OnClipboardCopy(Clipboard.GetText(TextDataFormat.Text)); }
private void OnClipboardPaste(object sender, ClipboardEventArgs e) { var clipboardText = (e.Text ?? string.Empty).Replace('.', _decimalSeparator).Replace(',', _decimalSeparator); double clipboardValue; if (double.TryParse(clipboardText, out clipboardValue) == false) { clipboardText = null; } e.Text = clipboardText; }
private void ClipboardListener(object sender, ClipboardEventArgs e) { if (hexCopied) { // releaseCtrl(); return; } hexCopied = true; Thread.Sleep(150); //releaseCtrl(); SendHexBack(); }
public void Read_Works() { // Arrange var args = new ClipboardEventArgs { Type = "Some type" }; var jsonElement = GetJsonElement(args); // Act var result = ClipboardEventArgsReader.Read(jsonElement); // Assert Assert.Equal(args.Type, result.Type); }
protected override void WndProc(ref Message m) { switch (m.Msg) { case WmCut: if (CutText != null) { var args = new ClipboardEventArgs(SelectedText); CutText(this, args); if (!args.Cancel) { base.WndProc(ref m); } } break; case WmCopy: if (CopiedText != null) { var args = new ClipboardEventArgs(SelectedText); CopiedText(this, args); if (!args.Cancel) { base.WndProc(ref m); } } break; case WmPaste: if (PastedText != null) { var args = new ClipboardEventArgs(Clipboard.GetText()); PastedText(this, args); if (!args.Cancel) { base.WndProc(ref m); } } break; default: base.WndProc(ref m); break; } }
protected override void WndProc(ref Message m) { if (m.Msg == 0x302 && Clipboard.ContainsText() && ClipboardPaste != null) { var clipboardEventArgs = new ClipboardEventArgs(Clipboard.GetText()); ClipboardPaste(this, clipboardEventArgs); if (string.IsNullOrEmpty(clipboardEventArgs.Text)) { return; } Clipboard.SetText(clipboardEventArgs.Text); } base.WndProc(ref m); }
internal static ClipboardEventArgs Read(JsonElement jsonElement) { var eventArgs = new ClipboardEventArgs(); foreach (var property in jsonElement.EnumerateObject()) { if (property.NameEquals(TypeKey.EncodedUtf8Bytes)) { eventArgs.Type = property.Value.GetString() !; } else { throw new JsonException($"Unknown property {property.Name}"); } } return(eventArgs); }
private void OnSourcePaste(Object sender, ClipboardEventArgs args) { String result; if (this.TryFormatJson(args.Text, out result)) { this.Source = result; this.Type = SourceType.Json; return; } if (this.TryFormatXml(args.Text, out result)) { this.Source = result; this.Type = SourceType.Xml; return; } this.ShowError("Unable to paste document, neither as JSON nor as XML. Maybe enable edit mode and try again."); }
// クリップボードにテキストがコピーされると呼び出される private void OnClipBoardChanged(object sender, ClipboardEventArgs args) { string input_str; int i = 0; this.textBox1.Text = args.Text; input_str = this.textBox1.Text; // unixtime or datetime を確認 DateTime dt; if (DateTime.TryParse(input_str, out dt)) { // date -> unixtime this.label2.Text = "DateTime -> UnixTime"; var dto = new DateTimeOffset(dt, new TimeSpan(+09, 00, 00)); var dtot = dto.ToUnixTimeSeconds(); string dt_str = dtot.ToString(); this.textBox2.Text = dt_str; } else if ( int.TryParse(input_str, out i) ) { // unixtime -> date this.label2.Text = "UnixTime -> DateTime"; //int input_int = int.Parse(input_str); var dto = (DateTimeOffset.FromUnixTimeSeconds(int.Parse(input_str)).ToLocalTime()); string dt_str = dto.ToString(); this.textBox2.Text = dt_str; } else { this.label2.Text = "DateTimeに変換できません。"; this.textBox2.Text = ""; } }
/// <summary>Occurs when the clipboard paste event fires.</summary> /// <param name="sender">The sender.</param> /// <param name="e">The event args.</param> protected virtual void OnClipboardPaste(object sender, ClipboardEventArgs e) { ClipboardPaste?.Invoke(sender, e); }
internal NativeClipboardEventArgs(ClipboardEventArgs src, NativeJsObject jsObject) { CopyProps(src, this); _jsObject = jsObject; }
private void TextBox_ClipboardPaste(object sender, ClipboardEventArgs e) { GenerateEventItem("Pasted from clipboard."); }
private void TextBox_ClipboardCut(object sender, ClipboardEventArgs e) { GenerateEventItem("Cut to clipboard."); }
private static void OnClipboardChanged(ClipboardEventArgs e) { if (ClipboardChanged != null) ClipboardChanged(null, e); }
// クリップボードにテキストがコピーされると呼び出される private void OnClipBoardChanged(object sender, ClipboardEventArgs args) { }
/// <summary> /// Paste hook for descendants. /// </summary> #pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously protected virtual async Task OnPaste(ClipboardEventArgs args) #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously { // do nothing return; }
private void TxtSegment_Pasted(object sender, ClipboardEventArgs e) { SetValueFromClipBoard(); }
private void txtVLCArgs_PastedText(object sender, ClipboardEventArgs e) { //reformat VLC local arguments to input arguments Clipboard.SetText(e.ClipboardText.Trim().Replace(":", Environment.NewLine + "-").Trim()); }
/// <summary> /// Raises the <c>@onpaste</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/> /// to the event handler. /// </summary> /// <param name="element">The element to raise the event on.</param> /// <param name="eventArgs">The event arguments to pass to the event handler.</param> public static void Paste(this IElement element, ClipboardEventArgs eventArgs) => _ = PasteAsync(element, eventArgs);
/// <summary> /// Raises the <c>@oncopy</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/> /// to the event handler. /// </summary> /// <param name="element">The element to raise the event on.</param> /// <param name="eventArgs">The event arguments to pass to the event handler.</param> public static void Copy(this IElement element, ClipboardEventArgs eventArgs) => _ = CopyAsync(element, eventArgs);
/// <summary>Occurs when the clipboard cut event fires.</summary> /// <param name="e">The event args.</param> protected virtual void OnClipboardCut(ClipboardEventArgs e) { ClipboardCut?.Invoke(this, e); }
/// <summary>Occurs when the clipboard paste event fires.</summary> /// <param name="e">The event args.</param> protected virtual void OnClipboardPaste(ClipboardEventArgs e) { ClipboardPaste?.Invoke(this, e); }
/// <summary> /// Raises the <c>@onpaste</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/> /// to the event handler. /// </summary> /// <param name="element"></param> /// <param name="eventArgs"></param> /// <returns>A task that completes when the event handler is done.</returns> public static Task PasteAsync(this IElement element, ClipboardEventArgs eventArgs) => element.TriggerEventAsync("onpaste", eventArgs);
public override void Run() { ClipboardEventArgs e1 = new ClipboardEventArgs(Client.RemoteEndPoint.ToString(), tmp); ClipboardEvent.OnClipboard(e1); }
/// <summary> /// Raises the <c>@oncopy</c> event on <paramref name="element"/>, passing the provided <paramref name="eventArgs"/> /// to the event handler. /// </summary> /// <param name="element"></param> /// <param name="eventArgs"></param> /// <returns>A task that completes when the event handler is done.</returns> public static Task CopyAsync(this IElement element, ClipboardEventArgs eventArgs) => element.TriggerEventAsync("oncopy", eventArgs);
private void OnClipBoardChanged(object sender, ClipboardEventArgs args) { if (Clipboard.ContainsText(System.Windows.Forms.TextDataFormat.Text)) { var clipText = ""; clipText = (String)System.Windows.Forms.Clipboard.GetData(System.Windows.Forms.DataFormats.StringFormat); using (MemoryStream ms = (MemoryStream)System.Windows.Forms.Clipboard.GetData("Csv")) { //★特別処理★Excelからのコピー (改行がある場合ダブルコーテーションが追加されるので削除する) //こちらの処理を入れない場合は一旦wordに貼り付けてコピー if (ms != null) { if (clipText.Contains("\n") && clipText.StartsWith(@"""")) { clipText = clipText.Replace(@"""""", "\t¶\t"); clipText = clipText.Replace(@"""", ""); clipText = clipText.Replace("\t¶\t", @""""); } } } var item = getClipTextItem(clipText); if (item == null) { return; } Point p = new Point(0, 0); APIList.GetCursorPos(out p); try { if (this.contextMenuStrip1.Items.Count > 0 && this.contextMenuStrip1.Items[0].Tag != null) { if ((String)(this.contextMenuStrip1.Items[0].Tag) == (String)clipText) { if (Properties.Settings.Default.SameWordAlert == true) { //キャレットの位置が違ったら(マウスの位置で判定しているのでカーソル移動の時は無視される(公認バグ?)) if ((oldPoint.X != p.X || oldPoint.Y != p.Y)) { this.Activate(); MessageBox.Show("同じデータが追加されました。"); //this.notifyIcon1.BalloonTipText = "同じデータが追加されました。"; //this.notifyIcon1.ShowBalloonTip(100); } } return; } } } finally { oldPoint = p; } this.contextMenuStrip1.Items.Insert(0, item); //履歴数を超えた場合の削除処理 int MaxCountData = Properties.Settings.Default.RirekiCount; if (this.ClipboardHistoryCount > MaxCountData) { for (int index = this.contextMenuStrip1.Items.Count - 1; index >= MaxCountData; index--) { if (this.contextMenuStrip1.Items[index].Tag != null) { this.contextMenuStrip1.Items.RemoveAt(index); } } } //検索用の履歴 int MaxSerchCountData = Properties.Settings.Default.ALLRirekiCount; if (this.ALLClipData.Contains(clipText) == false) { this.ALLClipData.Insert(0, clipText); if (this.ALLClipData.Count > MaxSerchCountData) { for (int index = this.ALLClipData.Count - 1; index >= MaxSerchCountData; index--) { this.ALLClipData.RemoveAt(index); } } } } }