public DisplayPreferences(Guid id) { this.Id = id; ArrayList list = new ArrayList(); foreach (ViewType v in Enum.GetValues(typeof(ViewType))) { list.Add(ViewTypeNames.GetName(v)); } viewType.Options = list; this.viewType.Chosen = ViewTypeNames.GetName(Config.Instance.DefaultViewType); showLabels = new BooleanChoice(); showLabels.Value = Config.Instance.DefaultShowLabels; verticalScroll = new BooleanChoice(); verticalScroll.Value = Config.Instance.DefaultVerticalScroll; useBanner = new BooleanChoice(); useBanner.Value = false; useCoverflow = new BooleanChoice(); useCoverflow.Value = false; useBackdrop = new BooleanChoice(); useBackdrop.Value = Config.Instance.ShowBackdrop; ArrayList al = new ArrayList(); foreach (SortOrder v in Enum.GetValues(typeof(SortOrder))) { al.Add(SortOrderNames.GetName(v)); } sortOrders.Options = al; al = new ArrayList(); foreach (IndexType v in Enum.GetValues(typeof(IndexType))) { al.Add(IndexTypeNames.GetName(v)); } indexBy.Options = al; sortOrders.ChosenChanged += new EventHandler(sortOrders_ChosenChanged); indexBy.ChosenChanged += new EventHandler(indexBy_ChosenChanged); viewType.ChosenChanged += new EventHandler(viewType_ChosenChanged); showLabels.ChosenChanged += new EventHandler(showLabels_ChosenChanged); verticalScroll.ChosenChanged += new EventHandler(verticalScroll_ChosenChanged); useBanner.ChosenChanged += new EventHandler(useBanner_ChosenChanged); useCoverflow.ChosenChanged += new EventHandler(useCoverflow_ChosenChanged); useBackdrop.ChosenChanged += new EventHandler(useBackdrop_ChosenChanged); thumbConstraint.PropertyChanged += new PropertyChangedEventHandler(thumbConstraint_PropertyChanged); }
public void WriteToStream(BinaryWriter bw) { bw.Write(Version); bw.SafeWriteString(ViewTypeNames.GetEnum((string)this.viewType.Chosen).ToString()); bw.Write(this.showLabels.Value); bw.Write(this.verticalScroll.Value); bw.SafeWriteString((string)this.SortOrder.ToString()); bw.SafeWriteString((string)this.IndexByString); bw.Write(this.useBanner.Value); bw.Write(this.thumbConstraint.Value.Width); bw.Write(this.thumbConstraint.Value.Height); bw.Write(this.useCoverflow.Value); bw.Write(this.useBackdrop.Value); }
public DisplayPreferences ReadFromStream(BinaryReader br) { this.saveEnabled = false; byte version = br.ReadByte(); try { this.viewType.Chosen = ViewTypeNames.GetName((ViewType)Enum.Parse(typeof(ViewType), br.SafeReadString())); } catch { this.viewType.Chosen = ViewTypeNames.GetName(MediaBrowser.Library.ViewType.Poster); } this.showLabels.Value = br.ReadBoolean(); this.verticalScroll.Value = br.ReadBoolean(); try { this.SortOrder = br.SafeReadString(); } catch { } try { this.IndexBy = br.SafeReadString(); } catch { } if (!Config.Instance.RememberIndexing) { this.IndexBy = Localization.LocalizedStrings.Instance.GetString("NoneDispPref"); } this.useBanner.Value = br.ReadBoolean(); this.thumbConstraint.Value = new Size(br.ReadInt32(), br.ReadInt32()); if (version >= 2) { this.useCoverflow.Value = br.ReadBoolean(); } if (version >= 3) { this.useBackdrop.Value = br.ReadBoolean(); } this.saveEnabled = true; return(this); }
public DisplayPreferences(Guid id, Folder folder) { this.Id = id; ArrayList list = new ArrayList(); foreach (ViewType v in Enum.GetValues(typeof(ViewType))) { list.Add(ViewTypeNames.GetName(v)); } viewType.Options = list; this.viewType.Chosen = ViewTypeNames.GetName(Config.Instance.DefaultViewType); //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(); showLabels = new BooleanChoice(); showLabels.Value = Config.Instance.DefaultShowLabels; verticalScroll = new BooleanChoice(); verticalScroll.Value = Config.Instance.DefaultVerticalScroll; useBanner = new BooleanChoice(); useBanner.Value = false; useCoverflow = new BooleanChoice(); useCoverflow.Value = false; useBackdrop = new BooleanChoice(); useBackdrop.Value = Config.Instance.ShowBackdrop; sortOrders.ChosenChanged += new EventHandler(sortOrders_ChosenChanged); indexBy.ChosenChanged += new EventHandler(indexBy_ChosenChanged); viewType.ChosenChanged += new EventHandler(viewType_ChosenChanged); showLabels.ChosenChanged += new EventHandler(showLabels_ChosenChanged); verticalScroll.ChosenChanged += new EventHandler(verticalScroll_ChosenChanged); useBanner.ChosenChanged += new EventHandler(useBanner_ChosenChanged); useCoverflow.ChosenChanged += new EventHandler(useCoverflow_ChosenChanged); useBackdrop.ChosenChanged += new EventHandler(useBackdrop_ChosenChanged); thumbConstraint.PropertyChanged += new PropertyChangedEventHandler(thumbConstraint_PropertyChanged); }
public static DisplayPreferences ReadFromStream(Guid id, BinaryReader br) { DisplayPreferences dp = new DisplayPreferences(id); dp.saveEnabled = false; byte version = br.ReadByte(); try { dp.viewType.Chosen = ViewTypeNames.GetName((ViewType)Enum.Parse(typeof(ViewType), br.SafeReadString())); } catch { dp.viewType.Chosen = ViewTypeNames.GetName(MediaBrowser.Library.ViewType.Poster); } dp.showLabels.Value = br.ReadBoolean(); dp.verticalScroll.Value = br.ReadBoolean(); try { dp.SortOrder = (SortOrder)Enum.Parse(typeof(SortOrder), br.SafeReadString()); } catch { } dp.IndexBy = (IndexType)Enum.Parse(typeof(IndexType), br.SafeReadString()); if (!Config.Instance.RememberIndexing) { dp.IndexBy = IndexType.None; } dp.useBanner.Value = br.ReadBoolean(); dp.thumbConstraint.Value = new Size(br.ReadInt32(), br.ReadInt32()); if (version >= 2) { dp.useCoverflow.Value = br.ReadBoolean(); } if (version >= 3) { dp.useBackdrop.Value = br.ReadBoolean(); } dp.saveEnabled = true; return(dp); }
public DisplayPreferences(Guid id, Folder folder) { this.Id = id; ArrayList list = new ArrayList(); foreach (ViewType v in Enum.GetValues(typeof(ViewType))) { list.Add(ViewTypeNames.GetName(v)); } viewType.Options = list; this.viewType.Chosen = ViewTypeNames.GetName(Config.Instance.DefaultViewType); //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(); showLabels = new BooleanChoice(); showLabels.Value = Config.Instance.DefaultShowLabels; verticalScroll = new BooleanChoice(); verticalScroll.Value = Config.Instance.DefaultVerticalScroll; useBanner = new BooleanChoice(); useBanner.Value = false; useCoverflow = new BooleanChoice(); useCoverflow.Value = false; useBackdrop = new BooleanChoice(); useBackdrop.Value = Config.Instance.ShowBackdrop; customParms = new Dictionary <string, string>(); ListenForChanges(); }
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(); }