Esempio n. 1
0
        private async void FormMain_Load(object sender, EventArgs e)
        {
            // Set synchronization context
            syncContext = SynchronizationContext.Current;

            if (Updater.Exists())
            {
                Updater.CheckSilent();
            }

            Version version = await Updater.CheckWebVersion();

            if (version != null)
            {
                notifyIcon.ShowBalloonTip(3000, "Update available", $"A new version ({version}) is available. Click here to get it!", ToolTipIcon.Info);
            }

            // Register Events
            ArkRcon.Client.Connecting       += Client_Connecting;
            ArkRcon.Client.Connected        += Client_Connected;
            ArkRcon.Client.ConnectionFailed += Client_ConnectionFailed;
            ArkRcon.Client.Disconnected     += Client_Disconnected;

            // Connect to default server
            Server defaultServer = Data.Data.Servers.FirstOrDefault(s => s.Default);

            if (defaultServer != null)
            {
                try
                {
                    ArkRcon.Connect(defaultServer);
                    //Rcon.Connect(defaultServer);
                }
                catch (Exception ex)
                {
                    new TaskDialog()
                    {
                        WindowTitle              = "Connection failed",
                        MainInstruction          = ex.Message,
                        Content                  = "Make sure that the server is online and configured correctly.",
                        CommonButtons            = TaskDialogCommonButtons.Ok,
                        MainIcon                 = TaskDialogIcon.Warning,
                        PositionRelativeToWindow = true
                    }.Show(this);
                }
            }
        }
Esempio n. 2
0
        private void Client_Disconnected(object sender, bool requested)
        {
            syncContext.Send(state =>
            {
                tsbConnect.Visible          = true;
                tsbDisconnect.Visible       = false;
                toolStripSeparator1.Visible = false;
                tsbSaveWorld.Visible        = false;
                tsExitServer.Visible        = false;

                tabControl1.Visible = false;

                tslConnection.Image = Resources.disconnect;
                tslConnection.Text  = "Not Connected";
            }, null);

            SetStatus("Disconnected");

            if (!requested)
            {
                // Reconnect
                try
                {
                    ArkRcon.Connect(ArkRcon.ConnectedServer);
                }
                catch (Exception)
                {
                    syncContext.Send(state =>
                    {
                        new TaskDialog()
                        {
                            WindowTitle              = "Reconnect failed",
                            MainInstruction          = "Reconnect failed",
                            Content                  = "Make sure that the server is online and configured correctly.",
                            CommonButtons            = TaskDialogCommonButtons.Ok,
                            MainIcon                 = TaskDialogIcon.Warning,
                            PositionRelativeToWindow = true
                        }.Show(this);
                    }, null);
                }
            }
        }