Beispiel #1
0
        private void App_Startup(object sender, StartupEventArgs e)
        {
#if !DEBUG
            if (Process.GetProcessesByName("MultiRPC").Length > 1)
            {
                if (File.Exists(FileLocations.OpenFileLocalLocation))
                {
                    try
                    {
                        File.Delete(FileLocations.OpenFileLocalLocation);
                    }
                    catch
                    {
                        App.Logging.Application(App.Text.CouldntDelete + " " + FileLocations.OpenFileLocalLocation);
                    }
                }
                if (e.Args.Length > 0)
                {
                    File.WriteAllLines(FileLocations.OpenFileLocalLocation, new List <string> {
                        "LOADCUSTOM", e.Args[1]
                    });
                }
                else
                {
                    File.Create(FileLocations.OpenFileLocalLocation);
                }
                Current.Shutdown();
            }
            else if (e.Args.Length > 1 && e.Args[0] == "-custom")
            {
                StartedWithJumpListLogic = true;
                _ = CustomPage.JumpListLogic(e.Args[1], true);
            }
#endif

            FileWatch.Create();
            SettingsPage.UIText = new List <UIText>();
            GetLangFiles().ConfigureAwait(false).GetAwaiter().GetResult();
            UITextUpdate().ConfigureAwait(false).GetAwaiter().GetResult();
            Config = Config.Load().Result;
            UITextUpdate().ConfigureAwait(false).GetAwaiter().GetResult();
            Logging = new Logging();
            File.AppendAllText(FileLocations.ErrorFileLocalLocation,
                               $"\r\n------------------------------------------------------------------------------------------------\r\n{Text.ErrorsFrom} {DateTime.Now.ToLongDateString()} {DateTime.Now.ToLongTimeString()}");
            DispatcherUnhandledException += App_DispatcherUnhandledException;
        }
Beispiel #2
0
        private static async void Watcher_FileCreated(object sender, FileSystemEventArgs e)
        {
            if (e.Name == FileLocations.OpenFileName)
            {
                await Application.Current.Dispatcher.InvokeAsync(async() =>
                {
                    await Application.Current.MainWindow.Dispatcher.InvokeAsync(async() =>
                    {
                        await Task.Delay(1000);
                        string[] text;
                        using (var reader = File.OpenText(FileLocations.OpenFileLocalLocation))
                        {
                            text = (await reader.ReadToEndAsync()).Split('\r', '\n');
                        }

                        if (text[0] == "LOADCUSTOM") //Load a custom profile
                        {
                            CustomPage.JumpListLogic(text[2]);
                        }
                        else
                        {
                            Application.Current.MainWindow.WindowState = WindowState.Normal;
                            Application.Current.MainWindow.Activate();
                        }

                        try
                        {
                            File.Delete(FileLocations.OpenFileLocalLocation);
                        }
                        catch
                        {
                            App.Logging.Application($"{App.Text.CouldntDelete} {FileLocations.OpenFileLocalLocation}");
                        }
                    });
                });
            }
        }