Beispiel #1
0
        public EditorTab OpenFile(string fileName)
        {
            bool      result    = false;
            EditorTab editorTab = null;

            foreach (var item in dockPanel.Documents)
            {
                EditorTab edit = item as EditorTab;
                if (edit != null)
                {
                    if (edit.Title == Path.GetFileName(fileName))
                    {
                        editorTab = edit;
                        result    = true;
                    }
                }
            }

            if (File.Exists(fileName))
            {
                if (!result)
                {
                    editorTab = new EditorTab(this);
                    editorTab.OpenFile(fileName);
                    ConfigClass.Config.AddHistoryItem(fileName);
                }
                editorTab.Show(dockPanel);
                return(editorTab);
            }
            else
            {
                MessageBox.Show(String.Format(MainForm.rm.GetString("fileDontExist"), Path.GetFileName(fileName)));
            }
            return(null);
        }
Beispiel #2
0
        public LanguageBinding(EditorTab editorTab)
        {
            this.editorTab = editorTab;
            stopWatch      = new Stopwatch();
            editorTab.editor.TextChanged                             += new EventHandler(editor_TextChanged);
            editorTab.editor.Caret.PositionChanged                   += new EventHandler(Caret_PositionChanged);
            editorTab.editor.OnHighlighterChangedHandler             += new HighlighterChangedEventHandler(editor_OnHighlighterChangedHandler);
            editorTab.editor.ActiveTextAreaControl.TextArea.KeyPress += new KeyPressEventHandler(TextArea_KeyPress);
            Application.Idle += new EventHandler(Application_Idle);

            #region Create Language bindings
            PHPBinding  = new PHPLanguageBinding(editorTab.editor);
            HTMLBinding = new HTMLLanguageBinding(editorTab.editor);
            JSBinding   = new JSLanguageBinding(editorTab.editor);
            CSSBinding  = new CSSLanguageBinding(editorTab.editor);
            #endregion

            HtmlCompletion = new HtmlCompletionClass(editorTab.editor);
            QuickTemplate  = new QuickletEngine();

            //Aktiviert das richtige Binding
            editor_OnHighlighterChangedHandler(null, new HighlighterChangedEventArgs(editorTab.editor.DocLanguage));

            if (editorTab.editor.Document.FoldingManager.FoldingStrategy != null)
            {
                editorTab.editor.Document.FoldingManager.UpdateFoldings(null, null);
            }
        }
Beispiel #3
0
        public EditorTab CreateNewDocumentWithTemplate(string TemplateFile)
        {
            int       count = EditorTabCount + 1;
            EditorTab db    = new EditorTab(this);

            db.CreateNewDocumentWithTemplate(rm.GetString("defaultFileName") + count, TemplateFile);
            return(db);
        }
Beispiel #4
0
        private void tbNew_Click(object sender, EventArgs e)
        {
            int       count = EditorTabCount + 1;
            EditorTab db    = new EditorTab(this);

            db.CreateEmptyDocument(rm.GetString("defaultFileName") + count, DocumentLanguage.PHP);
            db.Show(dockPanel);
        }
Beispiel #5
0
 private void tabControl_SelectedIndexChanged(object sender, EventArgs e)
 {
     currentTab = (EditorTab)tabControl.SelectedTab;
     try
     {
         CurrentEditor.Focus();
     }
     catch { }; //TODO: КОСТЫЛЬ!!!
 }
Beispiel #6
0
 public void ToLine(int line)
 {
     try
     {
         TextBox.Selection.Start = new Place(0, line);
         TextBox.InsertText("");
         EditorTab.Save();
     }
     catch { }
 }
Beispiel #7
0
        public void HtmlSelected(object sender, HtmlEventArgs e)
        {
            EditorTab editorTab = MainForm.mainForm.ActiveDocumentTab as EditorTab;

            if (editorTab != null)
            {
                TextLocation tl = editorTab.editor.Document.OffsetToPosition(e.Item.StreamPosition);
                editorTab.editor.Caret.Position = tl;
                editorTab.editor.Focus();
            }
        }
Beispiel #8
0
    private void SetEditorTab(string tab)
    {
        var selection = (EditorTab)Enum.Parse(typeof(EditorTab), tab);

        if (selection == selectedEditorTab)
        {
            return;
        }

        GUICommon.Instance.PlayButtonPressSound();

        // Hide all
        var cellEditor = GetNode <Control>("CellEditor");
        var report     = GetNode <Control>("Report");
        var patchMap   = GetNode <Control>("PatchMap");

        report.Hide();
        patchMap.Hide();
        cellEditor.Hide();

        // Show selected
        switch (selection)
        {
        case EditorTab.Report:
        {
            report.Show();
            reportTabButton.Pressed = true;
            break;
        }

        case EditorTab.PatchMap:
        {
            patchMap.Show();
            patchMapButton.Pressed = true;
            break;
        }

        case EditorTab.CellEditor:
        {
            cellEditor.Show();
            cellEditorButton.Pressed = true;
            break;
        }

        default:
            throw new Exception("Invalid editor tab");
        }

        selectedEditorTab = selection;

        editor.TutorialState.SendEvent(TutorialEventType.MicrobeEditorTabChanged, new StringEventArgs(tab), this);
    }
Beispiel #9
0
        private IDockContent GetContentFromPersistString(string persistString)
        {
            if (persistString == typeof(CodeBrowserDock).ToString())
            {
                return(codeBrowser);
            }
            else if (persistString == typeof(HelpBrowserDock).ToString())
            {
                return(helpBrowserDock);
            }
            else
            {
                // DummyDoc overrides GetPersistString to add extra information into persistString.
                // Any DockContent may override this value to add any needed information for deserialization.

                string[] parsedStrings = persistString.Split(new char[] { ',' });
                if (parsedStrings.Length != 2)
                {
                    return(null);
                }

                if (parsedStrings[0] == typeof(EditorTab).ToString())
                {
                    EditorTab editorTab = null;
                    if (parsedStrings[1] != string.Empty)
                    {
                        editorTab = OpenFile(parsedStrings[1]);
                    }

                    return(editorTab);
                }
                else if (parsedStrings[0] == typeof(HelpBrowserTab).ToString())
                {
                    HelpBrowserTab helpTab = null;
                    if (parsedStrings[1] != string.Empty)
                    {
                        helpTab = helpBrowserDock.ShowHelp(parsedStrings[1]);
                    }

                    return(helpTab);
                }
                else
                {
                    return(null);
                }
            }
        }
Beispiel #10
0
        private EditorTab CreateEditorTab()
        {
            const string code = "default\n{\n\tstate_entry()\n\t{\n\t\tllSay(0, \"Hello World!\");\n\t}\n}";

            var tab = new EditorTab(TabControl, EditorTabs, _libraryDataProvider)
            {
                SourceCode     = code,
                ChangesPending = false
            };

            tab.Content.EditControl.Editor.Document.UndoStack.ClearAll();

            tab.Content.EditControl.Settings.ShowEndOfLine = AppSettings.Settings.ShowEndOfLine;
            tab.Content.EditControl.Settings.ShowSpaces    = AppSettings.Settings.ShowSpaces;
            tab.Content.EditControl.Settings.ShowTabs      = AppSettings.Settings.ShowTabs;

            return(tab);
        }
Beispiel #11
0
        private void SetLibraryMenuFromTab(EditorTab tab)
        {
            if (tab == null)
            {
                throw new ArgumentNullException("tab");
            }

            _settingLibraryMenuProgrammaticallyFromTabCache = true;


            foreach (var menuItem in TabLibraryDataMenu.Items.Cast <MenuItem>())
            {
                menuItem.IsChecked = tab.ActiveLibraryDataSubsetsCache.Contains(menuItem.Tag.ToString());
            }


            _settingLibraryMenuProgrammaticallyFromTabCache = false;
        }
Beispiel #12
0
        //Wizard
        public void neuesDokumentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string SelectedTemplate = null;

            using (NewDocument newDoc = new NewDocument())
            {
                newDoc.Owner = this;
                newDoc.ShowDialog();
                SelectedTemplate = newDoc.SelectedTemplate;
            }

            if (SelectedTemplate != null)
            {
                EditorTab db = CreateNewDocumentWithTemplate(SelectedTemplate);
                db.Show(dockPanel);
                db.Focus();
            }
        }
Beispiel #13
0
        private void dockPanel_ActiveDocumentChanged(object sender, EventArgs e)
        {
            EditorTab editTab = (ActiveDocumentTab as EditorTab);

            if (editTab != null)
            {
                if (editTab.languageBinding != null)
                {
                    editTab.languageBinding.Parse();
                }

                editTab.editor.BringToFront();
                editTab.editor.Focus();
            }
            else
            {
                LanguageBinding.ClearAll();
            }
        }
Beispiel #14
0
        private void LoadTab(EditorTab tab)
        {
            if (tab != selectedTab)
            {
                selectedTab = tab;
            }

            switch (tab)
            {
            case EditorTab.Razor:
                CodeEditor.Text        = model.RazorCode;
                RazorButton.Foreground = greenBrush;
                GcodeButton.Foreground = whiteBrush;
                break;

            case EditorTab.GCode:
                CodeEditor.Text        = model.GCode;
                RazorButton.Foreground = whiteBrush;
                GcodeButton.Foreground = greenBrush;
                break;
            }
        }
Beispiel #15
0
        public void CssSelected(object sender, TreeNodeAdvMouseEventArgs e)
        {
            EditorTab editorTab = MainForm.mainForm.ActiveDocumentTab as EditorTab;

            if (editorTab != null)
            {
                if (e.Node.Tag != null)
                {
                    Node node = (e.Node.Tag as Node);
                    if (node != null)
                    {
                        RuleSet ruleSet = (node.Object as RuleSet);
                        if (ruleSet != null)
                        {
                            TextLocation tl        = new TextLocation(ruleSet.Col - 1, ruleSet.Line - 1);
                            HtmlNode     styleNode = GetParentStyleNode(node);
                            if (styleNode != null)
                            {
                                if (styleNode.Name == "link")
                                {
                                    if (File.Exists(styleNode.FileName))
                                    {
                                        MainForm.mainForm.OpenFile(styleNode.FileName);
                                    }
                                }
                                else
                                {
                                    TextLocation tl2 = editorTab.editor.Document.OffsetToPosition(styleNode.StreamPosition);
                                    tl.Line += tl2.Line;
                                }
                            }
                            (MainForm.mainForm.ActiveDocumentTab as EditorTab).editor.Caret.Position = tl;
                            (MainForm.mainForm.ActiveDocumentTab as EditorTab).editor.Focus();
                        }
                    }
                }
            }
        }
Beispiel #16
0
 public EditorTab OpenScript(string FileName, CodeEditor editor, bool blank = false)
 {
     try
     {
         if (blank)
         {
             currentTab = tabControl.LoadBlank(FileName, editor);
         }
         else
         {
             currentTab = tabControl.Load(FileName, editor);
         }
         fctbMain.TextChanged += fctbMain_TextChanged;
         fctbMain.KeyDown     += fctbMain_KeyDown;
         fctbMain.PaintLine   += fctbMain_PaintLine;
         return(currentTab);
     }
     catch (Exception e)
     {
         Log("FileSystem", "Unable to open script! " + e.Message, LOG_STYLE_ERROR);
         return(null);
     }
 }
Beispiel #17
0
 private void openPanel(object sender, IDockablePanel panel)
 {
     if (workspacePanel.ShowChild(panel.Control))
     {
         return;
     }
     if (mostRecentDocumentTabControl != null && panel is IDocumentPanel)
     {
         var item = new EditorTab(panel);
         mostRecentDocumentTabControl.Items.Add(item);
         mostRecentDocumentTabControl.SelectedItem = item;
     }
     else if (mostRecentToolTabControl != null && panel is IToolPanel)
     {
         var item = new EditorTab(panel);
         mostRecentToolTabControl.Items.Add(item);
         mostRecentToolTabControl.SelectedItem = item;
     }
     else
     {
         new EditorWindow(workspacePanel, panel).Show();
     }
 }
Beispiel #18
0
 void AddTab(string name, EditorTab newTab)
 {
     m_TabNames.Add(name);
     m_TabList.Add(newTab);
 }
        private void Open_Executed(object sender, RoutedEventArgs e)
        {
            var newEditor = new EditorTab();

            var openFile = new OpenFileDialog
            {
                Filter = Properties.Resources.RubyFileFilter,
                CheckFileExists = true
            };
            
            if (openFile.ShowDialog() != System.Windows.Forms.DialogResult.OK || openFile.FileName.Length <= 0)
                return;

            newEditor.FirstSave = false;
            newEditor.Saved = true;
            newEditor.Filepath = openFile.FileName;
            newEditor.MainWindow = this;
            newEditor.TextEditor.Text = File.ReadAllText(openFile.FileName);

            Settings.AddEditorToPane(EditorPane, newEditor, Path.GetFileNameWithoutExtension(openFile.FileName));

            var oldEditor = Settings.GetCurrentEditor(EditorPane);

            if(EditorPane.SelectedContent != null && EditorPane.SelectedContent.Title == "Untitled" && !oldEditor.Saved)
                EditorPane.RemoveChildAt(EditorPane.SelectedContentIndex);
        }
Beispiel #20
0
        private void tbNewCSS_Click(object sender, EventArgs e)
        {
            EditorTab db = CreateNewDocumentWithTemplate(@"templates\wizard\CSS\CSS.css");

            db.Show(dockPanel);
        }
Beispiel #21
0
        private void tbNewJavaScript_Click(object sender, EventArgs e)
        {
            EditorTab db = CreateNewDocumentWithTemplate(@"templates\wizard\JavaScript\template.js");

            db.Show(dockPanel);
        }
Beispiel #22
0
        private void tbNewXHTML_Click(object sender, EventArgs e)
        {
            EditorTab db = CreateNewDocumentWithTemplate(@"templates\wizard\HTML\XHTML10Trans.html");

            db.Show(dockPanel);
        }
Beispiel #23
0
        private void tbNewPHP_Click(object sender, EventArgs e)
        {
            EditorTab db = CreateNewDocumentWithTemplate(@"templates\templatePHP.php");

            db.Show(dockPanel);
        }
Beispiel #24
0
        public GMRoom(ProjectReader reader, GMProject proj)
        {
            Name        = reader.ReadString();
            LastChanged = reader.ReadDate();
            Version     = reader.ReadInt32();
            Caption     = reader.ReadString();
            Width       = reader.ReadUInt32();
            Height      = reader.ReadUInt32();
            int _snx = reader.ReadInt32();
            int _sny = reader.ReadInt32();

            Snap            = new Point(_snx, _sny);
            Isometric       = reader.ReadBoolean();
            Speed           = reader.ReadUInt32();
            Persistent      = reader.ReadBoolean();
            BackgroundColor = reader.ReadColor();
            int val = reader.ReadInt32();

            DrawBackgroundColor    = (val & 1) != 0;
            ClearBGWithWindowColor = (val & 0b10) == 0;
            CreationCode           = reader.ReadString();

            // Read room backgrounds.
            int bgcount = reader.ReadInt32();

            Backgrounds = new List <RoomBackground>(bgcount);
            for (int i = 0; i < bgcount; i++)
            {
                var bgstruct = new RoomBackground();
                bgstruct.Load(reader, proj);
                Backgrounds.Add(bgstruct);
            }

            // Read views.
            EnableViews = reader.ReadBoolean();
            int viewcount = reader.ReadInt32();

            Views = new List <RoomView>(viewcount);
            for (int i = 0; i < viewcount; i++)
            {
                var viewstruct = new RoomView();
                viewstruct.Load(reader, proj);
                Views.Add(viewstruct);
            }

            // Read room instances.
            int instcount = reader.ReadInt32();

            Instances = new List <RoomInstance>(instcount);
            for (int i = 0; i < instcount; i++)
            {
                var inststruct = new RoomInstance();
                inststruct.Load(reader, proj);
                Instances.Add(inststruct);
            }

            // Read room tiles.
            int tilecount = reader.ReadInt32();

            Tiles = new List <RoomTile>(tilecount);
            for (int i = 0; i < tilecount; i++)
            {
                var tilestruct = new RoomTile();
                tilestruct.Load(reader, proj);
                Tiles.Add(tilestruct);
            }

            // weird editor settings (aren't really important unless you make an IDE)
            REI                 = reader.ReadBoolean();
            EditorWidth         = reader.ReadInt32();
            EditorHeight        = reader.ReadInt32();
            ShowGrid            = reader.ReadBoolean();
            ShowObjects         = reader.ReadBoolean();
            ShowTiles           = reader.ReadBoolean();
            ShowBGs             = reader.ReadBoolean();
            ShowFGs             = reader.ReadBoolean();
            ShowViews           = reader.ReadBoolean();
            DeleteUnderlyingObj = reader.ReadBoolean();
            DeleteUnderlyingTil = reader.ReadBoolean();
            Tab                 = (EditorTab)reader.ReadInt32();
            int _hx = reader.ReadInt32();
            int _hy = reader.ReadInt32();

            Scrollbar = new Point(_hx, _hy);

            reader.Dispose();
        }