Browse Source

Fixed SD2-677: Copy file path/name menu option not disabled for new file

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1142 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
ff9c98b6cd
  1. 2
      src/Main/Base/Project/Src/Gui/AbstractViewContent.cs
  2. 51
      src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs
  3. 12
      src/Main/Core/Project/Src/Services/ToolBarService/ToolBarService.cs

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

@ -69,7 +69,7 @@ namespace ICSharpCode.SharpDevelop.Gui
public virtual string TitleName { public virtual string TitleName {
get { get {
return IsUntitled ? untitledName : titleName; return titleName;
} }
set { set {
titleName = value; titleName = value;

51
src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceWindow.cs

@ -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;
} }
} }

12
src/Main/Core/Project/Src/Services/ToolBarService/ToolBarService.cs

@ -15,7 +15,17 @@ namespace ICSharpCode.Core
{ {
public static ToolStripItem[] CreateToolStripItems(object owner, AddInTreeNode treeNode) public static ToolStripItem[] CreateToolStripItems(object owner, AddInTreeNode treeNode)
{ {
return (ToolStripItem[])(treeNode.BuildChildItems(owner)).ToArray(typeof(ToolStripItem)); List<ToolStripItem> collection = new List<ToolStripItem>();
foreach (object item in treeNode.BuildChildItems(owner)) {
if (item is ToolStripItem) {
collection.Add((ToolStripItem)item);
} else {
ISubmenuBuilder submenuBuilder = (ISubmenuBuilder)item;
collection.AddRange(submenuBuilder.BuildSubmenu(null, owner));
}
}
return collection.ToArray();
} }
public static ToolStrip CreateToolStrip(object owner, AddInTreeNode treeNode) public static ToolStrip CreateToolStrip(object owner, AddInTreeNode treeNode)

Loading…
Cancel
Save