Beispiel #1
0
        private async void buttonDirect_ClickAsync(object sender, EventArgs e)
        {
            int ov1 = Helper.ShowOverlay(this);
            FormDirectConnect formDirectConnect = new FormDirectConnect();

            if (formDirectConnect.ShowDialog() == DialogResult.OK)
            {
                string      ipToConnect = formDirectConnect.IP;
                int         ov2         = Helper.ShowOverlay(this);
                FormLoading formLoading = new FormLoading("Connecting to " + ipToConnect, 20);
                formLoading.Show();
                // Try to connect
                var result = await Task.Run(() => Connection.GetServiceOnIP(ipToConnect));

                formLoading.Close();
                Helper.HideOverlay(ov2);
                if (result != null) //Connected
                {
                    bool   pass      = (result["Password"].CompareTo("True") == 0) ? true : false;
                    string groupName = result["GroupName"];
                    Connect(ipToConnect, groupName, pass);
                }
                else
                {
                    int       ov3       = Helper.ShowOverlay(this);
                    FormAlert formAlert = new FormAlert("Error", "Can't establish connection to the server. Check provided IP", true);
                    formAlert.ShowDialog();
                    Helper.HideOverlay(ov3);
                }
            }
            Helper.HideOverlay(ov1);
        }
Beispiel #2
0
        private void buttonUsername_Click(object sender, EventArgs e)
        {
            int overlay = Helper.ShowOverlay(this);
            FormChangeUsername formChangeUsername = new FormChangeUsername();

            if (Connection.CurrentRole != Role.Notconnected)
            {
                FormAlert formAlert = new FormAlert("Error", "You are not allowed to change username when connected.", true);
                formAlert.ShowDialog();
            }
            else if (formChangeUsername.ShowDialog() == DialogResult.OK)
            {
                labelUsername.Text = Connection.CurrentUser.Username;
            }
            Helper.HideOverlay(overlay);
        }
Beispiel #3
0
        private void CloseViewer()
        {
            int       overlay   = Helper.ShowOverlay(this);
            FormAlert formAlert = new FormAlert("Confirm exit", "Exit viewer?");

            if (formAlert.ShowDialog() == DialogResult.OK)
            {
                if (Connection.CurrentGroup.settings.Download)
                {
                    FormAlert formAlert1 = new FormAlert("Slides available", "Would you like to download slides?");
                    if (formAlert1.ShowDialog() == DialogResult.OK)
                    {
                        FormDownloadSlide formProgress = new FormDownloadSlide();
                        formProgress.ShowDialog();
                    }
                }
                Helper.HideOverlay(overlay);
                this.Close();
                Connection.FormMenu.OnViewerClosed();
            }
            Helper.HideOverlay(overlay);
        }
Beispiel #4
0
 private void WorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     if (e.Cancelled)
     {
         // canceled
     }
     else if (e.Error != null)
     {
         Log.LogException(e.Error, "Error during converting");
         int       overlay   = Helper.ShowOverlay(this);
         FormAlert formAlert = new FormAlert("Error", "Error occured", true);
         formAlert.ShowDialog();
         Helper.HideOverlay(overlay);
         this.Close();
     }
     else
     {
         int       overlay   = Helper.ShowOverlay(this);
         FormAlert formAlert = new FormAlert("Finished", "Slides downloaded to " + dest, true);
         formAlert.ShowDialog();
         Helper.HideOverlay(overlay);
         this.Close();
     }
 }
Beispiel #5
0
        public void Connect(string ip = null, string name = null, bool passwordProtected = false)
        {
            if (listView1.SelectedItems.Count < 1 && ip == null)
            {
                return;
            }

            m_searchController.StopSearch();

            if (ip == null)
            {
                ip   = listView1.SelectedItems[0].SubItems[3].Text;
                name = listView1.SelectedItems[0].SubItems[0].Text;
                passwordProtected = (listView1.SelectedItems[0].ImageIndex == 0) ? true : false;
            }
            byte[] password = null;
            if (!String.IsNullOrEmpty(ip))
            {
                if (passwordProtected)
                {
                    FormPassword formPassword = new FormPassword(name);
                    int          overlay      = Helper.ShowOverlay(this);
                    if (formPassword.ShowDialog() == DialogResult.OK)
                    {
                        password = formPassword.Password;
                        Helper.HideOverlay(overlay);
                    }
                    else
                    {
                        Helper.HideOverlay(overlay);
                        return;
                    }
                }

                switch (Connection.EstablishClientConnection(ip, password))
                {
                case ConnectionResult.Error:
                    int       overlay        = Helper.ShowOverlay(this);
                    FormAlert formAlertError = new FormAlert("Error", "Some error occured during connection.", true);
                    formAlertError.ShowDialog();
                    Helper.HideOverlay(overlay);
                    StartSearch();
                    break;

                case ConnectionResult.WrongPassword:
                    int       overlay2        = Helper.ShowOverlay(this);
                    FormAlert formAlertError2 = new FormAlert("Wrong password", "Password you entered is incorrect. Prease try again.", true);
                    formAlertError2.ShowDialog();
                    Helper.HideOverlay(overlay2);
                    Connect();
                    break;

                case ConnectionResult.UsernameExists:
                    int       overlay3        = Helper.ShowOverlay(this);
                    FormAlert formAlertError3 = new FormAlert("Error", "Such username already exists in a group", true);
                    formAlertError3.ShowDialog();
                    Helper.HideOverlay(overlay3);
                    StartSearch();
                    break;

                case ConnectionResult.UserBanned:
                    int       pverlay4        = Helper.ShowOverlay(this);
                    FormAlert formAlertError4 = new FormAlert("Error", "You was banned from this group", true);
                    formAlertError4.ShowDialog();
                    Helper.HideOverlay(pverlay4);
                    StartSearch();
                    break;

                case ConnectionResult.Success:
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                    break;
                }
            }
            else
            {
                // TODO
            }
        }