Esempio n. 1
0
File: Input.cs Progetto: Ijwu/Raptor
        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);
            }
        }
Esempio n. 2
0
 static public void ToPlainText()
 {
     try
     {
         if (NClipboard.ContainsText())
         {
             string text = NClipboard.GetText();
             NClipboard.SetText(text); //all formatting (e.g. RTF) will be removed
         }
     }
     catch { }
 }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
        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());
                                    }
            };
        }
Esempio n. 5
0
        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();
        }
Esempio n. 6
0
 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);
 }
Esempio n. 7
0
 public override bool MatchesClipboard()
 {
     return(Clipboard.ContainsText() && Clipboard.GetText() == text);
 }