/[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:07:32	776
+++ trunk/RomCheater.ScratchPad/ScratchPadDocument.cs	2013/06/20 23:10:49	777
@@ -31,6 +31,7 @@
             this.DocumentTab.Name = string.Format("tp{0}", this.DocumentIndex);
             this.DocumentTab.Text = string.Format("{0}{1}", this.DocumentFilename, this.DocumentIndex);
             //this.DocumentClosing += new BaseEventHandler<ControlClosingEventArgs<int>>(ScratchPadDocument_DocumentClosing);
+            this.IsDefaultDocument = true;
             this.DocumentTab.Controls.Add(this);
         }
 
@@ -54,6 +55,8 @@
             return !DocumentSaved;
         }
 
+        private bool _IsDefaultDocument;
+        public bool IsDefaultDocument { get { return _IsDefaultDocument; } private set { _IsDefaultDocument = value; } }
 
         private bool _DocumentSaved;
         public bool DocumentSaved { get { return _DocumentSaved; } private set { _DocumentSaved = value; } }
@@ -104,6 +107,7 @@
             DialogResult result = FileLoader.ShowDialog();
             if (result != DialogResult.OK) return;
             FileInfo fi = new FileInfo(FileLoader.FileName);
+            this.DocumentFilename = fi.FullName;
             try
             {
                 
@@ -124,6 +128,7 @@
                                 CodeEditorSyntaxLoader.SetSyntax(txtEditor, language);
                                 txtEditor.Document.ReParse();
                                 this.UpdateTabName(fi.Name);
+                                this.IsDefaultDocument = false;
                             }
                             catch (Exception ex)
                             {
@@ -146,9 +151,17 @@
         }
         private void SaveDocument()
         {
-            DialogResult result = FileSaver.ShowDialog();
-            if (result != DialogResult.OK) return;
-            FileInfo fi = new FileInfo(FileSaver.FileName);
+            FileInfo fi = null;
+            if (this.IsDefaultDocument)
+            {
+                DialogResult result = FileSaver.ShowDialog();
+                if (result != DialogResult.OK) return;
+                fi = new FileInfo(FileSaver.FileName);
+            }
+            else
+            {
+                fi = new FileInfo(this.DocumentFilename);
+            }           
             try
             {
                 using (FileStream fs = new FileStream(fi.FullName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read))

 

  ViewVC Help
Powered by ViewVC 1.1.22