Browse Source

Grouped code according to interface implementations and added #region wrappers to identify them.

No change to code or functionality.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1031 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Alpert 20 years ago
parent
commit
e53be414f7
  1. 21
      src/Main/Base/Project/Src/Gui/AbstractBaseViewContent.cs
  2. 166
      src/Main/Base/Project/Src/Gui/AbstractViewContent.cs

21
src/Main/Base/Project/Src/Gui/AbstractBaseViewContent.cs

@ -14,6 +14,16 @@ namespace ICSharpCode.SharpDevelop.Gui
{ {
IWorkbenchWindow workbenchWindow = null; IWorkbenchWindow workbenchWindow = null;
public event EventHandler WorkbenchWindowChanged;
protected virtual void OnWorkbenchWindowChanged(EventArgs e)
{
if (WorkbenchWindowChanged != null) {
WorkbenchWindowChanged(this, e);
}
}
#region IBaseViewContent implementation
public abstract Control Control { public abstract Control Control {
get; get;
} }
@ -50,18 +60,13 @@ namespace ICSharpCode.SharpDevelop.Gui
{ {
} }
#region IDisposable implementation
public virtual void Dispose() public virtual void Dispose()
{ {
workbenchWindow = null; workbenchWindow = null;
} }
#endregion
protected virtual void OnWorkbenchWindowChanged(EventArgs e) #endregion
{
if (WorkbenchWindowChanged != null) {
WorkbenchWindowChanged(this, e);
}
}
public event EventHandler WorkbenchWindowChanged;
} }
} }

166
src/Main/Base/Project/Src/Gui/AbstractViewContent.cs

@ -17,10 +17,47 @@ namespace ICSharpCode.SharpDevelop.Gui
string untitledName = String.Empty; string untitledName = String.Empty;
string titleName = null; string titleName = null;
string fileName = null; string fileName = null;
bool isDirty = false;
bool isViewOnly = 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 { public virtual string UntitledName {
get { get {
return untitledName; return untitledName;
@ -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 { public virtual bool IsUntitled {
get { get {
return titleName == null; return titleName == null;
} }
} }
public virtual bool IsDirty {
get {
return isDirty;
}
set {
isDirty = value;
OnDirtyChanged(EventArgs.Empty);
}
}
public virtual bool IsReadOnly { public virtual bool IsReadOnly {
get { get {
return false; return false;
@ -114,7 +107,16 @@ namespace ICSharpCode.SharpDevelop.Gui
isViewOnly = value; isViewOnly = value;
} }
} }
/// <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() public virtual void Save()
{ {
if (IsDirty) { if (IsDirty) {
@ -132,38 +134,17 @@ namespace ICSharpCode.SharpDevelop.Gui
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
/// <summary> public event EventHandler TitleNameChanged;
/// Sets the file name to <paramref name="fileName"/> and the title to the file name without path. Sets dirty == false too. public event EventHandler Saving;
/// </summary> public event SaveEventHandler Saved;
/// <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);
}
}
protected virtual void OnTitleNameChanged(EventArgs e) protected virtual void OnTitleNameChanged(EventArgs e)
{ {
if (TitleNameChanged != null) { if (TitleNameChanged != null) {
TitleNameChanged(this, e); TitleNameChanged(this, e);
} }
} }
protected virtual void OnFileNameChanged(EventArgs e)
{
if (FileNameChanged != null) {
FileNameChanged(this, e);
}
}
protected virtual void OnSaving(EventArgs e) protected virtual void OnSaving(EventArgs e)
{ {
foreach (ISecondaryViewContent svc in SecondaryViewContents) { foreach (ISecondaryViewContent svc in SecondaryViewContents) {
@ -183,11 +164,42 @@ namespace ICSharpCode.SharpDevelop.Gui
Saved(this, e); Saved(this, e);
} }
} }
#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 TitleNameChanged;
public event EventHandler FileNameChanged;
public event EventHandler DirtyChanged; 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
} }
} }

Loading…
Cancel
Save