Beispiel #1
0
        public DocumentForm OpenFile(string filePath)
        {
            try
            {
                DocumentForm doc = new DocumentForm();
                //doc.Scintilla.BackColor = Settings1.Default.CodeEditorBackColor;
                //doc.Scintilla.ForeColor = Settings1.Default.CodeEditorFontColor;
                //doc.Scintilla.FindReplace.Indicator.Color = Settings1.Default.CodeEditorSelectionColor;

                if (filePath.Contains(".lua"))
                {
                    doc.Scintilla.CharAdded += new EventHandler<CharAddedEventArgs>(this.sciDocument_CharAdded);
                    doc.Scintilla.TextDeleted += new EventHandler<TextModifiedEventArgs>(Scintilla_TextDeleted);
                    doc.Scintilla.AutoCompleteAccepted += new EventHandler<AutoCompleteAcceptedEventArgs>(Scintilla_AutoCompleteAccepted);
                    doc.Scintilla.MarkerChanged += new EventHandler<MarkerChangedEventArgs>(Scintilla_MarkerChanged);
                    doc.Scintilla.SelectionChanged += new EventHandler(Scintilla_SelectionChanged);
                    //doc.Scintilla.NativeInterface.UpdateUI += new EventHandler<NativeScintillaEventArgs>(Scintilla_SUpdateUI);
                    doc.Scintilla.IsBraceMatching = true;

                }

                doc.Scintilla.UndoRedo.EmptyUndoBuffer();

                List<Marker> markers = doc.Scintilla.Markers.GetMarkers(0);
                if (markers.Count > 0)
                    markers[0].BackColor = Color.OrangeRed;

                doc.Show(dockPanel);
                doc.Scintilla.Text = File.ReadAllText(filePath);

                doc.Scintilla.Modified = false;
                doc.Text = Path.GetFileName(filePath);
                doc.FilePath = filePath;

                if (filePath.Contains(".lua"))
                {
                    checkIntegrityLuaSceneFileFromV1_14ToV1_15(doc);
                }

                doc.Save();

                if (this.Mode.Equals("DEBUG"))
                    doc.Scintilla.IsReadOnly = true;
                else
                {
                    doc.Scintilla.IsReadOnly = false;

                    foreach (DocumentForm documentForm in dockPanel.Documents)
                    {
                        documentForm.Scintilla.Snippets.List.Clear();

                        documentForm.Scintilla.Snippets.List.AddRange(this.codeEditorSnippets);
                    }

                }

                return doc;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }
        }