Beispiel #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            //Check Version
            var newVersion = GitChecker.CheckNewVersion();

            if (newVersion != null)
            {
                var result = MessageBox.Show($"There's a new Version available {newVersion.ToString()}\n Download it now?", "New Version", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
                if (result == MessageBoxResult.Yes)
                {
                    System.Diagnostics.Process.Start("https://github.com/adisadi/wotget/releases/latest");
                }
                Application.Current.Shutdown();
            }

            // get the theme from the current application
            var theme = ThemeManager.DetectAppStyle(Application.Current);

            // now set the Green accent and dark theme
            ThemeManager.ChangeAppStyle(Application.Current,
                                        ThemeManager.GetAccent(GUI.Properties.Settings.Default.Accent),
                                        ThemeManager.GetAppTheme(GUI.Properties.Settings.Default.Theme));

            base.OnStartup(e);
        }
Beispiel #2
0
        static void Main2()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //Check Version
            var newVersion = GitChecker.CheckNewVersion();

            if (newVersion != null)
            {
                var result = MessageBox.Show($"There's a new Version available {newVersion.ToString()}\n Download it now?", "New Version", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                if (result == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start("https://github.com/adisadi/wotget/releases/latest");
                }
                Application.Exit();
            }

            Application.Run(new Main());
        }
Beispiel #3
0
        static int Main2(string[] args)
        {
            try
            {
#if DEBUG
                System.Diagnostics.Debugger.Launch();
#endif

                string invokedVerb         = "";
                object invokedVerbInstance = "";

                var options = new Options();
                if (!CommandLine.Parser.Default.ParseArguments(args, options,
                                                               (verb, subOptions) =>
                {
                    // if parsing succeeds the verb name and correct instance
                    // will be passed to onVerbCommand delegate (string,object)
                    invokedVerb = verb.ToLower();
                    invokedVerbInstance = subOptions;
                }))
                {
                    Environment.Exit(CommandLine.Parser.DefaultExitCodeFail);
                }
                var version = Assembly.GetExecutingAssembly().GetName().Version;

                ConsoleHelper.ColoredConsoleWriteLine(ConsoleColor.Yellow, $"WoTget Version: {version.ToString()}");

                var newVersion = GitChecker.CheckNewVersion();
                if (newVersion != null)
                {
                    ConsoleHelper.ColoredConsoleWriteLine(ConsoleColor.Red, $"New WoTget Version: {newVersion.ToString()}");
                    System.Diagnostics.Process.Start("https://github.com/adisadi/wotget/releases/latest");
                    return(0);
                }


                AddConsoleAppender(invokedVerbInstance is BaseSubOptions && ((BaseSubOptions)invokedVerbInstance).Verbose ? Level.Debug : Level.Info);

                WoTget.Application.InitializeInstance((string)JsonConfig.Config.Global.GoogleKeyFile);
                App = Application.Instance;


                if (invokedVerb == "init")
                {
                    return(InitCommand((InitSubOptions)invokedVerbInstance));
                }

                if (!App.IsDatabaseInitialized() && invokedVerb != "init")
                {
                    Console.WriteLine();
                    ConsoleHelper.ColoredConsoleWrite(ConsoleColor.Yellow, $"What's your WoT Game Directory? (Default:C:\\Games\\World_of_Tanks):");
                    string wotDirectory = Console.ReadLine();
                    if (string.IsNullOrEmpty(wotDirectory))
                    {
                        wotDirectory = "C:\\Games\\World_of_Tanks";
                    }

                    var returnValue = InitCommand(new InitSubOptions {
                        WotGameDirectory = wotDirectory
                    });
                    if (returnValue == 1)
                    {
                        return(1);
                    }
                }



                ConsoleHelper.ColoredConsoleWriteLine(ConsoleColor.Green, $"WoT Version: '{App.GetWotVersion()}' Game Directory: '{App.GetWotHome()}'");
                Console.WriteLine("");

                if (invokedVerb == "list")
                {
                    return(ListCommand((ListSubOptions)invokedVerbInstance));
                }

                if (invokedVerb == "install")
                {
                    return(InstallCommand((InstallSubOptions)invokedVerbInstance));
                }

                if (invokedVerb == "update")
                {
                    return(UpdateCommand((UpdateSubOptions)invokedVerbInstance));
                }

                if (invokedVerb == "uninstall")
                {
                    return(UninstallCommand((UninstallSubOptions)invokedVerbInstance));
                }

                //Package Managment Commands
                if (invokedVerb == "add")
                {
                    return(AddCommand((AddSubOptions)invokedVerbInstance));
                }

                if (invokedVerb == "remove")
                {
                    return(RemoveCommand((RemoveSubOptions)invokedVerbInstance));
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.ToString());
                return(1);
            }

            return(0);
        }