예제 #1
0
        public async void About()
        {
            var message =
                "Copyright (c) 2019 Georgy Perevozghikov <*****@*****.**>\nGithub page: https://github.com/lizaalert/lacmus/. Press `Github` button for more details.\nProvided by Yandex Cloud: https://cloud.yandex.com/." +
                "\nThis program comes with ABSOLUTELY NO WARRANTY." +
                "\nThis is free software, and you are welcome to redistribute it under GNU GPLv3 conditions.\nPress `License` button to learn more about the license";

            var msgBoxCustomParams = new MessageBoxCustomParams
            {
                ButtonDefinitions = new []
                {
                    new ButtonDefinition {
                        Name = "Ok", Type = ButtonType.Colored
                    },
                    new ButtonDefinition {
                        Name = "License"
                    },
                    new ButtonDefinition {
                        Name = "Github"
                    }
                },
                ContentTitle   = "About",
                ContentHeader  = "Lacmus desktop application. Version 0.3.2 alpha.",
                ContentMessage = message,
                Icon           = Icon.Avalonia,
                Style          = Style.None,
                ShowInCenter   = true,
                Window         = new MsBoxCustomWindow
                {
                    Height    = 400,
                    Width     = 1000,
                    CanResize = true
                }
            };
            var msgbox = MessageBoxManager.GetMessageBoxCustomWindow(msgBoxCustomParams);
            var result = await msgbox.Show();

            switch (result.ToLower())
            {
            case "ok": return;

            case "license": OpenUrl("https://github.com/lizaalert/lacmus/blob/master/LICENSE"); break;

            case "github": OpenUrl("https://github.com/lizaalert/lacmus"); break;
            }
        }
예제 #2
0
        public static async Task <string> ShowDialogCustom(Window window, string header, string message, params string[] buttons)
        {
            ButtonDefinition[] definitions = new ButtonDefinition[buttons.Length];
            for (int i = 0; i < buttons.Length; i++)
            {
                definitions[i] = new ButtonDefinition {
                    Name = buttons[i], Type = ButtonType.Default
                };
            }

            return(await MessageBoxManager.GetMessageBoxCustomWindow(new MessageBoxCustomParams
            {
                Style = Style.Windows,
                ContentHeader = header,
                ContentMessage = message,
                ButtonDefinitions = definitions
            }).ShowDialog(window));
        }
예제 #3
0
        private async void BtnViewData_Click(object?sender, Avalonia.Interactivity.RoutedEventArgs e)
        {
            if (await FailIfNothingSelected())
            {
                return;
            }

            AssetInfoDataGridItem gridItem = GetGridItem();

            if (gridItem.Size > 500000)
            {
                var bigFileBox = MessageBoxManager
                                 .GetMessageBoxCustomWindow(new MessageBoxCustomParams
                {
                    Style             = Style.Windows,
                    ContentHeader     = "Warning",
                    ContentMessage    = "The asset you are about to open is very big and may take a lot of time and memory.",
                    ButtonDefinitions = new[] {
                        new ButtonDefinition {
                            Name = "Continue anyway", Type = ButtonType.Colored
                        },
                        new ButtonDefinition {
                            Name = "Cancel", Type = ButtonType.Default
                        }
                    }
                });
                string result = await bigFileBox.Show();

                if (result == "Cancel")
                {
                    return;
                }
            }

            AssetTypeValueField field = GetSelectedFieldReplaced();
            DataWindow          data  = new DataWindow(field);

            data.Show();
        }
        private async Task LaunchButtonClick()
        {
            if (GameInstalled == "No connection")
            {
                return;
            }

            integrityCheckCanceled = false;

            List <string> exeArguments = new List <string>()
            {
                "-server.zoneruniverse.com:2307"
            };

            if (Settings.Instance.LauncherData.WindowedMode)
            {
                exeArguments.Add("-w");
            }

            if (Settings.Instance.LauncherData.DefaultDesktopResolution)
            {
                int w = 0;
                int h = 0;

                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    try
                    {
                        Process p = new Process();
                        p.StartInfo.UseShellExecute        = false;
                        p.StartInfo.RedirectStandardOutput = true;
                        p.StartInfo.FileName       = "wmic";
                        p.StartInfo.Arguments      = "desktopmonitor get screenheight, screenwidth";
                        p.StartInfo.CreateNoWindow = true;
                        p.Start();
                        string output = p.StandardOutput.ReadToEnd();
                        p.WaitForExit();

                        var match = System.Text.RegularExpressions.Regex.Match(output, @".*?\n(\d+).*?(\d+)");
                        w = int.Parse(match.Groups[1].Value);
                        h = int.Parse(match.Groups[2].Value);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLog("Unable to get and set screen resolution WINDOWS. ERROR: " + ex.Message);
                    }
                }
                else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
                {
                    try
                    {
                        Process p = new Process();
                        p.StartInfo.UseShellExecute        = false;
                        p.StartInfo.RedirectStandardOutput = true;
                        p.StartInfo.FileName       = "xrandr";
                        p.StartInfo.CreateNoWindow = true;
                        p.Start();
                        string output = p.StandardOutput.ReadToEnd();
                        p.WaitForExit();

                        if (output.Contains("'xrandr' not found"))
                        {
                            // TODO: HANDLE
                        }
                        else
                        {
                            var match = System.Text.RegularExpressions.Regex.Match(output, @"(\d+)x(\d+)\+0\+0");
                            w = int.Parse(match.Groups[1].Value);
                            h = int.Parse(match.Groups[2].Value);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLog("Unable to get and set scree resolution LINUX. ERROR: " + ex.Message);
                    }
                }

                Settings.Instance.SetResolution(w, h);
            }
            else
            {
            }

            if (!string.IsNullOrEmpty(primaryWindowViewModel.LoggedUser.AccCode) && !string.IsNullOrEmpty(primaryWindowViewModel.LoggedUser.AccSig))
            {
                exeArguments.Add($"-AccCode={primaryWindowViewModel.LoggedUser.AccCode}");
                exeArguments.Add($"-AccSig={primaryWindowViewModel.LoggedUser.AccSig}");
            }
            else
            {
                var result = await Api.WebRequest.PutRequest("/api/game/generate", null);

                if (result.Key == HttpStatusCode.OK)
                {
                    primaryWindowViewModel.LoggedUser.AccCode = result.Value["user"]["FlhookUser"]["loginSignature"]?.ToString();
                    primaryWindowViewModel.LoggedUser.AccSig  = result.Value["user"]["FlhookUser"]["loginCode"]?.ToString();

                    exeArguments.Add($"-AccCode={primaryWindowViewModel.LoggedUser.AccCode}");
                    exeArguments.Add($"-AccSig={primaryWindowViewModel.LoggedUser.AccSig}");
                }
                else
                {
                    await MessageBoxManager.GetMessageBoxCustomWindow(new MessageBoxCustomParams
                    {
                        Style                 = Style.UbuntuLinux,
                        ContentMessage        = "Unable to generate AccSig and AccCode \n",
                        ContentHeader         = "WARNING",
                        Icon                  = Icon.Warning,
                        WindowStartupLocation = WindowStartupLocation.CenterScreen,
                        ShowInCenter          = false,
                        ButtonDefinitions     = new[]
                        {
                            new ButtonDefinition {
                                Name = "OK", Type = ButtonType.Colored
                            }
                        }
                    }).Show();

                    Logger.WriteLog("Unable to generate AccCode and AccSig");

                    return;
                }
            }

            Process[] processesNames = Process.GetProcessesByName("freelancer");
            if (processesNames.Length == 0)
            {
                await LaunchCheck();

                if (integrityCheckCanceled)
                {
                    return;
                }

                try
                {
                    Process.Start($@"{Settings.Instance.LauncherData.AftermathInstall}\EXE\Freelancer.exe", string.Join(" ", exeArguments.ToArray()));
                }
                catch (Exception ex)
                {
                    Logger.WriteLog("Unable to start Freelancer. ERROR: " + ex.Message);
                }
            }
            else
            {
                const string stop      = "Stop Launching Freelancer";
                const string cont      = "Start Anyway";
                const string terminate = "Terminate & Start New";

                var result = await MessageBoxManager.GetMessageBoxCustomWindow(new MessageBoxCustomParams
                {
                    Style                 = Style.UbuntuLinux,
                    ContentMessage        = "A copy of Freelancer appears to already be running. Would you like to terminate this running process?\n",
                    ContentHeader         = "Freelancer Already Running?",
                    Icon                  = Icon.Warning,
                    ShowInCenter          = true,
                    WindowStartupLocation = WindowStartupLocation.CenterScreen,
                    ButtonDefinitions     = new[]
                    {
                        new ButtonDefinition {
                            Name = stop
                        },
                        //new ButtonDefinition { Name = cont },
                        new ButtonDefinition {
                            Name = terminate, Type = ButtonType.Colored
                        }
                    }
                }).Show();

                if (result == cont)
                {
                    await LaunchCheck();

                    if (integrityCheckCanceled)
                    {
                        return;
                    }

                    try
                    {
                        Process.Start($@"{Settings.Instance.LauncherData.AftermathInstall}\EXE\Freelancer.exe", string.Join(" ", exeArguments.ToArray()));
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLog("Unable to start Freelancer. ERROR: " + ex.Message);
                    }
                }
                else if (result == terminate)
                {
                    processesNames[0].Kill();

                    await LaunchCheck();

                    if (integrityCheckCanceled)
                    {
                        return;
                    }

                    try
                    {
                        Process.Start($@"{Settings.Instance.LauncherData.AftermathInstall}\EXE\Freelancer.exe", string.Join(" ", exeArguments.ToArray()));
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLog("Unable to start Freelancer. ERROR: " + ex.Message);
                    }
                }
                else
                {
                    return;
                }
            }
        }