Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx35 / System.WorkflowServices / System / Workflow / ComponentModel / Design / FindSimilarActivitiesVerb.cs / 1305376 / FindSimilarActivitiesVerb.cs
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------
namespace System.Workflow.ComponentModel.Design
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Runtime;
using System.ServiceModel;
using System.Workflow.ComponentModel;
//
// This the the class that implements the Search by menu item displayed on the activityDesigner
// this is responsible for finding the matching activity designers and displaying them using
// the acticvitydesigner hightlighter.
//
internal class FindSimilarActivitiesVerb : ActivityDesignerVerb where TActivity : Activity
{
List matchingActivityDesigner;
ActivityComparer matchMaker;
ActivityDesigner owner;
public FindSimilarActivitiesVerb(ActivityDesigner designer, ActivityComparer matchMaker, string displayText)
: base(designer, DesignerVerbGroup.Misc, displayText, new EventHandler(OnInvoke))
{
Fx.Assert(designer != null,
"Received null for designer parameter to FindSimilarActivitiesVerb ctor.");
Fx.Assert(matchMaker != null,
"Received null for matchMaker parameter to FindSimilarActivitiesVerb ctor.");
this.owner = designer;
this.matchMaker = matchMaker;
}
private static void OnInvoke(object source, EventArgs e)
{
FindSimilarActivitiesVerb designerVerb = source as FindSimilarActivitiesVerb;
ActivityDesigner activityDesigner = designerVerb.owner;
List highlightedDesigners = designerVerb.GetMatchingActivityDesigners(activityDesigner);
ActivityDesignerHighlighter hightlighter = new ActivityDesignerHighlighter(activityDesigner);
hightlighter.Highlight(highlightedDesigners);
}
private ActivityDesigner GetDesigner(Activity activity)
{
IDesignerHost designerHost = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
return designerHost.GetDesigner(activity as IComponent) as ActivityDesigner;
}
private List GetMatchingActivityDesigners(ActivityDesigner activityDesigner)
{
CompositeActivityDesigner rootDesigner = DesignerPainter.GetRootDesigner(activityDesigner);
matchingActivityDesigner = new List();
Walker activityTreeWalker = new Walker();
activityTreeWalker.FoundActivity += new WalkerEventHandler(OnWalkerFoundActivity);
activityTreeWalker.Walk(rootDesigner.Activity);
return matchingActivityDesigner;
}
private object GetService(Type serviceType)
{
if (serviceType == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceType");
}
if (owner.Activity != null && owner.Activity.Site != null)
{
return owner.Activity.Site.GetService(serviceType);
}
else
{
return null;
}
}
private void OnWalkerFoundActivity(Walker walker, WalkerEventArgs eventArgs)
{
TActivity foundActivity = eventArgs.CurrentActivity as TActivity;
if (foundActivity != null)
{
if (this.matchMaker((TActivity) owner.Activity, foundActivity))
{
matchingActivityDesigner.Add(GetDesigner(eventArgs.CurrentActivity));
}
}
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- Compiler.cs
- TemplateBamlTreeBuilder.cs
- SqlFacetAttribute.cs
- mediapermission.cs
- ErrorItem.cs
- TimersDescriptionAttribute.cs
- DataGridViewMethods.cs
- SessionParameter.cs
- XmlImplementation.cs
- HebrewCalendar.cs
- MergeFailedEvent.cs
- X509CertificateStore.cs
- ILGenerator.cs
- XmlUtil.cs
- CompositeScriptReference.cs
- EllipticalNodeOperations.cs
- ListViewItemEventArgs.cs
- Help.cs
- OletxTransactionManager.cs
- Rotation3DAnimationUsingKeyFrames.cs
- MenuCommand.cs
- DependencyPropertyAttribute.cs
- TableLayoutPanel.cs
- ConfigurationManagerInternalFactory.cs
- DetailsViewPageEventArgs.cs
- BackEase.cs
- RuleRef.cs
- AutomationAttributeInfo.cs
- SafeRegistryKey.cs
- XmlTypeMapping.cs
- DNS.cs
- SqlDataSourceStatusEventArgs.cs
- TypeDescriptionProvider.cs
- IsolatedStorage.cs
- HostingMessageProperty.cs
- _SslSessionsCache.cs
- HttpCachePolicyBase.cs
- WebPartDisplayMode.cs
- OptimalTextSource.cs
- IsolatedStorageFilePermission.cs
- ServiceContractDetailViewControl.cs
- TypefaceMap.cs
- DetailsViewCommandEventArgs.cs
- OdbcConnectionFactory.cs
- FixedHighlight.cs
- IndicCharClassifier.cs
- FragmentQueryKB.cs
- ConsoleKeyInfo.cs
- CultureData.cs
- EditorPartDesigner.cs
- Rect3DConverter.cs
- DataBoundControlParameterTarget.cs
- TextEffectResolver.cs
- PathTooLongException.cs
- PassportAuthenticationModule.cs
- OleDbInfoMessageEvent.cs
- BaseConfigurationRecord.cs
- HtmlInputSubmit.cs
- MemberDescriptor.cs
- WsatAdminException.cs
- ProcessThread.cs
- XamlToRtfWriter.cs
- DropTarget.cs
- XmlDataSource.cs
- PersonalizationState.cs
- SchemaType.cs
- ComponentFactoryHelpers.cs
- DropDownButton.cs
- ViewSimplifier.cs
- BmpBitmapEncoder.cs
- UiaCoreApi.cs
- LayoutDump.cs
- DbException.cs
- Transform3DGroup.cs
- ButtonFlatAdapter.cs
- HtmlTernaryTree.cs
- Condition.cs
- FloatUtil.cs
- CodeTypeReferenceExpression.cs
- NamedElement.cs
- NewExpression.cs
- CreateUserWizardAutoFormat.cs
- AsymmetricKeyExchangeDeformatter.cs
- CancellationTokenSource.cs
- OleDbConnectionPoolGroupProviderInfo.cs
- LabelEditEvent.cs
- DecimalAnimation.cs
- HiddenField.cs
- SafeLibraryHandle.cs
- SqlErrorCollection.cs
- MessageBuffer.cs
- HtmlInputSubmit.cs
- HatchBrush.cs
- XpsPackagingPolicy.cs
- BindingCompleteEventArgs.cs
- XmlDictionaryWriter.cs
- EventMap.cs
- ValidationSummary.cs
- ConfigurationConverterBase.cs
- Token.cs