Exemple #1
0
            public ViewModel(string serializedPreset, CarObject carObject, string selectedSkinId)
            {
                ShowroomsManager.Instance.EnsureLoaded();
                PpFiltersManager.Instance.EnsureLoaded();

                SelectedCar    = carObject;
                SelectedSkinId = selectedSkinId ?? SelectedCar.SelectedSkin?.Id;

                VideoPresets = _helper.CreateGroup(AcSettingsHolder.VideoPresetsCategory, "", "Default");

                _saveable = new SaveHelper <SaveableData>("__CarOpenInShowroom", () => new SaveableData {
                    ShowroomId          = SelectedShowroom?.Id,
                    FilterId            = SelectedFilter?.Id,
                    CameraFov           = CameraFov,
                    DisableSweetFx      = DisableSweetFx,
                    DisableWatermark    = DisableWatermark,
                    VideoPresetFilename = VideoPresetFilename,
                }, o => {
                    if (o.ShowroomId != null)
                    {
                        SelectedShowroom = ShowroomsManager.Instance.GetById(o.ShowroomId) ?? SelectedShowroom;
                    }
                    if (o.FilterId != null)
                    {
                        SelectedFilter = PpFiltersManager.Instance.GetById(o.FilterId) ?? SelectedFilter;
                    }

                    CameraFov           = o.CameraFov;
                    DisableWatermark    = o.DisableWatermark;
                    DisableSweetFx      = o.DisableSweetFx;
                    VideoPresetFilename = o.VideoPresetFilename;
                }, () => {
                    SelectedShowroom    = ShowroomsManager.Instance.GetDefault();
                    SelectedFilter      = PpFiltersManager.Instance.GetDefault();
                    CameraFov           = 30;
                    DisableWatermark    = false;
                    DisableSweetFx      = false;
                    VideoPresetFilename = null;
                });

                if (string.IsNullOrEmpty(serializedPreset))
                {
                    _saveable.Initialize();
                }
                else
                {
                    _saveable.Reset();
                    _saveable.FromSerializedString(serializedPreset);
                }
            }
 public ViewModel()
 {
     AppPresets = _helper.CreateGroup(AcSettingsHolder.AppsPresetsCategory);
     Entries    = Enumerable.Range(0, 4).Select(x => new CombineDesktopEntry {
         DisplayName = $"Desktop #{x + 1}",
         IsSelected  = x == 0
     }).ToArray();
     foreach (var desktop in Entries)
     {
         desktop.PropertyChanged += (sender, args) => {
             if (args.PropertyName == nameof(CombineDesktopEntry.IsSelected) && ((CombineDesktopEntry)sender).IsSelected)
             {
                 foreach (var o in Entries.ApartFrom(sender))
                 {
                     o.IsSelected = false;
                 }
             }
         };
     }
 }