Esempio n. 1
0
        private void UpdateTarget(KeyValuePair <int, double> position)
        {
            Models.Parameter p = null;
            foreach (Models.Parameter parameter in ParameterData.ParameterList)
            {
                int pos = parameter.Position.Position;
                if (pos > position.Key)
                {
                    continue;
                }
                if (p is null)
                {
                    p = parameter;
                }
                else if (pos > p.Position.Position)
                {
                    p = parameter;
                }
            }

            _target = p;
            if (_target is null)
            {
                _hitTarget = false;
            }
            else
            {
                _hitTarget = position.Key == _target.Position.Position;
            }
        }
Esempio n. 2
0
        public IEnumerable <IParameter> GetParameters()
        {
            foreach (var parameter in Object[parameters])
            {
                var model = new Models.Parameter()
                {
                    Name = ((JProperty)parameter).Name
                };

                foreach (var child in parameter.Children())
                {
                    if (!child["type"].IsNullOrEmpty())
                    {
                        model.Type = child["type"]?.Value <string>();
                    }

                    if (!child["defaultValue"].IsNullOrEmpty())
                    {
                        var defaultValue = child["defaultValue"]?.Value <string>();

                        if (!CommandHelper.CheckIfIsCommand(defaultValue))
                        {
                            if (!string.IsNullOrEmpty(model.Type))
                            {
                                switch (model.Type)
                                {
                                case "string":
                                    model.DefaultParameter = child["defaultValue"]?.Value <string>();
                                    break;

                                case "int":
                                    model.DefaultParameter = child["defaultValue"]?.Value <int>();
                                    break;

                                case "bool":
                                    model.DefaultParameter = child["defaultValue"]?.Value <bool>();
                                    break;

                                default:
                                    model.DefaultParameter = defaultValue;
                                    break;
                                }
                            }
                            else
                            {
                                model.DefaultParameter = defaultValue;
                            }
                        }
                    }
                    if (!child["allowedValues"].IsNullOrEmpty())
                    {
                        model.AllowedValues = child["allowedValues"]?.ToObject <string[]>();
                    }
                }

                yield return(model);
            }
        }
Esempio n. 3
0
 public CallableParameterConfig(Models.Parameter property)
 {
     this.Value = property;
 }
Esempio n. 4
0
        private void UpdateData(double x, KeyValuePair <int, double> position)
        {
            if (_target is null)
            {
                return;
            }

            if (!_isMouseDown)
            {
                // Idle
                // TODO
                return;
            }
            switch (EditMode.Mode)
            {
            case EditModeEnum.Pencil:
            {
                if (_hitTarget)
                {
                    _target.Value.Position = Posit <double> .GetValueFromViewer(position.Value, VerticalScross,
                                                                                ActualHeight, ParameterData.VerticalTotal).Position;

                    UpdateView();
                }
                else
                {
                    Models.Parameter parameter = new Models.Parameter(
                        new Posit <int>(ParameterData.HorizontalTotal, position.Key, 0),
                        Posit <double> .GetValueFromViewer(position.Value, VerticalScross, ActualHeight, ParameterData.VerticalTotal));
                    ParameterData.ParameterList.Add(parameter);
                    FrameParameterContainer.Children.Add(parameter);
                    UpdateView();
                }
                break;
            }

            case EditModeEnum.Eraser:
            {
                if (_hitTarget)
                {
                    FrameParameterContainer.Children.Remove(_target);
                    ParameterData.ParameterList.Remove(_target);
                    UpdateView();
                }
                break;
            }

            case EditModeEnum.Playback:
            {
                PlaybackView.Current.SetPosition(Posit <int> .GetPositFromViewer(x, HorizontalScross,
                                                                                 ActualWidth, ParameterData.HorizontalTotal));
                break;
            }

            default:     // Arrow
            {
                DragRect(x);
                break;
            }
            }
        }