示例#1
0
        private async void delete_Click(object sender, EventArgs e)                                 // This method run when delete button clicked
        {
            logCreate.Visible = true;                                                               // Unvisable log info
            logCreate.Text    = "Deleteing code from database";                                     // Inform user about current operation
            var asyncControl = await deleteCode();                                                  // Setting value of variable with value returned by deleteCode async method

            if (asyncControl == 0)
            {
                logCreate.Visible = false;                                                          // Unvisable log info
                MessageBox.Show(appErrors.noInternet(), appErrors.webError(),                       // Inform user about no internet connection
                                MessageBoxButtons.OK, MessageBoxIcon.Error);                        // Set buttons and icon of messagebox
            }
            else if (asyncControl == 1)
            {
                logCreate.Visible = false;                                                          // Unvisable log info
                MessageBox.Show(appErrors.databaseFail(), appErrors.databaseError(),                // Inform user about error while working in database
                                MessageBoxButtons.OK, MessageBoxIcon.Error);                        // Set buttons and icon of messagebox
            }
            else if (asyncControl == 2)
            {
                logCreate.Font = new Font("Microsoft Sans Serif", 26);                              // Set normal font for log info
                logCreate.Text = "CODE DELETED, REFRESH";                                           // Inform user about current situation
                MessageBox.Show(appInfos.deleteingFine(), appInfos.everythingFine(),                // Inform user about deleteing went fine
                                MessageBoxButtons.OK, MessageBoxIcon.Information);                  // Set buttons and icon of messagebox
            }
        }
        private async void encrypt_Click(object sender, EventArgs e)                            // This method run when click on button encrypt
        {
            logCreate.Visible = true;                                                           // Visiable log
            logCreate.Text    = "Checking for empty gaps";                                      // inform user about current operation
            if (codeName.Text == "" || codePassword.Text == "")                                 // If some gap is empty
            {
                logCreate.Visible = false;                                                      // Visiable log
                MessageBox.Show(appErrors.emptyGap(), appErrors.textError(),                    // Inform user about some empty gaps
                                MessageBoxButtons.OK, MessageBoxIcon.Error);                    // Set buttons and icon of messagebox
            }
            else                                                                                // Else
            {
                logCreate.Text = "Checking for code data are correct";                          // Inform user about current operation
                var asyncControl = await checkCodeData();                                       // Set value of asyncControl with value returned by async method checkCodeData

                if (asyncControl == 0)                                                          // If asyncControl is 0
                {
                    logCreate.Visible = false;                                                  // Visiable log
                    MessageBox.Show(appErrors.noInternet(), appErrors.webError(),               // Inform user about no internet connection
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);                // Set buttons and icon for messagebox
                }
                else if (asyncControl == 1)                                                     // If asyncControl is 1
                {
                    logCreate.Visible = false;                                                  // Visiable log
                    MessageBox.Show(appErrors.databaseFail(), appErrors.databaseError(),        // Inform user about error while working in database
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);                // Set buttons and icon for messagebox
                }
                else if (asyncControl == 2)                                                     // If asyncControl is 2
                {
                    logCreate.Visible = false;                                                  // Visiable log
                    MessageBox.Show(appErrors.wrongLogin(), appErrors.databaseError(),          // Inform user about wrong login data
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);                // Set buttons and icon for messagebox
                }
                else if (asyncControl == 3)                                                     // If asyncControl is 3
                {
                    int textLength = textRTB.TextLength;                                        // Set value of variable with textRTB length
                    logCreate.Text = "Encrypting, char 0/" + textLength.ToString();             // Inform user about current operation
                    for (int i = 0; i < textLength; i++)                                        // For each char in textRTB
                    {
                        effectRTB.Text = effectRTB.Text +                                       // Adding to effect text
                                         await returnCodeForChar(                               // Value returned by async method returnCodeForChar
                            textRTB.Text[i].ToString()) + "\n";                                 // Seting it in new line

                        logCreate.Text = "Encrypting, char " + i.ToString() + "/" +             // Inform user about current operation progress
                                         textLength.ToString();                                 // Inform user about current operation progress
                    }
                    logCreate.Visible = false;                                                  // Visiable log
                    effectRTB.Text    = effectRTB.Text + "!CONTROL VALUE";                      // Adding control value to effect
                    MessageBox.Show(appInfos.encryptFine(), appInfos.everythingFine(),          // Inform user about successfull encryption
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);          // Set buttons and icon for messagebox
                }
            }
        }
        private async void logIn_Click(object sender, EventArgs e)                       // This method run when logIn click
        {
            logCreate.Visible = true;                                                    // Visiable log
            logCreate.Text    = "Checking for empty gaps";                               // inform user about current operation
            if (codename.Text == "" || codepassword.Text == "")                          // If password or code name is empty
            {
                logCreate.Visible = false;                                               // Unvisiable log
                MessageBox.Show(appErrors.emptyGap(), appErrors.textError(),             // Inform user about some empty gaps
                                MessageBoxButtons.OK, MessageBoxIcon.Error);             // Set buttons and icon of messagebox
            }
            else                                                                         // Else
            {
                logCreate.Text = "Checking login data";                                  // inform user about current operation
                int asyncControl = await checkLoginData();                               // Seting asyncControl variable value as a value returned by async method checkLoginData

                if (asyncControl == 0)                                                   // If asyncControl value is 0
                {
                    logCreate.Visible = false;                                           // Unvisiable log
                    MessageBox.Show(appErrors.noInternet(), appErrors.webError(),        // Inform user about no internet connection
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);         // Set buttons and icon for messagebox
                }
                else if (asyncControl == 1)                                              // If asyncControl value is 1
                {
                    logCreate.Visible = false;                                           // Unvisiable log
                    MessageBox.Show(appErrors.databaseFail(), appErrors.databaseError(), // Inform user about error while working in database
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);         // Set buttons and icon for messagebox
                }
                else if (asyncControl == 2)                                              // If asyncControl value is 2
                {
                    logCreate.Visible = false;                                           // Unvisiable log
                    MessageBox.Show(appErrors.wrongLogin(), appErrors.databaseError(),   // Inform user about wrong login data
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);         // Set buttons and icon for messagebox
                }
                else if (asyncControl == 3)                                              // If asyncControl value is 3
                {
                    logCreate.Text = "Creating temporary file";                          // inform user about current operation
                    asyncControl   = await checkFileStatus();                            // Seting asyncControl variable value as a value returned by async method checkFileStatus

                    if (asyncControl == 0)                                               // If asyncControl value is 0
                    {
                        logCreate.Visible = false;                                       // Unvisiable log
                        MessageBox.Show(appErrors.fileFail(), appErrors.fileError(),     // Inform user about error while creating temporary file
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);     // Set buttons and icon for messagebox
                    }
                    else
                    {
                        logCreate.Visible = false;                                         // Unvisiable log
                        MessageBox.Show(appInfos.loginFine(), appInfos.everythingFine(),   // Inform user about successfull login
                                        MessageBoxButtons.OK, MessageBoxIcon.Information); // Set buttons and icon for messagebox
                        after.BringToFront();                                              // Bring after to front
                    }
                }
            }
        }
示例#4
0
        private async void createButton_Click(object sender, EventArgs e)                               // This method run when createButton clicked
        {
            logCreate.Visible = true;                                                                   // Visiable log
            logCreate.Text    = "Checking for empty gaps";                                              // inform user about current operation
            int asyncControl = await checkForSomeEmptyGaps();                                           // Seting asyncControl variable value as a value returned by async method checkForSomeEmptyGaps

            if (asyncControl == 0)                                                                      // If asyncControl value is 0
            {
                logCreate.Visible = false;                                                              // Unvisiable log
                MessageBox.Show(appErrors.emptyGap(), appErrors.textError(),                            // Inform user about some empty gaps
                                MessageBoxButtons.OK, MessageBoxIcon.Error);                            // Set buttons and icon for messagebox
                return;                                                                                 // Stoping create code
            }
            else                                                                                        // Else
            {
                logCreate.Text = "Checking for some replaced char codes";                               // inform user about current operation
                asyncControl   = await checkForSomeReplaceCode();                                       // Seting asyncControl variable value as a value returned by async method checkForSomeReplaceCode

                if (asyncControl == 0)                                                                  // If asyncControl value is 0
                {
                    logCreate.Visible = false;                                                          // Unvisiable log
                    MessageBox.Show(appErrors.codeReplace(), appErrors.textError(),                     // Inform user about same code given two times
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);                        // Set buttons and icon for messagebox
                    return;                                                                             // Stoping create code
                }
                else                                                                                    // Else
                {
                    logCreate.Text = "Inserting new code to database";                                  // Inform user about current operation
                    asyncControl   = await insertNewCode();                                             // Seting asyncControl variable value as a value returned by async method insertNewCode

                    if (asyncControl == 0)                                                              // If asyncControl value is 0
                    {
                        logCreate.Visible = false;                                                      // Unvisiable log
                        MessageBox.Show(appErrors.noInternet(), appErrors.webError(),                   // Inform user about no internet connection
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);                    // Set buttons and icon for messagebox
                    }
                    else if (asyncControl == 1)                                                         // If asyncControl value is 1
                    {
                        logCreate.Visible = false;                                                      // Unvisiable log
                        MessageBox.Show(appErrors.databaseFail(), appErrors.databaseError(),            // Inform user about some error while working in database
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);                    // Set buttons and icon for messagebox
                    }
                    else if (asyncControl == 2)                                                         // If asyncControl value is 2
                    {
                        logCreate.Visible = false;                                                      // Unvisiable log
                        MessageBox.Show(appErrors.codeExist(), appErrors.databaseError(),               // Inform user about code with given name already exist
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);                    // Set buttons and icon for messagebox
                    }
                    else if (asyncControl == 3)                                                         // If asyncControl value is 3
                    {
                        logCreate.Visible = false;                                                      // Unvisiable log
                        MessageBox.Show(appErrors.insertFail(), appErrors.databaseError(),              // Inform user about some error while inserting new code
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);                    // Set buttons and icon for messagebox
                    }
                    else if (asyncControl == 4)                                                         // If asyncControl value is 4
                    {
                        logCreate.Visible = false;                                                      // Unvisiable log
                        MessageBox.Show(appInfos.insertingFine(), appInfos.everythingFine(),            // Inform user about successfull operation
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);              // Set buttons and icon for messagebox)
                    }
                }
            }
        }