Beispiel #1
0
        private async Task ReloadAppList()
        {
            this.SetStatusMessage("Loading list of apps.");

            bool onlyDevApps = this.OnlyDevApps.IsChecked ?? false;

            await Task.Run(() =>
            {
                this.Apps = new ObservableCollection <AppDetail>(AppTidier.GetAllAppNames(onlyDevApps));
                this.OnPropertyChanged(nameof(this.Apps));
            });

            this.SetStatusMessage();
        }
Beispiel #2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            if (e.Args.Any())
            {
                if (!NativeMethods.AttachConsole(-1))
                {
                    // allocate a new console
                    NativeMethods.AllocConsole();
                }

                var options = new Options();

                if (CommandLine.Parser.Default.ParseArguments(e.Args, options))
                {
                    DefaultColor = Console.ForegroundColor;

                    var appTitle = new HelpText
                    {
                        Heading   = HeadingInfo.Default,
                        Copyright = CopyrightInfo.Default,
                        AdditionalNewLineAfterOption = true,
                        AddDashesToOption            = true
                    };

                    Console.WriteLine(appTitle);

                    AppTidier.Tidy(options);

                    Console.ForegroundColor = DefaultColor;
                }
                else
                {
                    Console.WriteLine(options.GetUsage());
                }

                NativeMethods.FreeConsole();
                Environment.Exit(0);
            }
            else
            {
                new MainWindow().ShowDialog();
            }

            this.Shutdown();
        }
Beispiel #3
0
        private void UninstallClicked(object sender, RoutedEventArgs e)
        {
            try
            {
                ((Button)sender).IsEnabled = true;

                var selected = new Dictionary <string, string>();

                foreach (var item in this.AppList.SelectedItems)
                {
                    var app = (AppDetail)item;
                    selected.Add(app.ProductFamilyName, app.DisplayName);
                }

                if (selected.Count == 0)
                {
                    this.SetStatusMessage("Select apps to uninstall.");
                }
                else
                {
                    foreach (var selectedItem in selected)
                    {
                        this.SetStatusMessage($"Uninstalling: {selectedItem.Value}");

                        AppTidier.RemoveApp(selectedItem.Key);

                        this.Apps.Remove(this.Apps.First(a => a.ProductFamilyName == selectedItem.Key));

                        this.SetStatusMessage();
                    }
                }
            }
            finally
            {
                ((Button)sender).IsEnabled = true;
            }
        }