private void App_OnStartup(object sender, StartupEventArgs e)
        {
            if (SingleApplicationDetector.IsRunning())
            {
                if (MessageBox.Show(
                        "Detected already running TeknoParrot Ui, want me to close it for you?", "Error",
                        MessageBoxButton.YesNo, MessageBoxImage.Error) == MessageBoxResult.Yes)
                {
                    TerminateProcesses();
                }
                else
                {
                    Application.Current.Shutdown(0);
                    return;
                }
            }
            if (File.Exists("DumbJVSManager.exe"))
            {
                MessageBox.Show(
                    "Seems you have extracted me to directory of old TeknoParrot, please extract me to a new directory instead!",
                    "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown(0);
                return;
            }
            var parrotData = JoystickHelper.DeSerialize();

            if (parrotData == null)
            {
                StartApp();
                return;
            }
            if (e.Args.Length != 0)
            {
                // Process command args
                if (HandleArgs(e.Args))
                {
                    // Args ok, let's do stuff
                    if (_emuOnly)
                    {
                        TeknoParrotUi.Views.GameRunning g = new TeknoParrotUi.Views.GameRunning(_profile, _test, parrotData, _profile.TestMenuParameter,
                                                                                                _profile.TestMenuIsExecutable, _profile.TestMenuExtraParameters, true);
                        g.Show();
                        return;
                    }
                    else
                    {
                        TeknoParrotUi.Views.GameRunning g = new TeknoParrotUi.Views.GameRunning(_profile, _test, parrotData, _profile.TestMenuParameter,
                                                                                                _profile.TestMenuIsExecutable, _profile.TestMenuExtraParameters, false);
                        g.Show();
                        return;
                    }
                }
            }
            StartApp();
        }
Beispiel #2
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            // Localization testing without changing system language.
            // Language code list: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-lcid/70feba9f-294e-491e-b6eb-56532684c37f
            //System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-FR");

            if (SingleApplicationDetector.IsRunning())
            {
                if ((e.Args.Any(x => x.StartsWith("--profile=")) && e.Args.All(x => x != "--emuonly")) || (e.Args.Any(x => x.StartsWith("--profile=")) && e.Args.Any(x => x == "--emuonly")))
                {
                }
                else
                {
                    if (MessageBoxHelper.ErrorYesNo(TeknoParrotUi.Properties.Resources.ErrorAlreadyRunning))
                    {
                        TerminateProcesses();
                    }
                    else
                    {
                        Current.Shutdown(0);
                        return;
                    }
                }
            }

            if (File.Exists("DumbJVSManager.exe"))
            {
                MessageBoxHelper.ErrorOK(TeknoParrotUi.Properties.Resources.ErrorOldTeknoParrotDirectory);
                Current.Shutdown(0);
                return;
            }

            // updater cleanup
            var bakfiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.bak", SearchOption.AllDirectories);

            foreach (var file in bakfiles)
            {
                try
                {
                    Debug.WriteLine($"Deleting old updater file {file}");
                    File.Delete(file);
                }
                catch
                {
                    // ignore..
                }
            }

            // old description file cleanup
            var olddescriptions = Directory.GetFiles("Descriptions", "*.xml");

            foreach (var file in olddescriptions)
            {
                try
                {
                    Debug.WriteLine($"Deleting old description file {file}");
                    File.Delete(file);
                }
                catch
                {
                    // ignore..
                }
            }

            JoystickHelper.DeSerialize();

            Current.Resources.MergedDictionaries.Clear();
            Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
            {
                Source = new Uri(GetResourceString($"MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml"))
            });
            Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
            {
                Source = new Uri(GetResourceString("MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml"))
            });
            Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
            {
                Source = new Uri(GetResourceString($"MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.LightBlue.xaml"))
            });
            Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
            {
                Source = new Uri(GetResourceString("MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml"))
            });

            LoadTheme(Lazydata.ParrotData.UiColour, Lazydata.ParrotData.UiDarkMode, Lazydata.ParrotData.UiHolidayThemes);

            if (Lazydata.ParrotData.UiDisableHardwareAcceleration)
            {
                RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
            }

            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            if (e.Args.Length != 0)
            {
                // Process command args
                if (HandleArgs(e.Args) && Views.Library.ValidateAndRun(_profile, out var loader, out var dll, _emuOnly))
                {
                    var gamerunning = new Views.GameRunning(_profile, loader, dll, _test, _emuOnly, _profileLaunch);

                    // Args ok, let's do stuff
                    var window = new Window
                    {
                        Title     = "GameRunning",
                        Content   = gamerunning,
                        MaxWidth  = 800,
                        MaxHeight = 800,
                    };

                    //             d:DesignHeight="800" d:DesignWidth="800" Loaded="GameRunning_OnLoaded" Unloaded="GameRunning_OnUnloaded">
                    window.Dispatcher.ShutdownStarted += (x, x2) => gamerunning.GameRunning_OnUnloaded(null, null);

                    window.Show();

                    return;
                }
            }
            DiscordRPC.StartOrShutdown();

            StartApp();
        }
Beispiel #3
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            if (SingleApplicationDetector.IsRunning())
            {
                if ((e.Args.Any(x => x.StartsWith("--profile=")) && e.Args.All(x => x != "--emuonly")) || (e.Args.Any(x => x.StartsWith("--profile=")) && e.Args.Any(x => x == "--emuonly")))
                {
                }
                else
                {
                    if (MessageBox.Show(
                            "TeknoParrot UI seems to already be running, want me to close it?", "Error",
                            MessageBoxButton.YesNo, MessageBoxImage.Error) == MessageBoxResult.Yes)
                    {
                        TerminateProcesses();
                    }
                    else
                    {
                        Application.Current.Shutdown(0);
                        return;
                    }
                }
            }
            if (File.Exists("DumbJVSManager.exe"))
            {
                MessageBox.Show(
                    "Seems you have extracted me to directory of old TeknoParrot, please extract me to a new directory instead!",
                    "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown(0);
                return;
            }
            var parrotData = JoystickHelper.DeSerialize();

            if (parrotData == null)
            {
                StartApp();
                return;
            }

            if (parrotData.UseDiscordRPC && File.Exists("discord-rpc.dll"))
            {
                DiscordRPC.Initialize(APP_ID, IntPtr.Zero, false, null);
            }

            if (e.Args.Length != 0)
            {
                // Process command args
                if (HandleArgs(e.Args))
                {
                    // Args ok, let's do stuff
                    Window window = new Window
                    {
                        Title   = "GameRunning",
                        Content = new TeknoParrotUi.Views.GameRunning(_profile, _test, parrotData, _profile.TestMenuParameter,
                                                                      _profile.TestMenuIsExecutable, _profile.TestMenuExtraParameters, _emuOnly, _profileLaunch),
                        MaxWidth  = 800,
                        MaxHeight = 800
                    };
                    window.Show();
                    return;
                }
            }
            StartApp();
        }
Beispiel #4
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            if (SingleApplicationDetector.IsRunning())
            {
                if ((e.Args.Any(x => x.StartsWith("--profile=")) && e.Args.All(x => x != "--emuonly")) || (e.Args.Any(x => x.StartsWith("--profile=")) && e.Args.Any(x => x == "--emuonly")))
                {
                }
                else
                {
                    if (MessageBox.Show(
                            "TeknoParrot UI seems to already be running, want me to close it?", "Error",
                            MessageBoxButton.YesNo, MessageBoxImage.Error) == MessageBoxResult.Yes)
                    {
                        TerminateProcesses();
                    }
                    else
                    {
                        Current.Shutdown(0);
                        return;
                    }
                }
            }

            if (File.Exists("DumbJVSManager.exe"))
            {
                MessageBox.Show(
                    "Seems you have extracted me to directory of old TeknoParrot, please extract me to a new directory instead!",
                    "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Shutdown(0);
                return;
            }

            // updater cleanup
            var bakfiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.bak", SearchOption.AllDirectories);

            foreach (var file in bakfiles)
            {
                try
                {
                    Debug.WriteLine($"Deleting old updater file {file}");
                    File.Delete(file);
                }
                catch
                {
                    // ignore..
                }
            }

            // old description file cleanup
            var olddescriptions = Directory.GetFiles("Descriptions", "*.xml");

            foreach (var file in olddescriptions)
            {
                try
                {
                    Debug.WriteLine($"Deleting old description file {file}");
                    File.Delete(file);
                }
                catch
                {
                    // ignore..
                }
            }

            JoystickHelper.DeSerialize();

            Current.Resources.MergedDictionaries.Clear();
            Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
            {
                Source = new Uri(GetResourceString($"MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml"))
            });
            Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
            {
                Source = new Uri(GetResourceString("MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml"))
            });
            Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
            {
                Source = new Uri(GetResourceString($"MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.LightBlue.xaml"))
            });
            Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
            {
                Source = new Uri(GetResourceString("MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml"))
            });

            LoadTheme(Lazydata.ParrotData.UiColour, Lazydata.ParrotData.UiDarkMode);

            if (Lazydata.ParrotData.UiDisableHardwareAcceleration)
            {
                RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
            }

            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

            if (e.Args.Length != 0)
            {
                // Process command args
                if (HandleArgs(e.Args) && Views.Library.ValidateAndRun(_profile, out var loader, out var dll, _emuOnly))
                {
                    var gamerunning = new Views.GameRunning(_profile, loader, dll, _test, _emuOnly, _profileLaunch);

                    // Args ok, let's do stuff
                    var window = new Window
                    {
                        Title     = "GameRunning",
                        Content   = gamerunning,
                        MaxWidth  = 800,
                        MaxHeight = 800,
                    };

                    //             d:DesignHeight="800" d:DesignWidth="800" Loaded="GameRunning_OnLoaded" Unloaded="GameRunning_OnUnloaded">
                    window.Dispatcher.ShutdownStarted += (x, x2) => gamerunning.GameRunning_OnUnloaded(null, null);

                    window.Show();

                    return;
                }
            }
            DiscordRPC.StartOrShutdown();

            StartApp();
        }