|
|
|
@ -18,9 +18,46 @@ namespace ICSharpCode.SharpDevelop.Gui
@@ -18,9 +18,46 @@ namespace ICSharpCode.SharpDevelop.Gui
|
|
|
|
|
string titleName = null; |
|
|
|
|
string fileName = null; |
|
|
|
|
|
|
|
|
|
bool isDirty = false; |
|
|
|
|
bool isViewOnly = false; |
|
|
|
|
|
|
|
|
|
List<ISecondaryViewContent> secondaryViewContents = new List<ISecondaryViewContent>(); |
|
|
|
|
|
|
|
|
|
public AbstractViewContent() |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public AbstractViewContent(string titleName) |
|
|
|
|
{ |
|
|
|
|
this.titleName = titleName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public AbstractViewContent(string titleName, string fileName) |
|
|
|
|
{ |
|
|
|
|
this.titleName = titleName; |
|
|
|
|
this.fileName = fileName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sets the file name to <paramref name="fileName"/> and the title to the file name without path. Sets dirty == false too.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="fileName">The name of the file currently inside the content.</param>
|
|
|
|
|
protected void SetTitleAndFileName(string fileName) |
|
|
|
|
{ |
|
|
|
|
TitleName = Path.GetFileName(fileName); |
|
|
|
|
FileName = fileName; |
|
|
|
|
IsDirty = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public event EventHandler FileNameChanged; |
|
|
|
|
|
|
|
|
|
protected virtual void OnFileNameChanged(EventArgs e) |
|
|
|
|
{ |
|
|
|
|
if (FileNameChanged != null) { |
|
|
|
|
FileNameChanged(this, e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#region IViewContent implementation
|
|
|
|
|
public virtual string UntitledName { |
|
|
|
|
get { |
|
|
|
|
return untitledName; |
|
|
|
@ -50,56 +87,12 @@ namespace ICSharpCode.SharpDevelop.Gui
@@ -50,56 +87,12 @@ namespace ICSharpCode.SharpDevelop.Gui
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<ISecondaryViewContent> secondaryViewContents = new List<ISecondaryViewContent>(); |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the list of secondary view contents attached to this view content.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<ISecondaryViewContent> SecondaryViewContents { |
|
|
|
|
get { |
|
|
|
|
return secondaryViewContents; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override void Dispose() |
|
|
|
|
{ |
|
|
|
|
foreach (ISecondaryViewContent svc in secondaryViewContents) { |
|
|
|
|
svc.Dispose(); |
|
|
|
|
} |
|
|
|
|
base.Dispose(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public AbstractViewContent() |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public AbstractViewContent(string titleName) |
|
|
|
|
{ |
|
|
|
|
this.titleName = titleName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public AbstractViewContent(string titleName, string fileName) |
|
|
|
|
{ |
|
|
|
|
this.titleName = titleName; |
|
|
|
|
this.fileName = fileName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public virtual bool IsUntitled { |
|
|
|
|
get { |
|
|
|
|
return titleName == null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public virtual bool IsDirty { |
|
|
|
|
get { |
|
|
|
|
return isDirty; |
|
|
|
|
} |
|
|
|
|
set { |
|
|
|
|
isDirty = value; |
|
|
|
|
OnDirtyChanged(EventArgs.Empty); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public virtual bool IsReadOnly { |
|
|
|
|
get { |
|
|
|
|
return false; |
|
|
|
@ -115,6 +108,15 @@ namespace ICSharpCode.SharpDevelop.Gui
@@ -115,6 +108,15 @@ namespace ICSharpCode.SharpDevelop.Gui
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the list of secondary view contents attached to this view content.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public List<ISecondaryViewContent> SecondaryViewContents { |
|
|
|
|
get { |
|
|
|
|
return secondaryViewContents; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public virtual void Save() |
|
|
|
|
{ |
|
|
|
|
if (IsDirty) { |
|
|
|
@ -132,23 +134,9 @@ namespace ICSharpCode.SharpDevelop.Gui
@@ -132,23 +134,9 @@ namespace ICSharpCode.SharpDevelop.Gui
|
|
|
|
|
throw new System.NotImplementedException(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sets the file name to <paramref name="fileName"/> and the title to the file name without path. Sets dirty == false too.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="fileName">The name of the file currently inside the content.</param>
|
|
|
|
|
protected void SetTitleAndFileName(string fileName) |
|
|
|
|
{ |
|
|
|
|
TitleName = Path.GetFileName(fileName); |
|
|
|
|
FileName = fileName; |
|
|
|
|
IsDirty = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected virtual void OnDirtyChanged(EventArgs e) |
|
|
|
|
{ |
|
|
|
|
if (DirtyChanged != null) { |
|
|
|
|
DirtyChanged(this, e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
public event EventHandler TitleNameChanged; |
|
|
|
|
public event EventHandler Saving; |
|
|
|
|
public event SaveEventHandler Saved; |
|
|
|
|
|
|
|
|
|
protected virtual void OnTitleNameChanged(EventArgs e) |
|
|
|
|
{ |
|
|
|
@ -157,13 +145,6 @@ namespace ICSharpCode.SharpDevelop.Gui
@@ -157,13 +145,6 @@ namespace ICSharpCode.SharpDevelop.Gui
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected virtual void OnFileNameChanged(EventArgs e) |
|
|
|
|
{ |
|
|
|
|
if (FileNameChanged != null) { |
|
|
|
|
FileNameChanged(this, e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected virtual void OnSaving(EventArgs e) |
|
|
|
|
{ |
|
|
|
|
foreach (ISecondaryViewContent svc in SecondaryViewContents) { |
|
|
|
@ -184,10 +165,41 @@ namespace ICSharpCode.SharpDevelop.Gui
@@ -184,10 +165,41 @@ namespace ICSharpCode.SharpDevelop.Gui
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public event EventHandler TitleNameChanged; |
|
|
|
|
public event EventHandler FileNameChanged; |
|
|
|
|
#region IBaseViewContent implementation
|
|
|
|
|
// handled in AbstractBaseViewContent
|
|
|
|
|
|
|
|
|
|
#region IDisposable implementation
|
|
|
|
|
public override void Dispose() |
|
|
|
|
{ |
|
|
|
|
foreach (ISecondaryViewContent svc in secondaryViewContents) { |
|
|
|
|
svc.Dispose(); |
|
|
|
|
} |
|
|
|
|
base.Dispose(); |
|
|
|
|
} |
|
|
|
|
#endregion
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region ICanBeDirty implementation
|
|
|
|
|
public virtual bool IsDirty { |
|
|
|
|
get { |
|
|
|
|
return isDirty; |
|
|
|
|
} |
|
|
|
|
set { |
|
|
|
|
isDirty = value; |
|
|
|
|
OnDirtyChanged(EventArgs.Empty); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
bool isDirty = false; |
|
|
|
|
|
|
|
|
|
public event EventHandler DirtyChanged; |
|
|
|
|
public event EventHandler Saving; |
|
|
|
|
public event SaveEventHandler Saved; |
|
|
|
|
|
|
|
|
|
protected virtual void OnDirtyChanged(EventArgs e) |
|
|
|
|
{ |
|
|
|
|
if (DirtyChanged != null) { |
|
|
|
|
DirtyChanged(this, e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endregion
|
|
|
|
|
#endregion
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|