Browse Source
ToolBarCheckBox: Expose the caller and set the owner of the MenuCommand. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1885 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
15 changed files with 303 additions and 20 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,62 @@
@@ -0,0 +1,62 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Christian Hornung" email="c-hornung@gmx.de"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace Hornung.ResourceToolkit.Conditions |
||||
{ |
||||
/// <summary>
|
||||
/// Checks whether a solution is open and contains a either a project or a
|
||||
/// reference with the specified name.
|
||||
/// </summary>
|
||||
/// <attribute name="itemName">
|
||||
/// The name of the project or reference to find.
|
||||
/// </attribute>
|
||||
/// <example title="Check whether the open solution uses ICSharpCode.Core">
|
||||
/// <Condition name = "SolutionContainsProjectOrReference" itemName = "ICSharpCode.Core">
|
||||
/// </example>
|
||||
public class SolutionContainsProjectOrReferenceConditionEvaluator : IConditionEvaluator |
||||
{ |
||||
public bool IsValid(object caller, Condition condition) |
||||
{ |
||||
if (ProjectService.OpenSolution == null) { |
||||
return false; |
||||
} |
||||
|
||||
foreach (IProject p in ProjectService.OpenSolution.Projects) { |
||||
|
||||
// Check project name
|
||||
if (p.Name.Equals(condition.Properties["itemName"], StringComparison.InvariantCultureIgnoreCase)) { |
||||
return true; |
||||
} |
||||
|
||||
// Check references
|
||||
foreach (ProjectItem pi in p.Items) { |
||||
ReferenceProjectItem rpi = pi as ReferenceProjectItem; |
||||
if (rpi != null) { |
||||
if (rpi.Name.Equals(condition.Properties["itemName"], StringComparison.InvariantCultureIgnoreCase)) { |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
return false; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Initalizes a new instance of the <see cref="SolutionContainsProjectOrReferenceConditionEvaluator"/> class.
|
||||
/// </summary>
|
||||
public SolutionContainsProjectOrReferenceConditionEvaluator() |
||||
{ |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Christian Hornung" email="c-hornung@gmx.de"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace Hornung.ResourceToolkit.Gui |
||||
{ |
||||
/// <summary>
|
||||
/// Describes an object that applies a filter condition to items.
|
||||
/// </summary>
|
||||
public interface IFilter<T> |
||||
{ |
||||
/// <summary>
|
||||
/// Determines if the specified item matches the current filter criteria.
|
||||
/// </summary>
|
||||
/// <param name="item">The item to test.</param>
|
||||
/// <returns><c>true</c>, if the specified item matches the current filter criteria, otherwise <c>false</c>.</returns>
|
||||
bool IsMatch(T item); |
||||
} |
||||
} |
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Christian Hornung" email="c-hornung@gmx.de"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace Hornung.ResourceToolkit.Gui |
||||
{ |
||||
/// <summary>
|
||||
/// Describes an object that can filter items by registering
|
||||
/// one or more <see cref="IFilter"/> objects.
|
||||
/// </summary>
|
||||
public interface IFilterHost<T> |
||||
{ |
||||
/// <summary>
|
||||
/// Registers a new filter with the filter host, if the filter is not already registered,
|
||||
/// or signals that the filter condition of the specified filter has changed.
|
||||
/// </summary>
|
||||
/// <param name="filter">The filter to be registered.</param>
|
||||
void RegisterFilter(IFilter<T> filter); |
||||
|
||||
/// <summary>
|
||||
/// Removes the specified filter from the filter host, if it is currently registered there.
|
||||
/// </summary>
|
||||
/// <param name="filter">The filter to be removed.</param>
|
||||
void UnregisterFilter(IFilter<T> filter); |
||||
} |
||||
} |
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Christian Hornung" email="c-hornung@gmx.de"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
using ICSharpCode.Core; |
||||
|
||||
using Hornung.ResourceToolkit.Resolver; |
||||
|
||||
namespace Hornung.ResourceToolkit.Gui |
||||
{ |
||||
/// <summary>
|
||||
/// Hides or shows the ICSharpCode.Core host resources in an UnusedResourceKeysViewContent.
|
||||
/// </summary>
|
||||
public class UnusedResourceKeysHideICSharpCodeCoreHostResourcesCommand : AbstractCheckableMenuCommand, IFilter<KeyValuePair<string, string>> |
||||
{ |
||||
string icSharpCodeCoreHostResourceFileName; |
||||
|
||||
public override void Run() |
||||
{ |
||||
base.Run(); |
||||
|
||||
IFilterHost<KeyValuePair<string, string>> host = ((ToolBarCheckBox)this.Owner).Caller as IFilterHost<KeyValuePair<string, string>>; |
||||
if (host != null) { |
||||
if (this.IsChecked) { |
||||
this.icSharpCodeCoreHostResourceFileName = ICSharpCodeCoreResourceResolver.GetICSharpCodeCoreHostResourceFileName(null); |
||||
host.RegisterFilter(this); |
||||
} else { |
||||
host.UnregisterFilter(this); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Determines if the specified item matches the current filter criteria.
|
||||
/// </summary>
|
||||
/// <param name="item">The item to test.</param>
|
||||
/// <returns><c>true</c>, if the specified item matches the current filter criteria, otherwise <c>false</c>.</returns>
|
||||
public bool IsMatch(KeyValuePair<string, string> item) |
||||
{ |
||||
return !FileUtility.IsEqualFileName(item.Value, this.icSharpCodeCoreHostResourceFileName); |
||||
} |
||||
} |
||||
} |
Binary file not shown.
Loading…
Reference in new issue