/[RomCheater]/trunk/RomCheater.ScratchPad/ScratchPadDocument.cs
ViewVC logotype

Diff of /trunk/RomCheater.ScratchPad/ScratchPadDocument.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater.ScratchPad/ScratchPadDocument.cs	2013/06/20 23:10:49	777
+++ trunk/RomCheater.ScratchPad/ScratchPadDocument.cs	2013/06/21 04:26:36	783
@@ -10,15 +10,15 @@
 using RomCheater.Core;
 using System.IO;
 using RomCheater.Logging;
-using Fireball.CodeEditor.SyntaxFiles;
 
 namespace RomCheater.ScratchPad
 {
     public partial class ScratchPadDocument : UserControl
-    {
+    {        
+        public event EventHandler<LinkClickedEventArgs> LinkClicked;
         public event BaseEventHandler<ControlClosingEventArgs<int>> DocumentClosing;
 
-        const string NewDocumentFilename = "New";
+        const string NewDocumentFilename = "ScratchPad";
         public ScratchPadDocument() : this(NewDocumentFilename, new TabPage(), 0) { }
         public ScratchPadDocument(TabPage tp, int index) : this(NewDocumentFilename, tp, index) { }
         public ScratchPadDocument(int index) : this(NewDocumentFilename, new TabPage(), index) { }
@@ -32,6 +32,7 @@
             this.DocumentTab.Text = string.Format("{0}{1}", this.DocumentFilename, this.DocumentIndex);
             //this.DocumentClosing += new BaseEventHandler<ControlClosingEventArgs<int>>(ScratchPadDocument_DocumentClosing);
             this.IsDefaultDocument = true;
+            this.DocumentSaved = true;
             this.DocumentTab.Controls.Add(this);
         }
 
@@ -86,9 +87,26 @@
             }
         }
 
+        public override Font Font
+        {
+            get
+            {
+                return base.Font;
+            }
+            set
+            {
+                base.Font = value;
+                txtEditor.Font = base.Font;
+                mnuItemClose.Font = base.Font;
+                mnuItemOpen.Font = base.Font;
+                mnuItemSave.Font = base.Font;
+            }
+        }
+
         private void mnuItemOpen_Click(object sender, EventArgs e)
         {
             OpenDocument();
+            this.DocumentSaved = true; // the file was just opened
         }
 
         private void mnuItemSave_Click(object sender, EventArgs e)
@@ -121,14 +139,10 @@
                             {
                                 var text = sr.ReadToEnd();           
                                 sr.Close();
-
-                                txtEditor.Document = new Fireball.Syntax.SyntaxDocument();
-                                txtEditor.Document.Text = text;                                
-                                SyntaxLanguage language = SyntaxLanguage.Text;
-                                CodeEditorSyntaxLoader.SetSyntax(txtEditor, language);
-                                txtEditor.Document.ReParse();
+                                txtEditor.Text = text;                                
                                 this.UpdateTabName(fi.Name);
                                 this.IsDefaultDocument = false;
+                                this.DocumentSaved = true;
                             }
                             catch (Exception ex)
                             {
@@ -144,6 +158,7 @@
             }
             catch (Exception ex)
             {
+                this.DocumentSaved = false;
                 MessageBox.Show(string.Format("Failed to open: '{0}'", fi.Name), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 logger.Error.WriteLine("Failed to open: '{0}'", fi.FullName);
                 logger.Error.WriteLine(ex.ToString());
@@ -172,7 +187,7 @@
                         {
                             try
                             {
-                                foreach (var t in txtEditor.Document.Lines)
+                                foreach (var t in txtEditor.Lines)
                                 {
                                     sw.WriteLine(t);
                                 }
@@ -219,5 +234,13 @@
         {
             this.DocumentSaved = false;
         }
+
+        private void txtEditor_LinkClicked(object sender, LinkClickedEventArgs e)
+        {
+            if (this.LinkClicked != null)
+            {
+                this.LinkClicked.Invoke(sender, e);
+            }
+        }
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22