Beispiel #1
0
 public VrcParameterDefinition(AvatarDefinition parent, string name, ParameterValueType type) : base(parent, name)
 {
     Parent     = parent;
     Parameters = parent.VrcExpressionParameters;
     Type       = type;
     Name       = name;
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ModulationDepthRangeParameter"/> with the specified
 /// number of half-steps and cents and type of the data.
 /// </summary>
 /// <param name="halfSteps">The number of half-steps to tune by.</param>
 /// <param name="cents">the number of cents to tune by.</param>
 /// <param name="valueType">The type of parameter's data which defines whether it
 /// represents exact value, increment or decrement.</param>
 /// <exception cref="InvalidEnumArgumentException"><paramref name="valueType"/> specified an invalid value.</exception>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="cents"/> is out of
 /// [<see cref="MinCents"/>; <see cref="MaxCents"/>] range.</exception>
 public ModulationDepthRangeParameter(SevenBitNumber halfSteps, float cents, ParameterValueType valueType)
     : this()
 {
     HalfSteps = halfSteps;
     Cents     = cents;
     ValueType = valueType;
 }
Beispiel #3
0
 private QuotedStringParameterValue(string value)
 {
     UnitdefUtil.ArgumentMustNotBeNull(value, "string value");
     StringValue = value;
     TupleValue  = null;
     Type        = ParameterValueType.QuotedString;
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ModulationDepthRangeParameter"/> with the specified
 /// number of half-steps and cents and type of the data.
 /// </summary>
 /// <param name="halfSteps">The number of half-steps of the sensitivity range.</param>
 /// <param name="cents">the number of cents of the sensitivity range.</param>
 /// <param name="valueType">The type of parameter's data which defines whether it
 /// represents exact value, increment or decrement.</param>
 /// <exception cref="InvalidEnumArgumentException"><paramref name="valueType"/> specified an invalid value.</exception>
 public PitchBendSensitivityParameter(SevenBitNumber halfSteps, SevenBitNumber cents, ParameterValueType valueType)
     : this()
 {
     HalfSteps = halfSteps;
     Cents     = cents;
     ValueType = valueType;
 }
Beispiel #5
0
 public void UpdateFrom(Parameter param)
 {
     this.Name        = param.Name;
     this.Key         = param.Key;
     this.Description = param.Description;
     this.IsRequired  = param.IsRequired;
     this.IsEncoded   = param.IsEncoded;
     this.Value       = param.Value;
     this.ValueType   = param.ValueType;
 }
Beispiel #6
0
        public VrcParameterDefinition Create(AvatarDefinition parent, string name, ParameterValueType type)
        {
            if (!_parameterCache.TryGetValue(name, out var instance))
            {
                instance = new VrcParameterDefinition(parent, name, type);
                _parameterCache[name] = instance;
            }

            return(instance);
        }
        public IActionResult Manage(int submoduleId, int id = 0)
        {
            var submoduleParameter = id > 0 ? _context.SubmoduleParameter.Find(id) : new SubmoduleParameter()
            {
                SubmoduleId = submoduleId
            };

            ViewBag.ParameterValueTypes = ParameterValueType.GetAll();

            return(View(submoduleParameter));
        }
Beispiel #8
0
 public void CreateFrom(Parameter param)
 {
     this.Name = param.Name;
     this.Key  = param.Key;
     //this.Key = ParameterHelper.ToKey(param.Name);
     this.ParentId    = param.ParentId;
     this.ParentType  = param.ParentType;
     this.Description = param.Description;
     this.IsRequired  = param.IsRequired;
     this.IsEncoded   = param.IsEncoded;
     this.Value       = param.Value;
     this.ValueType   = param.ValueType;
 }
Beispiel #9
0
        public void AddParameter(string name, ParameterType type, ParameterValueType value_type, object value = null)
        {
            ParameterInfo info = new ParameterInfo
            {
                Name      = name,
                Direction = type,
                Type      = value_type,
                HasValue  = !(value is null),
                Value     = value
            };

            Parameters.Add(info.Name, info);
        }
        internal static DbType ToDbType(this ParameterValueType type)
        {
            switch (type)
            {
            case ParameterValueType.Int:
                return(DbType.Int32);

            case ParameterValueType.String:
                return(DbType.String);

            case ParameterValueType.DateTime:
                return(DbType.DateTime);
            }
            return(DbType.Object);
        }
Beispiel #11
0
 public AnimatorParameterDefinition(AnimatorDefinition parent, string name, ParameterValueType type) : base(parent, name)
 {
     Parent = parent;
     Type   = type;
     Name   = name;
 }
Beispiel #12
0
    private void ParameterValueTypeChanged(ParameterValueType valueType)
    {
        string nodePath = SelectedNode;

        int parameterOffset = nodePath.LastIndexOf("@", System.StringComparison.Ordinal);
        string functionPath = nodePath.Substring(0, parameterOffset - 1);
        string parameterName = nodePath.Substring(parameterOffset + 1);

        XElement functionNode = TreeHelper.FindByPath(FunctionMarkup.Root, functionPath);
        XElement parameterNode = functionNode.Elements(ParameterNodeXName).FirstOrDefault(element => element.Attribute("name").Value == parameterName);

        string nodeID = TreePathToIdMapping[nodePath];

        if (_state.AllowSelectingInputParameters)
        {
            if (valueType != ParameterValueType.InputParameter)
            {
                InputParameterNodeIDs.Remove(nodeID);
            }
            else
            {
                if (!InputParameterNodeIDs.Contains(nodeID))
                {
                    InputParameterNodeIDs.Add(nodeID);
                }
            }
        }

        if (valueType == ParameterValueType.Default)
        {
            BtnDefaultClicked(parameterNode);
        }
        else if (valueType == ParameterValueType.Constant)
        {
            BtnConstantClicked(functionNode, parameterNode, parameterName);
        }
        else if (valueType == ParameterValueType.FunctionCall)
        {
            BtnFunctionCallClicked(functionNode, parameterNode, parameterName);
        }
        else if (valueType == ParameterValueType.InputParameter)
        {
            BtnInputParameterClicked(functionNode, parameterNode, parameterName);
        }
    }
 /// <summary>
 /// Initializes a new instance of the <see cref="ChannelCoarseTuningParameter"/> with the specified
 /// number of half-steps and type of this number.
 /// </summary>
 /// <param name="halfSteps">Number of half-steps to tune by.</param>
 /// <param name="valueType">The type of parameter's data which defines whether it
 /// represents exact value, increment or decrement.</param>
 /// <exception cref="InvalidEnumArgumentException"><paramref name="valueType"/> specified an invalid value.</exception>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="halfSteps"/> is out of
 /// [<see cref="MinHalfSteps"/>; <see cref="MaxHalfSteps"/>] range.</exception>
 public ChannelCoarseTuningParameter(sbyte halfSteps, ParameterValueType valueType)
     : this()
 {
     HalfSteps = halfSteps;
     ValueType = valueType;
 }
Beispiel #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChannelFineTuningParameter"/> with the specified
 /// number of cents and type of this number.
 /// </summary>
 /// <param name="cents">The number of cents to tune by.</param>
 /// <param name="valueType">The type of parameter's data which defines whether it
 /// represents exact value, increment or decrement.</param>
 /// <exception cref="InvalidEnumArgumentException"><paramref name="valueType"/> specified an invalid value.</exception>
 /// <exception cref="ArgumentOutOfRangeException"><paramref name="cents"/> is out of
 /// [<see cref="MinCents"/>; <see cref="MaxCents"/>] range.</exception>
 public ChannelFineTuningParameter(float cents, ParameterValueType valueType)
     : this()
 {
     Cents     = cents;
     ValueType = valueType;
 }
        public IActionResult Manage(SubmoduleParameter submoduleParameter)
        {
            switch (submoduleParameter.Type)
            {
            case ParameterValueType.Bool:
                if (!bool.TryParse(submoduleParameter.Value, out bool boolValue))
                {
                    ModelState.AddModelError("Value", string.Format("{0} is not a valid boolean value.", submoduleParameter.Value));
                }
                break;

            case ParameterValueType.DateTime:
                if (!DateTime.TryParse(submoduleParameter.Value, out DateTime dateTimeValue))
                {
                    ModelState.AddModelError("Value", string.Format("{0} is not a valid datetime value.", submoduleParameter.Value));
                }
                break;

            case ParameterValueType.Decimal:
                if (!decimal.TryParse(submoduleParameter.Value, out decimal decimalValue))
                {
                    ModelState.AddModelError("Value", string.Format("{0} is not a valid decimal value.", submoduleParameter.Value));
                }
                break;

            case ParameterValueType.Integer:
                if (!int.TryParse(submoduleParameter.Value, out int integerValue))
                {
                    ModelState.AddModelError("Value", string.Format("{0} is not a valid integer value.", submoduleParameter.Value));
                }
                break;

            default:
                ModelState.AddModelError("Error", "A valid value type required.");
                break;
            }

            if (!ModelState.IsValid)
            {
                ViewBag.ParameterValueTypes = ParameterValueType.GetAll();

                return(View(submoduleParameter));
            }

            var persistentSubmoduleParameter = submoduleParameter.Id > 0 ? _context.SubmoduleParameter.Find(submoduleParameter.Id) : new SubmoduleParameter();

            persistentSubmoduleParameter.Name        = submoduleParameter.Name;
            persistentSubmoduleParameter.Description = submoduleParameter.Description;
            persistentSubmoduleParameter.IsActive    = submoduleParameter.IsActive;
            persistentSubmoduleParameter.Type        = submoduleParameter.Type;
            persistentSubmoduleParameter.Value       = submoduleParameter.Value;
            persistentSubmoduleParameter.UpdatedDate = DateTime.Now;
            persistentSubmoduleParameter.CreatedDate = submoduleParameter.Id > 0 ? submoduleParameter.CreatedDate : DateTime.Now;

            if (persistentSubmoduleParameter.Id == 0)
            {
                _context.Entry(submoduleParameter).State = Microsoft.EntityFrameworkCore.EntityState.Added;
            }

            if (_context.SaveChanges() > 0)
            {
                TempData["SuccessAlert"] = String.Format("{0} is successfully saved.", submoduleParameter.Name);
            }

            else
            {
                TempData["ErrorAlert"] = String.Format("An error occured while saving {0}.", submoduleParameter.Name);
            }

            return(RedirectToAction("List", new { submoduleId = submoduleParameter.SubmoduleId }));
        }
 public TuningBankSelectParameter(SevenBitNumber bankNumber, ParameterValueType valueType)
     : this()
 {
     BankNumber = bankNumber;
     ValueType  = valueType;
 }
 public TuningProgramChangeParameter(SevenBitNumber programNumber, ParameterValueType valueType)
     : this()
 {
     ProgramNumber = programNumber;
     ValueType     = valueType;
 }
Beispiel #18
0
 public Parameter() : base()
 {
     this.IsEncoded  = false;
     this.ValueType  = ParameterValueType.String;
     this.IsRequired = false;
 }
 TupleParameterValue(ITuple tuple)
 {
     UnitdefUtil.ArgumentMustNotBeNull(tuple, "tuple");
     TupleValue = tuple;
     Type       = ParameterValueType.Tuple;
 }
Beispiel #20
0
        /// <summary>
        /// Сохранить параметры операций базового объекта танк.
        /// </summary>
        /// <param name="objName">Имя объекта для записи</param>
        /// <param name="prefix">Отступ</param>
        /// <param name="modes">Операции объекта</param>
        /// <returns></returns>
        public string SaveOperationsParameters(TechObject obj, string objName,
                                               string prefix, List <Mode> modes)
        {
            var res = "";

            foreach (Mode mode in modes)
            {
                var baseOperation = mode.BaseOperation;
                if (baseOperation.Properties.Count == 0)
                {
                    continue;
                }

                string paramsForSave = "";
                foreach (var parameter in baseOperation.Properties)
                {
                    bool isEmpty = parameter.IsEmpty ||
                                   parameter.Value == "" ||
                                   parameter.NeedDisable;
                    if (isEmpty)
                    {
                        continue;
                    }

                    ParameterValueType type =
                        GetParameterValueType(obj, parameter);
                    switch (type)
                    {
                    case ParameterValueType.Boolean:
                        paramsForSave += $"{prefix}{parameter.LuaName} = " +
                                         $"{parameter.Value},\n";
                        break;

                    case ParameterValueType.Device:
                        paramsForSave += $"{prefix}{parameter.LuaName}" +
                                         $" = prg.control_modules.{parameter.Value},\n";
                        break;

                    case ParameterValueType.Number:
                        paramsForSave += GetNumberParameterStringForSave(
                            prefix, parameter, mode);
                        break;

                    case ParameterValueType.Parameter:
                        paramsForSave += $"{prefix}{parameter.LuaName} = " +
                                         $"{objName}.PAR_FLOAT.{parameter.Value},\n";
                        break;

                    case ParameterValueType.Other:
                        paramsForSave += $"{prefix}{parameter.LuaName} = " +
                                         $"{parameter.Value},\n";
                        break;
                    }
                }

                bool needSaveParameters = paramsForSave != "";
                if (needSaveParameters)
                {
                    res += $"{objName}.{baseOperation.LuaName} =\n";
                    res += prefix + "{\n";
                    res += paramsForSave;
                    res += prefix + "}\n";
                }
            }

            return(res);
        }