You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
@@ -0,0 +1 @@
|
||||
27733ce1230aa3117c70bc46258ae1f19a741e6a
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,498 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Workflow.ComponentModel;
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
using System.Workflow.ComponentModel.Compiler;
|
||||
using System.Workflow.ComponentModel.Serialization;
|
||||
|
||||
namespace System.Workflow.Activities.Rules
|
||||
{
|
||||
#region ConditionChangeAction
|
||||
[DesignerSerializer(typeof(WorkflowMarkupSerializer), typeof(WorkflowMarkupSerializer))]
|
||||
public abstract class RuleConditionChangeAction : WorkflowChangeAction
|
||||
{
|
||||
public abstract string ConditionName { get; }
|
||||
|
||||
protected override ValidationErrorCollection ValidateChanges(Activity activity)
|
||||
{
|
||||
// No validations required.
|
||||
return new ValidationErrorCollection();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region RuleSetChangeAction
|
||||
[DesignerSerializer(typeof(WorkflowMarkupSerializer), typeof(WorkflowMarkupSerializer))]
|
||||
public abstract class RuleSetChangeAction : WorkflowChangeAction
|
||||
{
|
||||
public abstract string RuleSetName { get; }
|
||||
|
||||
protected override ValidationErrorCollection ValidateChanges(Activity activity)
|
||||
{
|
||||
// No validations can be done since we don't know the context the policy
|
||||
// will execute in (i.e. no idea what the "this" object will be)
|
||||
return new ValidationErrorCollection();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region AddedConditionAction
|
||||
public sealed class AddedConditionAction : RuleConditionChangeAction
|
||||
{
|
||||
private RuleCondition _conditionDefinition;
|
||||
|
||||
public AddedConditionAction(RuleCondition addedConditionDefinition)
|
||||
{
|
||||
if (null == addedConditionDefinition)
|
||||
throw new ArgumentNullException("addedConditionDefinition");
|
||||
|
||||
_conditionDefinition = addedConditionDefinition;
|
||||
}
|
||||
|
||||
public AddedConditionAction()
|
||||
{
|
||||
}
|
||||
|
||||
public override string ConditionName
|
||||
{
|
||||
get { return _conditionDefinition.Name; }
|
||||
}
|
||||
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public RuleCondition ConditionDefinition
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._conditionDefinition;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (null == value)
|
||||
throw new ArgumentNullException("value");
|
||||
|
||||
this._conditionDefinition = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ApplyTo(Activity rootActivity)
|
||||
{
|
||||
if (rootActivity == null)
|
||||
return false;
|
||||
|
||||
RuleDefinitions rules = rootActivity.GetValue(RuleDefinitions.RuleDefinitionsProperty) as RuleDefinitions;
|
||||
if (rules == null)
|
||||
{
|
||||
rules = new RuleDefinitions();
|
||||
((Activity)rootActivity).SetValue(RuleDefinitions.RuleDefinitionsProperty, rules);
|
||||
}
|
||||
|
||||
//
|
||||
bool setRuntimeMode = false;
|
||||
if (rules.Conditions.RuntimeMode)
|
||||
{
|
||||
rules.Conditions.RuntimeMode = false;
|
||||
setRuntimeMode = true;
|
||||
}
|
||||
try
|
||||
{
|
||||
rules.Conditions.Add(this.ConditionDefinition);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (setRuntimeMode)
|
||||
rules.Conditions.RuntimeMode = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region RemovedConditionAction
|
||||
public sealed class RemovedConditionAction : RuleConditionChangeAction
|
||||
{
|
||||
private RuleCondition _conditionDefinition;
|
||||
|
||||
public RemovedConditionAction(RuleCondition removedConditionDefinition)
|
||||
{
|
||||
if (null == removedConditionDefinition)
|
||||
throw new ArgumentNullException("removedConditionDefinition");
|
||||
|
||||
_conditionDefinition = removedConditionDefinition;
|
||||
}
|
||||
public RemovedConditionAction()
|
||||
{
|
||||
}
|
||||
|
||||
public override string ConditionName
|
||||
{
|
||||
get { return _conditionDefinition.Name; }
|
||||
}
|
||||
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public RuleCondition ConditionDefinition
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._conditionDefinition;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (null == value)
|
||||
throw new ArgumentNullException("value");
|
||||
|
||||
this._conditionDefinition = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ApplyTo(Activity rootActivity)
|
||||
{
|
||||
|
||||
if (rootActivity == null)
|
||||
return false;
|
||||
|
||||
RuleDefinitions rules = rootActivity.GetValue(RuleDefinitions.RuleDefinitionsProperty) as RuleDefinitions;
|
||||
if (rules == null || rules.Conditions == null)
|
||||
return false;
|
||||
|
||||
//
|
||||
bool setRuntimeMode = false;
|
||||
if (rules.Conditions.RuntimeMode)
|
||||
{
|
||||
rules.Conditions.RuntimeMode = false;
|
||||
setRuntimeMode = true;
|
||||
}
|
||||
try
|
||||
{
|
||||
return rules.Conditions.Remove(this.ConditionDefinition.Name);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (setRuntimeMode)
|
||||
rules.Conditions.RuntimeMode = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UpdatedConditionAction
|
||||
public sealed class UpdatedConditionAction : RuleConditionChangeAction
|
||||
{
|
||||
private RuleCondition _conditionDefinition;
|
||||
private RuleCondition _newConditionDefinition;
|
||||
|
||||
public UpdatedConditionAction(RuleCondition conditionDefinition, RuleCondition newConditionDefinition)
|
||||
{
|
||||
if (null == conditionDefinition)
|
||||
throw new ArgumentNullException("conditionDefinition");
|
||||
if (null == newConditionDefinition)
|
||||
throw new ArgumentNullException("newConditionDefinition");
|
||||
|
||||
if (newConditionDefinition.Name != conditionDefinition.Name)
|
||||
{
|
||||
string message = string.Format(CultureInfo.CurrentCulture, Messages.ConditionNameNotIdentical, newConditionDefinition.Name, conditionDefinition.Name);
|
||||
throw new ArgumentException(message);
|
||||
}
|
||||
|
||||
_conditionDefinition = conditionDefinition;
|
||||
_newConditionDefinition = newConditionDefinition;
|
||||
}
|
||||
public UpdatedConditionAction()
|
||||
{
|
||||
}
|
||||
|
||||
public override string ConditionName
|
||||
{
|
||||
get { return _conditionDefinition.Name; }
|
||||
}
|
||||
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public RuleCondition ConditionDefinition
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._conditionDefinition;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (null == value)
|
||||
throw new ArgumentNullException("value");
|
||||
|
||||
this._conditionDefinition = value;
|
||||
}
|
||||
}
|
||||
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public RuleCondition NewConditionDefinition
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._newConditionDefinition;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (null == value)
|
||||
throw new ArgumentNullException("value");
|
||||
|
||||
this._newConditionDefinition = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ApplyTo(Activity rootActivity)
|
||||
{
|
||||
if (rootActivity == null)
|
||||
return false;
|
||||
|
||||
RuleDefinitions rules = rootActivity.GetValue(RuleDefinitions.RuleDefinitionsProperty) as RuleDefinitions;
|
||||
if (rules == null || rules.Conditions == null)
|
||||
return false;
|
||||
|
||||
if (rules.Conditions[this.ConditionDefinition.Name] == null)
|
||||
return false;
|
||||
|
||||
//
|
||||
bool setRuntimeMode = false;
|
||||
if (rules.Conditions.RuntimeMode)
|
||||
{
|
||||
rules.Conditions.RuntimeMode = false;
|
||||
setRuntimeMode = true;
|
||||
}
|
||||
try
|
||||
{
|
||||
rules.Conditions.Remove(this.ConditionDefinition.Name);
|
||||
rules.Conditions.Add(this.NewConditionDefinition);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (setRuntimeMode)
|
||||
rules.Conditions.RuntimeMode = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region AddedRuleSetAction
|
||||
public sealed class AddedRuleSetAction : RuleSetChangeAction
|
||||
{
|
||||
private RuleSet ruleset;
|
||||
|
||||
public AddedRuleSetAction(RuleSet addedRuleSetDefinition)
|
||||
{
|
||||
if (addedRuleSetDefinition == null)
|
||||
throw new ArgumentNullException("addedRuleSetDefinition");
|
||||
ruleset = addedRuleSetDefinition;
|
||||
}
|
||||
|
||||
public AddedRuleSetAction()
|
||||
{
|
||||
}
|
||||
|
||||
public override string RuleSetName
|
||||
{
|
||||
get { return ruleset.Name; }
|
||||
}
|
||||
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public RuleSet RuleSetDefinition
|
||||
{
|
||||
get { return ruleset; }
|
||||
set
|
||||
{
|
||||
if (null == value)
|
||||
throw new ArgumentNullException("value");
|
||||
ruleset = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ApplyTo(Activity rootActivity)
|
||||
{
|
||||
if (rootActivity == null)
|
||||
return false;
|
||||
|
||||
RuleDefinitions rules = rootActivity.GetValue(RuleDefinitions.RuleDefinitionsProperty) as RuleDefinitions;
|
||||
if (rules == null)
|
||||
{
|
||||
rules = new RuleDefinitions();
|
||||
((Activity)rootActivity).SetValue(RuleDefinitions.RuleDefinitionsProperty, rules);
|
||||
}
|
||||
|
||||
//
|
||||
bool setRuntimeMode = false;
|
||||
if (rules.RuleSets.RuntimeMode)
|
||||
{
|
||||
rules.RuleSets.RuntimeMode = false;
|
||||
setRuntimeMode = true;
|
||||
}
|
||||
try
|
||||
{
|
||||
rules.RuleSets.Add(ruleset);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (setRuntimeMode)
|
||||
rules.RuleSets.RuntimeMode = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region RemovedRuleSetAction
|
||||
public sealed class RemovedRuleSetAction : RuleSetChangeAction
|
||||
{
|
||||
private RuleSet ruleset;
|
||||
|
||||
public RemovedRuleSetAction(RuleSet removedRuleSetDefinition)
|
||||
{
|
||||
if (removedRuleSetDefinition == null)
|
||||
throw new ArgumentNullException("removedRuleSetDefinition");
|
||||
ruleset = removedRuleSetDefinition;
|
||||
}
|
||||
|
||||
public RemovedRuleSetAction()
|
||||
{
|
||||
}
|
||||
|
||||
public override string RuleSetName
|
||||
{
|
||||
get { return ruleset.Name; }
|
||||
}
|
||||
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public RuleSet RuleSetDefinition
|
||||
{
|
||||
get { return ruleset; }
|
||||
set
|
||||
{
|
||||
if (null == value)
|
||||
throw new ArgumentNullException("value");
|
||||
ruleset = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ApplyTo(Activity rootActivity)
|
||||
{
|
||||
|
||||
if (rootActivity == null)
|
||||
return false;
|
||||
|
||||
RuleDefinitions rules = rootActivity.GetValue(RuleDefinitions.RuleDefinitionsProperty) as RuleDefinitions;
|
||||
if (rules == null || rules.RuleSets == null)
|
||||
return false;
|
||||
|
||||
//
|
||||
bool setRuntimeMode = false;
|
||||
if (rules.RuleSets.RuntimeMode)
|
||||
{
|
||||
rules.RuleSets.RuntimeMode = false;
|
||||
setRuntimeMode = true;
|
||||
}
|
||||
try
|
||||
{
|
||||
return rules.RuleSets.Remove(ruleset.Name);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (setRuntimeMode)
|
||||
rules.RuleSets.RuntimeMode = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UpdatedRuleSetAction
|
||||
public sealed class UpdatedRuleSetAction : RuleSetChangeAction
|
||||
{
|
||||
private RuleSet original;
|
||||
private RuleSet updated;
|
||||
|
||||
public UpdatedRuleSetAction(RuleSet originalRuleSetDefinition, RuleSet updatedRuleSetDefinition)
|
||||
{
|
||||
if (originalRuleSetDefinition == null)
|
||||
throw new ArgumentNullException("originalRuleSetDefinition");
|
||||
if (updatedRuleSetDefinition == null)
|
||||
throw new ArgumentNullException("updatedRuleSetDefinition");
|
||||
|
||||
if (originalRuleSetDefinition.Name != updatedRuleSetDefinition.Name)
|
||||
{
|
||||
string message = string.Format(CultureInfo.CurrentCulture, Messages.ConditionNameNotIdentical, originalRuleSetDefinition.Name, updatedRuleSetDefinition.Name);
|
||||
throw new ArgumentException(message);
|
||||
}
|
||||
original = originalRuleSetDefinition;
|
||||
updated = updatedRuleSetDefinition;
|
||||
}
|
||||
|
||||
public UpdatedRuleSetAction()
|
||||
{
|
||||
}
|
||||
|
||||
public override string RuleSetName
|
||||
{
|
||||
get { return original.Name; }
|
||||
}
|
||||
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public RuleSet OriginalRuleSetDefinition
|
||||
{
|
||||
get { return original; }
|
||||
set
|
||||
{
|
||||
if (null == value)
|
||||
throw new ArgumentNullException("value");
|
||||
original = value;
|
||||
}
|
||||
}
|
||||
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public RuleSet UpdatedRuleSetDefinition
|
||||
{
|
||||
get { return updated; }
|
||||
set
|
||||
{
|
||||
if (null == value)
|
||||
throw new ArgumentNullException("value");
|
||||
updated = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ApplyTo(Activity rootActivity)
|
||||
{
|
||||
if (rootActivity == null)
|
||||
return false;
|
||||
|
||||
RuleDefinitions rules = rootActivity.GetValue(RuleDefinitions.RuleDefinitionsProperty) as RuleDefinitions;
|
||||
if (rules == null || rules.RuleSets == null)
|
||||
return false;
|
||||
|
||||
if (rules.RuleSets[RuleSetName] == null)
|
||||
return false;
|
||||
|
||||
//
|
||||
bool setRuntimeMode = false;
|
||||
if (rules.Conditions.RuntimeMode)
|
||||
{
|
||||
rules.Conditions.RuntimeMode = false;
|
||||
setRuntimeMode = true;
|
||||
}
|
||||
try
|
||||
{
|
||||
rules.RuleSets.Remove(RuleSetName);
|
||||
rules.RuleSets.Add(updated);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (setRuntimeMode)
|
||||
rules.RuleSets.RuntimeMode = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
// Copyright (C) 2005 Microsoft Corporation - All Rights Reserved
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.CodeDom;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel.Design.Serialization;
|
||||
using System.Collections.Generic;
|
||||
using System.Workflow.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Workflow.ComponentModel.Serialization;
|
||||
|
||||
namespace System.Workflow.Activities.Rules
|
||||
{
|
||||
#region RuleConditionCollection Class
|
||||
[Serializable]
|
||||
public sealed class RuleConditionCollection : KeyedCollection<string, RuleCondition>, IWorkflowChangeDiff
|
||||
{
|
||||
private bool _runtimeInitialized;
|
||||
[NonSerialized]
|
||||
private object _runtimeInitializationLock = new object();
|
||||
|
||||
public RuleConditionCollection()
|
||||
{
|
||||
}
|
||||
|
||||
protected override string GetKeyForItem(RuleCondition item)
|
||||
{
|
||||
return item.Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mark the DeclarativeConditionDefinitionCollection as Runtime Initialized to prevent direct runtime updates.
|
||||
/// </summary>
|
||||
internal void OnRuntimeInitialized()
|
||||
{
|
||||
lock (_runtimeInitializationLock)
|
||||
{
|
||||
if (_runtimeInitialized)
|
||||
return;
|
||||
|
||||
foreach (RuleCondition condition in this)
|
||||
{
|
||||
condition.OnRuntimeInitialized();
|
||||
}
|
||||
_runtimeInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void InsertItem(int index, RuleCondition item)
|
||||
{
|
||||
if (this._runtimeInitialized)
|
||||
throw new InvalidOperationException(SR.GetString(SR.Error_CanNotChangeAtRuntime));
|
||||
|
||||
if (item.Name != null && item.Name.Length >= 0 && this.Contains(item.Name))
|
||||
{
|
||||
string message = string.Format(CultureInfo.CurrentCulture, Messages.ConditionExists, item.Name);
|
||||
throw new ArgumentException(message);
|
||||
}
|
||||
|
||||
base.InsertItem(index, item);
|
||||
}
|
||||
|
||||
protected override void RemoveItem(int index)
|
||||
{
|
||||
if (this._runtimeInitialized)
|
||||
throw new InvalidOperationException(SR.GetString(SR.Error_CanNotChangeAtRuntime));
|
||||
|
||||
base.RemoveItem(index);
|
||||
}
|
||||
|
||||
protected override void SetItem(int index, RuleCondition item)
|
||||
{
|
||||
if (this._runtimeInitialized)
|
||||
throw new InvalidOperationException(SR.GetString(SR.Error_CanNotChangeAtRuntime));
|
||||
|
||||
base.SetItem(index, item);
|
||||
}
|
||||
|
||||
internal bool RuntimeMode
|
||||
{
|
||||
set { this._runtimeInitialized = value; }
|
||||
get { return this._runtimeInitialized; }
|
||||
}
|
||||
|
||||
new public void Add(RuleCondition item)
|
||||
{
|
||||
if (this._runtimeInitialized)
|
||||
throw new InvalidOperationException(SR.GetString(SR.Error_CanNotChangeAtRuntime));
|
||||
|
||||
if (null == item)
|
||||
{
|
||||
throw new ArgumentNullException("item");
|
||||
}
|
||||
|
||||
if (null == item.Name)
|
||||
{
|
||||
string message = string.Format(CultureInfo.CurrentCulture, Messages.InvalidConditionName, "item.Name");
|
||||
throw new ArgumentException(message);
|
||||
}
|
||||
|
||||
base.Add(item);
|
||||
}
|
||||
|
||||
public IList<WorkflowChangeAction> Diff(object originalDefinition, object changedDefinition)
|
||||
{
|
||||
List<WorkflowChangeAction> listChanges = new List<WorkflowChangeAction>();
|
||||
|
||||
RuleConditionCollection originalConditions = (RuleConditionCollection)originalDefinition;
|
||||
RuleConditionCollection changedConditions = (RuleConditionCollection)changedDefinition;
|
||||
|
||||
if (null != changedConditions)
|
||||
{
|
||||
foreach (RuleCondition cCondition in changedConditions)
|
||||
{
|
||||
if (null != originalConditions)
|
||||
{
|
||||
if (originalConditions.Contains(cCondition.Name))
|
||||
{
|
||||
RuleCondition oCondition = originalConditions[cCondition.Name];
|
||||
if (!oCondition.Equals(cCondition))
|
||||
{
|
||||
listChanges.Add(new UpdatedConditionAction(oCondition, cCondition));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
listChanges.Add(new AddedConditionAction(cCondition));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
listChanges.Add(new AddedConditionAction(cCondition));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (null != originalConditions)
|
||||
{
|
||||
foreach (RuleCondition oCondition in originalConditions)
|
||||
{
|
||||
if (null != changedConditions)
|
||||
{
|
||||
if (!changedConditions.Contains(oCondition.Name))
|
||||
{
|
||||
listChanges.Add(new RemovedConditionAction(oCondition));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
listChanges.Add(new RemovedConditionAction(oCondition));
|
||||
}
|
||||
}
|
||||
}
|
||||
return listChanges;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -0,0 +1,456 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
// Copyright (C) 2005 Microsoft Corporation - All Rights Reserved
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
using System.CodeDom;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Workflow.ComponentModel;
|
||||
using System.Workflow.ComponentModel.Compiler;
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
using System.Workflow.Activities.Common;
|
||||
|
||||
namespace System.Workflow.Activities.Rules
|
||||
{
|
||||
#region RuleCondition base class
|
||||
[Serializable]
|
||||
public abstract class RuleCondition
|
||||
{
|
||||
public abstract bool Validate(RuleValidation validation);
|
||||
public abstract bool Evaluate(RuleExecution execution);
|
||||
public abstract ICollection<string> GetDependencies(RuleValidation validation);
|
||||
|
||||
public abstract string Name { get; set; }
|
||||
public virtual void OnRuntimeInitialized() { }
|
||||
|
||||
public abstract RuleCondition Clone();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region RuleExpressionCondition Class
|
||||
[Serializable]
|
||||
public sealed class RuleExpressionCondition : RuleCondition
|
||||
{
|
||||
#region Properties
|
||||
private CodeExpression _expression;
|
||||
private string _name;
|
||||
private bool _runtimeInitialized;
|
||||
[NonSerialized]
|
||||
private object _expressionLock = new object();
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._name;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this._runtimeInitialized)
|
||||
throw new InvalidOperationException(SR.GetString(SR.Error_CanNotChangeAtRuntime));
|
||||
|
||||
this._name = value;
|
||||
}
|
||||
}
|
||||
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public CodeExpression Expression
|
||||
{
|
||||
get
|
||||
{
|
||||
return _expression;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (this._runtimeInitialized)
|
||||
throw new InvalidOperationException(SR.GetString(SR.Error_CanNotChangeAtRuntime));
|
||||
|
||||
lock (this._expressionLock)
|
||||
{
|
||||
_expression = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
public RuleExpressionCondition()
|
||||
{
|
||||
}
|
||||
|
||||
public RuleExpressionCondition(string conditionName)
|
||||
{
|
||||
if (null == conditionName)
|
||||
{
|
||||
throw new ArgumentNullException("conditionName");
|
||||
}
|
||||
_name = conditionName;
|
||||
}
|
||||
|
||||
public RuleExpressionCondition(string conditionName, CodeExpression expression)
|
||||
: this(conditionName)
|
||||
{
|
||||
_expression = expression;
|
||||
}
|
||||
|
||||
public RuleExpressionCondition(CodeExpression expression)
|
||||
{
|
||||
_expression = expression;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public override void OnRuntimeInitialized()
|
||||
{
|
||||
if (this._runtimeInitialized)
|
||||
|
||||
return;
|
||||
|
||||
_runtimeInitialized = true;
|
||||
}
|
||||
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
bool equals = false;
|
||||
RuleExpressionCondition declarativeConditionDefinition = obj as RuleExpressionCondition;
|
||||
|
||||
if (declarativeConditionDefinition != null)
|
||||
{
|
||||
equals = ((this.Name == declarativeConditionDefinition.Name) &&
|
||||
((this._expression == null && declarativeConditionDefinition.Expression == null) ||
|
||||
(this._expression != null && RuleExpressionWalker.Match(this._expression, declarativeConditionDefinition.Expression))));
|
||||
}
|
||||
|
||||
return equals;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (_expression != null)
|
||||
{
|
||||
StringBuilder decompilation = new StringBuilder();
|
||||
RuleExpressionWalker.Decompile(decompilation, _expression, null);
|
||||
return decompilation.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RuleExpressionCondition methods
|
||||
|
||||
public override bool Validate(RuleValidation validation)
|
||||
{
|
||||
if (validation == null)
|
||||
throw new ArgumentNullException("validation");
|
||||
|
||||
bool valid = true;
|
||||
|
||||
if (_expression == null)
|
||||
{
|
||||
valid = false;
|
||||
|
||||
string message = string.Format(CultureInfo.CurrentCulture, Messages.ConditionExpressionNull, typeof(CodePrimitiveExpression).ToString());
|
||||
ValidationError error = new ValidationError(message, ErrorNumbers.Error_EmptyExpression);
|
||||
error.UserData[RuleUserDataKeys.ErrorObject] = this;
|
||||
validation.AddError(error);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
valid = validation.ValidateConditionExpression(_expression);
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
public override bool Evaluate(RuleExecution execution)
|
||||
{
|
||||
if (_expression == null)
|
||||
return true;
|
||||
|
||||
return Executor.EvaluateBool(_expression, execution);
|
||||
}
|
||||
|
||||
public override ICollection<string> GetDependencies(RuleValidation validation)
|
||||
{
|
||||
RuleAnalysis analyzer = new RuleAnalysis(validation, false);
|
||||
if (_expression != null)
|
||||
RuleExpressionWalker.AnalyzeUsage(analyzer, _expression, true, false, null);
|
||||
return analyzer.GetSymbols();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Cloning
|
||||
|
||||
public override RuleCondition Clone()
|
||||
{
|
||||
RuleExpressionCondition ruleCondition = (RuleExpressionCondition)this.MemberwiseClone();
|
||||
ruleCondition._runtimeInitialized = false;
|
||||
ruleCondition._expression = RuleExpressionWalker.Clone(this._expression);
|
||||
return ruleCondition;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region RuleConditionReference Class
|
||||
[TypeConverter(typeof(Design.RuleConditionReferenceTypeConverter))]
|
||||
[ActivityValidator(typeof(RuleConditionReferenceValidator))]
|
||||
[SRDisplayName(SR.RuleConditionDisplayName)]
|
||||
[Obsolete("The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*")]
|
||||
public class RuleConditionReference : ActivityCondition
|
||||
{
|
||||
private bool _runtimeInitialized;
|
||||
private string _condition;
|
||||
private string declaringActivityId = string.Empty;
|
||||
|
||||
public RuleConditionReference()
|
||||
{
|
||||
}
|
||||
|
||||
public string ConditionName
|
||||
{
|
||||
get { return this._condition; }
|
||||
set { this._condition = value; }
|
||||
}
|
||||
|
||||
public override bool Evaluate(Activity activity, IServiceProvider provider)
|
||||
{
|
||||
if (activity == null)
|
||||
{
|
||||
throw new ArgumentNullException("activity");
|
||||
}
|
||||
if (string.IsNullOrEmpty(this._condition))
|
||||
{
|
||||
throw new InvalidOperationException(SR.GetString(SR.Error_MissingConditionName, activity.Name));
|
||||
}
|
||||
|
||||
RuleDefinitions defs = null;
|
||||
|
||||
if (string.IsNullOrEmpty(this.declaringActivityId))
|
||||
{
|
||||
// No Runtime Initialization.
|
||||
CompositeActivity declaringActivity = null;
|
||||
defs = RuleConditionReference.GetRuleDefinitions(activity, out declaringActivity);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Runtime Initialized.
|
||||
defs = (RuleDefinitions)activity.GetActivityByName(declaringActivityId).GetValue(RuleDefinitions.RuleDefinitionsProperty);
|
||||
}
|
||||
|
||||
if ((defs == null) || (defs.Conditions == null))
|
||||
{
|
||||
throw new InvalidOperationException(SR.GetString(SR.Error_MissingRuleConditions));
|
||||
}
|
||||
|
||||
RuleCondition conditionDefinitionToEvaluate = defs.Conditions[this._condition];
|
||||
if (conditionDefinitionToEvaluate != null)
|
||||
{
|
||||
Activity contextActivity = System.Workflow.Activities.Common.Helpers.GetEnclosingActivity(activity);
|
||||
RuleValidation validation = new RuleValidation(contextActivity);
|
||||
if (!conditionDefinitionToEvaluate.Validate(validation))
|
||||
{
|
||||
string message = string.Format(CultureInfo.CurrentCulture, Messages.ConditionValidationFailed, this._condition);
|
||||
throw new InvalidOperationException(message);
|
||||
}
|
||||
|
||||
RuleExecution context = new RuleExecution(validation, contextActivity, provider as ActivityExecutionContext);
|
||||
return conditionDefinitionToEvaluate.Evaluate(context);
|
||||
}
|
||||
else
|
||||
{
|
||||
// no condition, so defaults to true
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Method extracted from OnRuntimeInitialized
|
||||
// used on special Evaluation case too.
|
||||
//
|
||||
private static RuleDefinitions GetRuleDefinitions(
|
||||
Activity activity, out CompositeActivity declaringActivity)
|
||||
{
|
||||
declaringActivity = Helpers.GetDeclaringActivity(activity);
|
||||
if (declaringActivity == null)
|
||||
{
|
||||
declaringActivity = Helpers.GetRootActivity(activity) as CompositeActivity;
|
||||
}
|
||||
return ConditionHelper.Load_Rules_RT(declaringActivity);
|
||||
}
|
||||
|
||||
#region IInitializeForRuntime Members
|
||||
|
||||
[NonSerialized]
|
||||
private object syncLock = new object();
|
||||
|
||||
protected override void InitializeProperties()
|
||||
{
|
||||
lock (syncLock)
|
||||
{
|
||||
if (this._runtimeInitialized)
|
||||
return;
|
||||
|
||||
CompositeActivity declaringActivity = null;
|
||||
Activity ownerActivity = base.ParentDependencyObject as Activity;
|
||||
|
||||
RuleDefinitions definitions = GetRuleDefinitions(ownerActivity, out declaringActivity);
|
||||
definitions.OnRuntimeInitialized();
|
||||
|
||||
this.declaringActivityId = declaringActivity.QualifiedName;
|
||||
base.InitializeProperties();
|
||||
_runtimeInitialized = true;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region RuleConditionReferenceValidator Class
|
||||
internal sealed class RuleConditionReferenceValidator : ConditionValidator
|
||||
{
|
||||
public override ValidationErrorCollection Validate(ValidationManager manager, object obj)
|
||||
{
|
||||
if (manager == null)
|
||||
{
|
||||
throw new ArgumentNullException("manager");
|
||||
}
|
||||
if (manager.Context == null)
|
||||
{
|
||||
throw new InvalidOperationException(Messages.ContextStackMissing);
|
||||
}
|
||||
|
||||
ValidationErrorCollection validationErrors = base.Validate(manager, obj);
|
||||
|
||||
RuleConditionReference declarativeCondition = obj as RuleConditionReference;
|
||||
if (declarativeCondition == null)
|
||||
{
|
||||
string message = string.Format(CultureInfo.CurrentCulture, Messages.UnexpectedArgumentType, typeof(RuleConditionReference).FullName, "obj");
|
||||
throw new ArgumentException(message, "obj");
|
||||
}
|
||||
|
||||
Activity activity = manager.Context[typeof(Activity)] as Activity;
|
||||
if (activity == null)
|
||||
{
|
||||
string message = string.Format(CultureInfo.CurrentCulture, Messages.ContextStackItemMissing, typeof(Activity).Name);
|
||||
throw new InvalidOperationException(message);
|
||||
}
|
||||
|
||||
PropertyValidationContext validationContext = manager.Context[typeof(PropertyValidationContext)] as PropertyValidationContext;
|
||||
if (validationContext == null)
|
||||
{
|
||||
string message = string.Format(CultureInfo.CurrentCulture, Messages.ContextStackItemMissing, typeof(PropertyValidationContext).Name);
|
||||
throw new InvalidOperationException(message);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(declarativeCondition.ConditionName))
|
||||
{
|
||||
RuleDefinitions rules = null;
|
||||
RuleConditionCollection conditionDefinitions = null;
|
||||
|
||||
CompositeActivity declaringActivity = Helpers.GetDeclaringActivity(activity);
|
||||
if (declaringActivity == null)
|
||||
{
|
||||
declaringActivity = Helpers.GetRootActivity(activity) as CompositeActivity;
|
||||
}
|
||||
if (activity.Site != null)
|
||||
rules = ConditionHelper.Load_Rules_DT(activity.Site, declaringActivity);
|
||||
else
|
||||
rules = ConditionHelper.Load_Rules_RT(declaringActivity);
|
||||
|
||||
if (rules != null)
|
||||
conditionDefinitions = rules.Conditions;
|
||||
|
||||
if (conditionDefinitions == null || !conditionDefinitions.Contains(declarativeCondition.ConditionName))
|
||||
{
|
||||
string message = string.Format(CultureInfo.CurrentCulture, Messages.ConditionNotFound, declarativeCondition.ConditionName);
|
||||
ValidationError validationError = new ValidationError(message, ErrorNumbers.Error_ConditionNotFound);
|
||||
validationError.PropertyName = GetFullPropertyName(manager) + "." + "ConditionName";
|
||||
validationErrors.Add(validationError);
|
||||
}
|
||||
else
|
||||
{
|
||||
RuleCondition actualCondition = conditionDefinitions[declarativeCondition.ConditionName];
|
||||
|
||||
ITypeProvider typeProvider = (ITypeProvider)manager.GetService(typeof(ITypeProvider));
|
||||
|
||||
IDisposable localContextScope = (WorkflowCompilationContext.Current == null ? WorkflowCompilationContext.CreateScope(manager) : null);
|
||||
try
|
||||
{
|
||||
RuleValidation ruleValidator = new RuleValidation(activity, typeProvider, WorkflowCompilationContext.Current.CheckTypes);
|
||||
actualCondition.Validate(ruleValidator);
|
||||
|
||||
ValidationErrorCollection actualConditionErrors = ruleValidator.Errors;
|
||||
|
||||
if (actualConditionErrors.Count > 0)
|
||||
{
|
||||
string expressionPropertyName = GetFullPropertyName(manager);
|
||||
string genericErrorMsg = string.Format(CultureInfo.CurrentCulture, Messages.InvalidConditionExpression, expressionPropertyName);
|
||||
int errorNumber = ErrorNumbers.Error_InvalidConditionExpression;
|
||||
|
||||
if (activity.Site != null)
|
||||
{
|
||||
ValidationError validationError = new ValidationError(genericErrorMsg, errorNumber);
|
||||
validationError.PropertyName = expressionPropertyName + "." + "Expression";
|
||||
validationErrors.Add(validationError);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (ValidationError actualError in actualConditionErrors)
|
||||
{
|
||||
ValidationError validationError = new ValidationError(genericErrorMsg + " " + actualError.ErrorText, errorNumber);
|
||||
validationError.PropertyName = expressionPropertyName + "." + "Expression";
|
||||
validationErrors.Add(validationError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test duplicates
|
||||
foreach (RuleCondition definition in conditionDefinitions)
|
||||
{
|
||||
if (definition.Name == declarativeCondition.ConditionName && definition != actualCondition)
|
||||
{
|
||||
string message = string.Format(CultureInfo.CurrentCulture, Messages.DuplicateConditions, declarativeCondition.ConditionName);
|
||||
ValidationError validationError = new ValidationError(message, ErrorNumbers.Error_DuplicateConditions);
|
||||
validationError.PropertyName = GetFullPropertyName(manager) + "." + "ConditionName";
|
||||
validationErrors.Add(validationError);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (localContextScope != null)
|
||||
{
|
||||
localContextScope.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string message = string.Format(CultureInfo.CurrentCulture, Messages.InvalidConditionName, "ConditionName");
|
||||
ValidationError validationError = new ValidationError(message, ErrorNumbers.Error_InvalidConditionName);
|
||||
validationError.PropertyName = GetFullPropertyName(manager) + "." + "ConditionName";
|
||||
validationErrors.Add(validationError);
|
||||
}
|
||||
return validationErrors;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Workflow.ComponentModel;
|
||||
using System.Workflow.ComponentModel.Serialization;
|
||||
using System.Text;
|
||||
|
||||
namespace System.Workflow.Activities.Rules.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for DesignerHelpers.
|
||||
/// </summary>
|
||||
internal static class DesignerHelpers
|
||||
{
|
||||
internal static void DisplayError(string message, string messageBoxTitle, IServiceProvider serviceProvider)
|
||||
{
|
||||
IUIService uis = null;
|
||||
if (serviceProvider != null)
|
||||
uis = (IUIService)serviceProvider.GetService(typeof(IUIService));
|
||||
|
||||
if (uis != null)
|
||||
uis.ShowError(message);
|
||||
else
|
||||
MessageBox.Show(message, messageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, 0);
|
||||
}
|
||||
|
||||
static internal string GetRulePreview(Rule rule)
|
||||
{
|
||||
StringBuilder rulePreview = new StringBuilder();
|
||||
|
||||
if (rule != null)
|
||||
{
|
||||
rulePreview.Append("IF ");
|
||||
if (rule.Condition != null)
|
||||
rulePreview.Append(rule.Condition.ToString() + " ");
|
||||
rulePreview.Append("THEN ");
|
||||
|
||||
foreach (RuleAction action in rule.ThenActions)
|
||||
{
|
||||
rulePreview.Append(action.ToString());
|
||||
rulePreview.Append(' ');
|
||||
}
|
||||
|
||||
if (rule.ElseActions.Count > 0)
|
||||
{
|
||||
rulePreview.Append("ELSE ");
|
||||
foreach (RuleAction action in rule.ElseActions)
|
||||
{
|
||||
rulePreview.Append(action.ToString());
|
||||
rulePreview.Append(' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rulePreview.ToString();
|
||||
}
|
||||
|
||||
static internal string GetRuleSetPreview(RuleSet ruleSet)
|
||||
{
|
||||
StringBuilder preview = new StringBuilder();
|
||||
bool first = true;
|
||||
if (ruleSet != null)
|
||||
{
|
||||
foreach (Rule rule in ruleSet.Rules)
|
||||
{
|
||||
if (first)
|
||||
first = false;
|
||||
else
|
||||
preview.Append("\n");
|
||||
|
||||
preview.Append(rule.Name);
|
||||
preview.Append(": ");
|
||||
preview.Append(DesignerHelpers.GetRulePreview(rule));
|
||||
}
|
||||
}
|
||||
|
||||
return preview.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,383 @@
|
||||
#region Using directives
|
||||
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Workflow.ComponentModel;
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
using System.Workflow.Activities.Rules;
|
||||
using System.Workflow.Interop;
|
||||
using System.Globalization;
|
||||
using System.Workflow.Activities.Common;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace System.Workflow.Activities.Rules.Design
|
||||
{
|
||||
#region class BasicBrowserDialog
|
||||
|
||||
internal abstract partial class BasicBrowserDialog : Form
|
||||
{
|
||||
#region members and constructors
|
||||
|
||||
private Activity activity;
|
||||
private string name;
|
||||
private IServiceProvider serviceProvider;
|
||||
|
||||
protected BasicBrowserDialog(Activity activity, string name)
|
||||
{
|
||||
if (activity == null)
|
||||
throw (new ArgumentNullException("activity"));
|
||||
|
||||
this.activity = activity;
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
// set captions
|
||||
this.descriptionLabel.Text = DescriptionText;
|
||||
this.Text = TitleText;
|
||||
this.previewLabel.Text = PreviewLabelText;
|
||||
|
||||
this.newRuleToolStripButton.Enabled = true;
|
||||
this.name = name;
|
||||
|
||||
serviceProvider = activity.Site;
|
||||
|
||||
//Set dialog fonts
|
||||
IUIService uisvc = (IUIService)activity.Site.GetService(typeof(IUIService));
|
||||
if (uisvc != null)
|
||||
this.Font = (Font)uisvc.Styles["DialogFont"];
|
||||
|
||||
HelpRequested += new HelpEventHandler(OnHelpRequested);
|
||||
HelpButtonClicked += new CancelEventHandler(OnHelpClicked);
|
||||
|
||||
this.rulesListView.Select();
|
||||
}
|
||||
|
||||
protected Activity Activity
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.activity;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public properties
|
||||
|
||||
public string SelectedName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region event handlers
|
||||
|
||||
private void OnCancel(object sender, EventArgs e)
|
||||
{
|
||||
this.name = null;
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void OnOk(object sender, EventArgs e)
|
||||
{
|
||||
object ruleObject = this.rulesListView.SelectedItems[0].Tag;
|
||||
this.name = this.GetObjectName(ruleObject);
|
||||
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void OnHelpClicked(object sender, CancelEventArgs e)
|
||||
{
|
||||
e.Cancel = true;
|
||||
ShowHelp();
|
||||
}
|
||||
|
||||
private void OnHelpRequested(object sender, HelpEventArgs e)
|
||||
{
|
||||
ShowHelp();
|
||||
}
|
||||
|
||||
private void ShowHelp()
|
||||
{
|
||||
if (serviceProvider != null)
|
||||
{
|
||||
IHelpService helpService = serviceProvider.GetService(typeof(IHelpService)) as IHelpService;
|
||||
if (helpService != null)
|
||||
{
|
||||
helpService.ShowHelpFromKeyword(this.GetType().FullName + ".UI");
|
||||
}
|
||||
else
|
||||
{
|
||||
IUIService uisvc = serviceProvider.GetService(typeof(IUIService)) as IUIService;
|
||||
if (uisvc != null)
|
||||
uisvc.ShowError(Messages.NoHelp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IUIService uisvc = (IUIService)GetService(typeof(IUIService));
|
||||
if (uisvc != null)
|
||||
uisvc.ShowError(Messages.NoHelp);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnNew(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.OnComponentChanging();
|
||||
object newObject = OnNewInternal();
|
||||
if (newObject != null)
|
||||
{
|
||||
using (new WaitCursor())
|
||||
{
|
||||
ListViewItem listViewItem = this.rulesListView.Items.Add(new ListViewItem());
|
||||
this.UpdateListViewItem(newObject, listViewItem);
|
||||
listViewItem.Selected = true;
|
||||
this.OnComponentChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
DesignerHelpers.DisplayError(ex.Message, this.Text, this.activity.Site);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEdit(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.OnComponentChanging();
|
||||
object updatedRuleObject = null;
|
||||
object ruleObject = this.rulesListView.SelectedItems[0].Tag;
|
||||
if (OnEditInternal(ruleObject, out updatedRuleObject))
|
||||
{
|
||||
using (new WaitCursor())
|
||||
{
|
||||
this.UpdateListViewItem(updatedRuleObject, this.rulesListView.SelectedItems[0]);
|
||||
this.UpdatePreview(this.previewRichTextBox, updatedRuleObject);
|
||||
this.OnComponentChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
DesignerHelpers.DisplayError(ex.Message, this.Text, this.activity.Site);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRename(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.OnComponentChanging();
|
||||
object ruleObject = this.rulesListView.SelectedItems[0].Tag;
|
||||
string newName = OnRenameInternal(ruleObject);
|
||||
if (newName != null)
|
||||
{
|
||||
using (new WaitCursor())
|
||||
{
|
||||
ListViewItem selectedItem = this.rulesListView.SelectedItems[0];
|
||||
selectedItem.Text = newName;
|
||||
this.OnComponentChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
DesignerHelpers.DisplayError(ex.Message, this.Text, this.activity.Site);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDelete(object sender, EventArgs e)
|
||||
{
|
||||
MessageBoxOptions mbo = (MessageBoxOptions)0;
|
||||
if (CultureInfo.CurrentUICulture.TextInfo.IsRightToLeft)
|
||||
mbo = MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading;
|
||||
DialogResult dr = MessageBox.Show(this, this.ConfirmDeleteMessageText, this.ConfirmDeleteTitleText,
|
||||
MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, mbo);
|
||||
if (dr == DialogResult.OK)
|
||||
{
|
||||
using (new WaitCursor())
|
||||
{
|
||||
object ruleObject = this.rulesListView.SelectedItems[0].Tag;
|
||||
|
||||
try
|
||||
{
|
||||
this.OnComponentChanging();
|
||||
int selectionIndex = this.rulesListView.SelectedIndices[0];
|
||||
object selectedRuleObject = null;
|
||||
OnDeleteInternal(ruleObject);
|
||||
this.rulesListView.Items.RemoveAt(selectionIndex);
|
||||
if (this.rulesListView.Items.Count > 0)
|
||||
{
|
||||
int newSelectionIndex = Math.Min(selectionIndex, this.rulesListView.Items.Count - 1);
|
||||
this.rulesListView.Items[newSelectionIndex].Selected = true;
|
||||
selectedRuleObject = this.rulesListView.Items[newSelectionIndex].Tag;
|
||||
}
|
||||
this.UpdatePreview(this.previewRichTextBox, selectedRuleObject);
|
||||
this.OnComponentChanged();
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
DesignerHelpers.DisplayError(ex.Message, this.Text, this.activity.Site);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
|
||||
{
|
||||
if (e.IsSelected)
|
||||
e.Item.Focused = true;
|
||||
|
||||
OnToolbarStatus();
|
||||
this.okButton.Enabled = e.IsSelected;
|
||||
|
||||
object currentRuleObject = null;
|
||||
if (e.IsSelected)
|
||||
currentRuleObject = e.Item.Tag;
|
||||
|
||||
UpdatePreview(this.previewRichTextBox, currentRuleObject);
|
||||
}
|
||||
|
||||
private void OnDoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
if (this.rulesListView.SelectedItems.Count > 0)
|
||||
this.OnOk(sender, e);
|
||||
}
|
||||
|
||||
private void OnToolbarStatus()
|
||||
{
|
||||
if (this.rulesListView.SelectedItems.Count == 1)
|
||||
{
|
||||
this.editToolStripButton.Enabled = true;
|
||||
this.renameToolStripButton.Enabled = true;
|
||||
this.deleteToolStripButton.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.editToolStripButton.Enabled = false;
|
||||
this.renameToolStripButton.Enabled = false;
|
||||
this.deleteToolStripButton.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region helpers
|
||||
|
||||
private bool OnComponentChanging()
|
||||
{
|
||||
bool canChange = true;
|
||||
ISite site = ((IComponent)this.activity).Site;
|
||||
IComponentChangeService changeService = (IComponentChangeService)site.GetService(typeof(IComponentChangeService));
|
||||
|
||||
if (changeService != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
changeService.OnComponentChanging(this.activity, null);
|
||||
}
|
||||
catch (CheckoutException coEx)
|
||||
{
|
||||
if (coEx == CheckoutException.Canceled)
|
||||
canChange = false;
|
||||
else
|
||||
throw;
|
||||
}
|
||||
}
|
||||
return canChange;
|
||||
}
|
||||
|
||||
private void OnComponentChanged()
|
||||
{
|
||||
ISite site = ((IComponent)this.activity).Site;
|
||||
IComponentChangeService changeService = (IComponentChangeService)site.GetService(typeof(IComponentChangeService));
|
||||
|
||||
if (changeService != null)
|
||||
changeService.OnComponentChanged(this.activity, null, null, null);
|
||||
|
||||
ConditionHelper.Flush_Rules_DT(site, Helpers.GetRootActivity(this.activity));
|
||||
}
|
||||
|
||||
protected void InitializeListView(IList list, string selectedName)
|
||||
{
|
||||
foreach (object ruleObject in list)
|
||||
{
|
||||
ListViewItem listViewItem = this.rulesListView.Items.Add(new ListViewItem());
|
||||
this.UpdateListViewItem(ruleObject, listViewItem);
|
||||
if (GetObjectName(ruleObject) == selectedName)
|
||||
listViewItem.Selected = true;
|
||||
}
|
||||
|
||||
if (this.rulesListView.SelectedItems.Count == 0)
|
||||
OnToolbarStatus();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region override methods
|
||||
|
||||
protected abstract string GetObjectName(object ruleObject);
|
||||
|
||||
//commands
|
||||
protected abstract object OnNewInternal();
|
||||
protected abstract bool OnEditInternal(object currentRuleObject, out object updatedRuleObject);
|
||||
protected abstract void OnDeleteInternal(object ruleObject);
|
||||
protected abstract string OnRenameInternal(object ruleObject);
|
||||
|
||||
// populating controls
|
||||
protected abstract void UpdateListViewItem(object ruleObject, ListViewItem listViewItem);
|
||||
protected abstract void UpdatePreview(TextBox previewTextBox, object ruleObject);
|
||||
|
||||
// captions
|
||||
protected abstract string DescriptionText { get; }
|
||||
protected abstract string TitleText { get; }
|
||||
protected abstract string PreviewLabelText { get; }
|
||||
protected abstract string ConfirmDeleteMessageText { get; }
|
||||
protected abstract string ConfirmDeleteTitleText { get; }
|
||||
internal abstract string EmptyNameErrorText { get; }
|
||||
internal abstract string DuplicateNameErrorText { get; }
|
||||
internal abstract string NewNameLabelText { get; }
|
||||
internal abstract string RenameTitleText { get; }
|
||||
|
||||
internal abstract bool IsUniqueName(string ruleName);
|
||||
|
||||
#endregion
|
||||
|
||||
private class WaitCursor : IDisposable
|
||||
{
|
||||
private Cursor oldCursor;
|
||||
public WaitCursor()
|
||||
{
|
||||
Application.DoEvents(); // Force redraw before waiting
|
||||
oldCursor = Cursor.Current;
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
}
|
||||
public void Dispose()
|
||||
{
|
||||
Cursor.Current = oldCursor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
261
mcs/class/referencesource/System.Workflow.Activities/Rules/Design/Dialogs/BasicBrowserDialog.designer.cs
generated
Normal file
261
mcs/class/referencesource/System.Workflow.Activities/Rules/Design/Dialogs/BasicBrowserDialog.designer.cs
generated
Normal file
@@ -0,0 +1,261 @@
|
||||
namespace System.Workflow.Activities.Rules.Design
|
||||
{
|
||||
partial class BasicBrowserDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BasicBrowserDialog));
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.rulesListView = new System.Windows.Forms.ListView();
|
||||
this.nameColumnHeader = new System.Windows.Forms.ColumnHeader();
|
||||
this.validColumnHeader = new System.Windows.Forms.ColumnHeader();
|
||||
this.rulesPanel = new System.Windows.Forms.Panel();
|
||||
this.rulesToolStrip = new System.Windows.Forms.ToolStrip();
|
||||
this.imageList = new System.Windows.Forms.ImageList(this.components);
|
||||
this.newRuleToolStripButton = new System.Windows.Forms.ToolStripButton();
|
||||
this.editToolStripButton = new System.Windows.Forms.ToolStripButton();
|
||||
this.renameToolStripButton = new System.Windows.Forms.ToolStripButton();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.deleteToolStripButton = new System.Windows.Forms.ToolStripButton();
|
||||
this.preiviewPanel = new System.Windows.Forms.Panel();
|
||||
this.previewRichEditBoxPanel = new System.Windows.Forms.Panel();
|
||||
this.previewRichTextBox = new System.Windows.Forms.TextBox();
|
||||
this.previewLabel = new System.Windows.Forms.Label();
|
||||
this.descriptionLabel = new System.Windows.Forms.Label();
|
||||
this.headerPictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.okCancelTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.rulesPanel.SuspendLayout();
|
||||
this.rulesToolStrip.SuspendLayout();
|
||||
this.preiviewPanel.SuspendLayout();
|
||||
this.previewRichEditBoxPanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.headerPictureBox)).BeginInit();
|
||||
this.okCancelTableLayoutPanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
resources.ApplyResources(this.cancelButton, "cancelButton");
|
||||
this.cancelButton.CausesValidation = false;
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Click += new System.EventHandler(this.OnCancel);
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
resources.ApplyResources(this.okButton, "okButton");
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Click += new System.EventHandler(this.OnOk);
|
||||
//
|
||||
// rulesListView
|
||||
//
|
||||
this.rulesListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.nameColumnHeader,
|
||||
this.validColumnHeader});
|
||||
resources.ApplyResources(this.rulesListView, "rulesListView");
|
||||
this.rulesListView.FullRowSelect = true;
|
||||
this.rulesListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
|
||||
this.rulesListView.HideSelection = false;
|
||||
this.rulesListView.MultiSelect = false;
|
||||
this.rulesListView.Name = "rulesListView";
|
||||
this.rulesListView.Sorting = System.Windows.Forms.SortOrder.Ascending;
|
||||
this.rulesListView.UseCompatibleStateImageBehavior = false;
|
||||
this.rulesListView.View = System.Windows.Forms.View.Details;
|
||||
this.rulesListView.DoubleClick += new System.EventHandler(this.OnDoubleClick);
|
||||
this.rulesListView.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.OnItemSelectionChanged);
|
||||
//
|
||||
// nameColumnHeader
|
||||
//
|
||||
resources.ApplyResources(this.nameColumnHeader, "nameColumnHeader");
|
||||
//
|
||||
// validColumnHeader
|
||||
//
|
||||
resources.ApplyResources(this.validColumnHeader, "validColumnHeader");
|
||||
//
|
||||
// rulesPanel
|
||||
//
|
||||
resources.ApplyResources(this.rulesPanel, "rulesPanel");
|
||||
this.rulesPanel.Controls.Add(this.rulesToolStrip);
|
||||
this.rulesPanel.Controls.Add(this.rulesListView);
|
||||
this.rulesPanel.Name = "rulesPanel";
|
||||
//
|
||||
// rulesToolStrip
|
||||
//
|
||||
this.rulesToolStrip.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.rulesToolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
|
||||
this.rulesToolStrip.ImageList = this.imageList;
|
||||
this.rulesToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.newRuleToolStripButton,
|
||||
this.editToolStripButton,
|
||||
this.renameToolStripButton,
|
||||
this.toolStripSeparator1,
|
||||
this.deleteToolStripButton});
|
||||
resources.ApplyResources(this.rulesToolStrip, "rulesToolStrip");
|
||||
this.rulesToolStrip.Name = "rulesToolStrip";
|
||||
this.rulesToolStrip.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;
|
||||
this.rulesToolStrip.TabStop = true;
|
||||
//
|
||||
// imageList
|
||||
//
|
||||
this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream")));
|
||||
this.imageList.TransparentColor = System.Drawing.Color.Transparent;
|
||||
this.imageList.Images.SetKeyName(0, "NewRule.bmp");
|
||||
this.imageList.Images.SetKeyName(1, "EditRule.bmp");
|
||||
this.imageList.Images.SetKeyName(2, "RenameRule.bmp");
|
||||
this.imageList.Images.SetKeyName(3, "Delete.bmp");
|
||||
//
|
||||
// newRuleToolStripButton
|
||||
//
|
||||
resources.ApplyResources(this.newRuleToolStripButton, "newRuleToolStripButton");
|
||||
this.newRuleToolStripButton.Name = "newRuleToolStripButton";
|
||||
this.newRuleToolStripButton.Click += new System.EventHandler(this.OnNew);
|
||||
//
|
||||
// editToolStripButton
|
||||
//
|
||||
resources.ApplyResources(this.editToolStripButton, "editToolStripButton");
|
||||
this.editToolStripButton.Name = "editToolStripButton";
|
||||
this.editToolStripButton.Click += new System.EventHandler(this.OnEdit);
|
||||
//
|
||||
// renameToolStripButton
|
||||
//
|
||||
resources.ApplyResources(this.renameToolStripButton, "renameToolStripButton");
|
||||
this.renameToolStripButton.Name = "renameToolStripButton";
|
||||
this.renameToolStripButton.Click += new System.EventHandler(this.OnRename);
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
resources.ApplyResources(this.toolStripSeparator1, "toolStripSeparator1");
|
||||
//
|
||||
// deleteToolStripButton
|
||||
//
|
||||
resources.ApplyResources(this.deleteToolStripButton, "deleteToolStripButton");
|
||||
this.deleteToolStripButton.Name = "deleteToolStripButton";
|
||||
this.deleteToolStripButton.Click += new System.EventHandler(this.OnDelete);
|
||||
//
|
||||
// preiviewPanel
|
||||
//
|
||||
this.preiviewPanel.Controls.Add(this.previewRichEditBoxPanel);
|
||||
this.preiviewPanel.Controls.Add(this.previewLabel);
|
||||
resources.ApplyResources(this.preiviewPanel, "preiviewPanel");
|
||||
this.preiviewPanel.Name = "preiviewPanel";
|
||||
//
|
||||
// previewRichEditBoxPanel
|
||||
//
|
||||
resources.ApplyResources(this.previewRichEditBoxPanel, "previewRichEditBoxPanel");
|
||||
this.previewRichEditBoxPanel.BackColor = System.Drawing.SystemColors.GradientInactiveCaption;
|
||||
this.previewRichEditBoxPanel.Controls.Add(this.previewRichTextBox);
|
||||
this.previewRichEditBoxPanel.Name = "previewRichEditBoxPanel";
|
||||
//
|
||||
// previewRichTextBox
|
||||
//
|
||||
this.previewRichTextBox.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.previewRichTextBox.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
resources.ApplyResources(this.previewRichTextBox, "previewRichTextBox");
|
||||
this.previewRichTextBox.Name = "previewRichTextBox";
|
||||
this.previewRichTextBox.ReadOnly = true;
|
||||
this.previewRichTextBox.TabStop = false;
|
||||
//
|
||||
// previewLabel
|
||||
//
|
||||
resources.ApplyResources(this.previewLabel, "previewLabel");
|
||||
this.previewLabel.Name = "previewLabel";
|
||||
//
|
||||
// descriptionLabel
|
||||
//
|
||||
resources.ApplyResources(this.descriptionLabel, "descriptionLabel");
|
||||
this.descriptionLabel.Name = "descriptionLabel";
|
||||
//
|
||||
// headerPictureBox
|
||||
//
|
||||
resources.ApplyResources(this.headerPictureBox, "headerPictureBox");
|
||||
this.headerPictureBox.Name = "headerPictureBox";
|
||||
this.headerPictureBox.TabStop = false;
|
||||
//
|
||||
// okCancelTableLayoutPanel
|
||||
//
|
||||
resources.ApplyResources(this.okCancelTableLayoutPanel, "okCancelTableLayoutPanel");
|
||||
this.okCancelTableLayoutPanel.Controls.Add(this.okButton, 0, 0);
|
||||
this.okCancelTableLayoutPanel.Controls.Add(this.cancelButton, 1, 0);
|
||||
this.okCancelTableLayoutPanel.Name = "okCancelTableLayoutPanel";
|
||||
//
|
||||
// BasicBrowserDialog
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.CancelButton = this.cancelButton;
|
||||
this.Controls.Add(this.okCancelTableLayoutPanel);
|
||||
this.Controls.Add(this.headerPictureBox);
|
||||
this.Controls.Add(this.descriptionLabel);
|
||||
this.Controls.Add(this.preiviewPanel);
|
||||
this.Controls.Add(this.rulesPanel);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.HelpButton = true;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "BasicBrowserDialog";
|
||||
this.ShowInTaskbar = false;
|
||||
this.rulesPanel.ResumeLayout(false);
|
||||
this.rulesPanel.PerformLayout();
|
||||
this.rulesToolStrip.ResumeLayout(false);
|
||||
this.rulesToolStrip.PerformLayout();
|
||||
this.preiviewPanel.ResumeLayout(false);
|
||||
this.preiviewPanel.PerformLayout();
|
||||
this.previewRichEditBoxPanel.ResumeLayout(false);
|
||||
this.previewRichEditBoxPanel.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.headerPictureBox)).EndInit();
|
||||
this.okCancelTableLayoutPanel.ResumeLayout(false);
|
||||
this.okCancelTableLayoutPanel.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.ListView rulesListView;
|
||||
private System.Windows.Forms.Panel rulesPanel;
|
||||
private System.Windows.Forms.ToolStrip rulesToolStrip;
|
||||
private System.Windows.Forms.Panel preiviewPanel;
|
||||
private System.Windows.Forms.Label previewLabel;
|
||||
private System.Windows.Forms.ToolStripButton newRuleToolStripButton;
|
||||
private System.Windows.Forms.ToolStripButton renameToolStripButton;
|
||||
private System.Windows.Forms.ColumnHeader nameColumnHeader;
|
||||
private System.Windows.Forms.Label descriptionLabel;
|
||||
private System.Windows.Forms.PictureBox headerPictureBox;
|
||||
private System.Windows.Forms.ToolStripButton editToolStripButton;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripButton deleteToolStripButton;
|
||||
private System.Windows.Forms.Panel previewRichEditBoxPanel;
|
||||
private System.Windows.Forms.TextBox previewRichTextBox;
|
||||
private System.Windows.Forms.ImageList imageList;
|
||||
private System.Windows.Forms.ColumnHeader validColumnHeader;
|
||||
private System.Windows.Forms.TableLayoutPanel okCancelTableLayoutPanel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
#region Using directives
|
||||
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Workflow.ComponentModel;
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
using System.Workflow.ComponentModel.Compiler;
|
||||
using System.Workflow.Activities.Rules;
|
||||
using System.Workflow.Interop;
|
||||
using System.Globalization;
|
||||
using Microsoft.Win32;
|
||||
using System.Workflow.Activities.Common;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace System.Workflow.Activities.Rules.Design
|
||||
{
|
||||
#region class ConditionBrowserDialog
|
||||
|
||||
internal sealed class ConditionBrowserDialog : BasicBrowserDialog
|
||||
{
|
||||
#region members and constructors
|
||||
|
||||
private RuleConditionCollection declarativeConditionCollection;
|
||||
|
||||
public ConditionBrowserDialog(Activity activity, string name)
|
||||
: base(activity, name)
|
||||
{
|
||||
RuleDefinitions rules = ConditionHelper.Load_Rules_DT(activity.Site, Helpers.GetRootActivity(activity));
|
||||
if (rules != null)
|
||||
this.declarativeConditionCollection = rules.Conditions;
|
||||
|
||||
InitializeListView(this.declarativeConditionCollection, name);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region override members
|
||||
|
||||
protected override string GetObjectName(object ruleObject)
|
||||
{
|
||||
RuleExpressionCondition ruleExpressionCondition = ruleObject as RuleExpressionCondition;
|
||||
|
||||
return ruleExpressionCondition.Name;
|
||||
}
|
||||
|
||||
protected override object OnNewInternal()
|
||||
{
|
||||
using (RuleConditionDialog dlg = new RuleConditionDialog(this.Activity, null))
|
||||
{
|
||||
if (DialogResult.OK == dlg.ShowDialog(this))
|
||||
{
|
||||
RuleExpressionCondition declarativeRuleDefinition = new RuleExpressionCondition();
|
||||
declarativeRuleDefinition.Expression = dlg.Expression;
|
||||
declarativeRuleDefinition.Name = this.CreateNewName();
|
||||
this.declarativeConditionCollection.Add(declarativeRuleDefinition);
|
||||
return declarativeRuleDefinition;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override bool OnEditInternal(object currentRuleObject, out object updatedRuleObject)
|
||||
{
|
||||
RuleExpressionCondition declarativeRuleDefinition = currentRuleObject as RuleExpressionCondition;
|
||||
updatedRuleObject = null;
|
||||
|
||||
using (RuleConditionDialog dlg = new RuleConditionDialog(this.Activity, declarativeRuleDefinition.Expression))
|
||||
{
|
||||
if (DialogResult.OK == dlg.ShowDialog(this))
|
||||
{
|
||||
updatedRuleObject = new RuleExpressionCondition(declarativeRuleDefinition.Name, dlg.Expression);
|
||||
|
||||
this.declarativeConditionCollection.Remove(declarativeRuleDefinition.Name);
|
||||
this.declarativeConditionCollection.Add(updatedRuleObject as RuleExpressionCondition);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override string OnRenameInternal(object ruleObject)
|
||||
{
|
||||
RuleExpressionCondition declarativeRuleDefinition = ruleObject as RuleExpressionCondition;
|
||||
|
||||
using (RenameRuleObjectDialog dlg = new RenameRuleObjectDialog(this.Activity.Site, declarativeRuleDefinition.Name, new RenameRuleObjectDialog.NameValidatorDelegate(IsUniqueName), this))
|
||||
{
|
||||
if ((dlg.ShowDialog(this) == DialogResult.OK) && (dlg.RuleObjectName != declarativeRuleDefinition.Name))
|
||||
{
|
||||
this.declarativeConditionCollection.Remove(declarativeRuleDefinition);
|
||||
declarativeRuleDefinition.Name = dlg.RuleObjectName;
|
||||
this.declarativeConditionCollection.Add(declarativeRuleDefinition);
|
||||
return dlg.RuleObjectName;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override void OnDeleteInternal(object ruleObject)
|
||||
{
|
||||
RuleExpressionCondition declarativeRuleDefinition = ruleObject as RuleExpressionCondition;
|
||||
|
||||
this.declarativeConditionCollection.Remove(declarativeRuleDefinition.Name);
|
||||
}
|
||||
|
||||
protected override void UpdateListViewItem(object ruleObject, ListViewItem listViewItem)
|
||||
{
|
||||
RuleExpressionCondition declarativeRuleDefinition = ruleObject as RuleExpressionCondition;
|
||||
|
||||
ITypeProvider typeProvider = (ITypeProvider)this.Activity.Site.GetService(typeof(ITypeProvider));
|
||||
if (typeProvider == null)
|
||||
{
|
||||
string message = string.Format(CultureInfo.CurrentCulture, Messages.MissingService, typeof(ITypeProvider).FullName);
|
||||
throw new InvalidOperationException(message);
|
||||
}
|
||||
|
||||
RuleValidation validator = new RuleValidation(this.Activity, typeProvider, false);
|
||||
bool valid = declarativeRuleDefinition.Validate(validator);
|
||||
|
||||
listViewItem.Tag = declarativeRuleDefinition;
|
||||
listViewItem.Text = declarativeRuleDefinition.Name;
|
||||
|
||||
string validText = valid ? Messages.Yes : Messages.No;
|
||||
if (listViewItem.SubItems.Count == 1)
|
||||
listViewItem.SubItems.Add(validText);
|
||||
else
|
||||
listViewItem.SubItems[1].Text = validText;
|
||||
}
|
||||
|
||||
protected override void UpdatePreview(TextBox previewBox, object ruleObject)
|
||||
{
|
||||
RuleExpressionCondition declarativeRuleDefinition = ruleObject as RuleExpressionCondition;
|
||||
if (declarativeRuleDefinition != null && declarativeRuleDefinition.Expression != null)
|
||||
{
|
||||
RuleExpressionCondition ruleExpressionCondition = new RuleExpressionCondition(declarativeRuleDefinition.Expression);
|
||||
NativeMethods.SendMessage(previewBox.Handle, NativeMethods.WM_SETREDRAW, IntPtr.Zero, IntPtr.Zero);
|
||||
previewBox.Lines = ruleExpressionCondition.ToString().Split('\n');
|
||||
NativeMethods.SendMessage(previewBox.Handle, NativeMethods.WM_SETREDRAW, new IntPtr(1), IntPtr.Zero);
|
||||
previewBox.Invalidate();
|
||||
}
|
||||
else
|
||||
{
|
||||
previewBox.Text = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
protected override string DescriptionText { get { return Messages.ConditionDescriptionText; } }
|
||||
protected override string TitleText { get { return Messages.ConditionTitleText; } }
|
||||
protected override string PreviewLabelText { get { return Messages.ConditionPreviewLabelText; } }
|
||||
protected override string ConfirmDeleteMessageText { get { return Messages.ConditionConfirmDeleteMessageText; } }
|
||||
protected override string ConfirmDeleteTitleText { get { return Messages.DeleteCondition; } }
|
||||
internal override string EmptyNameErrorText { get { return Messages.ConditionEmptyNameErrorText; } }
|
||||
internal override string DuplicateNameErrorText { get { return Messages.ConditionDuplicateNameErrorText; } }
|
||||
internal override string NewNameLabelText { get { return Messages.ConditionNewNameLableText; } }
|
||||
internal override string RenameTitleText { get { return Messages.ConditionRenameTitleText; } }
|
||||
|
||||
|
||||
// used by RenameConditionDialog
|
||||
internal override bool IsUniqueName(string ruleName)
|
||||
{
|
||||
return (!this.declarativeConditionCollection.Contains(ruleName));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region helpers
|
||||
|
||||
private string CreateNewName()
|
||||
{
|
||||
string newRuleNameBase = Messages.NewConditionName;
|
||||
int index = 1;
|
||||
while (true)
|
||||
{
|
||||
string newRuleName = newRuleNameBase + index.ToString(CultureInfo.InvariantCulture);
|
||||
if (!this.declarativeConditionCollection.Contains(newRuleName))
|
||||
return newRuleName;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,78 @@
|
||||
namespace System.Workflow.Activities.Rules.Design
|
||||
{
|
||||
partial class IntellisenseTextBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(IntellisenseTextBox));
|
||||
this.autoCompletionImageList = new System.Windows.Forms.ImageList(this.components);
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// autoCompletionImageList
|
||||
//
|
||||
this.autoCompletionImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("autoCompletionImageList.ImageStream")));
|
||||
this.autoCompletionImageList.TransparentColor = System.Drawing.Color.Magenta;
|
||||
this.autoCompletionImageList.Images.SetKeyName(0, "");
|
||||
this.autoCompletionImageList.Images.SetKeyName(1, "");
|
||||
this.autoCompletionImageList.Images.SetKeyName(2, "");
|
||||
this.autoCompletionImageList.Images.SetKeyName(3, "");
|
||||
this.autoCompletionImageList.Images.SetKeyName(4, "");
|
||||
this.autoCompletionImageList.Images.SetKeyName(5, "");
|
||||
this.autoCompletionImageList.Images.SetKeyName(6, "");
|
||||
this.autoCompletionImageList.Images.SetKeyName(7, "");
|
||||
this.autoCompletionImageList.Images.SetKeyName(8, "");
|
||||
this.autoCompletionImageList.Images.SetKeyName(9, "");
|
||||
this.autoCompletionImageList.Images.SetKeyName(10, "");
|
||||
this.autoCompletionImageList.Images.SetKeyName(11, "");
|
||||
this.autoCompletionImageList.Images.SetKeyName(12, "");
|
||||
this.autoCompletionImageList.Images.SetKeyName(13, "");
|
||||
this.autoCompletionImageList.Images.SetKeyName(14, "Keyword.bmp");
|
||||
this.autoCompletionImageList.Images.SetKeyName(15, "MethodExtension.bmp");
|
||||
//
|
||||
// toolTip
|
||||
//
|
||||
this.toolTip.AutomaticDelay = 0;
|
||||
this.toolTip.UseAnimation = false;
|
||||
//
|
||||
// IntellisenseTextBox
|
||||
//
|
||||
this.Enter += new System.EventHandler(this.IntellisenseTextBox_Enter);
|
||||
this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.IntellisenseTextBox_MouseClick);
|
||||
this.Leave += new System.EventHandler(this.IntellisenseTextBox_Leave);
|
||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.IntellisenseTextBox_KeyDown);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ImageList autoCompletionImageList;
|
||||
private System.Windows.Forms.ToolTip toolTip;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
namespace System.Workflow.Activities.Rules.Design
|
||||
{
|
||||
partial class RenameRuleObjectDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RenameRuleObjectDialog));
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.newNamelabel = new System.Windows.Forms.Label();
|
||||
this.ruleNameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.okCancelTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.okCancelTableLayoutPanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
resources.ApplyResources(this.cancelButton, "cancelButton");
|
||||
this.cancelButton.CausesValidation = false;
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Click += new System.EventHandler(this.OnCancel);
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
resources.ApplyResources(this.okButton, "okButton");
|
||||
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Click += new System.EventHandler(this.OnOk);
|
||||
//
|
||||
// newNamelabel
|
||||
//
|
||||
resources.ApplyResources(this.newNamelabel, "newNamelabel");
|
||||
this.newNamelabel.Name = "newNamelabel";
|
||||
this.newNamelabel.UseCompatibleTextRendering = true;
|
||||
//
|
||||
// ruleNameTextBox
|
||||
//
|
||||
resources.ApplyResources(this.ruleNameTextBox, "ruleNameTextBox");
|
||||
this.ruleNameTextBox.Name = "ruleNameTextBox";
|
||||
//
|
||||
// okCancelTableLayoutPanel
|
||||
//
|
||||
resources.ApplyResources(this.okCancelTableLayoutPanel, "okCancelTableLayoutPanel");
|
||||
this.okCancelTableLayoutPanel.Controls.Add(this.okButton, 0, 0);
|
||||
this.okCancelTableLayoutPanel.Controls.Add(this.cancelButton, 1, 0);
|
||||
this.okCancelTableLayoutPanel.Name = "okCancelTableLayoutPanel";
|
||||
//
|
||||
// RenameRuleObjectDialog
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.CancelButton = this.cancelButton;
|
||||
this.Controls.Add(this.okCancelTableLayoutPanel);
|
||||
this.Controls.Add(this.ruleNameTextBox);
|
||||
this.Controls.Add(this.newNamelabel);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "RenameRuleObjectDialog";
|
||||
this.ShowInTaskbar = false;
|
||||
this.okCancelTableLayoutPanel.ResumeLayout(false);
|
||||
this.okCancelTableLayoutPanel.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Label newNamelabel;
|
||||
private System.Windows.Forms.TextBox ruleNameTextBox;
|
||||
private System.Windows.Forms.TableLayoutPanel okCancelTableLayoutPanel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
#region Using directives
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Design;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace System.Workflow.Activities.Rules.Design
|
||||
{
|
||||
internal partial class RenameRuleObjectDialog : Form
|
||||
{
|
||||
public delegate bool NameValidatorDelegate(string name);
|
||||
|
||||
private string name;
|
||||
private IServiceProvider serviceProvider;
|
||||
private NameValidatorDelegate nameValidator;
|
||||
private BasicBrowserDialog parent;
|
||||
|
||||
public RenameRuleObjectDialog(IServiceProvider serviceProvider, string oldName, NameValidatorDelegate nameValidator, BasicBrowserDialog parent)
|
||||
{
|
||||
if (oldName == null)
|
||||
throw (new ArgumentNullException("oldName"));
|
||||
if (serviceProvider == null)
|
||||
throw (new ArgumentNullException("serviceProvider"));
|
||||
if (nameValidator == null)
|
||||
throw (new ArgumentNullException("nameValidator"));
|
||||
|
||||
this.serviceProvider = serviceProvider;
|
||||
this.name = oldName;
|
||||
this.nameValidator = nameValidator;
|
||||
this.parent = parent;
|
||||
InitializeComponent();
|
||||
|
||||
this.ruleNameTextBox.Text = oldName;
|
||||
this.Text = parent.RenameTitleText;
|
||||
this.newNamelabel.Text = parent.NewNameLabelText;
|
||||
|
||||
this.Icon = null;
|
||||
|
||||
//Set dialog fonts
|
||||
IUIService uisvc = (IUIService)this.serviceProvider.GetService(typeof(IUIService));
|
||||
if (uisvc != null)
|
||||
this.Font = (Font)uisvc.Styles["DialogFont"];
|
||||
|
||||
}
|
||||
|
||||
public string RuleObjectName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCancel(object sender, EventArgs e)
|
||||
{
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void OnOk(object sender, EventArgs e)
|
||||
{
|
||||
string newName = this.ruleNameTextBox.Text;
|
||||
|
||||
if (newName.Trim().Length == 0)
|
||||
{
|
||||
string errorMessage = parent.EmptyNameErrorText;
|
||||
IUIService uisvc = (IUIService)this.serviceProvider.GetService(typeof(IUIService));
|
||||
if (uisvc != null)
|
||||
uisvc.ShowError(errorMessage);
|
||||
else
|
||||
MessageBox.Show(errorMessage, Messages.InvalidConditionNameCaption, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, DetermineOptions(sender));
|
||||
|
||||
this.DialogResult = DialogResult.None;
|
||||
}
|
||||
else if (this.name != newName && !nameValidator(newName))
|
||||
{
|
||||
string errorMessage = parent.DuplicateNameErrorText;
|
||||
IUIService uisvc = (IUIService)this.serviceProvider.GetService(typeof(IUIService));
|
||||
if (uisvc != null)
|
||||
uisvc.ShowError(errorMessage);
|
||||
else
|
||||
MessageBox.Show(errorMessage, Messages.InvalidConditionNameCaption, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, DetermineOptions(sender));
|
||||
|
||||
this.DialogResult = DialogResult.None;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.name = newName;
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private static MessageBoxOptions DetermineOptions(object sender)
|
||||
{
|
||||
MessageBoxOptions options = (MessageBoxOptions)0;
|
||||
Control someControl = sender as Control;
|
||||
RightToLeft rightToLeftValue = RightToLeft.Inherit;
|
||||
|
||||
while ((rightToLeftValue == RightToLeft.Inherit) && (someControl != null))
|
||||
{
|
||||
rightToLeftValue = someControl.RightToLeft;
|
||||
someControl = someControl.Parent;
|
||||
}
|
||||
|
||||
if (rightToLeftValue == RightToLeft.Yes)
|
||||
{
|
||||
options = MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign;
|
||||
}
|
||||
return options;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
namespace System.Workflow.Activities.Rules.Design
|
||||
{
|
||||
partial class RuleConditionDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RuleConditionDialog));
|
||||
this.okCancelTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.headerLabel = new System.Windows.Forms.Label();
|
||||
this.headerPictureBox = new System.Windows.Forms.PictureBox();
|
||||
this.conditionTextBox = new System.Workflow.Activities.Rules.Design.IntellisenseTextBox();
|
||||
this.conditionLabel = new System.Windows.Forms.Label();
|
||||
this.conditionErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
|
||||
this.okCancelTableLayoutPanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.headerPictureBox)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.conditionErrorProvider)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// okCancelTableLayoutPanel
|
||||
//
|
||||
resources.ApplyResources(this.okCancelTableLayoutPanel, "okCancelTableLayoutPanel");
|
||||
this.okCancelTableLayoutPanel.CausesValidation = false;
|
||||
this.okCancelTableLayoutPanel.Controls.Add(this.okButton, 0, 0);
|
||||
this.okCancelTableLayoutPanel.Controls.Add(this.cancelButton, 1, 0);
|
||||
this.okCancelTableLayoutPanel.Name = "okCancelTableLayoutPanel";
|
||||
//
|
||||
// okButton
|
||||
//
|
||||
resources.ApplyResources(this.okButton, "okButton");
|
||||
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Click += new System.EventHandler(this.okButton_Click);
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
resources.ApplyResources(this.cancelButton, "cancelButton");
|
||||
this.cancelButton.CausesValidation = false;
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
//
|
||||
// headerLabel
|
||||
//
|
||||
resources.ApplyResources(this.headerLabel, "headerLabel");
|
||||
this.headerLabel.Name = "headerLabel";
|
||||
//
|
||||
// headerPictureBox
|
||||
//
|
||||
resources.ApplyResources(this.headerPictureBox, "headerPictureBox");
|
||||
this.headerPictureBox.Name = "headerPictureBox";
|
||||
this.headerPictureBox.TabStop = false;
|
||||
//
|
||||
// conditionTextBox
|
||||
//
|
||||
this.conditionTextBox.AcceptsReturn = true;
|
||||
resources.ApplyResources(this.conditionTextBox, "conditionTextBox");
|
||||
this.conditionTextBox.Name = "conditionTextBox";
|
||||
this.conditionTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.conditionTextBox_Validating);
|
||||
//
|
||||
// conditionLabel
|
||||
//
|
||||
resources.ApplyResources(this.conditionLabel, "conditionLabel");
|
||||
this.conditionLabel.Name = "conditionLabel";
|
||||
//
|
||||
// conditionErrorProvider
|
||||
//
|
||||
this.conditionErrorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
|
||||
this.conditionErrorProvider.ContainerControl = this;
|
||||
//
|
||||
// RuleConditionDialog
|
||||
//
|
||||
this.AcceptButton = this.okButton;
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.cancelButton;
|
||||
this.Controls.Add(this.conditionLabel);
|
||||
this.Controls.Add(this.conditionTextBox);
|
||||
this.Controls.Add(this.okCancelTableLayoutPanel);
|
||||
this.Controls.Add(this.headerLabel);
|
||||
this.Controls.Add(this.headerPictureBox);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.HelpButton = true;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "RuleConditionDialog";
|
||||
this.ShowInTaskbar = false;
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.RuleConditionDialog_FormClosing);
|
||||
this.okCancelTableLayoutPanel.ResumeLayout(false);
|
||||
this.okCancelTableLayoutPanel.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.headerPictureBox)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.conditionErrorProvider)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TableLayoutPanel okCancelTableLayoutPanel;
|
||||
private System.Windows.Forms.Button okButton;
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.Label headerLabel;
|
||||
private System.Windows.Forms.PictureBox headerPictureBox;
|
||||
private IntellisenseTextBox conditionTextBox;
|
||||
private System.Windows.Forms.Label conditionLabel;
|
||||
private System.Windows.Forms.ErrorProvider conditionErrorProvider;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
// Copyright (C) 2006 Microsoft Corporation All Rights Reserved
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
#define CODE_ANALYSIS
|
||||
using System.CodeDom;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Workflow.ComponentModel;
|
||||
using System.Workflow.ComponentModel.Compiler;
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
|
||||
namespace System.Workflow.Activities.Rules.Design
|
||||
{
|
||||
public partial class RuleConditionDialog : Form
|
||||
{
|
||||
RuleExpressionCondition ruleExpressionCondition = new RuleExpressionCondition();
|
||||
private IServiceProvider serviceProvider;
|
||||
private Parser ruleParser;
|
||||
private Exception syntaxException;
|
||||
private bool wasOKed;
|
||||
|
||||
public RuleConditionDialog(Activity activity, CodeExpression expression)
|
||||
{
|
||||
if (activity == null)
|
||||
throw (new ArgumentNullException("activity"));
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
ITypeProvider typeProvider;
|
||||
serviceProvider = activity.Site;
|
||||
if (serviceProvider != null)
|
||||
{
|
||||
IUIService uisvc = serviceProvider.GetService(typeof(IUIService)) as IUIService;
|
||||
if (uisvc != null)
|
||||
this.Font = (Font)uisvc.Styles["DialogFont"];
|
||||
typeProvider = (ITypeProvider)serviceProvider.GetService(typeof(ITypeProvider));
|
||||
if (typeProvider == null)
|
||||
{
|
||||
string message = string.Format(CultureInfo.CurrentCulture, Messages.MissingService, typeof(ITypeProvider).FullName);
|
||||
throw new InvalidOperationException(message);
|
||||
}
|
||||
|
||||
WorkflowDesignerLoader loader = serviceProvider.GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;
|
||||
if (loader != null)
|
||||
loader.Flush();
|
||||
}
|
||||
else
|
||||
{
|
||||
// no service provider, so make a TypeProvider that has all loaded Assemblies
|
||||
TypeProvider newProvider = new TypeProvider(null);
|
||||
foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
|
||||
newProvider.AddAssembly(a);
|
||||
typeProvider = newProvider;
|
||||
}
|
||||
|
||||
RuleValidation validation = new RuleValidation(activity, typeProvider, false);
|
||||
this.ruleParser = new Parser(validation);
|
||||
|
||||
InitializeDialog(expression);
|
||||
}
|
||||
|
||||
public RuleConditionDialog(Type activityType, ITypeProvider typeProvider, CodeExpression expression)
|
||||
{
|
||||
if (activityType == null)
|
||||
throw (new ArgumentNullException("activityType"));
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
RuleValidation validation = new RuleValidation(activityType, typeProvider);
|
||||
this.ruleParser = new Parser(validation);
|
||||
|
||||
InitializeDialog(expression);
|
||||
}
|
||||
|
||||
private void InitializeDialog(CodeExpression expression)
|
||||
{
|
||||
HelpRequested += new HelpEventHandler(OnHelpRequested);
|
||||
HelpButtonClicked += new CancelEventHandler(OnHelpClicked);
|
||||
|
||||
if (expression != null)
|
||||
{
|
||||
this.ruleExpressionCondition.Expression = RuleExpressionWalker.Clone(expression);
|
||||
this.conditionTextBox.Text = ruleExpressionCondition.ToString().Replace("\n", "\r\n");
|
||||
}
|
||||
else
|
||||
this.conditionTextBox.Text = string.Empty;
|
||||
|
||||
this.conditionTextBox.PopulateAutoCompleteList += new EventHandler<AutoCompletionEventArgs>(ConditionTextBox_PopulateAutoCompleteList);
|
||||
this.conditionTextBox.PopulateToolTipList += new EventHandler<AutoCompletionEventArgs>(ConditionTextBox_PopulateAutoCompleteList);
|
||||
|
||||
try
|
||||
{
|
||||
this.ruleParser.ParseCondition(this.conditionTextBox.Text);
|
||||
conditionErrorProvider.SetError(this.conditionTextBox, string.Empty);
|
||||
}
|
||||
catch (RuleSyntaxException ex)
|
||||
{
|
||||
conditionErrorProvider.SetError(this.conditionTextBox, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public CodeExpression Expression
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.ruleExpressionCondition.Expression;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ConditionTextBox_PopulateAutoCompleteList(object sender, AutoCompletionEventArgs e)
|
||||
{
|
||||
e.AutoCompleteValues = this.ruleParser.GetExpressionCompletions(e.Prefix);
|
||||
}
|
||||
|
||||
|
||||
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
|
||||
private void conditionTextBox_Validating(object sender, CancelEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.ruleExpressionCondition = (RuleExpressionCondition)this.ruleParser.ParseCondition(this.conditionTextBox.Text);
|
||||
|
||||
if (!string.IsNullOrEmpty(this.conditionTextBox.Text))
|
||||
this.conditionTextBox.Text = this.ruleExpressionCondition.ToString().Replace("\n", "\r\n");
|
||||
conditionErrorProvider.SetError(this.conditionTextBox, string.Empty);
|
||||
syntaxException = null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
syntaxException = ex;
|
||||
conditionErrorProvider.SetError(this.conditionTextBox, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnHelpClicked(object sender, CancelEventArgs e)
|
||||
{
|
||||
e.Cancel = true;
|
||||
ShowHelp();
|
||||
}
|
||||
|
||||
|
||||
private void OnHelpRequested(object sender, HelpEventArgs e)
|
||||
{
|
||||
ShowHelp();
|
||||
}
|
||||
|
||||
|
||||
private void ShowHelp()
|
||||
{
|
||||
if (serviceProvider != null)
|
||||
{
|
||||
IHelpService helpService = serviceProvider.GetService(typeof(IHelpService)) as IHelpService;
|
||||
if (helpService != null)
|
||||
{
|
||||
helpService.ShowHelpFromKeyword(this.GetType().FullName + ".UI");
|
||||
}
|
||||
else
|
||||
{
|
||||
IUIService uisvc = serviceProvider.GetService(typeof(IUIService)) as IUIService;
|
||||
if (uisvc != null)
|
||||
uisvc.ShowError(Messages.NoHelp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IUIService uisvc = (IUIService)GetService(typeof(IUIService));
|
||||
if (uisvc != null)
|
||||
uisvc.ShowError(Messages.NoHelp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void okButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
wasOKed = true;
|
||||
}
|
||||
|
||||
private void RuleConditionDialog_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (wasOKed && syntaxException != null)
|
||||
{
|
||||
e.Cancel = true;
|
||||
DesignerHelpers.DisplayError(Messages.Error_ConditionParser + "\n" + syntaxException.Message, this.Text, this.serviceProvider);
|
||||
if (syntaxException is RuleSyntaxException)
|
||||
this.conditionTextBox.SelectionStart = ((RuleSyntaxException)syntaxException).Position;
|
||||
this.conditionTextBox.SelectionLength = 0;
|
||||
this.conditionTextBox.ScrollToCaret();
|
||||
wasOKed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Workflow.Activities.Rules;
|
||||
using System.Workflow.ComponentModel;
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
using System.Workflow.ComponentModel.Compiler;
|
||||
using System.Workflow.Interop;
|
||||
using System.Workflow.Activities.Common;
|
||||
|
||||
namespace System.Workflow.Activities.Rules.Design
|
||||
{
|
||||
#region class RuleSetBrowserDialog
|
||||
|
||||
internal sealed class RuleSetBrowserDialog : BasicBrowserDialog
|
||||
{
|
||||
#region members and constructors
|
||||
|
||||
private RuleSetCollection ruleSetCollection;
|
||||
|
||||
public RuleSetBrowserDialog(Activity activity, string name)
|
||||
: base(activity, name)
|
||||
{
|
||||
RuleDefinitions rules = ConditionHelper.Load_Rules_DT(activity.Site, Helpers.GetRootActivity(activity));
|
||||
if (rules != null)
|
||||
this.ruleSetCollection = rules.RuleSets;
|
||||
|
||||
InitializeListView(this.ruleSetCollection, name);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region override members
|
||||
|
||||
protected override string GetObjectName(object ruleObject)
|
||||
{
|
||||
RuleSet ruleSet = ruleObject as RuleSet;
|
||||
|
||||
return ruleSet.Name;
|
||||
}
|
||||
|
||||
protected override object OnNewInternal()
|
||||
{
|
||||
using (RuleSetDialog dlg = new RuleSetDialog(this.Activity, null))
|
||||
{
|
||||
if (DialogResult.OK == dlg.ShowDialog(this))
|
||||
{
|
||||
RuleSet ruleSet = dlg.RuleSet;
|
||||
ruleSet.Name = ruleSetCollection.GenerateRuleSetName();
|
||||
this.ruleSetCollection.Add(ruleSet);
|
||||
return ruleSet;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override bool OnEditInternal(object currentRuleObject, out object updatedRuleObject)
|
||||
{
|
||||
RuleSet ruleSet = currentRuleObject as RuleSet;
|
||||
updatedRuleObject = null;
|
||||
|
||||
using (RuleSetDialog dlg = new RuleSetDialog(this.Activity, ruleSet))
|
||||
{
|
||||
if (DialogResult.OK == dlg.ShowDialog())
|
||||
{
|
||||
this.ruleSetCollection.Remove(ruleSet.Name);
|
||||
this.ruleSetCollection.Add(dlg.RuleSet);
|
||||
updatedRuleObject = dlg.RuleSet;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override string OnRenameInternal(object ruleObject)
|
||||
{
|
||||
RuleSet ruleSet = ruleObject as RuleSet;
|
||||
|
||||
using (RenameRuleObjectDialog dlg = new RenameRuleObjectDialog(this.Activity.Site, ruleSet.Name, new RenameRuleObjectDialog.NameValidatorDelegate(IsUniqueName), this))
|
||||
{
|
||||
if ((dlg.ShowDialog(this) == DialogResult.OK) && (dlg.RuleObjectName != ruleSet.Name))
|
||||
{
|
||||
this.ruleSetCollection.Remove(ruleSet);
|
||||
ruleSet.Name = dlg.RuleObjectName;
|
||||
this.ruleSetCollection.Add(ruleSet);
|
||||
return dlg.RuleObjectName;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override void OnDeleteInternal(object ruleObject)
|
||||
{
|
||||
RuleSet ruleSet = ruleObject as RuleSet;
|
||||
|
||||
this.ruleSetCollection.Remove(ruleSet.Name);
|
||||
}
|
||||
|
||||
protected override void UpdateListViewItem(object ruleObject, ListViewItem listViewItem)
|
||||
{
|
||||
RuleSet ruleSet = ruleObject as RuleSet;
|
||||
|
||||
ValidationManager manager = new ValidationManager(this.Activity.Site);
|
||||
ITypeProvider typeProvider = (ITypeProvider)manager.GetService(typeof(ITypeProvider));
|
||||
RuleValidation validation = new RuleValidation(this.Activity, typeProvider, false);
|
||||
|
||||
bool valid;
|
||||
using (WorkflowCompilationContext.CreateScope(manager))
|
||||
{
|
||||
valid = ruleSet.Validate(validation);
|
||||
}
|
||||
|
||||
listViewItem.Tag = ruleSet;
|
||||
listViewItem.Text = ruleSet.Name;
|
||||
string validText = valid ? Messages.Yes : Messages.No;
|
||||
if (listViewItem.SubItems.Count == 1)
|
||||
listViewItem.SubItems.Add(validText);
|
||||
else
|
||||
listViewItem.SubItems[1].Text = validText;
|
||||
}
|
||||
|
||||
protected override void UpdatePreview(TextBox previewBox, object ruleObject)
|
||||
{
|
||||
RuleSet ruleSet = ruleObject as RuleSet;
|
||||
|
||||
NativeMethods.SendMessage(previewBox.Handle, NativeMethods.WM_SETREDRAW, IntPtr.Zero, IntPtr.Zero);
|
||||
previewBox.Lines = DesignerHelpers.GetRuleSetPreview(ruleSet).Split('\n');
|
||||
NativeMethods.SendMessage(previewBox.Handle, NativeMethods.WM_SETREDRAW, new IntPtr(1), IntPtr.Zero);
|
||||
previewBox.Invalidate();
|
||||
}
|
||||
|
||||
protected override string DescriptionText { get { return Messages.RuleSetDescriptionText; } }
|
||||
protected override string TitleText { get { return Messages.RuleSetTitleText; } }
|
||||
protected override string PreviewLabelText { get { return Messages.RuleSetPreviewLabelText; } }
|
||||
protected override string ConfirmDeleteMessageText { get { return Messages.RuleSetConfirmDeleteMessageText; } }
|
||||
protected override string ConfirmDeleteTitleText { get { return Messages.DeleteRuleSet; } }
|
||||
internal override string EmptyNameErrorText { get { return Messages.RuleSetEmptyNameErrorText; } }
|
||||
internal override string DuplicateNameErrorText { get { return Messages.RuleSetDuplicateNameErrorText; } }
|
||||
internal override string NewNameLabelText { get { return Messages.RuleSetNewNameLableText; } }
|
||||
internal override string RenameTitleText { get { return Messages.RuleSetRenameTitleText; } }
|
||||
|
||||
|
||||
// used by RenameConditionDialog
|
||||
internal override bool IsUniqueName(string ruleName)
|
||||
{
|
||||
return (!this.ruleSetCollection.Contains(ruleName));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
415
mcs/class/referencesource/System.Workflow.Activities/Rules/Design/Dialogs/RuleSetDialog.Designer.cs
generated
Normal file
415
mcs/class/referencesource/System.Workflow.Activities/Rules/Design/Dialogs/RuleSetDialog.Designer.cs
generated
Normal file
@@ -0,0 +1,415 @@
|
||||
namespace System.Workflow.Activities.Rules.Design
|
||||
{
|
||||
partial class RuleSetDialog
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RuleSetDialog));
|
||||
this.nameColumnHeader = new System.Windows.Forms.ColumnHeader();
|
||||
this.rulesListView = new System.Windows.Forms.ListView();
|
||||
this.priorityColumnHeader = new System.Windows.Forms.ColumnHeader();
|
||||
this.reevaluationCountColumnHeader = new System.Windows.Forms.ColumnHeader();
|
||||
this.activeColumnHeader = new System.Windows.Forms.ColumnHeader();
|
||||
this.rulePreviewColumnHeader = new System.Windows.Forms.ColumnHeader();
|
||||
this.rulesGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.chainingLabel = new System.Windows.Forms.Label();
|
||||
this.chainingBehaviourComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.rulesToolStrip = new System.Windows.Forms.ToolStrip();
|
||||
this.imageList = new System.Windows.Forms.ImageList(this.components);
|
||||
this.newRuleToolStripButton = new System.Windows.Forms.ToolStripButton();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.deleteToolStripButton = new System.Windows.Forms.ToolStripButton();
|
||||
this.buttonOK = new System.Windows.Forms.Button();
|
||||
this.ruleGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.reevaluationComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.elseTextBox = new System.Workflow.Activities.Rules.Design.IntellisenseTextBox();
|
||||
this.elseLabel = new System.Windows.Forms.Label();
|
||||
this.thenTextBox = new System.Workflow.Activities.Rules.Design.IntellisenseTextBox();
|
||||
this.thenLabel = new System.Windows.Forms.Label();
|
||||
this.conditionTextBox = new System.Workflow.Activities.Rules.Design.IntellisenseTextBox();
|
||||
this.conditionLabel = new System.Windows.Forms.Label();
|
||||
this.nameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.nameLabel = new System.Windows.Forms.Label();
|
||||
this.activeCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.reevaluationLabel = new System.Windows.Forms.Label();
|
||||
this.priorityTextBox = new System.Windows.Forms.TextBox();
|
||||
this.priorityLabel = new System.Windows.Forms.Label();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.headerTextLabel = new System.Windows.Forms.Label();
|
||||
this.pictureBoxHeader = new System.Windows.Forms.PictureBox();
|
||||
this.okCancelTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.conditionErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
|
||||
this.thenErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
|
||||
this.elseErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
|
||||
this.rulesGroupBox.SuspendLayout();
|
||||
this.panel1.SuspendLayout();
|
||||
this.rulesToolStrip.SuspendLayout();
|
||||
this.ruleGroupBox.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxHeader)).BeginInit();
|
||||
this.okCancelTableLayoutPanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.conditionErrorProvider)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.thenErrorProvider)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.elseErrorProvider)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// nameColumnHeader
|
||||
//
|
||||
this.nameColumnHeader.Name = "nameColumnHeader";
|
||||
resources.ApplyResources(this.nameColumnHeader, "nameColumnHeader");
|
||||
//
|
||||
// rulesListView
|
||||
//
|
||||
this.rulesListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.nameColumnHeader,
|
||||
this.priorityColumnHeader,
|
||||
this.reevaluationCountColumnHeader,
|
||||
this.activeColumnHeader,
|
||||
this.rulePreviewColumnHeader});
|
||||
resources.ApplyResources(this.rulesListView, "rulesListView");
|
||||
this.rulesListView.FullRowSelect = true;
|
||||
this.rulesListView.HideSelection = false;
|
||||
this.rulesListView.MultiSelect = false;
|
||||
this.rulesListView.Name = "rulesListView";
|
||||
this.rulesListView.UseCompatibleStateImageBehavior = false;
|
||||
this.rulesListView.View = System.Windows.Forms.View.Details;
|
||||
this.rulesListView.SelectedIndexChanged += new System.EventHandler(this.rulesListView_SelectedIndexChanged);
|
||||
this.rulesListView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.rulesListView_ColumnClick);
|
||||
//
|
||||
// priorityColumnHeader
|
||||
//
|
||||
resources.ApplyResources(this.priorityColumnHeader, "priorityColumnHeader");
|
||||
//
|
||||
// reevaluationCountColumnHeader
|
||||
//
|
||||
resources.ApplyResources(this.reevaluationCountColumnHeader, "reevaluationCountColumnHeader");
|
||||
//
|
||||
// activeColumnHeader
|
||||
//
|
||||
resources.ApplyResources(this.activeColumnHeader, "activeColumnHeader");
|
||||
//
|
||||
// rulePreviewColumnHeader
|
||||
//
|
||||
resources.ApplyResources(this.rulePreviewColumnHeader, "rulePreviewColumnHeader");
|
||||
//
|
||||
// rulesGroupBox
|
||||
//
|
||||
this.rulesGroupBox.Controls.Add(this.panel1);
|
||||
resources.ApplyResources(this.rulesGroupBox, "rulesGroupBox");
|
||||
this.rulesGroupBox.Name = "rulesGroupBox";
|
||||
this.rulesGroupBox.TabStop = false;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Controls.Add(this.chainingLabel);
|
||||
this.panel1.Controls.Add(this.chainingBehaviourComboBox);
|
||||
this.panel1.Controls.Add(this.rulesToolStrip);
|
||||
this.panel1.Controls.Add(this.rulesListView);
|
||||
resources.ApplyResources(this.panel1, "panel1");
|
||||
this.panel1.Name = "panel1";
|
||||
//
|
||||
// chainingLabel
|
||||
//
|
||||
resources.ApplyResources(this.chainingLabel, "chainingLabel");
|
||||
this.chainingLabel.Name = "chainingLabel";
|
||||
//
|
||||
// chainingBehaviourComboBox
|
||||
//
|
||||
this.chainingBehaviourComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.chainingBehaviourComboBox.FormattingEnabled = true;
|
||||
resources.ApplyResources(this.chainingBehaviourComboBox, "chainingBehaviourComboBox");
|
||||
this.chainingBehaviourComboBox.Name = "chainingBehaviourComboBox";
|
||||
this.chainingBehaviourComboBox.SelectedIndexChanged += new System.EventHandler(this.chainingBehaviourComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// rulesToolStrip
|
||||
//
|
||||
this.rulesToolStrip.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.rulesToolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
|
||||
this.rulesToolStrip.ImageList = this.imageList;
|
||||
this.rulesToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.newRuleToolStripButton,
|
||||
this.toolStripSeparator1,
|
||||
this.deleteToolStripButton});
|
||||
resources.ApplyResources(this.rulesToolStrip, "rulesToolStrip");
|
||||
this.rulesToolStrip.Name = "rulesToolStrip";
|
||||
this.rulesToolStrip.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;
|
||||
this.rulesToolStrip.TabStop = true;
|
||||
//
|
||||
// imageList
|
||||
//
|
||||
this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream")));
|
||||
this.imageList.TransparentColor = System.Drawing.Color.Transparent;
|
||||
this.imageList.Images.SetKeyName(0, "NewRule.bmp");
|
||||
this.imageList.Images.SetKeyName(1, "RenameRule.bmp");
|
||||
this.imageList.Images.SetKeyName(2, "Delete.bmp");
|
||||
//
|
||||
// newRuleToolStripButton
|
||||
//
|
||||
resources.ApplyResources(this.newRuleToolStripButton, "newRuleToolStripButton");
|
||||
this.newRuleToolStripButton.Name = "newRuleToolStripButton";
|
||||
this.newRuleToolStripButton.Click += new System.EventHandler(this.newRuleToolStripButton_Click);
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
resources.ApplyResources(this.toolStripSeparator1, "toolStripSeparator1");
|
||||
//
|
||||
// deleteToolStripButton
|
||||
//
|
||||
resources.ApplyResources(this.deleteToolStripButton, "deleteToolStripButton");
|
||||
this.deleteToolStripButton.Name = "deleteToolStripButton";
|
||||
this.deleteToolStripButton.Click += new System.EventHandler(this.deleteToolStripButton_Click);
|
||||
//
|
||||
// buttonOK
|
||||
//
|
||||
resources.ApplyResources(this.buttonOK, "buttonOK");
|
||||
this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.buttonOK.Name = "buttonOK";
|
||||
//
|
||||
// ruleGroupBox
|
||||
//
|
||||
this.ruleGroupBox.Controls.Add(this.reevaluationComboBox);
|
||||
this.ruleGroupBox.Controls.Add(this.elseTextBox);
|
||||
this.ruleGroupBox.Controls.Add(this.elseLabel);
|
||||
this.ruleGroupBox.Controls.Add(this.thenTextBox);
|
||||
this.ruleGroupBox.Controls.Add(this.thenLabel);
|
||||
this.ruleGroupBox.Controls.Add(this.conditionTextBox);
|
||||
this.ruleGroupBox.Controls.Add(this.conditionLabel);
|
||||
this.ruleGroupBox.Controls.Add(this.nameTextBox);
|
||||
this.ruleGroupBox.Controls.Add(this.nameLabel);
|
||||
this.ruleGroupBox.Controls.Add(this.activeCheckBox);
|
||||
this.ruleGroupBox.Controls.Add(this.reevaluationLabel);
|
||||
this.ruleGroupBox.Controls.Add(this.priorityTextBox);
|
||||
this.ruleGroupBox.Controls.Add(this.priorityLabel);
|
||||
resources.ApplyResources(this.ruleGroupBox, "ruleGroupBox");
|
||||
this.ruleGroupBox.Name = "ruleGroupBox";
|
||||
this.ruleGroupBox.TabStop = false;
|
||||
//
|
||||
// reevaluationComboBox
|
||||
//
|
||||
this.reevaluationComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.reevaluationComboBox.FormattingEnabled = true;
|
||||
resources.ApplyResources(this.reevaluationComboBox, "reevaluationComboBox");
|
||||
this.reevaluationComboBox.Name = "reevaluationComboBox";
|
||||
this.reevaluationComboBox.SelectedIndexChanged += new System.EventHandler(this.reevaluationComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// elseTextBox
|
||||
//
|
||||
this.elseTextBox.AcceptsReturn = true;
|
||||
resources.ApplyResources(this.elseTextBox, "elseTextBox");
|
||||
this.elseTextBox.Name = "elseTextBox";
|
||||
this.elseTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.elseTextBox_Validating);
|
||||
//
|
||||
// elseLabel
|
||||
//
|
||||
resources.ApplyResources(this.elseLabel, "elseLabel");
|
||||
this.elseLabel.Name = "elseLabel";
|
||||
//
|
||||
// thenTextBox
|
||||
//
|
||||
this.thenTextBox.AcceptsReturn = true;
|
||||
resources.ApplyResources(this.thenTextBox, "thenTextBox");
|
||||
this.thenTextBox.Name = "thenTextBox";
|
||||
this.thenTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.thenTextBox_Validating);
|
||||
//
|
||||
// thenLabel
|
||||
//
|
||||
resources.ApplyResources(this.thenLabel, "thenLabel");
|
||||
this.thenLabel.Name = "thenLabel";
|
||||
//
|
||||
// conditionTextBox
|
||||
//
|
||||
this.conditionTextBox.AcceptsReturn = true;
|
||||
resources.ApplyResources(this.conditionTextBox, "conditionTextBox");
|
||||
this.conditionTextBox.Name = "conditionTextBox";
|
||||
this.conditionTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.conditionTextBox_Validating);
|
||||
//
|
||||
// conditionLabel
|
||||
//
|
||||
resources.ApplyResources(this.conditionLabel, "conditionLabel");
|
||||
this.conditionLabel.Name = "conditionLabel";
|
||||
//
|
||||
// nameTextBox
|
||||
//
|
||||
resources.ApplyResources(this.nameTextBox, "nameTextBox");
|
||||
this.nameTextBox.Name = "nameTextBox";
|
||||
this.nameTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.nameTextBox_Validating);
|
||||
//
|
||||
// nameLabel
|
||||
//
|
||||
resources.ApplyResources(this.nameLabel, "nameLabel");
|
||||
this.nameLabel.Name = "nameLabel";
|
||||
//
|
||||
// activeCheckBox
|
||||
//
|
||||
resources.ApplyResources(this.activeCheckBox, "activeCheckBox");
|
||||
this.activeCheckBox.Name = "activeCheckBox";
|
||||
this.activeCheckBox.CheckedChanged += new System.EventHandler(this.activeCheckBox_CheckedChanged);
|
||||
//
|
||||
// reevaluationLabel
|
||||
//
|
||||
resources.ApplyResources(this.reevaluationLabel, "reevaluationLabel");
|
||||
this.reevaluationLabel.Name = "reevaluationLabel";
|
||||
//
|
||||
// priorityTextBox
|
||||
//
|
||||
resources.ApplyResources(this.priorityTextBox, "priorityTextBox");
|
||||
this.priorityTextBox.Name = "priorityTextBox";
|
||||
this.priorityTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.priorityTextBox_Validating);
|
||||
//
|
||||
// priorityLabel
|
||||
//
|
||||
resources.ApplyResources(this.priorityLabel, "priorityLabel");
|
||||
this.priorityLabel.Name = "priorityLabel";
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
resources.ApplyResources(this.buttonCancel, "buttonCancel");
|
||||
this.buttonCancel.CausesValidation = false;
|
||||
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
//
|
||||
// headerTextLabel
|
||||
//
|
||||
resources.ApplyResources(this.headerTextLabel, "headerTextLabel");
|
||||
this.headerTextLabel.Name = "headerTextLabel";
|
||||
//
|
||||
// pictureBoxHeader
|
||||
//
|
||||
resources.ApplyResources(this.pictureBoxHeader, "pictureBoxHeader");
|
||||
this.pictureBoxHeader.Name = "pictureBoxHeader";
|
||||
this.pictureBoxHeader.TabStop = false;
|
||||
//
|
||||
// okCancelTableLayoutPanel
|
||||
//
|
||||
resources.ApplyResources(this.okCancelTableLayoutPanel, "okCancelTableLayoutPanel");
|
||||
this.okCancelTableLayoutPanel.CausesValidation = false;
|
||||
this.okCancelTableLayoutPanel.Controls.Add(this.buttonOK, 0, 0);
|
||||
this.okCancelTableLayoutPanel.Controls.Add(this.buttonCancel, 1, 0);
|
||||
this.okCancelTableLayoutPanel.Name = "okCancelTableLayoutPanel";
|
||||
//
|
||||
// conditionErrorProvider
|
||||
//
|
||||
this.conditionErrorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
|
||||
this.conditionErrorProvider.ContainerControl = this;
|
||||
//
|
||||
// thenErrorProvider
|
||||
//
|
||||
this.thenErrorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
|
||||
this.thenErrorProvider.ContainerControl = this;
|
||||
//
|
||||
// elseErrorProvider
|
||||
//
|
||||
this.elseErrorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
|
||||
this.elseErrorProvider.ContainerControl = this;
|
||||
//
|
||||
// RuleSetDialog
|
||||
//
|
||||
this.AcceptButton = this.buttonOK;
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.buttonCancel;
|
||||
this.Controls.Add(this.ruleGroupBox);
|
||||
this.Controls.Add(this.headerTextLabel);
|
||||
this.Controls.Add(this.pictureBoxHeader);
|
||||
this.Controls.Add(this.okCancelTableLayoutPanel);
|
||||
this.Controls.Add(this.rulesGroupBox);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.HelpButton = true;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "RuleSetDialog";
|
||||
this.ShowInTaskbar = false;
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.rulesGroupBox.ResumeLayout(false);
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel1.PerformLayout();
|
||||
this.rulesToolStrip.ResumeLayout(false);
|
||||
this.rulesToolStrip.PerformLayout();
|
||||
this.ruleGroupBox.ResumeLayout(false);
|
||||
this.ruleGroupBox.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxHeader)).EndInit();
|
||||
this.okCancelTableLayoutPanel.ResumeLayout(false);
|
||||
this.okCancelTableLayoutPanel.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.conditionErrorProvider)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.thenErrorProvider)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.elseErrorProvider)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.conditionTextBox.Validating -= this.conditionTextBox_Validating;
|
||||
this.thenTextBox.Validating -= this.thenTextBox_Validating;
|
||||
this.elseTextBox.Validating -= this.elseTextBox_Validating;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ColumnHeader nameColumnHeader;
|
||||
private System.Windows.Forms.ListView rulesListView;
|
||||
private System.Windows.Forms.ColumnHeader priorityColumnHeader;
|
||||
private System.Windows.Forms.ColumnHeader reevaluationCountColumnHeader;
|
||||
private System.Windows.Forms.ColumnHeader activeColumnHeader;
|
||||
private System.Windows.Forms.ColumnHeader rulePreviewColumnHeader;
|
||||
private System.Windows.Forms.GroupBox rulesGroupBox;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.ToolStrip rulesToolStrip;
|
||||
private System.Windows.Forms.ToolStripButton newRuleToolStripButton;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripButton deleteToolStripButton;
|
||||
private System.Windows.Forms.ImageList imageList;
|
||||
private System.Windows.Forms.Button buttonOK;
|
||||
private System.Windows.Forms.GroupBox ruleGroupBox;
|
||||
private System.Windows.Forms.Button buttonCancel;
|
||||
private System.Windows.Forms.Label headerTextLabel;
|
||||
private System.Windows.Forms.PictureBox pictureBoxHeader;
|
||||
private System.Windows.Forms.TableLayoutPanel okCancelTableLayoutPanel;
|
||||
private System.Windows.Forms.CheckBox activeCheckBox;
|
||||
private System.Windows.Forms.Label reevaluationLabel;
|
||||
private System.Windows.Forms.TextBox priorityTextBox;
|
||||
private System.Windows.Forms.Label priorityLabel;
|
||||
private System.Windows.Forms.TextBox nameTextBox;
|
||||
private System.Windows.Forms.Label nameLabel;
|
||||
private System.Windows.Forms.ErrorProvider conditionErrorProvider;
|
||||
private System.Windows.Forms.ErrorProvider thenErrorProvider;
|
||||
private System.Windows.Forms.ErrorProvider elseErrorProvider;
|
||||
private IntellisenseTextBox elseTextBox;
|
||||
private System.Windows.Forms.Label elseLabel;
|
||||
private IntellisenseTextBox thenTextBox;
|
||||
private System.Windows.Forms.Label thenLabel;
|
||||
private IntellisenseTextBox conditionTextBox;
|
||||
private System.Windows.Forms.Label conditionLabel;
|
||||
private System.Windows.Forms.ComboBox reevaluationComboBox;
|
||||
private System.Windows.Forms.ComboBox chainingBehaviourComboBox;
|
||||
private System.Windows.Forms.Label chainingLabel;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,243 @@
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Security.Permissions;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.Drawing.Design;
|
||||
using System.Workflow.ComponentModel;
|
||||
using System.Workflow.ComponentModel.Design;
|
||||
using System.Globalization;
|
||||
using Microsoft.Win32;
|
||||
using System.Workflow.Activities.Common;
|
||||
|
||||
namespace System.Workflow.Activities.Rules.Design
|
||||
{
|
||||
internal sealed class LogicalExpressionEditor : UITypeEditor
|
||||
{
|
||||
private IWindowsFormsEditorService editorService;
|
||||
|
||||
public LogicalExpressionEditor()
|
||||
{
|
||||
}
|
||||
|
||||
public override object EditValue(ITypeDescriptorContext typeDescriptorContext, IServiceProvider serviceProvider, object o)
|
||||
{
|
||||
if (typeDescriptorContext == null)
|
||||
throw new ArgumentNullException("typeDescriptorContext");
|
||||
if (serviceProvider == null)
|
||||
throw new ArgumentNullException("serviceProvider");
|
||||
|
||||
object returnVal = o;
|
||||
|
||||
// Do not allow editing expression if the name is not set.
|
||||
RuleConditionReference conditionDeclaration = typeDescriptorContext.Instance as RuleConditionReference;
|
||||
|
||||
if (conditionDeclaration == null || conditionDeclaration.ConditionName == null || conditionDeclaration.ConditionName.Length <= 0)
|
||||
throw new ArgumentException(Messages.ConditionNameNotSet);
|
||||
|
||||
Activity baseActivity = null;
|
||||
|
||||
IReferenceService rs = serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;
|
||||
if (rs != null)
|
||||
baseActivity = rs.GetComponent(typeDescriptorContext.Instance) as Activity;
|
||||
|
||||
RuleConditionCollection conditionDefinitions = null;
|
||||
RuleDefinitions rules = ConditionHelper.Load_Rules_DT(serviceProvider, Helpers.GetRootActivity(baseActivity));
|
||||
if (rules != null)
|
||||
conditionDefinitions = rules.Conditions;
|
||||
|
||||
if (conditionDefinitions != null && !conditionDefinitions.Contains(conditionDeclaration.ConditionName))
|
||||
{
|
||||
string message = string.Format(CultureInfo.CurrentCulture, Messages.ConditionNotFound, conditionDeclaration.ConditionName);
|
||||
throw new ArgumentException(message);
|
||||
}
|
||||
|
||||
this.editorService = (IWindowsFormsEditorService)serviceProvider.GetService(typeof(IWindowsFormsEditorService));
|
||||
if (editorService != null)
|
||||
{
|
||||
CodeExpression experssion = typeDescriptorContext.PropertyDescriptor.GetValue(typeDescriptorContext.Instance) as CodeExpression;
|
||||
try
|
||||
{
|
||||
using (RuleConditionDialog dlg = new RuleConditionDialog(baseActivity, experssion))
|
||||
{
|
||||
if (DialogResult.OK == editorService.ShowDialog(dlg))
|
||||
returnVal = dlg.Expression;
|
||||
}
|
||||
}
|
||||
catch (NotSupportedException)
|
||||
{
|
||||
DesignerHelpers.DisplayError(Messages.Error_ExpressionNotSupported, Messages.ConditionEditor, serviceProvider);
|
||||
}
|
||||
}
|
||||
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext typeDescriptorContext)
|
||||
{
|
||||
return UITypeEditorEditStyle.Modal;
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class ConditionNameEditor : UITypeEditor
|
||||
{
|
||||
private IWindowsFormsEditorService editorService;
|
||||
|
||||
public ConditionNameEditor()
|
||||
{
|
||||
}
|
||||
|
||||
public override object EditValue(ITypeDescriptorContext typeDescriptorContext, IServiceProvider serviceProvider, object o)
|
||||
{
|
||||
if (typeDescriptorContext == null)
|
||||
throw new ArgumentNullException("typeDescriptorContext");
|
||||
if (serviceProvider == null)
|
||||
throw new ArgumentNullException("serviceProvider");
|
||||
|
||||
object returnVal = o;
|
||||
|
||||
this.editorService = (IWindowsFormsEditorService)serviceProvider.GetService(typeof(IWindowsFormsEditorService));
|
||||
if (editorService != null)
|
||||
{
|
||||
Activity baseActivity = null;
|
||||
|
||||
IReferenceService rs = serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;
|
||||
if (rs != null)
|
||||
baseActivity = rs.GetComponent(typeDescriptorContext.Instance) as Activity;
|
||||
|
||||
string conditionName = typeDescriptorContext.PropertyDescriptor.GetValue(typeDescriptorContext.Instance) as string;
|
||||
ConditionBrowserDialog dlg = new ConditionBrowserDialog(baseActivity, conditionName);
|
||||
|
||||
if (DialogResult.OK == editorService.ShowDialog(dlg))
|
||||
returnVal = dlg.SelectedName;
|
||||
}
|
||||
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext typeDescriptorContext)
|
||||
{
|
||||
return UITypeEditorEditStyle.Modal;
|
||||
}
|
||||
}
|
||||
|
||||
#region class RuleSetNameEditor
|
||||
|
||||
internal sealed class RuleSetNameEditor : UITypeEditor
|
||||
{
|
||||
private IWindowsFormsEditorService editorService;
|
||||
|
||||
public RuleSetNameEditor()
|
||||
{
|
||||
}
|
||||
|
||||
public override object EditValue(ITypeDescriptorContext typeDescriptorContext, IServiceProvider serviceProvider, object o)
|
||||
{
|
||||
if (typeDescriptorContext == null)
|
||||
throw new ArgumentNullException("typeDescriptorContext");
|
||||
if (serviceProvider == null)
|
||||
throw new ArgumentNullException("serviceProvider");
|
||||
|
||||
object returnVal = o;
|
||||
|
||||
this.editorService = (IWindowsFormsEditorService)serviceProvider.GetService(typeof(IWindowsFormsEditorService));
|
||||
if (editorService != null)
|
||||
{
|
||||
Activity baseActivity = null;
|
||||
|
||||
IReferenceService rs = serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;
|
||||
if (rs != null)
|
||||
baseActivity = rs.GetComponent(typeDescriptorContext.Instance) as Activity;
|
||||
|
||||
string ruleSetName = null;
|
||||
RuleSetReference ruleSetReference = typeDescriptorContext.PropertyDescriptor.GetValue(typeDescriptorContext.Instance) as RuleSetReference;
|
||||
if (ruleSetReference != null)
|
||||
ruleSetName = ruleSetReference.RuleSetName;
|
||||
|
||||
RuleSetBrowserDialog dlg = new RuleSetBrowserDialog(baseActivity, ruleSetName);
|
||||
|
||||
if (DialogResult.OK == editorService.ShowDialog(dlg))
|
||||
returnVal = typeDescriptorContext.PropertyDescriptor.Converter.ConvertFrom(typeDescriptorContext, CultureInfo.CurrentUICulture, dlg.SelectedName);
|
||||
}
|
||||
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext typeDescriptorContext)
|
||||
{
|
||||
return UITypeEditorEditStyle.Modal;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region class RuleSetDefinitionEditor
|
||||
|
||||
internal sealed class RuleSetDefinitionEditor : UITypeEditor
|
||||
{
|
||||
private IWindowsFormsEditorService editorService;
|
||||
|
||||
public RuleSetDefinitionEditor()
|
||||
{
|
||||
}
|
||||
|
||||
public override object EditValue(ITypeDescriptorContext typeDescriptorContext, IServiceProvider serviceProvider, object o)
|
||||
{
|
||||
if (typeDescriptorContext == null)
|
||||
throw new ArgumentNullException("typeDescriptorContext");
|
||||
if (serviceProvider == null)
|
||||
throw new ArgumentNullException("serviceProvider");
|
||||
|
||||
object returnVal = o;
|
||||
|
||||
// Do not allow editing if in debug mode.
|
||||
WorkflowDesignerLoader workflowDesignerLoader = serviceProvider.GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;
|
||||
if (workflowDesignerLoader != null && workflowDesignerLoader.InDebugMode)
|
||||
throw new InvalidOperationException(Messages.DebugModeEditsDisallowed);
|
||||
|
||||
// Do not allow editing expression if the name is not set.
|
||||
RuleSetReference ruleSetReference = typeDescriptorContext.Instance as RuleSetReference;
|
||||
|
||||
if (ruleSetReference == null || ruleSetReference.RuleSetName == null || ruleSetReference.RuleSetName.Length <= 0)
|
||||
throw new ArgumentException(Messages.RuleSetNameNotSet);
|
||||
|
||||
Activity baseActivity = null;
|
||||
|
||||
IReferenceService rs = serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;
|
||||
if (rs != null)
|
||||
baseActivity = rs.GetComponent(typeDescriptorContext.Instance) as Activity;
|
||||
|
||||
RuleSetCollection ruleSetCollection = null;
|
||||
RuleDefinitions rules = ConditionHelper.Load_Rules_DT(serviceProvider, Helpers.GetRootActivity(baseActivity));
|
||||
if (rules != null)
|
||||
ruleSetCollection = rules.RuleSets;
|
||||
|
||||
if (ruleSetCollection != null && !ruleSetCollection.Contains(ruleSetReference.RuleSetName))
|
||||
{
|
||||
string message = string.Format(CultureInfo.CurrentCulture, Messages.RuleSetNotFound, ruleSetReference.RuleSetName);
|
||||
throw new ArgumentException(message);
|
||||
}
|
||||
|
||||
this.editorService = (IWindowsFormsEditorService)serviceProvider.GetService(typeof(IWindowsFormsEditorService));
|
||||
if (editorService != null)
|
||||
{
|
||||
RuleSet ruleSet = ruleSetCollection[ruleSetReference.RuleSetName];
|
||||
using (RuleSetDialog dlg = new RuleSetDialog(baseActivity, ruleSet))
|
||||
{
|
||||
if (DialogResult.OK == editorService.ShowDialog(dlg))
|
||||
returnVal = dlg.RuleSet;
|
||||
}
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext typeDescriptorContext)
|
||||
{
|
||||
return UITypeEditorEditStyle.Modal;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user