From 88aee1b29e0264ef34667f3a94e42a28e4ec1f7b Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 26 Nov 2005 14:17:37 +0000 Subject: [PATCH] Added workaround for TreeView bug when drawing selected nodes when the treeview does not have focus. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@803 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Gui/Components/ExtTreeView/ExtTreeView.cs | 17 ++++++++++- .../Core/Project/Src/AddInTree/AddInTree.cs | 30 ++++++++++++------- .../Core/Project/Src/AddInTree/CoreStartup.cs | 2 +- 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/Main/Base/Project/Src/Gui/Components/ExtTreeView/ExtTreeView.cs b/src/Main/Base/Project/Src/Gui/Components/ExtTreeView/ExtTreeView.cs index 98d0edd91d..d09b1cbc31 100644 --- a/src/Main/Base/Project/Src/Gui/Components/ExtTreeView/ExtTreeView.cs +++ b/src/Main/Base/Project/Src/Gui/Components/ExtTreeView/ExtTreeView.cs @@ -279,7 +279,22 @@ namespace ICSharpCode.SharpDevelop.Gui node.Draw(e); e.DrawDefault = false; } else { - e.DrawDefault = true; + if ((e.State & (TreeNodeStates.Selected | TreeNodeStates.Focused)) == TreeNodeStates.Selected) { + // node is selected, but not focussed: + // HACK: work around TreeView bug in OwnerDrawText mode: + // overpaint blue selection with the correct gray selection + e.Graphics.FillRectangle(SystemBrushes.Control, e.Bounds); + if (e.Node.ForeColor.IsEmpty) { + e.Graphics.DrawString(e.Node.Text, this.Font, SystemBrushes.ControlText, e.Bounds.Location); + } else { + using (Brush brush = new SolidBrush(e.Node.ForeColor)) { + e.Graphics.DrawString(e.Node.Text, this.Font, brush, e.Bounds.Location); + } + } + e.DrawDefault = false; + } else { + e.DrawDefault = true; + } } } else { e.DrawDefault = false; diff --git a/src/Main/Core/Project/Src/AddInTree/AddInTree.cs b/src/Main/Core/Project/Src/AddInTree/AddInTree.cs index 2ca9586371..ef8e32b1f3 100644 --- a/src/Main/Core/Project/Src/AddInTree/AddInTree.cs +++ b/src/Main/Core/Project/Src/AddInTree/AddInTree.cs @@ -212,22 +212,32 @@ namespace ICSharpCode.Core } } - public static void Load(List addInFiles) + public static void Load(List addInFiles, List disabledAddIns) { List list = new List(); Dictionary dict = new Dictionary(); Dictionary addInDict = new Dictionary(); foreach (string fileName in addInFiles) { AddIn addIn = AddIn.Load(fileName); - foreach (KeyValuePair pair in addIn.Manifest.Identities) { - if (dict.ContainsKey(pair.Key)) { - MessageService.ShowError("Name '" + pair.Key + "' is used by " + - "'" + addInDict[pair.Key].FileName + "' and '" + fileName + "'"); - DisableAddin(addIn, dict, addInDict); - break; - } else { - dict.Add(pair.Key, pair.Value); - addInDict.Add(pair.Key, addIn); + if (disabledAddIns != null && disabledAddIns.Count > 0) { + foreach (string name in addIn.Manifest.Identities.Keys) { + if (disabledAddIns.Contains(name)) { + addIn.enabled = false; + break; + } + } + } + if (addIn.Enabled) { + foreach (KeyValuePair pair in addIn.Manifest.Identities) { + if (dict.ContainsKey(pair.Key)) { + MessageService.ShowError("Name '" + pair.Key + "' is used by " + + "'" + addInDict[pair.Key].FileName + "' and '" + fileName + "'"); + DisableAddin(addIn, dict, addInDict); + break; + } else { + dict.Add(pair.Key, pair.Value); + addInDict.Add(pair.Key, addIn); + } } } list.Add(addIn); diff --git a/src/Main/Core/Project/Src/AddInTree/CoreStartup.cs b/src/Main/Core/Project/Src/AddInTree/CoreStartup.cs index 2a24d3962c..7d53599662 100644 --- a/src/Main/Core/Project/Src/AddInTree/CoreStartup.cs +++ b/src/Main/Core/Project/Src/AddInTree/CoreStartup.cs @@ -138,7 +138,7 @@ namespace ICSharpCode.Core public void RunInitialization() { - AddInTree.Load(addInFiles); + AddInTree.Load(addInFiles, disabledAddIns); // run workspace autostart commands LoggingService.Info("Running autostart commands...");