Example #1
0
        public BinaryLogicalOperator(IElementCreationContext context, BinaryLogicalOperatorType defaultType) 
            : base(context, context.Owner.GetBooleanType())
        {
            ParameterA = context.Owner.CreateParameter("a", context.Owner.GetBooleanType());
            ParameterB = context.Owner.CreateParameter("b", context.Owner.GetBooleanType());

            Parameters.Add(ParameterA);
            Parameters.Add(ParameterB);

            var services = new[]
            {
                new BinaryLogicalOperatorService(BinaryLogicalOperatorType.And, "And", (a, b) => a && b),
                new BinaryLogicalOperatorService(BinaryLogicalOperatorType.Or, "Or", (a, b) => a || b),
            };

            foreach (var service in services)
            {
                AddAction(new ElementAction(service.Text, () => OperatorType = service.Type));
            }

            _services = services.ToDictionary(s => s.Type, s => s);

            OperatorType = defaultType;

            if (!string.IsNullOrWhiteSpace(context.Data))
            {
                var data = JsonConvert.DeserializeObject<BinaryLogicalOperatorData>(context.Data);

                OperatorType = data.OperatorType;
            }
        }
        public NotOperator(IElementCreationContext context)
            : base(context, context.Owner.GetBooleanType())
        {
            ParameterA = context.Owner.CreateParameter("a", context.Owner.GetVplTypeOrThrow(VplTypeId.Boolean), "Not");

            Parameters.Add(ParameterA);
        }
Example #3
0
        public NotOperator(IElementCreationContext context) 
            : base(context, context.Owner.GetBooleanType())
        {
            ParameterA = context.Owner.CreateParameter("a", context.Owner.GetVplTypeOrThrow(VplTypeId.Boolean), "Not");

            Parameters.Add(ParameterA);
        }
Example #4
0
        public AddToDate(IElementCreationContext context)
            : base(context, context.Owner.GetVplTypeOrThrow(VplTypeId.DateTime))
        {
            DateParameter = context.Owner.CreateParameter("date", context.Owner.GetVplTypeOrThrow(VplTypeId.DateTime),
                                                          "Date");

            DateParameter.Postfix = " + ";

            AmountParameter = context.Owner.CreateParameter("amount", context.Owner.GetFloatType());

            Parameters.Add(DateParameter);
            Parameters.Add(AmountParameter);

            _services = new OperationService[]
            {
                new OperationService(OperationType.Seconds, "Seconds", TimeSpan.FromSeconds),
                new OperationService(OperationType.Minutes, "Minutes", TimeSpan.FromMinutes),
                new OperationService(OperationType.Hours, "Hours", TimeSpan.FromHours),
                new OperationService(OperationType.Days, "Days", TimeSpan.FromDays),
            };

            Operation = OperationType.Seconds;

            if (!string.IsNullOrWhiteSpace(context.Data))
            {
                var data = JsonConvert.DeserializeObject <OperatorData>(context.Data);

                Operation = data.Operation;
            }

            foreach (var service in _services)
            {
                AddAction(new ElementAction(service.Text, () => Operation = service.Operation, () => Operation != service.Operation));
            }
        }
Example #5
0
        public AddToDate(IElementCreationContext context) 
            : base(context, context.Owner.GetVplTypeOrThrow(VplTypeId.DateTime))
        {
            DateParameter = context.Owner.CreateParameter("date", context.Owner.GetVplTypeOrThrow(VplTypeId.DateTime),
                "Date");

            DateParameter.Postfix = " + ";

            AmountParameter = context.Owner.CreateParameter("amount", context.Owner.GetFloatType());

            Parameters.Add(DateParameter);
            Parameters.Add(AmountParameter);

            _services = new OperationService[]
            {
                new OperationService(OperationType.Seconds, "Seconds", TimeSpan.FromSeconds),
                new OperationService(OperationType.Minutes, "Minutes", TimeSpan.FromMinutes),
                new OperationService(OperationType.Hours, "Hours", TimeSpan.FromHours),
                new OperationService(OperationType.Days, "Days", TimeSpan.FromDays),
            };

            Operation = OperationType.Seconds;

            if (!string.IsNullOrWhiteSpace(context.Data))
            {
                var data = JsonConvert.DeserializeObject<OperatorData>(context.Data);

                Operation = data.Operation;
            }

            foreach (var service in _services)
            {
                AddAction(new ElementAction(service.Text, () => Operation = service.Operation, () => Operation != service.Operation));
            }
        }
        public BinaryLogicalOperator(IElementCreationContext context, BinaryLogicalOperatorType defaultType)
            : base(context, context.Owner.GetBooleanType())
        {
            ParameterA = context.Owner.CreateParameter("a", context.Owner.GetBooleanType());
            ParameterB = context.Owner.CreateParameter("b", context.Owner.GetBooleanType());

            Parameters.Add(ParameterA);
            Parameters.Add(ParameterB);

            var services = new[]
            {
                new BinaryLogicalOperatorService(BinaryLogicalOperatorType.And, "And", (a, b) => a && b),
                new BinaryLogicalOperatorService(BinaryLogicalOperatorType.Or, "Or", (a, b) => a || b),
            };

            foreach (var service in services)
            {
                AddAction(new ElementAction(service.Text, () => OperatorType = service.Type));
            }

            _services = services.ToDictionary(s => s.Type, s => s);

            OperatorType = defaultType;

            if (!string.IsNullOrWhiteSpace(context.Data))
            {
                var data = JsonConvert.DeserializeObject <BinaryLogicalOperatorData>(context.Data);

                OperatorType = data.OperatorType;
            }
        }
Example #7
0
        public Block(IElementCreationContext context, string id) 
            : base(context)
        {
            _id = id;

            _elements = new Elements(context.Owner);
        }
        public Block(IElementCreationContext context, string id)
            : base(context)
        {
            _id = id;

            _elements = new Elements(context.Owner);
        }
Example #9
0
        public WaitStatement(IElementCreationContext context) 
            : base(context)
        {
            SecondsParameter = Owner.CreateParameter("seconds", Owner.GetFloatType(), "Wait", "Seconds");

            SecondsParameter.SetValue(5.0);

            Parameters.Add(SecondsParameter);
        }
 protected Operator(IElementCreationContext context, IVplType type)
     : base(context)
 {
     if (type == null)
     {
         throw new ArgumentNullException(nameof(type));
     }
     _type = type;
 }
        public WaitStatement(IElementCreationContext context)
            : base(context)
        {
            SecondsParameter = Owner.CreateParameter("seconds", Owner.GetFloatType(), "Wait", "Seconds");

            SecondsParameter.SetValue(5.0);

            Parameters.Add(SecondsParameter);
        }
Example #12
0
        public WhileStatement(IElementCreationContext context) 
            : base(context)
        {
            Condition = Owner.CreateParameter("condition", Owner.GetBooleanType());

            Block = Owner.CreateBlock("block", "While");

            Block.Parameters.Add(Condition);
            Blocks.Add(Block);
        }
Example #13
0
        public CallFunctionStatement(IElementCreationContext context)
            : base(context)
        {
            _behavior = new CommonFunctionBehavior(context, Parameters, "Call", this);

            AddActions(_behavior.Actions);

            BackgroundColor = Colors.Lavender;
            ForegroundColor = Colors.Black;
        }
        public EvaluateFunctionOperator(IElementCreationContext context) 
            : base(context, context.Owner.GetAnyType())
        {
            _behavior = new CommonFunctionBehavior(context, Parameters, "Evaluate", this);

            AddActions(_behavior.Actions);

            ForegroundColor = Colors.MediumSeaGreen;
            ForegroundColor = Colors.Black;
        }
        public RepeatStatement(IElementCreationContext context)
            : base(context)
        {
            Condition = Owner.CreateParameter("condition", Owner.GetFloatType());

            Block = Owner.CreateBlock("block", "Repeat");

            Block.Parameters.Add(Condition);
            Blocks.Add(Block);
        }
Example #16
0
        public CallFunctionStatement(IElementCreationContext context) 
            : base(context)
        {
            _behavior = new CommonFunctionBehavior(context, Parameters, "Call", this);

            AddActions(_behavior.Actions);

            BackgroundColor = Colors.Lavender;
            ForegroundColor = Colors.Black;
        }
Example #17
0
        public RepeatStatement(IElementCreationContext context) 
            : base(context)
        {
            Condition = Owner.CreateParameter("condition", Owner.GetFloatType());

            Block = Owner.CreateBlock("block", "Repeat");

            Block.Parameters.Add(Condition);
            Blocks.Add(Block);
        }
Example #18
0
        public WhileStatement(IElementCreationContext context)
            : base(context)
        {
            Condition = Owner.CreateParameter("condition", Owner.GetBooleanType());

            Block = Owner.CreateBlock("block", "While");

            Block.Parameters.Add(Condition);
            Blocks.Add(Block);
        }
Example #19
0
        public EvaluateFunctionOperator(IElementCreationContext context)
            : base(context, context.Owner.GetAnyType())
        {
            _behavior = new CommonFunctionBehavior(context, Parameters, "Evaluate", this);

            AddActions(_behavior.Actions);

            ForegroundColor = Colors.MediumSeaGreen;
            ForegroundColor = Colors.Black;
        }
Example #20
0
        public VariableSetter(IElementCreationContext context, Guid variableId) 
            : base(context)
        {
            if (variableId == Guid.Empty)
                throw new ArgumentException("variableId was default value.", nameof(variableId));

            _variable = context.Owner.GetVariableOrThrow(variableId);
            _variable.NameChanged += VariableNameChanged;
            _parameter = AddParameter(_variable);
        }
Example #21
0
        public VariableGetter(IElementCreationContext context, Guid variableId)
            : base(context)
        {
            if (variableId == Guid.Empty)
                throw new ArgumentException("variableId was default value.", nameof(variableId));

            _id = variableId;

            _variable = new Lazy<IVariable>(GetVariable);
        }
Example #22
0
        public Parameter(IElementCreationContext context, string id, IVplType type) 
            : base(context)
        {
            if (type == null) throw new ArgumentNullException(nameof(type));
            _id = id;
            _type = type;

            Value = type.DefaultValue;

            _editor = new Lazy<Visual>(type.CreateVisual);
        }
Example #23
0
        internal UnaryFloatOperator(IElementCreationContext context, Func<double, double> func, string label) 
            : base(context, context.Owner.GetFloatType())
        {
            if (func == null) throw new ArgumentNullException(nameof(func));

            _func = func;
            _label = label;

            Parameter = context.Owner.CreateParameter("a", context.Owner.GetFloatType());
            Parameters.Add(Parameter);
        }
        public VariableSetter(IElementCreationContext context, Guid variableId)
            : base(context)
        {
            if (variableId == Guid.Empty)
            {
                throw new ArgumentException("variableId was default value.", nameof(variableId));
            }

            _variable              = context.Owner.GetVariableOrThrow(variableId);
            _variable.NameChanged += VariableNameChanged;
            _parameter             = AddParameter(_variable);
        }
Example #25
0
        public VariableGetter(IElementCreationContext context, Guid variableId)
            : base(context)
        {
            if (variableId == Guid.Empty)
            {
                throw new ArgumentException("variableId was default value.", nameof(variableId));
            }

            _id = variableId;

            _variable = new Lazy <IVariable>(GetVariable);
        }
Example #26
0
        public VariableSetter(IElementCreationContext context) 
            : base(context)
        {
            if (string.IsNullOrWhiteSpace(context.Data))
                throw new ArgumentNullException($"Custom serialization data missing for {GetType().Name}");

            var data = JsonConvert.DeserializeObject<VariableSetterData>(context.Data);

            _variable = context.Owner.GetVariableOrThrow(data.VariableId);
            _variable.NameChanged += VariableNameChanged;
            _parameter = AddParameter(_variable);
        }
Example #27
0
        public VariableGetter(IElementCreationContext context)
            : base(context)
        {
            if (string.IsNullOrWhiteSpace(context.Data))
                throw new ArgumentNullException($"Custom serialization data missing for {GetType().Name}");

            var data = JsonConvert.DeserializeObject<VariableGetterData>(context.Data);

            _id = data.VariableId;

            _variable = new Lazy<IVariable>(GetVariable);
        }
Example #28
0
        public CommentStatement(IElementCreationContext context)
            : base(context)
        {
            Comment = context.Data;

            ForegroundColor = Colors.Black;
            BackgroundColor = Colors.Yellow;

            _commentView = new CommentView()
            {
                DataContext = this
            };
        }
        public CommentStatement(IElementCreationContext context)
            : base(context)
        {
            Comment = context.Data;

            ForegroundColor = Colors.Black;
            BackgroundColor = Colors.Yellow;

            _commentView = new CommentView()
            {
                DataContext = this
            };
        }
        internal CommonFunctionBehavior(IElementCreationContext context, Parameters parameters, string text, IElement parent)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }
            if (parent == null)
            {
                throw new ArgumentNullException(nameof(parent));
            }

            _owner      = context.Owner;
            _parameters = parameters;
            _text       = text;
            _parent     = parent;

            _labelView = new CallFunctionView()
            {
                DataContext = this
            };

            if (string.IsNullOrWhiteSpace(context.Data))
            {
                _model = new CallFunctionData();
            }
            else
            {
                _model = JsonConvert.DeserializeObject <CallFunctionData>(context.Data);

                var functionService = context.Owner.GetService <IFunctionService>();

                if (functionService == null)
                {
                    MessageBox.Show("No function service was provided.");
                    return;
                }

                //Get the function
                SelectFunction(functionService.GetFunction(_model.FunctionId));
            }

            _actions = new IElementAction[]
            {
                new ElementAction("Select function...", SelectFunction),
                new ElementAction("Go to definition...", GoToDefinition, CanGoToDefinition),
            };
        }
        public VariableSetter(IElementCreationContext context)
            : base(context)
        {
            if (string.IsNullOrWhiteSpace(context.Data))
            {
                throw new ArgumentNullException($"Custom serialization data missing for {GetType().Name}");
            }

            var data = JsonConvert.DeserializeObject <VariableSetterData>(context.Data);

            _variable              = context.Owner.GetVariableOrThrow(data.VariableId);
            _variable.NameChanged += VariableNameChanged;
            _parameter             = AddParameter(_variable);
        }
Example #32
0
        public VariableGetter(IElementCreationContext context)
            : base(context)
        {
            if (string.IsNullOrWhiteSpace(context.Data))
            {
                throw new ArgumentNullException($"Custom serialization data missing for {GetType().Name}");
            }

            var data = JsonConvert.DeserializeObject <VariableGetterData>(context.Data);

            _id = data.VariableId;

            _variable = new Lazy <IVariable>(GetVariable);
        }
Example #33
0
        public Parameter(IElementCreationContext context, string id, IVplType type)
            : base(context)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }
            _id   = id;
            _type = type;

            Value = type.DefaultValue;

            _editor = new Lazy <Visual>(type.CreateVisual);
        }
Example #34
0
        internal UnaryFloatOperator(IElementCreationContext context, Func <double, double> func, string label)
            : base(context, context.Owner.GetFloatType())
        {
            if (func == null)
            {
                throw new ArgumentNullException(nameof(func));
            }

            _func  = func;
            _label = label;

            Parameter = context.Owner.CreateParameter("a", context.Owner.GetFloatType());
            Parameters.Add(Parameter);
        }
Example #35
0
        protected Element(IElementCreationContext context)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));

            _owner = context.Owner;
            _factory = context.Factory;

            DeleteCommand = new RelayCommand(DeleteSelected, CanDelete);
            CopyCommand = new RelayCommand(Copy);
            CutCommand = new RelayCommand(Cut, CanDelete);
            PasteCommand = new RelayCommand(Paste, CanPaste);

            BackgroundColor = Colors.Plum;
            ForegroundColor = Colors.Black;
        }
Example #36
0
        public ForStatement(IElementCreationContext context)
            : base(context)
        {
            From = Owner.CreateParameter("from", Owner.GetFloatType(), null, " : ");
            To   = Owner.CreateParameter("to", Owner.GetFloatType(), null, " ; ");
            Step = Owner.CreateParameter("step", Owner.GetFloatType(), "step : ");

            Block = Owner.CreateBlock("block", "For");

            Block.Parameters.Add(From);
            Block.Parameters.Add(To);
            Block.Parameters.Add(Step);

            Blocks.Add(Block);
        }
Example #37
0
        protected Element(IElementCreationContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            _owner   = context.Owner;
            _factory = context.Factory;

            DeleteCommand = new RelayCommand(DeleteSelected, CanDelete);
            CopyCommand   = new RelayCommand(Copy);
            CutCommand    = new RelayCommand(Cut, CanDelete);
            PasteCommand  = new RelayCommand(Paste, CanPaste);

            BackgroundColor = Colors.Plum;
            ForegroundColor = Colors.Black;
        }
Example #38
0
        internal CommonFunctionBehavior(IElementCreationContext context, Parameters parameters, string text, IElement parent)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));
            if (parameters == null) throw new ArgumentNullException(nameof(parameters));
            if (parent == null) throw new ArgumentNullException(nameof(parent));

            _owner = context.Owner;
            _parameters = parameters;
            _text = text;
            _parent = parent;

            _labelView = new CallFunctionView()
            {
                DataContext = this
            };

            if (string.IsNullOrWhiteSpace(context.Data))
            {
                _model = new CallFunctionData();
            }
            else
            {
                _model = JsonConvert.DeserializeObject<CallFunctionData>(context.Data);

                var functionService = context.Owner.GetService<IFunctionService>();

                if (functionService == null)
                {
                    MessageBox.Show("No function service was provided.");
                    return;
                }

                //Get the function
                SelectFunction(functionService.GetFunction(_model.FunctionId));
            }

            _actions = new IElementAction[]
            {
                new ElementAction("Select function...", SelectFunction)
            };
        }
Example #39
0
        public BinaryOperator(IElementCreationContext context, BinaryOperatorType defaultOperatorType) 
            : base(context, context.Owner.GetFloatType())
        {
            var services = new []
            {
                new BinaryOperatorService(BinaryOperatorType.Addition, "+", (a, b) => a + b),
                new BinaryOperatorService(BinaryOperatorType.Subtraction, "-", (a, b) => a - b),
                new BinaryOperatorService(BinaryOperatorType.Multiplication, "*", (a, b) => a * b),
                new BinaryOperatorService(BinaryOperatorType.Division, "/", (a, b) => a / b),
                new BinaryOperatorService(BinaryOperatorType.ShiftLeft, "<<", (a, b) => a << b), 
                new BinaryOperatorService(BinaryOperatorType.ShiftRight, ">>", (a, b) => a >> b), 
                new BinaryOperatorService(BinaryOperatorType.BitwiseAnd, "&", (a , b) => a & b),
                new BinaryOperatorService(BinaryOperatorType.BitwiseOr, "|", (a , b) => a | b),
                new BinaryOperatorService(BinaryOperatorType.Modulus, "%", (a , b) => a % b),
            };

            foreach (var service in services)
            {
                AddAction(new ElementAction(service.Text, () => OperatorType = service.Type));
            }

            _services = services.ToDictionary(s => s.Type, s => s);

            ParameterA = context.Owner.CreateParameter("a", context.Owner.GetFloatType());
            ParameterB = context.Owner.CreateParameter("b", context.Owner.GetFloatType());

            Parameters.Add(ParameterA);
            Parameters.Add(ParameterB);

            Service = _services[BinaryOperatorType.Addition];

            OperatorType = defaultOperatorType;

            if (!string.IsNullOrWhiteSpace(context.Data))
            {
                var data = JsonConvert.DeserializeObject<BinaryOperatorData>(context.Data);

                OperatorType = data.OperatorType;
            }
        }
        public BinaryOperator(IElementCreationContext context, BinaryOperatorType defaultOperatorType)
            : base(context, context.Owner.GetFloatType())
        {
            var services = new []
            {
                new BinaryOperatorService(BinaryOperatorType.Addition, "+", (a, b) => a + b),
                new BinaryOperatorService(BinaryOperatorType.Subtraction, "-", (a, b) => a - b),
                new BinaryOperatorService(BinaryOperatorType.Multiplication, "*", (a, b) => a * b),
                new BinaryOperatorService(BinaryOperatorType.Division, "/", (a, b) => a / b),
                new BinaryOperatorService(BinaryOperatorType.ShiftLeft, "<<", (a, b) => a << b),
                new BinaryOperatorService(BinaryOperatorType.ShiftRight, ">>", (a, b) => a >> b),
                new BinaryOperatorService(BinaryOperatorType.BitwiseAnd, "&", (a, b) => a & b),
                new BinaryOperatorService(BinaryOperatorType.BitwiseOr, "|", (a, b) => a | b),
                new BinaryOperatorService(BinaryOperatorType.Modulus, "%", (a, b) => a % b),
            };

            foreach (var service in services)
            {
                AddAction(new ElementAction(service.Text, () => OperatorType = service.Type));
            }

            _services = services.ToDictionary(s => s.Type, s => s);

            ParameterA = context.Owner.CreateParameter("a", context.Owner.GetFloatType());
            ParameterB = context.Owner.CreateParameter("b", context.Owner.GetFloatType());

            Parameters.Add(ParameterA);
            Parameters.Add(ParameterB);

            Service = _services[BinaryOperatorType.Addition];

            OperatorType = defaultOperatorType;

            if (!string.IsNullOrWhiteSpace(context.Data))
            {
                var data = JsonConvert.DeserializeObject <BinaryOperatorData>(context.Data);

                OperatorType = data.OperatorType;
            }
        }
Example #41
0
        public ComparisonOperator(IElementCreationContext context, ComparisonOperatorType comparisonType) 
            : base(context, context.Owner.GetBooleanType())
        {
            ParameterA = Owner.CreateParameter("a", context.Owner.GetFloatType());
            ParameterB = Owner.CreateParameter("b", context.Owner.GetFloatType());

            Parameters.Add(ParameterA);
            Parameters.Add(ParameterB);

            _services = new[]
            {
                new ComparisonOperatorService(ComparisonOperatorType.LessThan, "<", (a, b) => a < b),
                new ComparisonOperatorService(ComparisonOperatorType.LessThanOrEqual, "<=", (a, b) => a <= b),
                new ComparisonOperatorService(ComparisonOperatorType.Equal, "=", (a, b) => a == b),
                new ComparisonOperatorService(ComparisonOperatorType.NotEqual, "<>", (a, b) => a != b),
                new ComparisonOperatorService(ComparisonOperatorType.GreaterThan, ">", (a, b) => a > b),
                new ComparisonOperatorService(ComparisonOperatorType.GreaterThanOrEqual, ">=", (a, b) => a >= b),
            };

            //Add actions so we can just change the type instead of having to recreate it.
            foreach (var service in _services)
            {
                AddAction(new ElementAction(service.Text, () => ComparisonType = service.ComparisonType, () => ComparisonType != service.ComparisonType));
            }

            ComparisonType = ComparisonOperatorType.Equal;

            if (!string.IsNullOrWhiteSpace(context.Data))
            {
                var data = JsonConvert.DeserializeObject<ComparisonOperatorData>(context.Data);

                ComparisonType = data.ComparisonType;
            }
            else
            {
                ComparisonType = comparisonType;
            }

        }
Example #42
0
        public IfElseStatement(IElementCreationContext context) 
            : base(context)
        {
            _data = new IfElseData();

            try
            {
                if (!string.IsNullOrWhiteSpace(context.Data))
                {
                    _data = JsonConvert.DeserializeObject<IfElseData>(context.Data);
                }

                if (_data.NumberOfIfs == 0)
                {
                    _data.NumberOfIfs = 1;
                }
            }
            catch (Exception ex)
            {
                //TODO: Add this to the IElementCreationContext error/warning interface that we have yet to add.
                Console.WriteLine(ex);
            }

            for (var index = 0; index < _data.NumberOfIfs; index++)
            {
                AddIfClause(index);
            }

            if (_data.IncludeElse)
            {
               AddElse();
            }

            //Add actions for adding / removing else clauses.
            this.AddAction("Add 'Else If'", AddIfClause);
            this.AddAction("Remove last 'Else If'", RemoveLastIf, CanRemoveLastIf);
            this.AddAction("Add 'Else'", AddElse, CanAddElse);
            this.AddAction("Remove 'Else'", RemoveElse, CanRemoveElse);
        }
        public IfElseStatement(IElementCreationContext context)
            : base(context)
        {
            _data = new IfElseData();

            try
            {
                if (!string.IsNullOrWhiteSpace(context.Data))
                {
                    _data = JsonConvert.DeserializeObject <IfElseData>(context.Data);
                }

                if (_data.NumberOfIfs == 0)
                {
                    _data.NumberOfIfs = 1;
                }
            }
            catch (Exception ex)
            {
                //TODO: Add this to the IElementCreationContext error/warning interface that we have yet to add.
                Console.WriteLine(ex);
            }

            for (var index = 0; index < _data.NumberOfIfs; index++)
            {
                AddIfClause(index);
            }

            if (_data.IncludeElse)
            {
                AddElse();
            }

            //Add actions for adding / removing else clauses.
            this.AddAction("Add 'Else If'", AddIfClause);
            this.AddAction("Remove last 'Else If'", RemoveLastIf, CanRemoveLastIf);
            this.AddAction("Add 'Else'", AddElse, CanAddElse);
            this.AddAction("Remove 'Else'", RemoveElse, CanRemoveElse);
        }
Example #44
0
        public ComparisonOperator(IElementCreationContext context, ComparisonOperatorType comparisonType)
            : base(context, context.Owner.GetBooleanType())
        {
            ParameterA = Owner.CreateParameter("a", context.Owner.GetFloatType());
            ParameterB = Owner.CreateParameter("b", context.Owner.GetFloatType());

            Parameters.Add(ParameterA);
            Parameters.Add(ParameterB);

            _services = new[]
            {
                new ComparisonOperatorService(ComparisonOperatorType.LessThan, "<", (a, b) => a < b),
                new ComparisonOperatorService(ComparisonOperatorType.LessThanOrEqual, "<=", (a, b) => a <= b),
                new ComparisonOperatorService(ComparisonOperatorType.Equal, "=", (a, b) => a == b),
                new ComparisonOperatorService(ComparisonOperatorType.NotEqual, "<>", (a, b) => a != b),
                new ComparisonOperatorService(ComparisonOperatorType.GreaterThan, ">", (a, b) => a > b),
                new ComparisonOperatorService(ComparisonOperatorType.GreaterThanOrEqual, ">=", (a, b) => a >= b),
            };

            //Add actions so we can just change the type instead of having to recreate it.
            foreach (var service in _services)
            {
                AddAction(new ElementAction(service.Text, () => ComparisonType = service.ComparisonType, () => ComparisonType != service.ComparisonType));
            }

            ComparisonType = ComparisonOperatorType.Equal;

            if (!string.IsNullOrWhiteSpace(context.Data))
            {
                var data = JsonConvert.DeserializeObject <ComparisonOperatorData>(context.Data);

                ComparisonType = data.ComparisonType;
            }
            else
            {
                ComparisonType = comparisonType;
            }
        }
Example #45
0
        public Cast(IElementCreationContext context)
            : base(context)
        {
            TypeSelected(VplTypeId.Any);

            //Add the action.
            AddAction(new ElementAction("Select Type...", SelectType));

            try
            {
                if (!string.IsNullOrWhiteSpace(context.Data))
                {
                    var data = JsonConvert.DeserializeObject <OperatorData>(context.Data);

                    TypeSelected(data.VplTypeId);
                }
            }
            catch (Exception ex)
            {
                //TODO: Add something to IElementCreationContext to log this to
                Console.WriteLine(ex);
            }
        }
Example #46
0
        public Cast(IElementCreationContext context)
            : base(context)
        {
            TypeSelected(VplTypeId.Any);

            //Add the action.
            AddAction(new ElementAction("Select Type...", SelectType));

            try
            {
                if (!string.IsNullOrWhiteSpace(context.Data))
                {
                    var data = JsonConvert.DeserializeObject<OperatorData>(context.Data);

                    TypeSelected(data.VplTypeId);
                }
            }
            catch (Exception ex)
            {
                //TODO: Add something to IElementCreationContext to log this to
                Console.WriteLine(ex);
            }
        }
Example #47
0
 protected Statement(IElementCreationContext context) 
     : base(context)
 {
     BackgroundColor = Colors.CornflowerBlue;
     ForegroundColor = Colors.White;
 }
Example #48
0
 public IElement Create(IElementCreationContext context)
 {
     return _factory(context);
 }
Example #49
0
 public UtcNow(IElementCreationContext context)
     : base(context, context.Owner.GetVplTypeOrThrow(VplTypeId.DateTime))
 {
 }
Example #50
0
 public Now(IElementCreationContext context)
     : base(context, context.Owner.GetVplTypeOrThrow(VplTypeId.DateTime))
 {
 }
 protected CompoundStatement(IElementCreationContext context)
     : base(context)
 {
 }
Example #52
0
 protected Operator(IElementCreationContext context, IVplType type)
     : base(context)
 {
     if (type == null) throw new ArgumentNullException(nameof(type));
     _type = type;
 }
Example #53
0
 protected OperatorBase(IElementCreationContext context)
     : base(context)
 {
 }
Example #54
0
 public CommentViewModel(IElementCreationContext context)
     : base(context)
 {
     Comment = context.Data;
 }
Example #55
0
 public CommentViewModel(IElementCreationContext context)
     : base(context)
 {
     Comment = context.Data;
 }
 public Annotation(IElementCreationContext context) 
     : base(context)
 {
 }
Example #57
0
        public Alert(IElementCreationContext context) : base(context)
        {
            _messageParameter = context.Owner.CreateParameter("message", context.Owner.GetStringType());

            Parameters.Add(_messageParameter);
        }
Example #58
0
 protected CompoundStatement(IElementCreationContext context)
     : base(context)
 {
 }
 protected OperatorBase(IElementCreationContext context)
     : base(context)
 {
 }
Example #60
0
        public Alert(IElementCreationContext context) : base(context)
        {
            _messageParameter = context.Owner.CreateParameter("message", context.Owner.GetStringType());

            Parameters.Add(_messageParameter);
        }