private void ApplySort() { List <AssetRowControl> sorted = SortRowControlHandlers(); for (int i = 0; i < sorted.Count; i++) { AssetRowControl arc = AssetEditor.Items.OfType <AssetRowControl>().First(arc => arc.Asset == sorted[i].Asset); AssetEditor.Items.Remove(arc); AssetEditor.Items.Insert(i, arc); } SetAssetEditorBackgroundColors(AssetEditor.Items); }
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); } }