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

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

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

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

@ -15,7 +15,17 @@ namespace ICSharpCode.Core @@ -15,7 +15,17 @@ namespace ICSharpCode.Core
{
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)

Loading…
Cancel
Save