public override void OnSelected(AutocompleteMenu popupMenu, SelectedEventArgs e)
 {
     e.Tb.BeginUpdate();
     e.Tb.Selection.BeginUpdate();
     //remember places
     var p1 = popupMenu.Fragment.Start;
     var p2 = e.Tb.Selection.Start;
     //do auto indent
     if (e.Tb.AutoIndent)
     {
         for (int iLine = p1.iLine + 1; iLine <= p2.iLine; iLine++)
         {
             e.Tb.Selection.Start = new Place(0, iLine);
             e.Tb.DoAutoIndent(iLine);
         }
     }
     e.Tb.Selection.Start = p1;
     //move caret position right and find char ^
     while (e.Tb.Selection.CharBeforeStart != '^')
         if (!e.Tb.Selection.GoRightThroughFolded())
             break;
     //remove char ^
     e.Tb.Selection.GoLeft(true);
     e.Tb.InsertText("");
     //
     e.Tb.Selection.EndUpdate();
     e.Tb.EndUpdate();
 }
Пример #2
0
        public frmScript(bool forceBlank = false)
        {
            InitializeComponent();

            DebugInfo config = ConfigManager.Config.DebugInfo;

            _popupMenu           = new AutocompleteMenu(txtScriptContent, this);
            _popupMenu.ImageList = new ImageList();
            _popupMenu.ImageList.Images.Add(Resources.Enum);
            _popupMenu.ImageList.Images.Add(Resources.Function);
            _popupMenu.SelectedColor = Color.LightBlue;
            _popupMenu.SearchPattern = @"[\w\.]";

            List <AutocompleteItem> items = new List <AutocompleteItem>();

            _availableFunctions.Sort((a, b) => {
                int type = a[0].CompareTo(b[0]);
                if (type == 0)
                {
                    return(a[1].CompareTo(b[1]));
                }
                else
                {
                    return(-type);
                }
            });

            foreach (List <string> item in _availableFunctions)
            {
                MethodAutocompleteItem autocompleteItem = new MethodAutocompleteItem(item[1]);
                autocompleteItem.ImageIndex   = item[0] == "func" ? 1 : 0;
                autocompleteItem.ToolTipTitle = item[2];
                if (!string.IsNullOrWhiteSpace(item[3]))
                {
                    autocompleteItem.ToolTipText = "Parameters" + Environment.NewLine + item[3] + Environment.NewLine + Environment.NewLine;
                }
                if (!string.IsNullOrWhiteSpace(item[4]))
                {
                    autocompleteItem.ToolTipText += "Return Value" + Environment.NewLine + item[4] + Environment.NewLine + Environment.NewLine;
                }
                if (!string.IsNullOrWhiteSpace(item[5]))
                {
                    autocompleteItem.ToolTipText += "Description" + Environment.NewLine + item[5] + Environment.NewLine + Environment.NewLine;
                }
                items.Add(autocompleteItem);
            }

            _popupMenu.Items.SetAutocompleteItems(items);

            UpdateRecentScripts();

            mnuTutorialScript.Checked     = config.ScriptStartupBehavior == ScriptStartupBehavior.ShowTutorial;
            mnuBlankWindow.Checked        = config.ScriptStartupBehavior == ScriptStartupBehavior.ShowBlankWindow;
            mnuAutoLoadLastScript.Checked = config.ScriptStartupBehavior == ScriptStartupBehavior.LoadLastScript;

            if (!forceBlank)
            {
                if (mnuAutoLoadLastScript.Checked && mnuRecentScripts.DropDownItems.Count > 0)
                {
                    string scriptToLoad = config.RecentScripts.Where((s) => File.Exists(s)).FirstOrDefault();
                    if (scriptToLoad != null)
                    {
                        LoadScriptFile(scriptToLoad, false);
                    }
                }
                else if (mnuTutorialScript.Checked)
                {
                    using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Mesen.GUI.Debugger.Example.lua")) {
                        using (StreamReader reader = new StreamReader(stream)) {
                            txtScriptContent.Text = reader.ReadToEnd();
                            _originalText         = txtScriptContent.Text;
                            txtScriptContent.ClearUndo();
                        }
                    }
                }
            }

            if (!config.ScriptWindowSize.IsEmpty)
            {
                this.Size = config.ScriptWindowSize;
            }
            mnuSaveBeforeRun.Checked = config.SaveScriptBeforeRun;

            if (config.ScriptCodeWindowHeight >= ctrlSplit.Panel1MinSize)
            {
                if (config.ScriptCodeWindowHeight == Int32.MaxValue)
                {
                    ctrlSplit.CollapsePanel();
                }
                else
                {
                    ctrlSplit.SplitterDistance = config.ScriptCodeWindowHeight;
                }
            }

            txtScriptContent.Font = new Font(config.ScriptFontFamily, config.ScriptFontSize, config.ScriptFontStyle);
            txtScriptContent.Zoom = config.ScriptZoom;

            if (!this.DesignMode)
            {
                this._notifListener = new InteropEmu.NotificationListener();
                this._notifListener.OnNotification += this._notifListener_OnNotification;

                this.InitShortcuts();
            }
        }
 public override void OnSelected(AutocompleteMenu popupMenu, SelectedEventArgs e)
 {
     base.OnSelected(popupMenu, e);
 }
Пример #4
0
        public frmScript(bool forceBlank = false)
        {
            InitializeComponent();
            ThemeHelper.ExcludeFromTheme(txtScriptContent);
            txtScriptContent.ForeColor = Color.Black;

            DebugInfo.ApplyConfig();

            List <string> builtInScripts = new List <string> {
                "DmcCapture.lua", "DrawMode.lua", "Example.lua", "GameBoyMode.lua", "Grid.lua", "LogParallax.lua", "ModifyScreen.lua", "NtscSafeArea.lua", "ReverseMode.lua", "SpriteBox.lua"
            };

            foreach (string script in builtInScripts)
            {
                ToolStripItem item = mnuBuiltInScripts.DropDownItems.Add(script);
                item.Click += (s, e) => {
                    LoadBuiltInScript(item.Text);
                };
            }

            tsToolbar.AddItemsToToolbar(
                mnuOpen, mnuSave, null,
                mnuRun, mnuStop, null,
                mnuBuiltInScripts
                );

            DebugInfo config = ConfigManager.Config.DebugInfo;

            _popupMenu           = new AutocompleteMenu(txtScriptContent, this);
            _popupMenu.ImageList = new ImageList();
            _popupMenu.ImageList.Images.Add(Resources.Enum);
            _popupMenu.ImageList.Images.Add(Resources.Function);
            _popupMenu.SelectedColor = Color.LightBlue;
            _popupMenu.SearchPattern = @"[\w\.]";

            List <AutocompleteItem> items = new List <AutocompleteItem>();

            _availableFunctions.Sort((a, b) => {
                int type = a[0].CompareTo(b[0]);
                if (type == 0)
                {
                    return(a[1].CompareTo(b[1]));
                }
                else
                {
                    return(-type);
                }
            });

            foreach (List <string> item in _availableFunctions)
            {
                MethodAutocompleteItem autocompleteItem = new MethodAutocompleteItem(item[1]);
                autocompleteItem.ImageIndex   = item[0] == "func" ? 1 : 0;
                autocompleteItem.ToolTipTitle = item[2];
                if (!string.IsNullOrWhiteSpace(item[3]))
                {
                    autocompleteItem.ToolTipText = "Parameters" + Environment.NewLine + item[3] + Environment.NewLine + Environment.NewLine;
                }
                if (!string.IsNullOrWhiteSpace(item[4]))
                {
                    autocompleteItem.ToolTipText += "Return Value" + Environment.NewLine + item[4] + Environment.NewLine + Environment.NewLine;
                }
                if (!string.IsNullOrWhiteSpace(item[5]))
                {
                    autocompleteItem.ToolTipText += "Description" + Environment.NewLine + item[5] + Environment.NewLine + Environment.NewLine;
                }
                items.Add(autocompleteItem);
            }

            _popupMenu.Items.SetAutocompleteItems(items);

            UpdateRecentScripts();

            mnuTutorialScript.Checked     = config.ScriptStartupBehavior == ScriptStartupBehavior.ShowTutorial;
            mnuBlankWindow.Checked        = config.ScriptStartupBehavior == ScriptStartupBehavior.ShowBlankWindow;
            mnuAutoLoadLastScript.Checked = config.ScriptStartupBehavior == ScriptStartupBehavior.LoadLastScript;

            if (!forceBlank)
            {
                if (mnuAutoLoadLastScript.Checked && mnuRecentScripts.DropDownItems.Count > 0)
                {
                    string scriptToLoad = config.RecentScripts.Where((s) => File.Exists(s)).FirstOrDefault();
                    if (scriptToLoad != null)
                    {
                        LoadScriptFile(scriptToLoad, false);
                    }
                }
                else if (mnuTutorialScript.Checked)
                {
                    LoadBuiltInScript("Example.lua");
                }
            }

            RestoreLocation(config.ScriptWindowLocation, config.ScriptWindowSize);
            mnuSaveBeforeRun.Checked = config.SaveScriptBeforeRun;

            if (config.ScriptCodeWindowHeight >= ctrlSplit.Panel1MinSize)
            {
                if (config.ScriptCodeWindowHeight == Int32.MaxValue)
                {
                    ctrlSplit.CollapsePanel();
                }
                else
                {
                    ctrlSplit.SplitterDistance = config.ScriptCodeWindowHeight;
                }
            }

            txtScriptContent.Font = new Font(config.ScriptFontFamily, config.ScriptFontSize, config.ScriptFontStyle);
            txtScriptContent.Zoom = config.ScriptZoom;
        }
Пример #5
0
 public CssAutoCompletionMap(AutocompleteMenu menu)
     : base(menu)
 {
 }
Пример #6
0
        public void crea_un_nuovo_progetto(string path = "", bool is_example = false, string type = "pa")
        {
            try
            {
                foreach (TabPage tab in develop_area.Controls)
                {
                    if ((tab.Tag != null && tab.Tag.ToString() != "") && tab.Tag.ToString() == path)
                    {
                        MessageBox.Show("Documento già aperto!");
                        return;
                    }
                }

                string title = "";
                if (string.IsNullOrWhiteSpace(path))
                {
                    title = "New_project_" + (develop_area.TabCount + 1).ToString() + ".pa";
                    //console.AppendText("Created New_project_" + (develop_area.TabCount + 1).ToString() + ".pa\n");
                    consoleTextBox1.WriteLine("Created New_project_" + (develop_area.TabCount + 1).ToString() + "." + type + "\r\n");
                }
                else
                {
                    title = Path.GetFileName(path);
                    //console.AppendText("Loaded : " + title + "\n");
                    consoleTextBox1.WriteLine("Loaded : " + title + "\r\n");
                }

                saveAsToolStripMenuItem.Enabled = true;
                saveToolStripMenuItem.Enabled   = true;

                TabPage new_proj = new TabPage();
                new_proj.Tag  = is_example ? "" : path;
                new_proj.Text = title;

                var tb = new FastColoredTextBox();
                tb.Font = new Font("Curier", 10.25F);
                //tb.ContextMenuStrip = cmMain; Bello da fare!
                tb.Dock = DockStyle.Fill;
                //tb.BorderStyle = BorderStyle.Fixed3D;
                //tb.VirtualSpace = true;
                tb.LeftPadding = 17;
                tb.Language    = type == "pa" ? Language.PA : Language.C;
                tb.AddStyle(sameWordsStyle);//same words style
                tb.MouseDoubleClick += removeBook;
                //tb.OpenFile(path);
                tb.Tag = new TbInfo();

                tb.ToolTipNeeded += ToolTipNeeded;

                new_proj.Controls.Add(tb);
                develop_area.TabPages.Add(new_proj);

                develop_area.SelectedTab = new_proj;

                tb.Focus();
                tb.DelayedTextChangedInterval = 1000;
                tb.DelayedEventsInterval      = 500;

                tb.DragDrop  += DragDrop;
                tb.DragEnter += DragEnter;

                tb.HighlightingRangeType = HighlightingRangeType.VisibleRange;

                if (path == "")
                {
                    tb.Text = "# PoliAssembly 1.1.0v Project\r\n# Created by : " + Environment.MachineName + "\r\n# Data : " + DateTime.Now + "\r\n# info [email protected]";
                }
                else
                {
                    tb.Text = (type == "pa" ? decrypt_file_ex(File.ReadAllText(path)) : File.ReadAllText(path));
                }

                tb.IsChanged = false;
                //MENU CON SUGGERIMENTI
                if (type == "pa")
                {
                    AutocompleteMenu popupMenu = new AutocompleteMenu(tb);
                    popupMenu.Opening += new EventHandler <CancelEventArgs>(popupMenu_Opening);
                    BuildAutocompleteMenu(popupMenu);
                    (tb.Tag as TbInfo).popupMenu = popupMenu;
                }

                CloseTab.Enabled = true;
            }
            catch (Exception ex)
            {
                if (MessageBox.Show(ex.Message, "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == System.Windows.Forms.DialogResult.Retry)
                {
                    crea_un_nuovo_progetto(path);
                }
            }
        }
Пример #7
0
 public DynamicCollection(AutocompleteMenu menu, FastColoredTextBox tb)
 {
     this.menu = menu;
     this.tb   = tb;
 }
Пример #8
0
 public CSharpAutoCompletionMap(AutocompleteMenu menu)
     : base(menu, _separators)
 {
 }
Пример #9
0
        private void initAutoComplete()
        {
            autoComplete = new AutocompleteMenu(sourceCodeBox);
            autoComplete.MinFragmentLength = 2;
            autoComplete.MaximumSize       = new Size(200, 300);
            autoComplete.Items.Width       = 200;
            var keywords = new List <string>();
            var operand1 = new List <string>();
            var items    = new List <AutocompleteItem>();

            keywords.Add("SET");
            keywords.Add("ADD");
            keywords.Add("SUB");
            keywords.Add("MUL");
            keywords.Add("DIV");
            keywords.Add("MOD");
            keywords.Add("SHL");
            keywords.Add("SHR");
            keywords.Add("AND");
            keywords.Add("BOR");
            keywords.Add("XOR");
            keywords.Add("IFE");
            keywords.Add("IFN");
            keywords.Add("IFG");
            keywords.Add("IFB");

            keywords.Add("JSR");

            operand1.Add("A");
            operand1.Add("B");
            operand1.Add("C");
            operand1.Add("I");
            operand1.Add("J");
            operand1.Add("X");
            operand1.Add("Y");
            operand1.Add("Z");

            operand1.Add("PUSH");
            operand1.Add("POP");
            operand1.Add("PEEK");
            operand1.Add("SP");
            operand1.Add("PC");
            operand1.Add("O");

            //operand1.Add("[");
            //operand1.Add("+");
            //operand1.Add("]");

            var operand2 = new List <string>(operand1);

            operand2.Add("0x");

            foreach (string s in keywords)
            {
                items.Add(new AutocompleteItem(s));
            }

            foreach (string s in operand1)
            {
                items.Add(new AutocompleteItem(s));
            }



            keywords.Add("DAT");

            operand1.Add(".vram");
            operand1.Add(".keyboard");


            items.Add(new InsertSpaceSnippet());
            items.Add(new InsertSpaceSnippet("(\\w+)([=<>!:,]+)(\\w+)"));

            autoComplete.Items.SetAutocompleteItems(items);
        }
Пример #10
0
        private void CreateTab(string fileName)
        {
            try
            {
                var tb = new FastColoredTextBox();
                tb.BackColor       = Color.FromArgb(31, 39, 42);
                tb.ForeColor       = Color.FromArgb(200, 200, 200);
                tb.IndentBackColor = Color.FromArgb(5, 7, 15);
                tb.LineNumberColor = Color.FromArgb(10, 192, 200);
                //  tb.SelectionColor =  Color.FromArgb(200,255,240,150);
                tb.SelectionColor = Color.FromArgb(255, 240, 150);
                ///   tb.FoldingIndicatorColor =  Color.FromArgb(240,208,88,37);
                tb.FoldingIndicatorColor = Color.FromArgb(240, 255, 196, 68);
                //   tb.High =  Color.FromArgb(240,208,88,37);

                // tb.Font = new Font("Courier New", 9.75f,FontStyle.Bold);
                tb.Font             = new Font("Consolas", 9.75f, FontStyle.Bold);
                tb.ContextMenuStrip = cmMain;
                tb.Dock             = DockStyle.Fill;
                tb.BorderStyle      = BorderStyle.Fixed3D;
                //tb.VirtualSpace = true;
                tb.LeftPadding = 17;
                tb.Language    = Language.CSharp;
                tb.AddStyle(sameWordsStyle);//same words style
                var tab = new FATabStripItem(fileName != null?Path.GetFileName(fileName):"[new]", tb);
                tab.Tag = fileName;

                //  tab.Cor = Color.FromArgb(255,196,68);
                if (fileName != null)
                {
                    tb.OpenFile(fileName);
                }
                tb.Tag = new TbInfo();
                tsFiles.AddTab(tab);


                tsFiles.SelectedItem = tab;
                tb.Focus();
                // tb.DelayedTextChangedInterval = 1000;
                tb.DelayedTextChangedInterval = 1;
                // tb.DelayedEventsInterval = 500;
                tb.DelayedEventsInterval    = 1;
                tb.TextChangedDelayed      += new EventHandler <TextChangedEventArgs>(tb_TextChangedDelayed);
                tb.SelectionChangedDelayed += new EventHandler(tb_SelectionChangedDelayed);
                tb.KeyDown         += new KeyEventHandler(tb_KeyDown);
                tb.MouseMove       += new MouseEventHandler(tb_MouseMove);
                tb.ChangedLineColor = changedLineColor;
                if (btHighlightCurrentLine.Checked)
                {
                    tb.CurrentLineColor = currentLineColor;
                }
                tb.ShowFoldingLines      = btShowFoldingLines.Checked;
                tb.HighlightingRangeType = HighlightingRangeType.VisibleRange;
                //create autocomplete popup menu
                AutocompleteMenu popupMenu = new AutocompleteMenu(tb);
                popupMenu.Items.ImageList = ilAutocomplete;
                popupMenu.Opening        += new EventHandler <CancelEventArgs>(popupMenu_Opening);
                BuildAutocompleteMenu(popupMenu);
                (tb.Tag as TbInfo).popupMenu = popupMenu;


                tab.BackColor = Color.FromArgb(255, 196, 68); //NotWork?
            }
            catch (Exception ex)
            {
                if (MessageBox.Show(ex.Message, "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) == System.Windows.Forms.DialogResult.Retry)
                {
                    CreateTab(fileName);
                }
            }
        }
Пример #11
0
 public AutocompleteItems(AutocompleteMenu argMenu, BoardTextBox argBoard)
 {
     mMenu  = argMenu;
     mBoard = argBoard;
 }
Пример #12
0
 /// <summary>
 /// This method is called after item inserted into text
 /// </summary>
 public virtual void OnSelected(AutocompleteMenu popupMenu, SelectedEventArgs e)
 {
     ;
 }
Пример #13
0
 public SyntaxRichTextBox()
 {
     Intelisense = new AutocompleteMenu();
 }
Пример #14
0
        /// <summary>
        /// The main_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        /// <exception cref="FileNotFoundException">
        /// Exception thrown if the file is not found
        /// </exception>
        private void Main_Load(object sender, EventArgs e)
        {
            // Populate Treeview
            this.DashGlobal.FilesHelper.SetTreeviewDirectory(this.directoryTreeView, Settings.Default.TreeviewDir);

            // TODO - Optimise this
            this.DashGlobal.EditorHelper.UserVariablesCurrentFile = new List <UserVariable>();

            // Set window size from memory
            if (Settings.Default.WindowMaximised)
            {
                this.WindowState = FormWindowState.Maximized;
            }
            else
            {
                this.Size = new Size(
                    Convert.ToInt32(Settings.Default.Window_Width),
                    Convert.ToInt32(Settings.Default.Window_Height));
            }

            // Clear tabs + add default tab
            foreach (TabPage tab in this.mainTabControl.TabPages)
            {
                this.mainTabControl.TabPages.Remove(tab);
            }

            // Allow the textArea_TextChanged event to fire so
            // we get syntax highlighting in open files on form load
            allowSyntaxHighlighting = true;

            if (Settings.Default.OpenTabs != null)
            {
                if (Settings.Default.OpenTabs.Count == 0)
                {
                    this.DashGlobal.TabsHelper.CreateBlankTab(FileType.Other);
                    this.ArmaSense = this.DashGlobal.EditorHelper.CreateArmaSense();
                }
                else
                {
                    foreach (var file in Settings.Default.OpenTabs)
                    {
                        try
                        {
                            if (File.Exists(file))
                            {
                                this.DashGlobal.TabsHelper.CreateTabOpenFile(file);
                            }
                            else
                            {
                                throw new FileNotFoundException("The file was not found!");
                            }
                        }
                        catch
                        {
                            MessageBox.Show(string.Format("Unable to open file:\n\n{0}", file));
                        }
                    }

                    if (Settings.Default.SelectedTab < this.mainTabControl.TabCount)
                    {
                        this.mainTabControl.SelectTab(Settings.Default.SelectedTab);
                    }
                }
            }
            else
            {
                Settings.Default.OpenTabs = new List <string>();
            }

            if (this.mainTabControl.TabPages.Count == 0)
            {
                this.DashGlobal.TabsHelper.CreateBlankTab();
                this.DashGlobal.SetWindowTitle("{new file}");
            }

            if (Settings.Default.FirstLoad)
            {
                var tutorialFile = AppDomain.CurrentDomain.BaseDirectory + "\\tutorial.txt";
                if (File.Exists(tutorialFile))
                {
                    this.DashGlobal.TabsHelper.CreateBlankTab(FileType.Other, "tutorial.txt");
                    this.DashGlobal.EditorHelper.GetActiveEditor().Text = File.ReadAllText(tutorialFile);
                    this.DashGlobal.TabsHelper.SetSelectedTabClean();
                }
            }

            // Add file watcher to update treeview on file change
            // watcher.Path = Settings.Default.TreeviewDir;

            // watcher.NotifyFilter = NotifyFilters.DirectoryName |
            // NotifyFilters.FileName |
            // NotifyFilters.LastAccess |
            // NotifyFilters.LastWrite;

            // watcher.Created += FileSystemChanged;
            // watcher.Changed += FileSystemChanged;
            // watcher.Deleted += FileSystemChanged;
            // watcher.Renamed += FileSystemChanged;

            // watcher.EnableRaisingEvents = true;
            formLoaded = true;

            // Apply stored settings
            this.mainSplitContainer.SplitterDistance = Convert.ToInt32(Settings.Default.SplitterWidth);

            this.DashGlobal.EditorHelper.ActiveEditor.GoHome();
        }
Пример #15
0
 private void InitControls()
 {
     luaAcm = CreateAcm(editor);
     miEanbleCodeAnalyze.Checked = false;
     smiLbCodeanalyze.Enabled    = false;
 }
Пример #16
0
 /// <summary>
 ///     Initializes AutoComplteMenu
 /// </summary>
 private void CreateAutoCompleteMenu()
 {
     _autocomplete = new AutocompleteMenu(codebox);
     _autocomplete.AppearInterval = 50;
     _autocomplete.AllowTabKey    = true;
 }
Пример #17
0
        public void refresh()
        {
            nomeAcaoTxt.Text = acao.Nome;
            tooltipTxt.Text  = acao.Tooltip;
            requerParametroCheck.IsChecked = acao.requerParametro;



            scintilla = new ScintillaNET.Scintilla();
            scintilla.StyleResetDefault();
            scintilla.Styles[ScintillaNET.Style.Default].Font = "Monaco";
            scintilla.Styles[ScintillaNET.Style.Default].Size = 10;
            scintilla.StyleClearAll();
            scintilla.AutomaticFold = (AutomaticFold.Show | AutomaticFold.Click | AutomaticFold.Change);
            scintilla.Dock          = DockStyle.Fill;


            // Configure the CPP (C#) lexer styles
            scintilla.Styles[ScintillaNET.Style.Cpp.Default].ForeColor        = Color.Silver;
            scintilla.Styles[ScintillaNET.Style.Cpp.Comment].ForeColor        = Color.FromArgb(0, 128, 0);     // Green
            scintilla.Styles[ScintillaNET.Style.Cpp.CommentLine].ForeColor    = Color.FromArgb(0, 128, 0);     // Green
            scintilla.Styles[ScintillaNET.Style.Cpp.CommentLineDoc].ForeColor = Color.FromArgb(128, 128, 128); // Gray
            scintilla.Styles[ScintillaNET.Style.Cpp.Number].ForeColor         = Color.Olive;
            scintilla.Styles[ScintillaNET.Style.Cpp.Word].ForeColor           = Color.Blue;
            scintilla.Styles[ScintillaNET.Style.Cpp.Word2].ForeColor          = Color.Blue;
            scintilla.Styles[ScintillaNET.Style.Cpp.String].ForeColor         = Color.FromArgb(163, 21, 21); // Red
            scintilla.Styles[ScintillaNET.Style.Cpp.Character].ForeColor      = Color.FromArgb(163, 21, 21); // Red
            scintilla.Styles[ScintillaNET.Style.Cpp.Verbatim].ForeColor       = Color.FromArgb(163, 21, 21); // Red
            scintilla.Styles[ScintillaNET.Style.Cpp.StringEol].BackColor      = Color.Pink;
            scintilla.Styles[ScintillaNET.Style.Cpp.Operator].ForeColor       = Color.Purple;
            scintilla.Styles[ScintillaNET.Style.Cpp.Preprocessor].ForeColor   = Color.Maroon;
            scintilla.Lexer = Lexer.Cpp;


            // Set the keywords
            scintilla.SetKeywords(0, "abstract as base break case catch checked continue default delegate do else event explicit extern false finally fixed for foreach goto if implicit in interface internal is lock namespace new null object operator out override params private protected public readonly ref return sealed sizeof stackalloc switch this throw true try typeof unchecked unsafe using virtual while");
            scintilla.SetKeywords(1, "var bool byte char class const decimal double enum float int long sbyte short static string struct uint ulong ushort void");
            scintilla.Text    = acao.CodeScript;
            winFormHost.Child = scintilla;

            AutocompleteMenu menu = new AutocompleteMenu();

            menu.TargetControlWrapper = new ScintillaWrapper(scintilla);

            List <string> arqs = Directory.GetFiles("source-codes").ToList();


            List <string> arqsContent = new List <string>();

            foreach (var arq in arqs)
            {
                arqsContent.Add(File.ReadAllText(arq, Encoding.Default));
            }

            string[] snippets = arqsContent.ToArray();
            //string[] snippets = {   "//Input Template\nBrowser.Wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(\"principal\"));\nBy modoDeProcura = By.Name(\"elementName\");\nBrowser.Wait.Until(ExpectedConditions.ElementExists(modoDeProcura));\nIWebElement inputElement = Browser.Driver.FindElement(modoDeProcura);\ninputElement.SendKeys(Parametro);\nPassou = true;",
            //                        "//Button Template\nBrowser.Wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(\"toolbar\"));\nBy modoDeProcura = By.Id(\"elementId\");\nBrowser.Wait.Until(ExpectedConditions.ElementExists(modoDeProcura));\nIWebElement btn_Element = Browser.Driver.FindElement(modoDeProcura);\nbtn_Element.Click();\nPassou = true;",
            //                        "//RadioButton Template\n//Mudar para o Frame que contém o elemento\nBrowser.Wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(\"principal\"));\nint opt = 0;\n//Colocar elementos referentes a ordem\nif (Parametro.ToUpper() == \"MÉDICO\")\nopt = 0;\nif (Parametro.ToUpper() == \"ODONTOLÓGICO\")\nopt = 1;\n//Seletor Do Elemento\nBy modoDeProcura = By.Name(\"elementName\");\nBrowser.Wait.Until(ExpectedConditions.ElementExists(modoDeProcura));\nIWebElement radioBtn_Element = Browser.Driver.FindElements(modoDeProcura)[opt];\nradioBtn_Element.Click();\nPassou = true;",
            //                        "//CheckBox Template\n //Mudar para o Frame que contém o elemento\nBrowser.Wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(\"principal\"));\nstring opt = \"\";\n//Colocar elementos referentes a ordem\nif (Parametro.ToUpper() == \"AMBULATÓRIO / CONSULTÓRIO\")\nopt = \"regime_1\";\nif (Parametro.ToUpper() == \"SADT\")\nopt = \"regime_2\";\nif (Parametro.ToUpper() == \"INTERNAÇÃO HOSPITALAR\")\nopt = \"regime_3\";\nif (Parametro.ToUpper() == \"HOSPITAL DIA\")\nopt = \"regime_4\";\n//Seletor Do Elemento\nBy modoDeProcura = By.Name(opt);\nBrowser.Wait.Until(ExpectedConditions.ElementExists(modoDeProcura));\nIWebElement checkBox_Element = Browser.Driver.FindElement(modoDeProcura);\ncheckBox_Element.Click();\nPassou = true;",
            //                        "//Dropdown Template\nBrowser.Wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(\"principal\"));\nBy modoDeProcura = By.Name(\"element_name\");\nBrowser.Wait.Until(ExpectedConditions.ElementExists(modoDeProcura));\nvar dropDownElement = new SelectElement(Browser.Driver.FindElement(modoDeProcura));\ndropDownElement.SelectByText(Parametro);\nPassou = true;",
            //                        "//Javascript Command\nBrowser.Wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(\"menu\"));\nBrowser.Sleep(3);\n//Comando javascript referente ao acesso da função (verificar menu)\nBrowser.JSexec.ExecuteScript(@\"\nSelecionarMenu('../../ans/asp/ans1025a.asp?cod_funcao=F&pt=Finalizar\nReferência&pprf=ADMIN&pprm=N,N,N,N,N,S&pcf=ANS20.4&pm=2&pr=S', '');\n\");\nBrowser.Sleep(3);\nPassou = true;",
            //                        "//Alerta\nBrowser.Wait.Until(ExpectedConditions.AlertIsPresent());\nBrowser.Driver.SwitchTo().Alert().Accept();",
            //                        "//VERIFICADOR\ntry\n{\nBrowser.Wait.Until(ExpectedConditions.FrameToBeAvailableAndSwitchToIt(\"menu\"));\nPassou = true;\n}\ncatch (Exception ex)\n{\nPassou = false;\n}\n//Se o resultado esperado é a FALHA, então inverta o sucesso.\nif (Parametro.ToUpper() == \"SIM\")\n{\nPassou = Passou;\n}\nelse //\"NÃO\"\n{\nPassou = !Passou;\n}",
            //                        File.ReadAllText("source-codes\\alterar-janela.cs"),
            //                        File.ReadAllText("source-codes\\by-cssSelector.cs")
            //                   };

            //string[] snippets = { "if(^)\n{\n}", "if(^)\n{\n}\nelse\n{\n}", "for(^;;)\n{\n}", "while(^)\n{\n}", "do${\n^}while();", "switch(^)\n{\n\tcase : break;\n}" };
            menu.Items = snippets;
        }
Пример #18
0
        public void buildAutoCompleteMenu(AutocompleteMenu popupMenu)
        {
            AutoPop();
            List <AutocompleteItem> items = new List <AutocompleteItem>();

            foreach (var item in delRepeatData(folderName))
            {
                items.Add(new MethodAutocompleteItem(item)
                {
                    ImageIndex = 4
                });
            }
            foreach (var item in delRepeatData(fileName))
            {
                items.Add(new MethodAutocompleteItem(item)
                {
                    ImageIndex = 3
                });
            }
            foreach (var item in delRepeatData(classes))
            {
                items.Add(new MethodAutocompleteItem(item)
                {
                    ImageIndex = 1
                });
            }
            foreach (var item in delRepeatData(methods))
            {
                items.Add(new MethodAutocompleteItem(item)
                {
                    ImageIndex = 2
                });
            }

            foreach (var item in snippets)
            {
                items.Add(new SnippetAutocompleteItem(item)
                {
                    ImageIndex = 1
                });
            }
            foreach (var item in declarationSnippets)
            {
                items.Add(new DeclarationSnippet(item)
                {
                    ImageIndex = 0
                });
            }
            foreach (var item in keywords)
            {
                items.Add(new AutocompleteItem(item));
            }

            items.Add(new InsertSpaceSnippet());
            items.Add(new InsertSpaceSnippet(@"^(\w+)([=<>!:]+)(\w+)$"));
            items.Add(new InsertEnterSnippet());

            //set as autocomplete source
            popupMenu.Items.SetAutocompleteItems(items);
            popupMenu.Items.MaximumSize = new System.Drawing.Size(200, 300);
            popupMenu.Items.Width       = 200;
            popupMenu.SearchPattern     = @"[\w\.:=!<>]";
            popupMenu.ImageList.Images.Add(global::TestExerciser.Properties.Resources.python);
            popupMenu.ImageList.Images.Add(global::TestExerciser.Properties.Resources.folder);
        }
Пример #19
0
 void InitControls()
 {
     // script editor
     luaEditor = Misc.UI.CreateLuaEditor(pnlEditorContainer);
     luaAcm    = settings.AttachSnippetsTo(luaEditor);
 }
Пример #20
0
        public TextEditor(string path, Control parent)
        {
            InitPlatformSpecificRegexes();
            path = path.NormalizePath();

            Parrent = parent as Editor;
            if (!File.Exists(path))
            {
                MessageBox.Show($"Unable to find file \"{path}\"");
                return;
            }

            TextBox = new FastColoredTextBox
            {
                Dock = DockStyle.Fill,
                Text = File.ReadAllText(path),

                BracketsHighlightStrategy = BracketsHighlightStrategy.Strategy1,
                AutoCompleteBrackets      = true,
                LeftBracket  = '(',
                RightBracket = ')',
            };


            popupMenu = new AutocompleteMenu(TextBox)
            {
                ImageList         = AutocompleteImageList,
                MinFragmentLength = 1
            };
            popupMenu.Items.SetAutocompleteItems(AutoCompleteStaticValues);
            popupMenu.Items.MaximumSize = new Size(300, 200);
            popupMenu.Items.Width       = 300;

            HASMSource source = new HASMSource(Parrent.Machine, TextBox.Text);

            TaskRunner = new ParseTaskRunner(source);

            Directory   = new FileInfo(path).Directory.FullName;
            DisplayName = path.Remove(0, path.LastIndexOf(PlatformSpecific.NameSeparator) + 1) + "  [x]";
            Text        = DisplayName;

            if (DisplayName.EndsWith(".cfg", true, CultureInfo.InvariantCulture))
            {
                TextBox.VisibleRangeChanged += (obj, args) =>
                {
                    TextBox.VisibleRange.ClearStyle(StyleIndex.All);
                    TextBox.SyntaxHighlighter.XMLSyntaxHighlight(TextBox.VisibleRange);
                    TextBox.SyntaxHighlighter.XmlTagNameStyle = TextBox.SyntaxHighlighter.BlueStyle;
                };
            }
            else
            {
                TextBox.SyntaxHighlighter.InitStyleSchema(Language.CSharp);
                TextBox.ToolTipDelay = 200;
                TextBox.ToolTip      = new ToolTip();
                TextBox.DelayedTextChangedInterval = 200;
                TextBox.ToolTipNeeded      += TextBox_ToolTipNeeded;
                TextBox.TextChangedDelayed += TextBox_TextChangedDelayed;
            }

            TextBox.TextChanged          += TextBox_TextChanged;
            TextBox.KeyDown              += TextBox_KeyDown;
            TextBox.HighlightingRangeType = HighlightingRangeType.ChangedRange;
            Path = path;

            Controls.Add(TextBox);
            toolStripLabel = Parrent.toolStripLabel1;
        }
Пример #21
0
        public FastColoredTextBoxHandler(FastColoredTextBox fastColoredTextBox, bool addKeywordItem, Dictionary <MetadataPriorityKey, MetadataPriorityValues> metadataPrioityDictionary)
        {
            //create autocomplete popup menu
            popupMenuMetadataProperties = new AutocompleteMenu(fastColoredTextBox);
            popupMenuMetadataProperties.MinFragmentLength = 2;

            List <AutocompleteItem> autoCompleteItems = new List <AutocompleteItem>();

            string[] listOfProperties = Metadata.ListOfPropertiesCombined(addKeywordItem);

            string regexPatternProperties = "";

            foreach (string item in listOfProperties)
            {
                regexPatternProperties += (regexPatternProperties == "" ? "" : "|") + item;
                autoCompleteItems.Add(new AutocompleteItem(item.TrimStart('{').TrimEnd('}')));
            }

            List <string> addeMetadataTags    = new List <string>();
            List <string> addeMetadataRegions = new List <string>();
            List <string> addedAutoComplete   = new List <string>();

            foreach (KeyValuePair <MetadataPriorityKey, MetadataPriorityValues> keyValuePair in metadataPrioityDictionary)
            {
                if (!addedAutoComplete.Contains(keyValuePair.Key.Region))
                {
                    addedAutoComplete.Add(keyValuePair.Key.Region);
                }
                if (!addedAutoComplete.Contains(keyValuePair.Key.Tag))
                {
                    addedAutoComplete.Add(keyValuePair.Key.Tag);
                }

                string[] regions = keyValuePair.Key.Region.Split(':');
                string   tag     = "[-:]" + keyValuePair.Key.Tag + "[+-]?=";

                foreach (string regionSplit in regions)
                {
                    string region = regionSplit + ":";
                    if (!addeMetadataRegions.Contains(region))
                    {
                        addeMetadataRegions.Add(region);
                    }
                }
                if (!addeMetadataTags.Contains(tag))
                {
                    addeMetadataTags.Add(tag);
                }
            }

            //Auto Complete
            addedAutoComplete.Sort();
            foreach (string autoCompleteItem in addedAutoComplete)
            {
                autoCompleteItems.Add(new AutocompleteItem(autoCompleteItem));
            }

            //Tags
            string regexPatternMetadataTags = "";
            IEnumerable <string> query      = addeMetadataTags.OrderBy(pet => pet.Length);

            foreach (string value in query)
            {
                regexPatternMetadataTags += (regexPatternMetadataTags == "" ? "" : "|") + value;
            }

            //Regions
            string regexPatternMetadataRegions = "";
            IEnumerable <string> queryRegions  = addeMetadataRegions.OrderBy(pet => pet.Length);

            foreach (string value in queryRegions)
            {
                regexPatternMetadataRegions += (regexPatternMetadataRegions == "" ? "" : "|") + value;
            }

            regexProperties      = new Regex("(" + regexPatternProperties + ")", RegexOptions.IgnoreCase);
            regexMetadataTags    = new Regex("(" + regexPatternMetadataTags + ")", RegexOptions.IgnoreCase);
            regexMetadataRegions = new Regex("(" + regexPatternMetadataRegions + ")", RegexOptions.IgnoreCase);

            popupMenuMetadataProperties.Items.SetAutocompleteItems(autoCompleteItems);
            popupMenuMetadataProperties.Items.MaximumSize = new System.Drawing.Size(200, 300);
            popupMenuMetadataProperties.Items.Width       = 200;
        }
Пример #22
0
        public MainForm()
        {
            var items = new List <AutocompleteItem>
            {
                new SnippetAutocompleteItem(
                    "if ^[expression]\r\n\r\t#do something\nend if"),
                new SnippetAutocompleteItem(
                    "try \r\n\r^#do something\n\rcatch ex\r\n#do something\n\nfinally\n#do something\nend try"),
                new SnippetAutocompleteItem(
                    "switch ^parent \r\n\r#do something\ncase condition:\r\n#do something\nbreak;\ndefault:\n#do something\nend switch")
            };

            //items.Add(new MethodAutocompleteItem2("Console.WriteLine"));

            foreach (ExtensionNode node in AddinManager.GetExtensionObjects("/EcIDE/Intellisense/Snippets"))
            {
                var cmd = node.CreateInstances <ISnippet>();

                cmd.ForEach(c => c.Init(new ServiceContainer()));
                cmd.ForEach(c => items.Add(new SnippetAutocompleteItem(c.GetSnippet())));
            }

            IntellisenseManager.PopulateClass(items, typeof(Console));
            IntellisenseManager.PopulateClass(items, typeof(MessageBox));

            foreach (ExtensionNode node in AddinManager.GetExtensionObjects("/EcIDE/Intellisense/Commands"))
            {
                var cmd = node.CreateInstances <IIntellisenseCommand>();

                cmd.ForEach(c => c.Init(new ServiceContainer()));

                foreach (IIntellisenseCommand intellisenseCommand in cmd)
                {
                    StyleManager.Add(
                        intellisenseCommand.GetPattern(),
                        intellisenseCommand.GetColor(),
                        intellisenseCommand.GetStyle());
                    InfoManager.Add(intellisenseCommand.GetPattern(), intellisenseCommand.GetDescription());

                    items.Add(new AutocompleteItem(intellisenseCommand.GetPattern(), 0));
                }
            }

            this.InitializeComponent();

            var menu = new AutocompleteMenu(this.fastColoredTextBox1)
            {
                SearchPattern = @"[\w\.]", AllowTabKey = true
            };

            menu.Items.SetAutocompleteItems(items);

            Console.SetOut(new ControlWriter(this.console));
            Console.SetIn(this.rdtxt);
            engine = new Engine {
                Flag = Engine.ExecutanFlags.RamOptimized
            };

            OptionsManager.Load();

            ServiceProviderContainer.AddService(new EditorService(this.fastColoredTextBox1));
            ServiceProviderContainer.AddService(new MenuService(this.MainMenu));
            ServiceProviderContainer.AddService(new AddinService(AddinManager.Registry));
            ServiceProviderContainer.AddService(new NotificationService(this.RadDesktopAlert));
            ServiceProviderContainer.AddService(new WindowService(this.dock));
            ServiceProviderContainer.AddService(new OptionsService());

            foreach (ExtensionNode node in AddinManager.GetExtensionObjects("/EcIDE/StartupCommands"))
            {
                var cmd = node.CreateInstances <ICommand>();

                cmd.ForEach(c => c.Init(new ServiceContainer()));
                cmd.ForEach(c => c.Run());

                var ecommand = node.GetCommand();

                foreach (var ec in ecommand)
                {
                    var ep = ec as window;
                    if (ep != null)
                    {
                        if (ep.title != "")
                        {
                            this.Text = ep.title;
                        }
                        if (ep.close != "")
                        {
                            cmd.ForEach(
                                c =>
                            {
                                this.FormClosing += (sender, args) => c.GetType().GetMethod(ep.close).Invoke(c, null);
                            });
                        }
                    }
                }
            }

            foreach (ExtensionNode node in AddinManager.GetExtensionObjects("/EcIDE/Menu"))
            {
                foreach (var ec in node.GetCommand())
                {
                    var ep = ec as menuitem;
                    if (ep != null)
                    {
                        var target = node.CreateInstances <IMenu>()[0];
                        target.Init(new ServiceContainer());

                        MainMenu.Items.Add(
                            new ToolStripMenuItem(ep.text, null, (sender, args) => target.GetType().GetMethod(ep.click).Invoke(target, new[] { sender, args })));
                    }
                }
            }

            MenuBinder.Bind(MainMenu);

            explorerTree.ExpandAll();

            projectProperties1.AddCurrentTabPage(new GeneralPage());
            this.AddPropertyTabPage("General", new GeneralPage());

            dock.CloseWindow(propertiesWindow);

            fastColoredTextBox1.Refresh();
        }
 public DynamicCollection(AutocompleteMenu menu, FastColoredTextBox tb, GraphEditor editor)
 {
     this.menu   = menu;
     this.tb     = tb;
     this.editor = editor;
 }
Пример #24
0
        //private string LocateFile(string filename, string msg1, string msg2, string template, bool mandatory, string capt)
        //{
        //    if (File.Exists(filename))
        //        return filename;
        //    else
        //    {
        //MessageBox.Show(msg1, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        //filename = OpenFile(capt, template);
        //if (filename != null)
        //    return filename;
        //else
        //{
        //    if (!mandatory)
        //    {
        //        var res = MessageBox.Show(msg2, "Information", MessageBoxButtons.OKCancel,
        //            MessageBoxIcon.Question);
        //        if (res == DialogResult.Cancel)
        //            Close();
        //        return null;
        //    }
        //    else
        //    {
        //        Close();
        //        return null;
        //    }
        //}
        //}
        //}

        private void CreateTab(string fileName, string text = "", bool tryLoad = true)
        {
            try
            {
                var tb = new FastColoredTextBox
                {
                    Font         = new Font("Consolas", 9.75f),
                    Dock         = DockStyle.Fill,
                    BorderStyle  = BorderStyle.Fixed3D,
                    VirtualSpace = true,
                    LeftPadding  = 9,
                    Language     = Language.Custom,
                    Text         = text
                };

                var tab = new FATabStripItem(fileName != null ? Path.GetFileName(fileName) : "[new]", tb)
                {
                    Tag = fileName
                };
                if (fileName != null && tryLoad == true)
                {
                    tb.Text = File.ReadAllText(fileName);
                }
                //else
                //    tb.Text = "\n";
                //else
                //    tb.Text = "\n"; //bug?
                tb.ClearUndo();
                tb.Tag       = new TbInfo();
                tb.IsChanged = false;
                tsFiles.AddTab(tab);
                tsFiles.SelectedItem = tab;
                tb.Focus();
                tb.DelayedTextChangedInterval = 500;
                tb.DelayedEventsInterval      = 500;
                //tb.SizeChanged += TbOnSizeChanged;
                tb.HintClick += tb_HintClick;
                //tb.LineInserted += tb_LineInserted;
                //tb.TextChangedDelayed += new EventHandler<TextChangedEventArgs>(tb_TextChangedDelayed);
                tb.SelectionChangedDelayed += tb_SelectionChangedDelayed;
                tb.KeyDown += new KeyEventHandler(tb_KeyDown);
                //tb.MouseMove += new MouseEventHandler(tb_MouseMove);
                //tb.ChangedLineColor = changedLineColor;
                //if (btHighlightCurrentLine.Checked)
                //    tb.CurrentLineColor = currentLineColor;
                //tb.ShowFoldingLines = btShowFoldingLines.Checked;
                tb.DescriptionFile = DescFile;

                tb.HighlightingRangeType = HighlightingRangeType.VisibleRange;
                var popupMenu = new AutocompleteMenu(tb)
                {
                    MinFragmentLength = 2
                };
                popupMenu.Items.Width = 100;
                popupMenu.Items.SetAutocompleteItems(Constants.Commands);
                //create autocomplete popup menu
                //AutocompleteMenu popupMenu = new AutocompleteMenu(tb);
                //popupMenu.Items.ImageList = ilAutocomplete;
                popupMenu.Opening += new EventHandler <CancelEventArgs>(popupMenu_Opening);
                //BuildAutocompleteMenu(popupMenu);
                (tb.Tag as TbInfo).popupMenu = popupMenu;
            }
            catch (Exception ex)
            {
                if (MessageBox.Show(ex.Message, "Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error) ==
                    DialogResult.Retry)
                {
                    CreateTab(fileName);
                }
            }
        }
Пример #25
0
        /// <summary>
        /// private constructor
        /// </summary>
        private WorksheetEntry(Worksheet o, Document doc, WorksheetEntry p, WorksheetEntry n, string commandStr, string resultStr)
        {
            m_doc   = doc;
            m_owner = o;
            if (p != null)
            {
                this.m_prev = p;
                p.m_next    = this;
            }
            if (n != null)
            {
                this.m_next = n;
                n.m_prev    = this;
            }
            if (m_prev != null)
            {
                this.Index = m_prev.Index + 1;
            }

            m_owner.DocumentPanel.SuspendLayout();
            m_owner.BlockResizeClient = true;

            {
                this.GlowAnimationTimer          = new System.Windows.Forms.Timer(this.m_owner.components);
                this.GlowAnimationTimer.Interval = 40; // 25 fps
                this.GlowAnimationTimer.Tick    += new System.EventHandler(this.GlowAnimationTimer_Tick);
            }

            {
                Command = new FastColoredTextBox();
                m_owner.DocumentPanel.Controls.Add(Command);

                Command.AutoCompleteBracketsList = new char[] { '(', ')', '{', '}', '[', ']', '\"', '\"', '\'', '\'' };
                Command.AutoIndentExistingLines  = false;
                Command.AutoScrollMinSize        = new System.Drawing.Size(284, 285);
                Command.BackBrush   = null;
                Command.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;

                //Command.CharHeight = 15;
                //Command.CharWidth = 7;
                Command.Cursor = System.Windows.Forms.Cursors.IBeam;
                Command.DelayedEventsInterval      = 200;
                Command.DelayedTextChangedInterval = 500;
                Command.DisabledColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))));
                Font fa = m_owner.CommandFont;
                Font fb = new Font("Courier New", 12.0F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0)));
                Command.Font = fb;

                Command.WordWrapMode = WordWrapMode.CharWrapControlWidth;
                //Command.WordWrapMode = WordWrapMode.CharWrapPreferredWidth;
                Command.WordWrap = true;

                Command.ImeMode                        = System.Windows.Forms.ImeMode.Off;
                Command.IsReplaceMode                  = false;
                Command.Location                       = new System.Drawing.Point(0, 24);
                Command.Name                           = "fctb";
                Command.Paddings                       = new System.Windows.Forms.Padding(0);
                Command.PreferredLineWidth             = 80;
                Command.ReservedCountOfLineNumberChars = 3;
                Command.SelectionColor                 = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(255)))));
                //Command.ServiceColors = ((FastColoredTextBoxNS.ServiceColors)(resources.GetObject("fctb.ServiceColors")));
                Command.Size     = new System.Drawing.Size(346, 311);
                Command.TabIndex = 3;
                Command.Text     = commandStr != null ? commandStr : "";
                Command.Zoom     = 100;
                Command.SelectionChangedDelayed += new System.EventHandler(Command_SelectionChangedDelayed);
                Command.AutoIndentNeeded        += this.Command_AutoIndentNeeded;
                Command.LineRemoved             += this.Command_LineRemoved;
                Command.LineInserted            += this.Command_LineInserted;
                Command.TextChanged             += this.Command_TextChanged;
                Command.ZoomChanged             += this.ZoomChanged;
                Command.SelectionChanged        += this.SelectionChanged;

                Command.Language = Language.CSharp;
                Command.OnSyntaxHighlight(new TextChangedEventArgs(Command.Range));

                Command.GotFocus += Command_GotFocus;
                Command.KeyDown  += this.KeyDown;

                // Map redo action to Ctrl+Y (as in most editors)
                Command.HotkeysMapping.Add(Keys.Control | Keys.Y, FCTBAction.Redo);
            }

            {
                AutoCompleteBox = new AutocompleteMenu(this.Command);
                AutoCompleteBox.MinFragmentLength = 2;

                AutoCompleteBox.Items.MaximumSize = new System.Drawing.Size(200, 300);
                AutoCompleteBox.Items.Width       = 200;

                AutoCompleteBox.Items.SetAutocompleteItems(
                    new DynamicAutoCompleteList(m_owner));
            }

            {
                m_owner.BlockTextChanged = true;
                Result = new FastColoredTextBox();
                m_owner.DocumentPanel.Controls.Add(Result);

                Result.BorderStyle   = System.Windows.Forms.BorderStyle.Fixed3D;
                Result.Cursor        = System.Windows.Forms.Cursors.IBeam;
                Result.DisabledColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))));
                Result.Font          = new Font("Courier New", 12.0F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0)));

                Result.WordWrapMode = WordWrapMode.CharWrapControlWidth;
                Result.WordWrap     = true;

                Result.Paddings        = new System.Windows.Forms.Padding(0);
                Result.ShowLineNumbers = false;
                Result.SelectionColor  = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(255)))));

                Result.Zoom         = 100;
                Result.ZoomChanged += this.ZoomChanged;

                Result.MouseWheel       += Scroll;
                Result.TextChanged      += Result_TextChanged;
                Result.GotFocus         += Result_GotFocus;
                Result.KeyDown          += KeyDown;
                Result.SelectionChanged += this.SelectionChanged;


                Result.BackColor   = Color.White;
                Result.BackBrush   = null;
                Result.ForeColor   = Color.DarkBlue;
                Result.BorderStyle = BorderStyle.None;


                m_defaultResultCharHeight = Result.CharHeight;
                Result.Text = resultStr != null ? resultStr : "";
                // This seems to be the only way to tell FastColoredTextBox to
                // be of zero height if empty
                Result.CharHeight = Result.Text.IsNullOrEmpty() ? 0 : m_defaultResultCharHeight;

                Result.ReadOnly          = true;
                m_owner.BlockTextChanged = false;
            }

            {
                GraphicsResult = new PictureBox();
                m_owner.DocumentPanel.Controls.Add(GraphicsResult);

                GraphicsResult.SizeMode = PictureBoxSizeMode.Zoom;

                GraphicsResult.Visible = false; // only activated in special cases.
            }

            m_owner.DocumentPanel.ResumeLayout();
            //Command.Show();
            //Result.Show();

            Resize();

            m_owner.BlockResizeClient = false;
        }
Пример #26
0
 public override AutoCompletionMap CreateAutoCompletionMap(AutocompleteMenu menu)
 {
     return(null);
 }
Пример #27
0
        /// <summary>
        /// 初始化代码补全
        /// </summary>
        /// <param name="autoCompleteRules">代码补全规则</param>
        /// <param name="acMenu">自动完成菜单</param>
        /// <param name="fctb">FCTB编辑框</param>
        /// <param name="imageList">图标列表</param>
        public static void InitAutoComplete(string autoCompleteRules, AutocompleteMenu acMenu, FastColoredTextBox fctb, ImageList imageList)
        {
            //解析代码补全数据
            string[] keywords            = GetKeywordList(autoCompleteRules, "Keyword").ToArray();
            string[] functions           = GetKeywordList(autoCompleteRules, "Functions").ToArray();
            string[] methods             = GetKeywordList(autoCompleteRules, "Methods").ToArray();
            string[] snippets            = GetKeywordList(autoCompleteRules, "Snippets").ToArray();
            string[] declarationSnippets = GetKeywordList(autoCompleteRules, "DeclarationSnippets").ToArray();
            string[] headers             = GetKeywordList(autoCompleteRules, "Headers").ToArray();

            //初始化AutocompleteMenu
            acMenu.ImageList     = imageList;
            acMenu.SearchPattern = @"[#\w\.:=!<>]";
            acMenu.AllowTabKey   = true;

            //Build
            List <AutocompleteItem> items = new List <AutocompleteItem>();

            foreach (var item in snippets)
            {
                items.Add(new SnippetAutocompleteItem(item)
                {
                    ImageIndex = 1
                });
            }
            foreach (var item in declarationSnippets)
            {
                items.Add(new DeclarationSnippet(item)
                {
                    ImageIndex = 0
                });
            }
            foreach (var item in methods)
            {
                items.Add(new MethodAutocompleteItem(item)
                {
                    ImageIndex = 2
                });
            }
            foreach (var item in keywords)
            {
                items.Add(new AutocompleteItem(item));
            }
            foreach (var item in functions)
            {
                items.Add(new SnippetAutocompleteItem(item));
            }
            foreach (var item in headers)
            {
                items.Add(new HeaderAutocompleteItem(item));
            }

            items.Add(new InsertSpaceSnippet());
            items.Add(new InsertSpaceSnippet(@"^(\w+)([=<>!:]+)(\w+)$"));
            items.Add(new InsertEnterSnippet());

            //set appear interval
            acMenu.AppearInterval = 100;
            //set as autocomplete source
            acMenu.Items.SetAutocompleteItems(items);
        }
Пример #28
0
 public override AutoCompletionMap CreateAutoCompletionMap(AutocompleteMenu menu)
 {
     return(new CSharpAutoCompletionMap(menu));
 }
Пример #29
0
 public IdlAutoCompleteCollection(AutocompleteMenu autocompleteMenu, IronyFCTB textBox)
 {
     m_AutocompleteMenu = autocompleteMenu;
     m_TextBox          = textBox;
 }
 public override void OnSelected(AutocompleteMenu popupMenu, SelectedEventArgs e)
 {
     base.OnSelected(popupMenu, e);
     if (Parent.Fragment.tb.AutoIndent)
         Parent.Fragment.tb.DoAutoIndent();
 }
Пример #31
0
 private static void SetAutoComplete(IEnumerable <AutocompleteItem> items, AutocompleteMenu completemenu,
                                     Control tb)
 {
     completemenu.SetAutocompleteMenu(tb, completemenu);
     completemenu.SetAutocompleteItems(items);
 }
Пример #32
0
 /// <summary>
 /// This method is called after item inserted into text
 /// </summary>
 public virtual void OnSelected(AutocompleteMenu popupMenu, SelectedEventArgs e)
 {
     ;
 }
Пример #33
0
 public CodeEdit()
 {
     menu = new AutocompleteMenu(this);
     menu.AppearInterval   = 100;
     menu.ShowItemToolTips = true;
 }