Example #1
0
        /// <summary>Handles errors after the background worker and populates the listview with the result from the server.</summary>
        private void UpdateDirectoryBW_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            Enabled = true;
            DirectoryUpdateForm.Close();
            DirectoryUpdateForm.Dispose();

            if (e.Error is FileNotFoundException)
            {
                MessageBox.Show("Folder " + PathAsString + " not found!", "LBL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Path.Pop();
                UpdateDirectory();
                return;
            }

            if (e.Error != null)
            {
                if (e.Error is AuthenticationException)
                {
                    MessageBox.Show("Not enough permissions to use the server", "LBL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                if (e.Error is InvalidOperationException)
                {
                    MessageBox.Show("Server doesn't have the LBL Extension", "LBL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                if (e.Error is TimeoutException)
                {
                    MessageBox.Show("Server timed out! Disconnect and reconnect.", "LBL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                Close();
                return;
            }

            //Populate the listview
            FolderListBox.Items.Clear();
            FilesListBox.Items.Clear();

            //Populate Folders
            if (CurrentDirectory.Folders != null)
            {
                foreach (string Folder in CurrentDirectory.Folders)
                {
                    FolderListBox.Items.Add(Folder);
                }
            }


            //Populate Files
            if (CurrentDirectory.Files != null)
            {
                foreach (string File in CurrentDirectory.Files)
                {
                    FilesListBox.Items.Add(File);
                }
            }
        }
Example #2
0
        /// <summary>Interprets the results from the background worker</summary>
        private void LoginBW_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            Form.Close();
            Enabled = true;

            //Check if we're connected
            if (!Connection.Connected)
            {
                MessageBox.Show("Could not connect to the server!", "LBL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //Switch on login result.
            switch (Result)
            {
            case SwitchboardClient.LoginResult.SUCCESS:
                //We've successfully connected. Launch the de-esta cosa

                //Launch the mainform
                MainForm Haha = new MainForm(Connection);
                Hide();
                Haha.ShowDialog();
                Show();
                Connection.Close();

                break;

            case SwitchboardClient.LoginResult.INVALID:
                Connection.Close();
                MessageBox.Show("Invalid Login Credentials", "LBL", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                break;

            case SwitchboardClient.LoginResult.ALREADY:
                Connection.Close();
                //These shouldn't happen
                MessageBox.Show("?", "This isn't supposed to happen", MessageBoxButtons.OK, MessageBoxIcon.Question);
                break;

            case SwitchboardClient.LoginResult.OTHERLOCALE:
                Connection.Close();
                MessageBox.Show("Already logged in on another client.", "LBL", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                break;

            default:
                Connection.Close();
                MessageBox.Show("?", "This isn't supposed to happen", MessageBoxButtons.OK, MessageBoxIcon.Question);
                break;
            }
        }