using System; using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; using System.Runtime.CompilerServices; using System.Text.Json.Serialization; using System.Windows; using System.Windows.Media; using static QuikDawEditor.EDITING.VstMethods; namespace QuikDawEditor.VST; public class VstFavorite : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged([CallerMemberName] String propertyName = "") { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } [JsonConstructor] public VstFavorite() { } public VstFavorite(string itemType, VstPluginReference pluginRef = null) { ItemType = itemType; switch (itemType) { case "Folder": FolderName = "New folder"; break; case "Plugin": myPluginRef = pluginRef; break; } } public string ItemType { get; set; } public ObservableCollection VstFavorites { get; set; } = new ObservableCollection(); public VstPluginReference myPluginRef { get; set; } public bool ExistsVstFx { get { return ItemType == "Folder" || ScannedVstEffectReferences.Where(svir=>svir.VstDllFileFullPath == myPluginRef.VstDllFileFullPath).Count() > 0; } } public bool ExistsVsti { get { return ItemType == "Folder" || ScannedVstInstrumentReferences.Where(svir=>svir.VstDllFileFullPath == myPluginRef.VstDllFileFullPath).Count() > 0; } } [JsonIgnore(Condition = JsonIgnoreCondition.Always)] public SolidColorBrush Background { get; set; } private SolidColorBrush DisabledPluginBrush = new SolidColorBrush(Color.FromArgb(100, 180, 160, 160)); public Uri iconImageSource { get { return new Uri("pack://application:,,,/EDITING/images/" + (ItemType == "Folder" ? "FolderIcon.png" : "Synth.png"), UriKind.RelativeOrAbsolute); } } public FontWeight FontWeight { get { return ItemType == "Folder" ? FontWeights.Bold : FontWeights.Normal; } } public SolidColorBrush Foreground { get { return !(ExistsVstFx | ExistsVsti) ? DisabledPluginBrush : ( ItemType == "Folder" ? Brushes.Orange : Brushes.White); } } private string _FolderName; public string FolderName { get { return _FolderName; } set { _FolderName = value; NotifyPropertyChanged(nameof(DisplayName)); } } private bool _IsExpanded = false; public bool IsExpanded { get { return _IsExpanded; } set { _IsExpanded = value; NotifyPropertyChanged(nameof(IsExpanded)); } } public string DisplayName { get { return ItemType == "Folder" ? FolderName : (myPluginRef == null ? "NULL VST" : myPluginRef.PluginName); }} public string DisplayDescription { get { return ItemType == "Folder" ? "" : (myPluginRef == null ? "NULL VST" : myPluginRef.PluginCategory); } } }