Fixed naming in Wabbajack

This commit is contained in:
erri120 2019-11-21 16:45:00 +01:00
parent abd2ef70d5
commit 80cdefe33f
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135
13 changed files with 146 additions and 146 deletions

View File

@ -11,7 +11,7 @@ namespace Wabbajack
[JsonObject(MemberSerialization.OptOut)]
public class MainSettings
{
private static string Filename = "settings.json";
private static string _filename = "settings.json";
public double PosX { get; set; }
public double PosY { get; set; }
@ -27,8 +27,8 @@ namespace Wabbajack
public static MainSettings LoadSettings()
{
string[] args = Environment.GetCommandLineArgs();
if (!File.Exists(Filename) || args.Length > 1 && args[1] == "nosettings") return new MainSettings();
return JsonConvert.DeserializeObject<MainSettings>(File.ReadAllText(Filename));
if (!File.Exists(_filename) || args.Length > 1 && args[1] == "nosettings") return new MainSettings();
return JsonConvert.DeserializeObject<MainSettings>(File.ReadAllText(_filename));
}
public static void SaveSettings(MainSettings settings)
@ -40,7 +40,7 @@ namespace Wabbajack
//settings._saveSignal.OnCompleted();
//await settings._saveSignal;
File.WriteAllText(Filename, JsonConvert.SerializeObject(settings, Formatting.Indented));
File.WriteAllText(_filename, JsonConvert.SerializeObject(settings, Formatting.Indented));
}
}

View File

@ -82,28 +82,28 @@ namespace Wabbajack
private class Capture : IDisposable
{
private readonly INotifyCollectionChanged incc;
private readonly ListBox listBox;
private readonly INotifyCollectionChanged _incc;
private readonly ListBox _listBox;
public Capture(ListBox listBox)
{
this.listBox = listBox;
incc = listBox.ItemsSource as INotifyCollectionChanged;
if (incc != null) incc.CollectionChanged += incc_CollectionChanged;
this._listBox = listBox;
_incc = listBox.ItemsSource as INotifyCollectionChanged;
if (_incc != null) _incc.CollectionChanged += incc_CollectionChanged;
}
public void Dispose()
{
if (incc != null)
incc.CollectionChanged -= incc_CollectionChanged;
if (_incc != null)
_incc.CollectionChanged -= incc_CollectionChanged;
}
private void incc_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add)
{
listBox.ScrollIntoView(e.NewItems[0]);
listBox.SelectedItem = e.NewItems[0];
_listBox.ScrollIntoView(e.NewItems[0]);
_listBox.SelectedItem = e.NewItems[0];
}
}
}

View File

@ -16,23 +16,23 @@ namespace Wabbajack
{
public MainWindowVM MWVM { get; }
private readonly ObservableAsPropertyHelper<BitmapImage> _Image;
public BitmapImage Image => _Image.Value;
private readonly ObservableAsPropertyHelper<BitmapImage> _image;
public BitmapImage Image => _image.Value;
[Reactive]
public ModManager SelectedCompilerType { get; set; }
private readonly ObservableAsPropertyHelper<ISubCompilerVM> _Compiler;
public ISubCompilerVM Compiler => _Compiler.Value;
private readonly ObservableAsPropertyHelper<ISubCompilerVM> _compiler;
public ISubCompilerVM Compiler => _compiler.Value;
private readonly ObservableAsPropertyHelper<ModlistSettingsEditorVM> _CurrentModlistSettings;
public ModlistSettingsEditorVM CurrentModlistSettings => _CurrentModlistSettings.Value;
private readonly ObservableAsPropertyHelper<ModlistSettingsEditorVM> _currentModlistSettings;
public ModlistSettingsEditorVM CurrentModlistSettings => _currentModlistSettings.Value;
private readonly ObservableAsPropertyHelper<StatusUpdateTracker> _CurrentStatusTracker;
public StatusUpdateTracker CurrentStatusTracker => _CurrentStatusTracker.Value;
private readonly ObservableAsPropertyHelper<StatusUpdateTracker> _currentStatusTracker;
public StatusUpdateTracker CurrentStatusTracker => _currentStatusTracker.Value;
private readonly ObservableAsPropertyHelper<bool> _Compiling;
public bool Compiling => _Compiling.Value;
private readonly ObservableAsPropertyHelper<bool> _compiling;
public bool Compiling => _compiling.Value;
public CompilerVM(MainWindowVM mainWindowVM)
{
@ -49,7 +49,7 @@ namespace Wabbajack
.DisposeWith(CompositeDisposable);
// Swap to proper sub VM based on selected type
_Compiler = this.WhenAny(x => x.SelectedCompilerType)
_compiler = this.WhenAny(x => x.SelectedCompilerType)
// Delay so the initial VM swap comes in immediately, subVM comes right after
.DelayInitial(TimeSpan.FromMilliseconds(50), RxApp.MainThreadScheduler)
.Select<ModManager, ISubCompilerVM>(type =>
@ -74,14 +74,14 @@ namespace Wabbajack
.ToProperty(this, nameof(Compiler));
// Let sub VM determine what settings we're displaying and when
_CurrentModlistSettings = this.WhenAny(x => x.Compiler.ModlistSettings)
_currentModlistSettings = this.WhenAny(x => x.Compiler.ModlistSettings)
.ToProperty(this, nameof(CurrentModlistSettings));
// Let sub VM determine what progress we're seeing
_CurrentStatusTracker = this.WhenAny(x => x.Compiler.StatusTracker)
_currentStatusTracker = this.WhenAny(x => x.Compiler.StatusTracker)
.ToProperty(this, nameof(CurrentStatusTracker));
_Image = this.WhenAny(x => x.CurrentModlistSettings.ImagePath.TargetPath)
_image = this.WhenAny(x => x.CurrentModlistSettings.ImagePath.TargetPath)
// Throttle so that it only loads image after any sets of swaps have completed
.Throttle(TimeSpan.FromMilliseconds(50), RxApp.MainThreadScheduler)
.DistinctUntilChanged()
@ -96,7 +96,7 @@ namespace Wabbajack
})
.ToProperty(this, nameof(Image));
_Compiling = this.WhenAny(x => x.Compiler.ActiveCompilation)
_compiling = this.WhenAny(x => x.Compiler.ActiveCompilation)
.Select(compilation => compilation != null)
.ObserveOnGuiThread()
.ToProperty(this, nameof(Compiling));

View File

@ -12,13 +12,13 @@ namespace Wabbajack
{
public class MO2CompilerVM : ViewModel, ISubCompilerVM
{
private readonly MO2CompilationSettings settings;
private readonly MO2CompilationSettings _settings;
private readonly ObservableAsPropertyHelper<string> _Mo2Folder;
public string Mo2Folder => _Mo2Folder.Value;
private readonly ObservableAsPropertyHelper<string> _mo2Folder;
public string Mo2Folder => _mo2Folder.Value;
private readonly ObservableAsPropertyHelper<string> _MOProfile;
public string MOProfile => _MOProfile.Value;
private readonly ObservableAsPropertyHelper<string> _moProfile;
public string MOProfile => _moProfile.Value;
public FilePickerVM DownloadLocation { get; }
@ -29,8 +29,8 @@ namespace Wabbajack
[Reactive]
public ACompiler ActiveCompilation { get; private set; }
private readonly ObservableAsPropertyHelper<ModlistSettingsEditorVM> _ModlistSettings;
public ModlistSettingsEditorVM ModlistSettings => _ModlistSettings.Value;
private readonly ObservableAsPropertyHelper<ModlistSettingsEditorVM> _modlistSettings;
public ModlistSettingsEditorVM ModlistSettings => _modlistSettings.Value;
[Reactive]
public StatusUpdateTracker StatusTracker { get; private set; }
@ -50,13 +50,13 @@ namespace Wabbajack
PromptTitle = "Select Download Location",
};
_Mo2Folder = this.WhenAny(x => x.ModlistLocation.TargetPath)
_mo2Folder = this.WhenAny(x => x.ModlistLocation.TargetPath)
.Select(loc =>
{
try
{
var profile_folder = Path.GetDirectoryName(loc);
return Path.GetDirectoryName(Path.GetDirectoryName(profile_folder));
var profileFolder = Path.GetDirectoryName(loc);
return Path.GetDirectoryName(Path.GetDirectoryName(profileFolder));
}
catch (Exception)
{
@ -64,13 +64,13 @@ namespace Wabbajack
}
})
.ToProperty(this, nameof(Mo2Folder));
_MOProfile = this.WhenAny(x => x.ModlistLocation.TargetPath)
_moProfile = this.WhenAny(x => x.ModlistLocation.TargetPath)
.Select(loc =>
{
try
{
var profile_folder = Path.GetDirectoryName(loc);
return Path.GetFileName(profile_folder);
var profileFolder = Path.GetDirectoryName(loc);
return Path.GetFileName(profileFolder);
}
catch (Exception)
{
@ -135,27 +135,27 @@ namespace Wabbajack
});
// Load settings
settings = parent.MWVM.Settings.Compiler.MO2Compilation;
ModlistLocation.TargetPath = settings.LastCompiledProfileLocation;
if (!string.IsNullOrWhiteSpace(settings.DownloadLocation))
_settings = parent.MWVM.Settings.Compiler.MO2Compilation;
ModlistLocation.TargetPath = _settings.LastCompiledProfileLocation;
if (!string.IsNullOrWhiteSpace(_settings.DownloadLocation))
{
DownloadLocation.TargetPath = settings.DownloadLocation;
DownloadLocation.TargetPath = _settings.DownloadLocation;
}
parent.MWVM.Settings.SaveSignal
.Subscribe(_ => Unload())
.DisposeWith(CompositeDisposable);
// Load custom modlist settings per MO2 profile
_ModlistSettings = Observable.CombineLatest(
_modlistSettings = Observable.CombineLatest(
this.WhenAny(x => x.ModlistLocation.ErrorState),
this.WhenAny(x => x.ModlistLocation.TargetPath),
resultSelector: (State, Path) => (State, Path))
resultSelector: (state, path) => (State: state, Path: path))
// A short throttle is a quick hack to make the above changes "atomic"
.Throttle(TimeSpan.FromMilliseconds(25))
.Select(u =>
{
if (u.State.Failed) return null;
var modlistSettings = settings.ModlistSettings.TryCreate(u.Path);
var modlistSettings = _settings.ModlistSettings.TryCreate(u.Path);
return new ModlistSettingsEditorVM(modlistSettings)
{
ModListName = MOProfile
@ -184,8 +184,8 @@ namespace Wabbajack
{
try
{
var tmp_compiler = new MO2Compiler(Mo2Folder);
DownloadLocation.TargetPath = tmp_compiler.MO2DownloadsFolder;
var tmpCompiler = new MO2Compiler(Mo2Folder);
DownloadLocation.TargetPath = tmpCompiler.MO2DownloadsFolder;
}
catch (Exception ex)
{
@ -197,8 +197,8 @@ namespace Wabbajack
public void Unload()
{
settings.DownloadLocation = DownloadLocation.TargetPath;
settings.LastCompiledProfileLocation = ModlistLocation.TargetPath;
_settings.DownloadLocation = DownloadLocation.TargetPath;
_settings.LastCompiledProfileLocation = ModlistLocation.TargetPath;
ModlistSettings?.Save();
}
}

View File

@ -6,7 +6,7 @@ namespace Wabbajack
{
public class ModlistSettingsEditorVM : ViewModel
{
private CompilationModlistSettings settings;
private CompilationModlistSettings _settings;
[Reactive]
public string ModListName { get; set; }
@ -26,7 +26,7 @@ namespace Wabbajack
public ModlistSettingsEditorVM(CompilationModlistSettings settings)
{
this.settings = settings;
this._settings = settings;
ImagePath = new FilePickerVM()
{
ExistCheckOption = FilePickerVM.ExistCheckOptions.IfNotEmpty,
@ -45,25 +45,25 @@ namespace Wabbajack
public void Init()
{
AuthorText = settings.Author;
if (!string.IsNullOrWhiteSpace(settings.ModListName))
AuthorText = _settings.Author;
if (!string.IsNullOrWhiteSpace(_settings.ModListName))
{
ModListName = settings.ModListName;
ModListName = _settings.ModListName;
}
Description = settings.Description;
ReadMeText.TargetPath = settings.Readme;
ImagePath.TargetPath = settings.SplashScreen;
Website = settings.Website;
Description = _settings.Description;
ReadMeText.TargetPath = _settings.Readme;
ImagePath.TargetPath = _settings.SplashScreen;
Website = _settings.Website;
}
public void Save()
{
settings.Author = AuthorText;
settings.ModListName = ModListName;
settings.Description = Description;
settings.Readme = ReadMeText.TargetPath;
settings.SplashScreen = ImagePath.TargetPath;
settings.Website = Website;
_settings.Author = AuthorText;
_settings.ModListName = ModListName;
_settings.Description = Description;
_settings.Readme = ReadMeText.TargetPath;
_settings.SplashScreen = ImagePath.TargetPath;
_settings.Website = Website;
}
}
}

View File

@ -48,17 +48,17 @@ namespace Wabbajack
[Reactive]
public IObservable<IErrorResponse> AdditionalError { get; set; }
private readonly ObservableAsPropertyHelper<bool> _Exists;
public bool Exists => _Exists.Value;
private readonly ObservableAsPropertyHelper<bool> _exists;
public bool Exists => _exists.Value;
private readonly ObservableAsPropertyHelper<ErrorResponse> _ErrorState;
public ErrorResponse ErrorState => _ErrorState.Value;
private readonly ObservableAsPropertyHelper<ErrorResponse> _errorState;
public ErrorResponse ErrorState => _errorState.Value;
private readonly ObservableAsPropertyHelper<bool> _InError;
public bool InError => _InError.Value;
private readonly ObservableAsPropertyHelper<bool> _inError;
public bool InError => _inError.Value;
private readonly ObservableAsPropertyHelper<string> _ErrorTooltip;
public string ErrorTooltip => _ErrorTooltip.Value;
private readonly ObservableAsPropertyHelper<string> _errorTooltip;
public string ErrorTooltip => _errorTooltip.Value;
public List<CommonFileDialogFilter> Filters { get; } = new List<CommonFileDialogFilter>();
@ -77,11 +77,11 @@ namespace Wabbajack
.Skip(1)
.Debounce(TimeSpan.FromMilliseconds(200))
.StartWith(default(string)),
resultSelector: (ExistsOption, Type, Path) => (ExistsOption, Type, Path))
resultSelector: (existsOption, type, path) => (ExistsOption: existsOption, Type: type, Path: path))
.Publish()
.RefCount();
_Exists = Observable.Interval(TimeSpan.FromSeconds(3))
_exists = Observable.Interval(TimeSpan.FromSeconds(3))
// Only check exists on timer if desired
.FilterSwitch(existsCheckTuple
.Select(t =>
@ -139,7 +139,7 @@ namespace Wabbajack
.ObserveOn(RxApp.MainThreadScheduler)
.ToProperty(this, nameof(Exists));
_ErrorState = Observable.CombineLatest(
_errorState = Observable.CombineLatest(
this.WhenAny(x => x.Exists)
.Select(exists => ErrorResponse.Create(successful: exists, exists ? default(string) : "Path does not exist")),
this.WhenAny(x => x.AdditionalError)
@ -152,13 +152,13 @@ namespace Wabbajack
})
.ToProperty(this, nameof(ErrorState));
_InError = this.WhenAny(x => x.ErrorState)
_inError = this.WhenAny(x => x.ErrorState)
.Select(x => !x.Succeeded)
.ToProperty(this, nameof(InError));
// Doesn't derive from ErrorState, as we want to bubble non-empty tooltips,
// which is slightly different logic
_ErrorTooltip = Observable.CombineLatest(
_errorTooltip = Observable.CombineLatest(
this.WhenAny(x => x.Exists)
.Select(exists => exists ? default(string) : "Path does not exist"),
this.WhenAny(x => x.AdditionalError)

View File

@ -28,8 +28,8 @@ namespace Wabbajack
public BitmapImage WabbajackLogo { get; } = UIUtils.BitmapImageFromResource("Wabbajack.Resources.Wabba_Mouth.png");
private readonly ObservableAsPropertyHelper<ModListVM> _ModList;
public ModListVM ModList => _ModList.Value;
private readonly ObservableAsPropertyHelper<ModListVM> _modList;
public ModListVM ModList => _modList.Value;
[Reactive]
public string ModListPath { get; set; }
@ -37,8 +37,8 @@ namespace Wabbajack
[Reactive]
public bool UIReady { get; set; }
private readonly ObservableAsPropertyHelper<string> _HTMLReport;
public string HTMLReport => _HTMLReport.Value;
private readonly ObservableAsPropertyHelper<string> _htmlReport;
public string HTMLReport => _htmlReport.Value;
/// <summary>
/// Tracks whether an install is currently in progress
@ -56,26 +56,26 @@ namespace Wabbajack
public FilePickerVM DownloadLocation { get; }
private readonly ObservableAsPropertyHelper<float> _ProgressPercent;
public float ProgressPercent => _ProgressPercent.Value;
private readonly ObservableAsPropertyHelper<float> _progressPercent;
public float ProgressPercent => _progressPercent.Value;
private readonly ObservableAsPropertyHelper<ImageSource> _Image;
public ImageSource Image => _Image.Value;
private readonly ObservableAsPropertyHelper<ImageSource> _image;
public ImageSource Image => _image.Value;
private readonly ObservableAsPropertyHelper<string> _TitleText;
public string TitleText => _TitleText.Value;
private readonly ObservableAsPropertyHelper<string> _titleText;
public string TitleText => _titleText.Value;
private readonly ObservableAsPropertyHelper<string> _AuthorText;
public string AuthorText => _AuthorText.Value;
private readonly ObservableAsPropertyHelper<string> _authorText;
public string AuthorText => _authorText.Value;
private readonly ObservableAsPropertyHelper<string> _Description;
public string Description => _Description.Value;
private readonly ObservableAsPropertyHelper<string> _description;
public string Description => _description.Value;
private readonly ObservableAsPropertyHelper<string> _ProgressTitle;
public string ProgressTitle => _ProgressTitle.Value;
private readonly ObservableAsPropertyHelper<string> _progressTitle;
public string ProgressTitle => _progressTitle.Value;
private readonly ObservableAsPropertyHelper<string> _ModListName;
public string ModListName => _ModListName.Value;
private readonly ObservableAsPropertyHelper<string> _modListName;
public string ModListName => _modListName.Value;
// Command properties
public IReactiveCommand BeginCommand { get; }
@ -128,7 +128,7 @@ namespace Wabbajack
})
.DisposeWith(CompositeDisposable);
_ModList = this.WhenAny(x => x.ModListPath)
_modList = this.WhenAny(x => x.ModListPath)
.ObserveOn(RxApp.TaskpoolScheduler)
.Select(modListPath =>
{
@ -155,10 +155,10 @@ namespace Wabbajack
.ObserveOnGuiThread()
.StartWith(default(ModListVM))
.ToProperty(this, nameof(ModList));
_HTMLReport = this.WhenAny(x => x.ModList)
_htmlReport = this.WhenAny(x => x.ModList)
.Select(modList => modList?.ReportHTML)
.ToProperty(this, nameof(HTMLReport));
_ProgressPercent = Observable.CombineLatest(
_progressPercent = Observable.CombineLatest(
this.WhenAny(x => x.Installing),
this.WhenAny(x => x.InstallingMode),
resultSelector: (installing, mode) => !installing && mode)
@ -172,7 +172,7 @@ namespace Wabbajack
// Set display items to modlist if configuring or complete,
// or to the current slideshow data if installing
_Image = Observable.CombineLatest(
_image = Observable.CombineLatest(
this.WhenAny(x => x.ModList)
.SelectMany(x => x?.ImageObservable ?? Observable.Empty<BitmapImage>())
.NotNull()
@ -183,28 +183,28 @@ namespace Wabbajack
resultSelector: (modList, slideshow, installing) => installing ? slideshow : modList)
.Select<BitmapImage, ImageSource>(x => x)
.ToProperty(this, nameof(Image));
_TitleText = Observable.CombineLatest(
_titleText = Observable.CombineLatest(
this.WhenAny(x => x.ModList.Name),
this.WhenAny(x => x.Slideshow.TargetMod.ModName)
.StartWith(default(string)),
this.WhenAny(x => x.Installing),
resultSelector: (modList, mod, installing) => installing ? mod : modList)
.ToProperty(this, nameof(TitleText));
_AuthorText = Observable.CombineLatest(
_authorText = Observable.CombineLatest(
this.WhenAny(x => x.ModList.Author),
this.WhenAny(x => x.Slideshow.TargetMod.ModAuthor)
.StartWith(default(string)),
this.WhenAny(x => x.Installing),
resultSelector: (modList, mod, installing) => installing ? mod : modList)
.ToProperty(this, nameof(AuthorText));
_Description = Observable.CombineLatest(
_description = Observable.CombineLatest(
this.WhenAny(x => x.ModList.Description),
this.WhenAny(x => x.Slideshow.TargetMod.ModDescription)
.StartWith(default(string)),
this.WhenAny(x => x.Installing),
resultSelector: (modList, mod, installing) => installing ? mod : modList)
.ToProperty(this, nameof(Description));
_ModListName = this.WhenAny(x => x.ModList)
_modListName = this.WhenAny(x => x.ModList)
.Select(x => x?.Name)
.ToProperty(this, nameof(ModListName));
@ -245,7 +245,7 @@ namespace Wabbajack
})
.DisposeWith(CompositeDisposable);
_ProgressTitle = Observable.CombineLatest(
_progressTitle = Observable.CombineLatest(
this.WhenAny(x => x.Installing),
this.WhenAny(x => x.InstallingMode),
resultSelector: (installing, mode) =>

View File

@ -1,4 +1,4 @@
using DynamicData;
using DynamicData;
using DynamicData.Binding;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
@ -21,8 +21,8 @@ namespace Wabbajack
public MainSettings Settings { get; }
private readonly ObservableAsPropertyHelper<ViewModel> _ActivePane;
public ViewModel ActivePane => _ActivePane.Value;
private readonly ObservableAsPropertyHelper<ViewModel> _activePane;
public ViewModel ActivePane => _activePane.Value;
public ObservableCollectionExtended<CPUStatus> StatusList { get; } = new ObservableCollectionExtended<CPUStatus>();
@ -31,16 +31,16 @@ namespace Wabbajack
[Reactive]
public RunMode Mode { get; set; }
private readonly Lazy<CompilerVM> _Compiler;
private readonly Lazy<InstallerVM> _Installer;
private readonly Lazy<CompilerVM> _compiler;
private readonly Lazy<InstallerVM> _installer;
public MainWindowVM(RunMode mode, string source, MainWindow mainWindow, MainSettings settings)
{
Mode = mode;
MainWindow = mainWindow;
Settings = settings;
_Installer = new Lazy<InstallerVM>(() => new InstallerVM(this, source));
_Compiler = new Lazy<CompilerVM>(() => new CompilerVM(this));
_installer = new Lazy<InstallerVM>(() => new InstallerVM(this, source));
_compiler = new Lazy<CompilerVM>(() => new CompilerVM(this));
// Set up logging
Utils.LogMessages
@ -58,15 +58,15 @@ namespace Wabbajack
// Wire mode to drive the active pane.
// Note: This is currently made into a derivative property driven by mode,
// but it can be easily changed into a normal property that can be set from anywhere if needed
_ActivePane = this.WhenAny(x => x.Mode)
_activePane = this.WhenAny(x => x.Mode)
.Select<RunMode, ViewModel>(m =>
{
switch (m)
{
case RunMode.Compile:
return _Compiler.Value;
return _compiler.Value;
case RunMode.Install:
return _Installer.Value;
return _installer.Value;
default:
return default;
}

View File

@ -17,12 +17,12 @@ namespace Wabbajack.UI
[Reactive]
public ModlistMetadata SelectedModList { get; set; }
private readonly ObservableAsPropertyHelper<bool> _CanInstall;
public bool CanInstall => _CanInstall.Value;
private readonly ObservableAsPropertyHelper<bool> _canInstall;
public bool CanInstall => _canInstall.Value;
public ModeSelectionWindowVM()
{
_CanInstall = this.WhenAny(x => x.SelectedModList)
_canInstall = this.WhenAny(x => x.SelectedModList)
.Select(x => x != null)
.ToProperty(this, nameof(CanInstall));
}

View File

@ -1,4 +1,4 @@
using DynamicData;
using DynamicData;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
using System;
@ -24,11 +24,11 @@ namespace Wabbajack
[Reactive]
public bool Enable { get; set; } = true;
private readonly ObservableAsPropertyHelper<BitmapImage> _Image;
public BitmapImage Image => _Image.Value;
private readonly ObservableAsPropertyHelper<BitmapImage> _image;
public BitmapImage Image => _image.Value;
private readonly ObservableAsPropertyHelper<ModVM> _TargetMod;
public ModVM TargetMod => _TargetMod.Value;
private readonly ObservableAsPropertyHelper<ModVM> _targetMod;
public ModVM TargetMod => _targetMod.Value;
public IReactiveCommand SlideShowNextItemCommand { get; } = ReactiveCommand.Create(() => { });
public IReactiveCommand VisitNexusSiteCommand { get; }
@ -95,7 +95,7 @@ namespace Wabbajack
.RefCount();
// Find target mod to display by combining dynamic list with currently desired index
_TargetMod = Observable.CombineLatest(
_targetMod = Observable.CombineLatest(
modVMs.QueryWhenChanged(),
selectedIndex,
resultSelector: (query, selected) => query.Items.ElementAtOrDefault(selected % query.Count))
@ -104,7 +104,7 @@ namespace Wabbajack
.ToProperty(this, nameof(TargetMod));
// Mark interest and materialize image of target mod
_Image = this.WhenAny(x => x.TargetMod)
_image = this.WhenAny(x => x.TargetMod)
// We want to Switch here, not SelectMany, as we want to hotswap to newest target without waiting on old ones
.Select(x => x?.ImageObservable ?? Observable.Return(default(BitmapImage)))
.Switch()

View File

@ -51,28 +51,28 @@ namespace Wabbajack
public static readonly DependencyProperty DescriptionProperty = DependencyProperty.Register(nameof(Description), typeof(string), typeof(DetailImageView),
new FrameworkPropertyMetadata(default(string), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, WireNotifyPropertyChanged));
private readonly ObservableAsPropertyHelper<bool> _ShowAuthor;
public bool ShowAuthor => _ShowAuthor.Value;
private readonly ObservableAsPropertyHelper<bool> _showAuthor;
public bool ShowAuthor => _showAuthor.Value;
private readonly ObservableAsPropertyHelper<bool> _ShowDescription;
public bool ShowDescription => _ShowDescription.Value;
private readonly ObservableAsPropertyHelper<bool> _showDescription;
public bool ShowDescription => _showDescription.Value;
private readonly ObservableAsPropertyHelper<bool> _ShowTitle;
public bool ShowTitle => _ShowTitle.Value;
private readonly ObservableAsPropertyHelper<bool> _showTitle;
public bool ShowTitle => _showTitle.Value;
public DetailImageView()
{
InitializeComponent();
_ShowAuthor = this.WhenAny(x => x.Author)
_showAuthor = this.WhenAny(x => x.Author)
.Select(x => !string.IsNullOrWhiteSpace(x))
.ToProperty(this, nameof(ShowAuthor));
_ShowDescription = this.WhenAny(x => x.Description)
_showDescription = this.WhenAny(x => x.Description)
.Select(x => !string.IsNullOrWhiteSpace(x))
.ToProperty(this, nameof(ShowDescription));
_ShowTitle = this.WhenAny(x => x.Title)
_showTitle = this.WhenAny(x => x.Title)
.Select(x => !string.IsNullOrWhiteSpace(x))
.ToProperty(this, nameof(ShowTitle));
}

View File

@ -14,7 +14,7 @@ namespace Wabbajack
/// </summary>
public partial class ModeSelectionWindow : Window
{
MainSettings settings;
MainSettings _settings;
public ModeSelectionWindow()
{
@ -28,14 +28,14 @@ namespace Wabbajack
var discordIcon = UIUtils.BitmapImageFromResource("Wabbajack.Resources.Icons.discord.png");
Discord.Source = discordIcon;
settings = MainSettings.LoadSettings();
_settings = MainSettings.LoadSettings();
DataContext = new ModeSelectionWindowVM();
}
private void CreateModlist_Click(object sender, RoutedEventArgs e)
{
ShutdownOnClose = false;
var window = new MainWindow(RunMode.Compile, null, settings);
var window = new MainWindow(RunMode.Compile, null, _settings);
window.Left = Left;
window.Top = Top;
window.Show();
@ -56,15 +56,15 @@ namespace Wabbajack
OpenMainWindowInstall(
UIUtils.OpenFileDialog(
$"*{ExtensionManager.Extension}|*{ExtensionManager.Extension}",
initialDirectory: settings.Installer.LastInstalledListLocation));
initialDirectory: _settings.Installer.LastInstalledListLocation));
}
private void OpenMainWindowInstall(string file)
{
if (file == null) return;
ShutdownOnClose = false;
settings.Installer.LastInstalledListLocation = Path.GetDirectoryName(file);
var window = new MainWindow(RunMode.Install, file, settings);
_settings.Installer.LastInstalledListLocation = Path.GetDirectoryName(file);
var window = new MainWindow(RunMode.Install, file, _settings);
window.Left = Left;
window.Top = Top;
window.Show();

View File

@ -22,14 +22,14 @@ namespace Wabbajack
PropertyChanged?.Invoke(this, args);
}
private readonly Lazy<CompositeDisposable> _CompositeDisposable = new Lazy<CompositeDisposable>();
public CompositeDisposable CompositeDisposable => _CompositeDisposable.Value;
private readonly Lazy<CompositeDisposable> _compositeDisposable = new Lazy<CompositeDisposable>();
public CompositeDisposable CompositeDisposable => _compositeDisposable.Value;
public virtual void Dispose()
{
if (_CompositeDisposable.IsValueCreated)
if (_compositeDisposable.IsValueCreated)
{
_CompositeDisposable.Value.Dispose();
_compositeDisposable.Value.Dispose();
}
}