Пример #1
0
        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 obj2 = o;
            RuleConditionReference instance = typeDescriptorContext.Instance as RuleConditionReference;

            if (((instance == null) || (instance.ConditionName == null)) || (instance.ConditionName.Length <= 0))
            {
                throw new ArgumentException(Messages.ConditionNameNotSet);
            }
            Activity          component = null;
            IReferenceService service   = serviceProvider.GetService(typeof(IReferenceService)) as IReferenceService;

            if (service != null)
            {
                component = service.GetComponent(typeDescriptorContext.Instance) as Activity;
            }
            RuleConditionCollection conditions  = null;
            RuleDefinitions         definitions = ConditionHelper.Load_Rules_DT(serviceProvider, Helpers.GetRootActivity(component));

            if (definitions != null)
            {
                conditions = definitions.Conditions;
            }
            if ((conditions != null) && !conditions.Contains(instance.ConditionName))
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Messages.ConditionNotFound, new object[] { instance.ConditionName }));
            }
            this.editorService = (IWindowsFormsEditorService)serviceProvider.GetService(typeof(IWindowsFormsEditorService));
            if (this.editorService != null)
            {
                CodeExpression expression = typeDescriptorContext.PropertyDescriptor.GetValue(typeDescriptorContext.Instance) as CodeExpression;
                try
                {
                    using (RuleConditionDialog dialog = new RuleConditionDialog(component, expression))
                    {
                        if (DialogResult.OK == this.editorService.ShowDialog(dialog))
                        {
                            obj2 = dialog.Expression;
                        }
                    }
                }
                catch (NotSupportedException)
                {
                    DesignerHelpers.DisplayError(Messages.Error_ExpressionNotSupported, Messages.ConditionEditor, serviceProvider);
                }
            }
            return(obj2);
        }
        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;
        }
Пример #3
0
 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 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;
 }
Пример #5
0
 protected override object OnNewInternal()
 {
     using (RuleConditionDialog dialog = new RuleConditionDialog(base.Activity, null))
     {
         if (DialogResult.OK == dialog.ShowDialog(this))
         {
             RuleExpressionCondition item = new RuleExpressionCondition {
                 Expression = dialog.Expression,
                 Name       = this.CreateNewName()
             };
             this.declarativeConditionCollection.Add(item);
             return(item);
         }
     }
     return(null);
 }
Пример #6
0
        protected override bool OnEditInternal(object currentRuleObject, out object updatedRuleObject)
        {
            RuleExpressionCondition condition = currentRuleObject as RuleExpressionCondition;

            updatedRuleObject = null;
            using (RuleConditionDialog dialog = new RuleConditionDialog(base.Activity, condition.Expression))
            {
                if (DialogResult.OK == dialog.ShowDialog(this))
                {
                    updatedRuleObject = new RuleExpressionCondition(condition.Name, dialog.Expression);
                    this.declarativeConditionCollection.Remove(condition.Name);
                    this.declarativeConditionCollection.Add(updatedRuleObject as RuleExpressionCondition);
                    return(true);
                }
            }
            return(false);
        }
        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;
        }
Пример #8
0
        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);
        }