private void OnRationalTextChanged(object sender, RoutedEventArgs e) { if (_settingInternally) { return; // we should call validate later } if (sender is TextBox tb) { // validate rational //Rational r = Rational.Parse(tb.Text); //SetRationalError(tb, r.IsDefault() ? "Invalid Rational" : null); // reset cents text - we will set exact (default) cents value in OnRationalLostFocus int rowIndex = Grid.GetRow(tb); RowControls cs = GetRowControls(rowIndex); cs.cents.Text = ""; Changed?.Invoke(); } }
public AssetTabControl(BinaryFileType binaryFileType, AssetType assetType, string openDialogFilter, string assetTypeJsonFileName) { InitializeComponent(); AssetType = assetType; List <AbstractAsset> assets = AssetHandler.Instance.GetAssets(binaryFileType, assetTypeJsonFileName).ToList(); int i = 0; foreach (AbstractAsset asset in assets) { AssetRowControl rowHandler = new AssetRowControl(asset, assetType, i++ % 2 == 0, openDialogFilter); RowControls.Add(rowHandler); } AllFilters = RowControls.Select(a => a.Asset).SelectMany(a => a.Tags ?? new List <string>()).Where(t => !string.IsNullOrEmpty(t)).Distinct().OrderBy(s => s); FiltersCount = AllFilters.Count(); FilterHighlightColor = EditorUtils.FromRgbTuple(assetType.GetColor()) * 0.25f; Previewer = assetType switch { AssetType.Audio => new AudioPreviewerControl(), AssetType.Model => new ModelPreviewerControl(), AssetType.ModelBinding => new ModelBindingPreviewerControl(), AssetType.Particle => new ParticlePreviewerControl(), AssetType.Shader => new ShaderPreviewerControl(), AssetType.Texture => new TexturePreviewerControl(), _ => throw new NotSupportedException($"Previewer control for type {assetType} is not supported."), }; MainGrid.Children.Add(Previewer); if (assetType == AssetType.Audio) { StackPanelLoudness.Visibility = Visibility.Visible; ColumnDefinitionLoudness.Width = new GridLength(96); } }
private float GetRowCents(RowControls cs) { return((float)cs.cents.Value); }
private Rational GetRowRational(RowControls cs) { return(Rational.Parse(cs.rational.Text)); }
public void SetRationalError(int rowIndex, string error) { RowControls cs = GetRowControls(rowIndex); MainWindow.SetControlTip(cs.rational, null, error); }
public List <AbstractAsset> GetAssets() => RowControls.Select(a => a.Asset).ToList();