31 |
|
this.DocumentTab.Name = string.Format("tp{0}", this.DocumentIndex); |
32 |
|
this.DocumentTab.Text = string.Format("{0}{1}", this.DocumentFilename, this.DocumentIndex); |
33 |
|
//this.DocumentClosing += new BaseEventHandler<ControlClosingEventArgs<int>>(ScratchPadDocument_DocumentClosing); |
34 |
+ |
this.IsDefaultDocument = true; |
35 |
|
this.DocumentTab.Controls.Add(this); |
36 |
|
} |
37 |
|
|
55 |
|
return !DocumentSaved; |
56 |
|
} |
57 |
|
|
58 |
+ |
private bool _IsDefaultDocument; |
59 |
+ |
public bool IsDefaultDocument { get { return _IsDefaultDocument; } private set { _IsDefaultDocument = value; } } |
60 |
|
|
61 |
|
private bool _DocumentSaved; |
62 |
|
public bool DocumentSaved { get { return _DocumentSaved; } private set { _DocumentSaved = value; } } |
107 |
|
DialogResult result = FileLoader.ShowDialog(); |
108 |
|
if (result != DialogResult.OK) return; |
109 |
|
FileInfo fi = new FileInfo(FileLoader.FileName); |
110 |
+ |
this.DocumentFilename = fi.FullName; |
111 |
|
try |
112 |
|
{ |
113 |
|
|
128 |
|
CodeEditorSyntaxLoader.SetSyntax(txtEditor, language); |
129 |
|
txtEditor.Document.ReParse(); |
130 |
|
this.UpdateTabName(fi.Name); |
131 |
+ |
this.IsDefaultDocument = false; |
132 |
|
} |
133 |
|
catch (Exception ex) |
134 |
|
{ |
151 |
|
} |
152 |
|
private void SaveDocument() |
153 |
|
{ |
154 |
< |
DialogResult result = FileSaver.ShowDialog(); |
155 |
< |
if (result != DialogResult.OK) return; |
156 |
< |
FileInfo fi = new FileInfo(FileSaver.FileName); |
154 |
> |
FileInfo fi = null; |
155 |
> |
if (this.IsDefaultDocument) |
156 |
> |
{ |
157 |
> |
DialogResult result = FileSaver.ShowDialog(); |
158 |
> |
if (result != DialogResult.OK) return; |
159 |
> |
fi = new FileInfo(FileSaver.FileName); |
160 |
> |
} |
161 |
> |
else |
162 |
> |
{ |
163 |
> |
fi = new FileInfo(this.DocumentFilename); |
164 |
> |
} |
165 |
|
try |
166 |
|
{ |
167 |
|
using (FileStream fs = new FileStream(fi.FullName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read)) |