public bool TrySet(int i, int j, string newVal) { double res; if (!double.TryParse(newVal, out res)) { Input[i, j].Foreground = Brushes.Red; return(false); } Input[i, j].Foreground = Brushes.Black; Values[i, j] = res; ParamChanged?.Invoke(Name, Values); return(true); }
public void Set(double[,] values) { int rows = Math.Min(values.GetLength(0), Values.GetLength(0)); int columns = Math.Min(values.GetLength(1), Values.GetLength(1)); for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { Values[i, j] = values[i, j]; Input[i, j].Text = values[i, j].ToString(); } } ParamChanged?.Invoke(Name, Values); }
public void CreateNewParam(Enum param, float value, bool logWarning = false) { if (_params.ContainsKey(param)) { _params[param] = value; ParamChanged?.Invoke(param, value); if (logWarning) { Debug.LogWarning($"{this} already has {param} param"); } return; } _params.Add(param, value); ParamChanged?.Invoke(param, value); if (logWarning) { Debug.LogWarning($"{this} has no {param} param (created now)"); } }
public float this[Enum param] { get { if (_params.ContainsKey(param)) { return(_params[param]); } CreateNewParam(param, 0f, true); return(0f); } set { if (_params.ContainsKey(param)) { _params[param] = value; ParamChanged?.Invoke(param, value); return; } CreateNewParam(param, value, true); } }
protected virtual void OnChanged() { ParamChanged?.Invoke(this, EventArgs.Empty); }