コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: mrlacey/UwpDevTidy
        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();
        }
コード例 #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();
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: mrlacey/UwpDevTidy
        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;
            }
        }