internal static string GetInputText(string text) { if (!Main.hasFocus) { return(text); } Main.inputTextEnter = ActiveSpecialKeys.HasFlag(SpecialKeys.Enter); if (ActiveSpecialKeys.HasFlag(SpecialKeys.Backspace) && text.Length != 0) { if (Control) { string[] words = text.Split(' '); return(String.Join(" ", words, 0, words.Length - 1)); } else { return(text.Substring(0, text.Length - 1)); } } else if (Control && ActiveSpecialKeys.HasFlag(SpecialKeys.V) && Clipboard.ContainsText()) { return(text + Clipboard.GetText()); } else { return(text + TypedString); } }
public string Classify(string work, out bool isEol) { // Log.Debug(new StackFrame(0, true)); string tempstring = Clipboard.GetText(); //Clipboard.Clear(); isEol = Regex.IsMatch(tempstring, @"reaching the end"); if (Replace(ref work, tempstring, out string replace)) { return(replace); }
static public void ToPlainText() { try { if (NClipboard.ContainsText()) { string text = NClipboard.GetText(); NClipboard.SetText(text); //all formatting (e.g. RTF) will be removed } } catch { } }
public winMain(winSplash splash = null) { InitializeComponent(); DataContext = this; if (splash != null) { splash.InvokeUpdate("Loading application settings ..."); } _FormulaZoom = Settings.Default.FormulaScale; ClipBgColor.SelectedColor = Settings.Default.BgColorToClip; JpgBgColor.SelectedColor = Settings.Default.BgColorToJpg; if (splash != null) { splash.InvokeUpdate("Loading V8 javascipt engine ..."); } _ = MathjaxParser.GetInstance(); if (splash != null) { splash.InvokeUpdate("Loading application resouces ..."); } //InitializeFontSelector(); //formulaFontName = ((FontFamily)eFontFamily.GetFirstCheckedItem().Tag).ToString(); //formulaFontSize = (double)eFontSize.EditValue; DataObject.AddCopyingHandler(txtInputFomula, OnInputFomulaCopying); if (Clipboard.ContainsText()) { myClipboard.Add(Clipboard.GetText()); } if (splash != null) { splash.InvokeUpdate("Loading latex resources ..."); } LoadSymbols(); if (splash != null) { splash.InvokeUpdate("Show window ..."); } AddNotifiactions(); Application.Current.Exit += OnApplicationExit; }
public GLTextBox(GLGui gui) : base(gui) { Render += OnRender; MouseDown += OnMouseDown; MouseUp += OnMouseUp; MouseEnter += OnMouseEnter; MouseLeave += OnMouseLeave; MouseMove += OnMouseMove; Focus += OnFocus; FocusLost += OnFocusLost; KeyDown += OnKeyDown; KeyPress += OnKeyPress; skinEnabled = Gui.Skin.TextBoxEnabled; skinActive = Gui.Skin.TextBoxActive; skinHover = Gui.Skin.TextBoxHover; skinDisabled = Gui.Skin.TextBoxDisabled; outer = new Rectangle(0, 0, 100, 0); ContextMenu = new GLContextMenu(gui); ContextMenu.Add(new GLContextMenuEntry(gui) { Text = "Copy" }).Click += (s, e) => { if (selectionStart.Index != cursorPosition.Index) { CopySelection(); } }; ContextMenu.Add(new GLContextMenuEntry(gui) { Text = "Paste" }).Click += (s, e) => { if (Clipboard.ContainsText()) { Insert(Clipboard.GetText()); } }; }
private void OnUIInit() { QMSingleButton CopyIDButton = new QMSingleButton( "ShortcutMenu", ButtonsX.Value, ButtonsY.Value, "Copy\nInstance ID", delegate() { Clipboard.SetText($"{RoomManager.field_Internal_Static_ApiWorld_0.id}:{RoomManager.field_Internal_Static_ApiWorldInstance_0.instanceId}"); }, "Copy the ID of the current instance." ); QMSingleButton JoinInstanceButton = new QMSingleButton( "ShortcutMenu", ButtonsX.Value, ButtonsY.Value, "Join\nInstance", delegate() { new PortalInternal().Method_Private_Void_String_String_PDM_0(Clipboard.GetText().Split(':')[0], Clipboard.GetText().Split(':')[1]); }, "Join an instance via your clipboard." ); Misc.ChangeButtonSize(CopyIDButton.getGameObject(), 420, 210); Misc.ChangeButtonSize(JoinInstanceButton.getGameObject(), 420, 210); Misc.MoveButton(CopyIDButton.getGameObject(), CopyIDButton.getGameObject().GetComponent <RectTransform>().localPosition.x, CopyIDButton.getGameObject().GetComponent <RectTransform>().localPosition.y + 105); Misc.MoveButton(JoinInstanceButton.getGameObject(), JoinInstanceButton.getGameObject().GetComponent <RectTransform>().localPosition.x, JoinInstanceButton.getGameObject().GetComponent <RectTransform>().localPosition.y - 105); }
private static bool TryParseClipboard(out Frame fr, out double ext) { if (ClipBoard.ContainsText()) { string cmd = ClipBoard.GetText().ToLower(); while (cmd.Contains(" ")) { cmd = cmd.Replace(" ", " "); // remove repeated spaces } List <string> tokens = cmd.Split(null).ToList(); // list elements can be removed. bool edef = false; // flags that ext, bas and or are defined from clipboard. bool bdef = false; bool odef = false; Point mm; Vector bx, by; double e1 = 0; while (tokens.Count > 0) { SpaceClaim.Api.V16.Application.ReportStatus(string.Format("Parsing token {0} from {1}", tokens[0], tokens.Count), StatusMessageType.Information, null); if (tokens[0].Contains("or")) { double x = float.Parse(tokens[1], CultureInfo.InvariantCulture.NumberFormat); double y = float.Parse(tokens[2], CultureInfo.InvariantCulture.NumberFormat); double z = float.Parse(tokens[3], CultureInfo.InvariantCulture.NumberFormat); tokens.RemoveAt(0); tokens.RemoveAt(0); tokens.RemoveAt(0); tokens.RemoveAt(0); odef = true; mm = Point.Create(x / cc, y / cc, z / cc); SpaceClaim.Api.V16.Application.ReportStatus(string.Format("Parsed or: {0}, {1}, {2}", x, y, z), StatusMessageType.Information, null); } else if (tokens[0].Contains("bas")) { tokens.RemoveAt(0); var vals = new List <Double> { }; for (int i = 1; i <= 6; i++) { vals.Add(float.Parse(tokens[0], CultureInfo.InvariantCulture.NumberFormat)); SpaceClaim.Api.V16.Application.ReportStatus(string.Format("Parsed bas: {0}, {1}", tokens[0], vals.Last()), StatusMessageType.Information, null); tokens.RemoveAt(0); } bx = Vector.Create(vals[0], vals[1], vals[2]); by = Vector.Create(vals[3], vals[4], vals[5]); bdef = true; } else if (tokens[0].Contains("ext")) { // use only the first entry here e1 = float.Parse(tokens[1], CultureInfo.InvariantCulture.NumberFormat); tokens.RemoveAt(0); tokens.RemoveAt(0); edef = true; SpaceClaim.Api.V16.Application.ReportStatus(string.Format("Parsed ext: {0}", e1), StatusMessageType.Information, null); } else { tokens.RemoveAt(0); } } if (odef && bdef && edef) { fr = Frame.Create(mm, bx.Direction, by.Direction); ext = e1 / cc; SpaceClaim.Api.V16.Application.ReportStatus("ClipBoard parsed.", StatusMessageType.Information, null); return(true); } else { fr = Frame.Create(mm, Vector.Create(0, 0, 1).Direction); ext = 0.0; return(false); } } throw new NotImplementedException(); }
public static async Task <bool> ReadAloud(FunctionArgs args) { string action = args["action"]; switch (action) { case "pause": App.Current.Logger.LogError("ReadAloud: pause not supported"); break; case "stop": case "play": Functions.speechPlayer?.Stop(); Functions.speechPlayer?.Dispose(); Functions.speechPlayer = null; if (action == "stop") { break; } App.Current.Logger.LogDebug("ReadAloud: Storing clipboard"); IDataObject?clipboardData = Clipboard.GetDataObject(); Dictionary <string, object?>?dataStored = null; if (clipboardData != null) { dataStored = clipboardData.GetFormats() .ToDictionary(format => format, format => (object?)clipboardData.GetData(format, false)); } Clipboard.Clear(); // Get the selection App.Current.Logger.LogDebug("ReadAloud: Getting selected text"); await SelectionReader.Default.GetSelectedText(System.Windows.Forms.SendKeys.SendWait); string text = Clipboard.GetText(); // Restore the clipboard App.Current.Logger.LogDebug("ReadAloud: Restoring clipboard"); Clipboard.Clear(); dataStored?.Where(kv => kv.Value != null).ToList() .ForEach(kv => Clipboard.SetData(kv.Key, kv.Value)); // Talk the talk SpeechSynthesizer synth = new SpeechSynthesizer(); SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync(text); speechPlayer = new SoundPlayer(stream.AsStream()); speechPlayer.LoadCompleted += (o, args) => { speechPlayer.Play(); }; speechPlayer.LoadAsync(); break; } return(true); }
private bool OnKeyDown(object sender, KeyboardKeyEventArgs e) { if (!enabled) { return(false); } if (e.Key == Key.Delete) { if (selectionStart.Index != cursorPosition.Index) { future.Clear(); history.Push(text); RemoveSelection(); } else if (cursorPosition.Index < text.Length) { future.Clear(); history.Push(text); text = text.Remove(cursorPosition.Index, 1); } else { return(true); } Invalidate(); if (Changed != null) { Changed(this, e); } return(true); } if (e.Key == Key.BackSpace) { if (selectionStart.Index != cursorPosition.Index) { future.Clear(); history.Push(text); RemoveSelection(); } else if (cursorPosition.Index > 0) { future.Clear(); history.Push(text); text = text.Remove(--cursorPosition.Index, 1); selectionStart = cursorPosition; } else { return(true); } Invalidate(); if (Changed != null) { Changed(this, e); } return(true); } if (e.Key == Key.Enter && Multiline) { Insert("\n"); return(true); } if (e.Key == Key.Left && cursorPosition.Index > 0) { cursorPosition.Index--; cursorPosition.Position = new Vector2(float.MaxValue, float.MaxValue); cursorPosition = skin.Font.GetTextPosition(textProcessed, cursorPosition); if (!e.Shift) { selectionStart = cursorPosition; } return(true); } if (e.Key == Key.Right && cursorPosition.Index < text.Length) { cursorPosition.Index++; cursorPosition.Position = new Vector2(float.MaxValue, float.MaxValue); cursorPosition = skin.Font.GetTextPosition(textProcessed, cursorPosition); if (!e.Shift) { selectionStart = cursorPosition; } return(true); } if (e.Key == Key.Up && cursorPosition.Position.Y > 0.0f) { cursorPosition.Index = int.MaxValue; cursorPosition.Position.Y -= skin.Font.LineSpacing; cursorPosition = skin.Font.GetTextPosition(textProcessed, cursorPosition); if (!e.Shift) { selectionStart = cursorPosition; } return(true); } if (e.Key == Key.Down) { cursorPosition.Index = int.MaxValue; cursorPosition.Position.Y += skin.Font.LineSpacing; cursorPosition = skin.Font.GetTextPosition(textProcessed, cursorPosition); if (!e.Shift) { selectionStart = cursorPosition; } return(true); } if (e.Control && e.Key == Key.A) { selectionStart.Index = 0; selectionStart.Position = new Vector2(float.MaxValue, float.MaxValue); selectionStart = skin.Font.GetTextPosition(textProcessed, selectionStart); cursorPosition.Index = text.Length; cursorPosition.Position = new Vector2(float.MaxValue, float.MaxValue); cursorPosition = skin.Font.GetTextPosition(textProcessed, cursorPosition); return(true); } if (e.Control && e.Key == Key.X) { if (selectionStart.Index != cursorPosition.Index) { future.Clear(); history.Push(text); CopySelection(); RemoveSelection(); Invalidate(); if (Changed != null) { Changed(this, e); } } return(true); } if (e.Control && e.Key == Key.C) { if (selectionStart.Index != cursorPosition.Index) { CopySelection(); } return(true); } if (e.Control && e.Key == Key.V) { if (Clipboard.ContainsText()) { Insert(Clipboard.GetText()); } return(true); } if (e.Control && e.Key == Key.Z) { if (!e.Shift) { if (history.Count > 0) { future.Push(text); text = history.Pop(); Invalidate(); } } else if (future.Count > 0) { history.Push(text); text = future.Pop(); Invalidate(); } return(true); } if (e.Key == Key.Tab) { if (selectionStart.Index != cursorPosition.Index) { Indent(e.Shift); } else { Insert("\t"); } return(true); } if (e.Key == Key.Home) { cursorPosition.Index = int.MaxValue; cursorPosition.Position.X = 0; cursorPosition = skin.Font.GetTextPosition(textProcessed, cursorPosition); if (!e.Shift) { selectionStart = cursorPosition; } return(true); } if (e.Key == Key.End) { cursorPosition.Index = int.MaxValue; cursorPosition.Position.X = float.MaxValue; cursorPosition = skin.Font.GetTextPosition(textProcessed, cursorPosition); if (!e.Shift) { selectionStart = cursorPosition; } return(true); } return(false); }
public string GetText() => WinClipboard.GetText();
public override bool MatchesClipboard() { return(Clipboard.ContainsText() && Clipboard.GetText() == text); }