|
|
@ -26,15 +26,19 @@ namespace ICSharpCode.SharpDevelop.Gui |
|
|
|
public enum OpenFileTabState { |
|
|
|
public enum OpenFileTabState { |
|
|
|
Nothing = 0, |
|
|
|
Nothing = 0, |
|
|
|
FileDirty = 1, |
|
|
|
FileDirty = 1, |
|
|
|
ClickedWindowIsForm = 2, |
|
|
|
FileReadOnly = 2, |
|
|
|
FileUntitled = 4 |
|
|
|
FileUntitled = 4 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
OpenFileTabState internalState = OpenFileTabState.Nothing; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public System.Enum InternalState { |
|
|
|
public System.Enum InternalState { |
|
|
|
get { |
|
|
|
get { |
|
|
|
return internalState; |
|
|
|
OpenFileTabState state = OpenFileTabState.Nothing; |
|
|
|
|
|
|
|
if (content != null) { |
|
|
|
|
|
|
|
if (content.IsDirty) state |= OpenFileTabState.FileDirty; |
|
|
|
|
|
|
|
if (content.IsReadOnly) state |= OpenFileTabState.FileReadOnly; |
|
|
|
|
|
|
|
if (content.IsUntitled) state |= OpenFileTabState.FileUntitled; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return state; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
@ -42,15 +46,13 @@ namespace ICSharpCode.SharpDevelop.Gui |
|
|
|
TabControl viewTabControl = null; |
|
|
|
TabControl viewTabControl = null; |
|
|
|
IViewContent content; |
|
|
|
IViewContent content; |
|
|
|
|
|
|
|
|
|
|
|
string myUntitledTitle = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string Title { |
|
|
|
public string Title { |
|
|
|
get { |
|
|
|
get { |
|
|
|
return Text; |
|
|
|
return Text; |
|
|
|
} |
|
|
|
} |
|
|
|
set { |
|
|
|
set { |
|
|
|
Text = value; |
|
|
|
Text = value; |
|
|
|
OnTitleChanged(null); |
|
|
|
OnTitleChanged(EventArgs.Empty); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -58,7 +60,7 @@ namespace ICSharpCode.SharpDevelop.Gui |
|
|
|
get { |
|
|
|
get { |
|
|
|
if (viewTabControl != null) { |
|
|
|
if (viewTabControl != null) { |
|
|
|
int selectedIndex = 0; |
|
|
|
int selectedIndex = 0; |
|
|
|
if (viewTabControl.InvokeRequired) { |
|
|
|
if (WorkbenchSingleton.InvokeRequired) { |
|
|
|
// the window might have been disposed just here, invoke on the
|
|
|
|
// the window might have been disposed just here, invoke on the
|
|
|
|
// Workbench instead
|
|
|
|
// Workbench instead
|
|
|
|
selectedIndex = (int)WorkbenchSingleton.SafeThreadCall(this, "GetSelectedIndex"); |
|
|
|
selectedIndex = (int)WorkbenchSingleton.SafeThreadCall(this, "GetSelectedIndex"); |
|
|
@ -119,8 +121,6 @@ namespace ICSharpCode.SharpDevelop.Gui |
|
|
|
content.TitleNameChanged += new EventHandler(SetTitleEvent); |
|
|
|
content.TitleNameChanged += new EventHandler(SetTitleEvent); |
|
|
|
content.DirtyChanged += new EventHandler(SetTitleEvent); |
|
|
|
content.DirtyChanged += new EventHandler(SetTitleEvent); |
|
|
|
|
|
|
|
|
|
|
|
SetTitleEvent(null, null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.DockableAreas = WeifenLuo.WinFormsUI.DockAreas.Document; |
|
|
|
this.DockableAreas = WeifenLuo.WinFormsUI.DockAreas.Document; |
|
|
|
this.DockPadding.All = 2; |
|
|
|
this.DockPadding.All = 2; |
|
|
|
|
|
|
|
|
|
|
@ -230,50 +230,25 @@ namespace ICSharpCode.SharpDevelop.Gui |
|
|
|
|
|
|
|
|
|
|
|
public void SetTitleEvent(object sender, EventArgs e) |
|
|
|
public void SetTitleEvent(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
internalState = OpenFileTabState.Nothing; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (content == null) { |
|
|
|
if (content == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
SetToolTipText(); |
|
|
|
SetToolTipText(); |
|
|
|
string newTitle = ""; |
|
|
|
string newTitle; |
|
|
|
if (content.TitleName == null) { |
|
|
|
if (content.TitleName == null) { |
|
|
|
myUntitledTitle = Path.GetFileNameWithoutExtension(content.UntitledName); |
|
|
|
newTitle = Path.GetFileName(content.UntitledName); |
|
|
|
// if (myUntitledTitle == null) {
|
|
|
|
|
|
|
|
// string baseName
|
|
|
|
|
|
|
|
// int number = 1;
|
|
|
|
|
|
|
|
// bool found = true;
|
|
|
|
|
|
|
|
// while (found) {
|
|
|
|
|
|
|
|
// found = false;
|
|
|
|
|
|
|
|
// foreach (IViewContent windowContent in WorkbenchSingleton.Workbench.ViewContentCollection) {
|
|
|
|
|
|
|
|
// string title = windowContent.WorkbenchWindow.Title;
|
|
|
|
|
|
|
|
// if (title.EndsWith("*") || title.EndsWith("+")) {
|
|
|
|
|
|
|
|
// title = title.Substring(0, title.Length - 1);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (title == baseName + number) {
|
|
|
|
|
|
|
|
// found = true;
|
|
|
|
|
|
|
|
// ++number;
|
|
|
|
|
|
|
|
// break;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// myUntitledTitle = baseName + number;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
newTitle = myUntitledTitle; |
|
|
|
|
|
|
|
internalState |= OpenFileTabState.FileUntitled; |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
newTitle = content.TitleName; |
|
|
|
newTitle = content.TitleName; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (content.IsDirty) { |
|
|
|
if (content.IsDirty) { |
|
|
|
internalState |= OpenFileTabState.FileDirty; |
|
|
|
|
|
|
|
newTitle += "*"; |
|
|
|
newTitle += "*"; |
|
|
|
} else if (content.IsReadOnly) { |
|
|
|
} else if (content.IsReadOnly) { |
|
|
|
newTitle += "+"; |
|
|
|
newTitle += "+"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (newTitle != Title) { |
|
|
|
if (newTitle != Title) { |
|
|
|
Text = newTitle; |
|
|
|
Title = newTitle; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|