public DisplayPreferences(string id, Folder folder) { this.Id = new Guid(id); Folder = folder; ArrayList list = new ArrayList(); foreach (ViewType v in Enum.GetValues(typeof(ViewType))) list.Add(ViewTypeNames.GetName(v)); viewType.Options = list; try { this.viewType.Chosen = folder.DisplayPreferences != null ? folder.DisplayPreferences.ViewType ?? Config.Instance.DefaultViewType.ToString() : Config.Instance.DefaultViewType.ToString(); } catch (ArgumentException) { Logging.Logger.ReportError("Invalid view type stored for {0}. Setting to Poster.", folder.Name ?? folder.GetType().Name); viewType.Chosen = Localization.LocalizedStrings.Instance.GetString("PosterDispPref"); } //set our dynamic choice options this.sortDict = folder.SortOrderOptions; this.sortOrders.Options = sortDict.Keys.ToArray(); this.indexDict = folder.IndexByOptions; this.indexBy.Options = folder.IndexByOptions.Keys.ToArray(); verticalScroll = new BooleanChoice {Value = folder.DisplayPreferences != null && folder.DisplayPreferences.ScrollDirection == ScrollDirection.Vertical}; useBanner = new BooleanChoice(); showLabels = new BooleanChoice(); useCoverflow = new BooleanChoice {Value = false}; useBackdrop = new BooleanChoice {Value = folder.DisplayPreferences != null ? folder.DisplayPreferences.ShowBackdrop : Config.Instance.ShowBackdrop}; if (folder.DisplayPreferences != null) { var width = folder.DisplayPreferences.PrimaryImageWidth > 0 ? folder.DisplayPreferences.PrimaryImageWidth : Config.Instance.DefaultPosterSize.Width; var height = folder.DisplayPreferences.PrimaryImageHeight > 0 ? folder.DisplayPreferences.PrimaryImageHeight : Config.Instance.DefaultPosterSize.Height; customParms = folder.DisplayPreferences.CustomPrefs ?? new Dictionary<string, string>(); thumbConstraint = new SizeRef(new Size(width, height)); useBanner.Value = (customParms.GetValueOrDefault("MBCUseBanner", "false") == "true"); showLabels.Value = (customParms.GetValueOrDefault("MBCShowLabels", "false") == "true"); try { if (Config.Instance.RememberIndexing) indexBy.Chosen = folder.DisplayPreferences.IndexBy; } catch { indexBy.Chosen = Localization.LocalizedStrings.Instance.GetString("NoneDispPref"); } } try { sortOrders.Chosen = folder.DisplayPreferences != null ? folder.DisplayPreferences.SortBy ?? "Name" : "Name"; } catch (ArgumentException) { Logging.Logger.ReportError("Invalid sort by stored for {0}. Setting to Name.", folder.Name ?? folder.GetType().Name); sortOrders.Chosen = Localization.LocalizedStrings.Instance.GetString("NameDispPref"); } ListenForChanges(); }
static void RunActionRecursively(string desc, Folder folder, Action<BaseItem> action) { Console.Out.WriteLine("Refreshing Folder: " + folder.Path); Console.Out.WriteLine("{0} - {1} : {2} {3} (t) {4}", desc, folder.GetType(), folder.Name, folder.Path, TimeSinceStart()); action(folder); foreach (var item in folder.RecursiveChildren.OrderByDescending(i => i.DateModified)) { Console.Out.WriteLine("{0} - {1} : {2} {3} (t) {4}", desc ,item.GetType(), item.Name, item.Path, TimeSinceStart()); action(item); } }