Example #1
0
        //protected override bool ProcessKeyPreview(ref System.Windows.Forms.Message m)
        //{
        //    int key = m.WParam.ToInt32();
        //    if (m.Msg == WM_KEYUP)
        //    {
        //        if (key == (int)Keys.ControlKey)
        //        {
        //            if (Control.ModifierKeys == Keys.L)
        //            {
        //                aboutLandToolStripMenuItem.PerformClick();
        //            }
        //            else if (Control.ModifierKeys == Keys.P)
        //            {
        //                tmnuPrefs.PerformClick();
        //            }
        //            else if (Control.ModifierKeys == Keys.E)
        //            {
        //                Close();
        //            }
        //            else if (Control.ModifierKeys == Keys.R)
        //            {
        //                avatarToolStripMenuItem.PerformClick();
        //            }
        //            else if (Control.ModifierKeys == Keys.W)
        //            {
        //                awayToolStripMenuItem.PerformClick();
        //            }
        //            else if (Control.ModifierKeys == Keys.B)
        //            {
        //                busyToolStripMenuItem.PerformClick();
        //            }
        //            else if (Control.ModifierKeys == Keys.F)
        //            {
        //                fallOnFaceToolStripMenuItem.PerformClick();
        //            }
        //            else if (Control.ModifierKeys == Keys.H)
        //            {
        //                tPHomeToolStripMenuItem.PerformClick();
        //            }
        //            else if (Control.ModifierKeys == Keys.T)
        //            {
        //                tbtnTeleport.PerformClick();
        //            }
        //            else if (Control.ModifierKeys == Keys.M)
        //            {
        //                btnMap.PerformClick();
        //            }
        //            else if (Control.ModifierKeys == Keys.O)
        //            {
        //                tbtnObjects.PerformClick();
        //            }
        //            //else if (Control.ModifierKeys == Keys.D)
        //            //{
        //            //    tbtnDebug.Visible = !tbtnDebug.Visible;
        //            //}
        //            else if (Control.ModifierKeys == Keys.Y)
        //            {
        //                helpToolStripMenuItem.PerformClick();
        //            }
        //        }
        //        else if (key == (int)Keys.Alt)
        //        {
        //            if (Control.ModifierKeys == Keys.D)
        //            {
        //                tbtnDebug.Visible = !tbtnDebug.Visible;
        //            }
        //        }
        //    }
        //    return false;
        //}
        /// <summary>
        /// Disconnects from the server.
        /// Optionally forks METArestart.exe based on this.LogOffClicked
        /// Optionally closes the window.
        /// 
        /// This method ensures its logic executes only once to eliminate errors and unintentional conflicts.
        /// </summary>
        /// <param name="closeWindow">Determines whether this method should call this.Close()</param>
        private void Disconnect(bool closeWindow)
        {
            // Only run this once
            if (this.disconnectHasExecuted)
            {
                return;
            }

            this.disconnectHasExecuted = true;

            // Functional shutdown
            statusTimer.Elapsed -= new ElapsedEventHandler(statusTimer_Elapsed);
            statusTimer.Stop();

            if (!string.IsNullOrEmpty(netcom.LoginOptions.FirstName) && !string.IsNullOrEmpty(netcom.LoginOptions.LastName))
            {
                if (netcom.IsLoggedIn)
                {
                    string full_name = netcom.LoginOptions.FirstName + "_" + netcom.LoginOptions.LastName;
                    instance.Config.SetAvConfig(full_name);
                }
            }

            if (netcom.IsLoggedIn)
            {
                netcom.Logout();
            }

            // Special case for server-side disconnect rather than user-initiated
            if (!instance.LogOffClicked)
            {
                if (!instance.Config.CurrentConfig.AutoRestart)
                {
                    // Auto-restart
                    try
                    {
                        int restartinterval = instance.Config.CurrentConfig.ReStartTime * 60; // convert to seconds

                        Process p = new Process();
                        p.StartInfo.FileName = "METArestart.exe";
                        p.StartInfo.WorkingDirectory = Application.StartupPath;
                        p.StartInfo.Arguments = netcom.LoginOptions.FirstName + " " + netcom.LoginOptions.LastName + " " + netcom.LoginOptions.Password + " " + disconnectreason.Replace(" ", "|") + " " + restartinterval.ToString(CultureInfo.CurrentCulture);
                        p.Start();
                    }
                    catch (Exception ex)
                    {
                        Logger.Log("Exception while trying to execute METArestart.exe: " + ex.Message, Helpers.LogLevel.Error);
                        return;
                    }
                }
                else
                {
                    tlTools.Enabled = tlLogs.Enabled = tsUtilities.Enabled = btnMap.Enabled = btnAvatar.Enabled = tbtnTeleport.Enabled = tbtnObjects.Enabled = false;
                    statusTimer.Enabled = false;
                    statusTimer.Stop();

                    RefreshStatusBar();
                    RefreshWindowTitle();

                    //instance.ReadIMs = false;

                    //(new frmDisconnected(instance, disconnectreason)).ShowDialog(this);

                    if (!instance.Config.CurrentConfig.HideDisconnectPrompt)
                    {
                        (new frmDisconnected(instance, disconnectreason)).ShowDialog(this);

                        if (instance.ReadIMs) return;
                    }
                }
            }

            try
            {
                // UI shutdown
                tlTools.Enabled = btnMap.Enabled = btnAvatar.Enabled = tbtnTeleport.Enabled = tbtnObjects.Enabled = false;
                RefreshStatusBar();
                RefreshWindowTitle();

                if (debugLogForm != null && !debugLogForm.Disposing)
                {
                    debugLogForm.Dispose();
                    debugLogForm.Close();
                    debugLogForm = null;
                }
            }
            catch
            {
                ;
            }

            if (closeWindow)
            {
                this.Close();
            }
        }
Example #2
0
        /// <summary>
        /// Disconnects from the server on request.
        /// Always forks METArestart.exe overriding disconnectreason and restartinterval
        /// Optionally closes the window.
        /// 
        /// This method ensures its logic executes only once to eliminate errors and unintentional conflicts.
        /// </summary>
        /// <param name="closeWindow">Determines whether this method should call this.Close()</param>
        /// <returns>false if already run or failed to execute METArestart, otherwise true</returns>
        public bool DisconnectClient(bool CloseWindow, string Reason, int ReconnectWaitMinutes)
        {
            // Only run this once
            if (this.disconnectHasExecuted)
            {
                return false;
            }

            this.disconnectHasExecuted = true;

            // Functional shutdown
            statusTimer.Elapsed -= new ElapsedEventHandler(statusTimer_Elapsed);
            statusTimer.Stop();

            if (!string.IsNullOrEmpty(netcom.LoginOptions.FirstName) && !string.IsNullOrEmpty(netcom.LoginOptions.LastName))
            {
                if (netcom.IsLoggedIn)
                {
                    string full_name = netcom.LoginOptions.FirstName + "_" + netcom.LoginOptions.LastName;
                    instance.Config.SetAvConfig(full_name);
                }
            }

            if (netcom.IsLoggedIn)
            {
                netcom.Logout();
            }

            if (!instance.Config.CurrentConfig.AutoRestart)
            {
                try
                {
                    int restartinterval = 10;

                    checked
                    {
                        restartinterval = ReconnectWaitMinutes * 60; // convert to seconds
                    }

                    disconnectreason = Reason;

                    Process p = new Process();
                    p.StartInfo.FileName = "METArestart.exe";
                    p.StartInfo.WorkingDirectory = Application.StartupPath;
                    p.StartInfo.Arguments = netcom.LoginOptions.FirstName + " " + netcom.LoginOptions.LastName + " " + netcom.LoginOptions.Password + " " + disconnectreason.Replace(" ", "|") + " " + restartinterval.ToString(CultureInfo.CurrentCulture);
                    p.Start();
                }
                catch (Exception ex)
                {
                    Logger.Log("Exception while trying to execute METArestart.exe: " + ex.Message, Helpers.LogLevel.Error);
                    return false;
                }
            }

            try
            {
                // UI shutdown
                tlTools.Enabled = btnMap.Enabled = btnAvatar.Enabled = tbtnTeleport.Enabled = tbtnObjects.Enabled = false;

                RefreshStatusBar();
                RefreshWindowTitle();

                if (debugLogForm != null && !debugLogForm.Disposing)
                {
                    debugLogForm.Dispose();
                    debugLogForm.Close();
                    debugLogForm = null;
                }
            }
            catch
            {
                ;
            }

            if (CloseWindow)
            {
                this.Close();
            }

            return true;
        }
Example #3
0
 private void debugLogsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         debugLogForm.Show(this);
     }
     catch
     {
         //Logger.Log(String.Format("Debug Form Display Error: {0}", exp), Helpers.LogLevel.Error);
         debugLogForm.Dispose();
         debugLogForm = new frmDebugLog(instance);
     }
 }
Example #4
0
        private void InitializeDebugLogForm()
        {
            if (InvokeRequired)
            {
                BeginInvoke((MethodInvoker)delegate
                {
                    InitializeDebugLogForm();
                });

                return;
            }

            debugLogForm = new frmDebugLog(instance);
        }