diff --git a/src/Main/Base/Project/Src/Gui/AbstractViewContent.cs b/src/Main/Base/Project/Src/Gui/AbstractViewContent.cs
index 935976a433..bfc8a35f2f 100644
--- a/src/Main/Base/Project/Src/Gui/AbstractViewContent.cs
+++ b/src/Main/Base/Project/Src/Gui/AbstractViewContent.cs
@@ -348,18 +348,19 @@ namespace ICSharpCode.SharpDevelop.Gui
string IViewContent.TitleName {
get {
- if (titleName != null)
+ if (titleName != null) {
return titleName;
- else if (files.Count > 0)
+ } else if (files.Count > 0) {
return Path.GetFileName(files[0].FileName);
- else
+ } else {
return "[Default Title]";
+ }
}
}
public string TitleName {
get { return titleName; }
- protected set {
+ set {
if (titleNameLocalizeExtension != null) {
titleNameLocalizeExtension.PropertyChanged -= OnTitleNameLocalizationChanged;
titleNameLocalizeExtension = null;
@@ -391,6 +392,78 @@ namespace ICSharpCode.SharpDevelop.Gui
}
}
#endregion
+
+
+ #region InfoTip
+ public event EventHandler InfoTipChanged;
+
+ void OnInfoTipChanged()
+ {
+ if (InfoTipChanged != null)
+ {
+ InfoTipChanged(this, EventArgs.Empty);
+ }
+ }
+
+ string infoTip;
+ LanguageDependentExtension infoTipLocalizeExtension;
+
+ string IViewContent.InfoTip
+ {
+ get
+ {
+ if (infoTip != null)
+ return infoTip;
+ else if (files.Count > 0)
+ return files[0].FileName;
+ else
+ return "[Default Info Tip]";
+ }
+ set
+ {
+ this.InfoTip = value;
+ }
+ }
+
+ public string InfoTip
+ {
+ get { return infoTip; }
+ set
+ {
+ if (infoTipLocalizeExtension != null)
+ {
+ infoTipLocalizeExtension.PropertyChanged -= OnInfoTipLocalizationChanged;
+ infoTipLocalizeExtension = null;
+ }
+ if (infoTip != value)
+ {
+ infoTip = value;
+ OnInfoTipChanged();
+ }
+ }
+ }
+
+ ///
+ /// Sets a localized info tip that will update automatically when the language changes.
+ ///
+ /// The input to the string parser which will localize info tip.
+ protected void SetLocalizedInfoTip(string text)
+ {
+ infoTipLocalizeExtension = new StringParseExtension(text) { UsesAccessors = false };
+ infoTipLocalizeExtension.PropertyChanged += OnInfoTipLocalizationChanged;
+ OnInfoTipLocalizationChanged(null, null);
+ }
+
+ void OnInfoTipLocalizationChanged(object sender, EventArgs e)
+ {
+ string value = infoTipLocalizeExtension.Value;
+ if (infoTip != value)
+ {
+ infoTip = value;
+ OnInfoTipChanged();
+ }
+ }
+ #endregion
#region IDisposable
public event EventHandler Disposed;
diff --git a/src/Main/Base/Project/Src/Gui/IViewContent.cs b/src/Main/Base/Project/Src/Gui/IViewContent.cs
index d0617d3587..ec18b3f5c3 100644
--- a/src/Main/Base/Project/Src/Gui/IViewContent.cs
+++ b/src/Main/Base/Project/Src/Gui/IViewContent.cs
@@ -83,6 +83,18 @@ namespace ICSharpCode.SharpDevelop.Gui
///
event EventHandler TitleNameChanged;
+ ///
+ /// The tooltip that will be shown when you hover the mouse over the title
+ ///
+ string InfoTip {
+ get;
+ }
+
+ ///
+ /// Is called each time the info tip for the content has changed.
+ ///
+ event EventHandler InfoTipChanged;
+
///
/// Saves the content to the location fileName
///
diff --git a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonWorkbenchWindow.cs b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonWorkbenchWindow.cs
index 2e672548d3..38ec218fee 100644
--- a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonWorkbenchWindow.cs
+++ b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonWorkbenchWindow.cs
@@ -135,8 +135,12 @@ namespace ICSharpCode.SharpDevelop.Gui
void UpdateActiveViewContent()
{
- UpdateTitle();
+ UpdateTitleAndInfoTip();
+
IViewContent newActiveViewContent = this.ActiveViewContent;
+ if (newActiveViewContent != null)
+ IsLocked = newActiveViewContent.IsReadOnly;
+
if (oldActiveViewContent != newActiveViewContent && ActiveViewContentChanged != null) {
ActiveViewContentChanged(this, EventArgs.Empty);
}
@@ -262,7 +266,7 @@ namespace ICSharpCode.SharpDevelop.Gui
if (this.DragEnabledArea != null) {
this.DragEnabledArea.ContextMenu = MenuService.CreateContextMenu(this, contextMenuPath);
- UpdateTitle(); // set tooltip
+ UpdateInfoTip(); // set tooltip
}
}
@@ -347,6 +351,13 @@ namespace ICSharpCode.SharpDevelop.Gui
UpdateTitle();
}
}
+
+ void OnInfoTipChanged(object sender, EventArgs e)
+ {
+ if (sender == ActiveViewContent) {
+ UpdateInfoTip();
+ }
+ }
void OnIsDirtyChanged(object sender, EventArgs e)
{
@@ -354,36 +365,54 @@ namespace ICSharpCode.SharpDevelop.Gui
CommandManager.InvalidateRequerySuggested();
}
+ void UpdateTitleAndInfoTip()
+ {
+ UpdateInfoTip();
+ UpdateTitle();
+ }
+
+ void UpdateInfoTip()
+ {
+ IViewContent content = ActiveViewContent;
+ if (content != null)
+ {
+ string newInfoTip = content.InfoTip;
+
+ if (newInfoTip != this.InfoTip) {
+ this.InfoTip = newInfoTip;
+ if (DragEnabledArea != null)
+ DragEnabledArea.ToolTip = this.InfoTip;
+
+ OnInfoTipChanged();
+ }
+ }
+ }
+
void UpdateTitle()
{
IViewContent content = ActiveViewContent;
if (content != null) {
- this.InfoTip = content.PrimaryFileName;
-
string newTitle = content.TitleName;
-
- if (this.IsDirty) {
+ if (content.IsDirty)
newTitle += "*";
- }
-
- IsLocked = content.IsReadOnly;
-
if (newTitle != Title) {
Title = newTitle;
- OnTitleChanged(EventArgs.Empty);
+ OnTitleChanged();
}
}
}
-
+
+
void RegisterNewContent(IViewContent content)
{
Debug.Assert(content.WorkbenchWindow == null);
content.WorkbenchWindow = this;
content.TabPageTextChanged += OnTabPageTextChanged;
- content.TitleNameChanged += OnTitleNameChanged;
- content.IsDirtyChanged += OnIsDirtyChanged;
-
+ content.TitleNameChanged += OnTitleNameChanged;
+ content.InfoTipChanged += OnInfoTipChanged;
+ content.IsDirtyChanged += OnIsDirtyChanged;
+
this.dockLayout.Workbench.OnViewOpened(new ViewContentEventArgs(content));
}
@@ -392,9 +421,10 @@ namespace ICSharpCode.SharpDevelop.Gui
content.WorkbenchWindow = null;
content.TabPageTextChanged -= OnTabPageTextChanged;
- content.TitleNameChanged -= OnTitleNameChanged;
- content.IsDirtyChanged -= OnIsDirtyChanged;
-
+ content.TitleNameChanged -= OnTitleNameChanged;
+ content.InfoTipChanged -= OnInfoTipChanged;
+ content.IsDirtyChanged -= OnIsDirtyChanged;
+
this.dockLayout.Workbench.OnViewClosed(new ViewContentEventArgs(content));
}
@@ -466,16 +496,27 @@ namespace ICSharpCode.SharpDevelop.Gui
}
}
}
-
- void OnTitleChanged(EventArgs e)
+
+ void OnTitleChanged()
{
- if (TitleChanged != null) {
- TitleChanged(this, e);
+ if (TitleChanged != null)
+ {
+ TitleChanged(this, EventArgs.Empty);
}
}
-
+
public event EventHandler TitleChanged;
-
+
+ void OnInfoTipChanged()
+ {
+ if (InfoTipChanged != null)
+ {
+ InfoTipChanged(this, EventArgs.Empty);
+ }
+ }
+
+ public event EventHandler InfoTipChanged;
+
public override string ToString()
{
return "[AvalonWorkbenchWindow: " + this.Title + "]";
diff --git a/src/Main/Base/Project/Src/Util/FakeXmlViewContent.cs b/src/Main/Base/Project/Src/Util/FakeXmlViewContent.cs
index 557636e7c1..58f302d613 100644
--- a/src/Main/Base/Project/Src/Util/FakeXmlViewContent.cs
+++ b/src/Main/Base/Project/Src/Util/FakeXmlViewContent.cs
@@ -89,6 +89,11 @@ namespace ICSharpCode.SharpDevelop.Util
add { }
remove { }
}
+
+ event EventHandler IViewContent.InfoTipChanged {
+ add { }
+ remove { }
+ }
public event EventHandler Disposed;
@@ -128,6 +133,10 @@ namespace ICSharpCode.SharpDevelop.Util
get {
throw new NotImplementedException();
}
+ set
+ {
+ throw new NotImplementedException();
+ }
}
System.Collections.Generic.IList IViewContent.Files {
@@ -153,6 +162,16 @@ namespace ICSharpCode.SharpDevelop.Util
throw new NotImplementedException();
}
}
+
+ string IViewContent.InfoTip {
+ get {
+ throw new NotImplementedException();
+ }
+ set {
+ throw new NotImplementedException();
+ }
+ }
+
bool IViewContent.CloseWithSolution {
get {