Beispiel #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            panel1.Visible = true;
            engine         = new Engine();
            engine.Flag    = Engine.ExecutanFlags.RamOptimized;
            engine.Evaluate(fastColoredTextBox1.Text);
            fastColoredTextBox1.Text =
                fastColoredTextBox1.Text.Replace(
                    "Console.WriteLine(\"hello world\"); #gets replaced by msg box in load event",
                    "MessageBox.Show(\"hello world\");");
            listBox1.Items.Clear();
            if (ShowConsole == false)
            {
                panel1.Visible = false;
            }

            var items = new List <AutocompleteItem>();

            items.Add(new MethodAutocompleteItem2("Console.WriteLine"));
            items.Add(new SnippetAutocompleteItem("if ^[expression]\r\n\r\t#do something\nend if"));
            items.Add(new SnippetAutocompleteItem("try \r\n\r^#do something\n\rcatch ex\r\n#do something\n\nfinally\n#do something\nend try"));
            items.Add(new SnippetAutocompleteItem("switch ^parent \r\n\r#do something\ncase condition:\r\n#do something\nbreak;\ndefault:\n#do something\nend switch"));

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

                Array.ForEach(cmd, c => items.Add(new SnippetAutocompleteItem(c.GetSnippet())));
            }

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

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

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

            var menu = new AutocompleteMenu(fastColoredTextBox1);

            menu.SearchPattern = @"[\w\.]";
            menu.AllowTabKey   = true;
            menu.ImageList     = imageList1;
            menu.Items.SetAutocompleteItems(items);
        }
Beispiel #2
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();
        }