public PixelDisplayViewModel(ModelsEx models) { this.models = models; this.models.Display.PropertyChanged += DisplayOnPropertyChanged; this.models.Settings.PropertyChanged += SettingsOnPropertyChanged; this.decimalPlaces = models.Settings.TexelDecimalPlaces; this.radius = models.Display.TexelRadius; AvailableFormats.Add(new ListItemViewModel <SettingsModel.TexelDisplayMode> { Cargo = SettingsModel.TexelDisplayMode.LinearDecimal, Name = "decimal (linear)" }); AvailableFormats.Add(new ListItemViewModel <SettingsModel.TexelDisplayMode> { Cargo = SettingsModel.TexelDisplayMode.LinearFloat, Name = "float (linear)" }); AvailableFormats.Add(new ListItemViewModel <SettingsModel.TexelDisplayMode> { Cargo = SettingsModel.TexelDisplayMode.SrgbDecimal, Name = "decimal (sRGB)" }); AvailableFormats.Add(new ListItemViewModel <SettingsModel.TexelDisplayMode> { Cargo = SettingsModel.TexelDisplayMode.SrgbByte, Name = "byte (sRGB)" }); selectedFormat = AvailableFormats.Find(box => box.Cargo == models.Settings.TexelDisplay); }
public void OnViewLoaded() { // Select last used format SelectedFormat = !string.IsNullOrWhiteSpace(_settingsService.LastFormat) && AvailableFormats.Contains(_settingsService.LastFormat) ? _settingsService.LastFormat : AvailableFormats.FirstOrDefault(); }
protected override async Task InitializeAsync() { await base.InitializeAsync(); using (AvailableFormats.SuspendChangeNotifications()) { foreach (var cultureInfo in CultureInfo.GetCultures(CultureTypes.AllCultures)) { var format = new CultureFormat { CultureCode = $"[{cultureInfo.IetfLanguageTag}]", FormatValue = cultureInfo.DateTimeFormat.ShortDatePattern }; AvailableFormats.Add(format); if (!cultureInfo.Equals(CultureInfo.CurrentCulture)) { continue; } SelectedFormat = format; DateValueString = DateValue.Value.ToString(format.FormatValue); } } }
protected DownloadSetupViewModelBase(IViewModelFactory viewModelFactory, DownloadService downloadService) { _viewModelFactory = viewModelFactory; _downloadService = downloadService; // Default format SelectedFormat = AvailableFormats.FirstOrDefault(); }
protected override void OnViewLoaded() { base.OnViewLoaded(); // Select last used format SelectedFormat = AvailableFormats.Contains(_settingsService.LastFormat) ? _settingsService.LastFormat : AvailableFormats.FirstOrDefault(); }
protected override void OnViewLoaded() { base.OnViewLoaded(); // Persist preferences SelectedFormat = AvailableFormats.Contains(_settingsService.LastFormat) ? _settingsService.LastFormat : AvailableFormats.FirstOrDefault(); }
public void OnViewLoaded() { SelectedFormat = !string.IsNullOrWhiteSpace(_settingsService.LastFormat) && AvailableFormats.Contains(_settingsService.LastFormat, StringComparer.OrdinalIgnoreCase) ? _settingsService.LastFormat : AvailableFormats.FirstOrDefault(); SelectedVideoQualityPreference = _settingsService.LastVideoQualityPreference; }
private static bool AvailableFormat(string anchor) { var dotIndex = anchor.IndexOf('.'); if (dotIndex < 0) { return(true); } return(AvailableFormats.Any(format => anchor.EndsWith(format))); }
private void SettingsOnPropertyChanged(object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case nameof(SettingsModel.TexelDecimalPlaces): DecimalPlaces = models.Settings.TexelDecimalPlaces; break; case nameof(SettingsModel.TexelDisplay): SelectedFormat = AvailableFormats.Find(box => box.Cargo == models.Settings.TexelDisplay); break; } }
public PixelDisplayViewModel(Models.Models models) { this.models = models; this.models.Display.PropertyChanged += DisplayOnPropertyChanged; this.decimalPlaces = models.Display.TexelDecimalPlaces; this.radius = models.Display.TexelRadius; this.alpha = models.Display.TexelDisplayAlpha; AvailableFormats.Add(new ComboBoxItem <DisplayModel.TexelDisplayMode>("decimal linear", DisplayModel.TexelDisplayMode.LinearDecimal)); AvailableFormats.Add(new ComboBoxItem <DisplayModel.TexelDisplayMode>("decimal srgb", DisplayModel.TexelDisplayMode.SrgbDecimal)); AvailableFormats.Add(new ComboBoxItem <DisplayModel.TexelDisplayMode>("byte linear", DisplayModel.TexelDisplayMode.LinearByte)); AvailableFormats.Add(new ComboBoxItem <DisplayModel.TexelDisplayMode>("byte srgb", DisplayModel.TexelDisplayMode.SrgbByte)); selectedFormat = AvailableFormats.Find(box => box.Cargo == models.Display.TexelDisplay); }
private void DisplayOnPropertyChanged(object sender, PropertyChangedEventArgs args) { switch (args.PropertyName) { case nameof(DisplayModel.TexelDecimalPlaces): DecimalPlaces = models.Display.TexelDecimalPlaces; break; case nameof(DisplayModel.TexelRadius): Radius = models.Display.TexelRadius; break; case nameof(DisplayModel.TexelDisplayAlpha): Alpha = models.Display.TexelDisplayAlpha; break; case nameof(DisplayModel.TexelDisplay): SelectedFormat = AvailableFormats.Find(box => box.Cargo == models.Display.TexelDisplay); break; } }
protected override async Task InitializeAsync() { await base.InitializeAsync(); using (AvailableFormats.SuspendChangeNotifications()) { foreach (var cultureInfo in CultureInfo.GetCultures(CultureTypes.AllCultures)) { var format = new CultureFormat { Culture = cultureInfo, FormatValue = cultureInfo.DateTimeFormat.ShortDatePattern + " " + cultureInfo.DateTimeFormat.LongTimePattern }; AvailableFormats.Add(format); format = new CultureFormat { Culture = cultureInfo, FormatValue = cultureInfo.DateTimeFormat.ShortDatePattern }; AvailableFormats.Add(format); format = new CultureFormat { Culture = cultureInfo, FormatValue = cultureInfo.DateTimeFormat.ShortDatePattern + " " + cultureInfo.DateTimeFormat.ShortTimePattern }; AvailableFormats.Add(format); if (cultureInfo.Equals(CultureInfo.CurrentCulture)) { SelectedFormat = format; } } } }
/// <summary> /// Checks to see if the <see cref="DataPackageView"/> contains a specific data format. /// </summary> /// <param name="formatId">The name of the format.</param> /// <returns>True if the <see cref="DataPackageView"/> contains the format; false otherwise.</returns> public bool Contains(string formatId) { return(AvailableFormats.Contains <string>(formatId)); }
private async Task LoadVideoInfo(bool validateUrl) { Exception getVideosException = null; await DialogHost.Show(new WaitDialog(), "NewDownloadDialogHost", (DialogOpenedEventHandler)(async(sender, e) => { if (validateUrl) { if (!await IsValidVideoUrl(Url)) { InvalidUrl = true; e.Session.Close(); return; } } await DataService.GetVideoAsync(Url, (res, ex) => { if (ex != null) { getVideosException = ex; } else if (res.Videos.Length > 0) { ResultItem = res.Videos[0]; VideoFormat = AvailableFormats.First(); // Set default save path if (ResultItem != null) { VideoSavePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), GetVideoFileName()); } } else if (res.Playlists.Length > 0) { // ResultItem = new VideoPlaylist(res.Playlists[0]); // VideoSavePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), MakeValidFileName(ResultItem.Title)); ResultItem = null; AddError("Playlists are not supported yet.", () => Url); } else { ResultItem = null; NoResultFound = true; } }); e.Session.Close(); })); if (getVideosException != null) { await ShowExceptionDialog(getVideosException, "Loading video info failed!"); AddError("An error occured.", () => Url); return; } if (ResultItem is VideoPlaylist) { await((VideoPlaylist)ResultItem).FillItemsInfo(DataService); RaisePropertyChanged(() => AvailableFormats); } if (AvailableFormats != null) { VideoFormat = AvailableFormats.FirstOrDefault(); } }