// Your application's entry point. Here you can initialize your MVVM framework, DI // container, etc. private static void AppMain(Application app, string[] args) { var keytool = new MacOsKeyTool(); var commandExecutor = new MacOsCommandExecutor(new CommandBuilder()); var window = new MainWindow(); var templatesModule = new TemplatesModule(); window.DataContext = new MainWindowViewModel(window, keytool, commandExecutor, templatesModule); app.Run(window); }
public MainWindowViewModel(Window window, KeyTool keyTool, CommandExecutor executor, TemplatesModule templatesModule) { _window = window ?? throw new ArgumentNullException(nameof(window)); _keyTool = keyTool ?? throw new ArgumentNullException(nameof(keyTool)); _executor = executor ?? throw new ArgumentNullException(nameof(executor)); _templatesModule = templatesModule ?? throw new ArgumentNullException(nameof(templatesModule)); _executor.LogMessage += PrintMessage; this.WhenAnyValue(x => x.BundlePath, x => x.ApksPath) .Where(t => string.IsNullOrWhiteSpace(t.Item2)) .Where(t => !string.IsNullOrWhiteSpace(t.Item1)) .Where(t => string.Equals(Path.GetExtension(t.Item1) !.Substring(1), ExtAab)) .Select(t => Path.ChangeExtension(t.Item1, ExtApks)) .Subscribe(path => ApksPath = path); this.WhenAnyValue(x => x.KeystorePath, x => x.KeystorePassword) .Select(x => new { Path = x.Item1, Pass = x.Item2 }) .Where(x => !string.IsNullOrWhiteSpace(x.Path)) .Where(x => !string.IsNullOrWhiteSpace(x.Pass)) .Where(x => (File.GetAttributes(x.Path) & FileAttributes.Directory) != FileAttributes.Directory) .Where(x => File.Exists(x.Path)) .Subscribe(x => UpdateAliases()); _executeModes = new[] { ExecuteMode.BuildApks, ExecuteMode.InstallApks, ExecuteMode.ShowApkSize }; ExecuteModesNames = new ObservableCollection <string>(_executeModes.Select(m => m.GetModeName())); AvailableAliases = new ObservableCollection <string>(); _isOnBuildMode = this.WhenAnyValue(x => x.SelectedExecuteModeIndex) .Select(index => _executeModes[index]) .Select(mode => mode == ExecuteMode.BuildApks) .ToProperty(this, x => x.IsOnBuildMode); }