Пример #1
0
 private void BtnSendText_Click(object sender, EventArgs e)
 {
     try
     {
         BtnSendText.Enabled = false;
         BtnSendFile.Enabled = false;
         TxtInput.ReadOnly   = true;
         Logger?.Debug("FrmTcpClient {0} sends text: {1}", Id, TxtInput.Text);
         WriteLogToUI("{0:yyyy-MM-dd HH:mm:ss} Send text: {1}", DateTime.Now, TxtInput.Text);
         bool isSuccessful;
         ///// Old method.
         // isSuccessful = TcpClientSend(Models.Param.TcpDataType.Text, Encoding.UTF8.GetBytes(TxtInput.Text));
         /// New method.
         isSuccessful = TcpClientSend(Helpers.TTcpSocket.Serialization.SerializeText(TxtInput.Text));
         if (isSuccessful)
         {
             TxtInput.Text       = "";
             TxtInput.ReadOnly   = false;
             BtnSendText.Enabled = true;
             BtnSendFile.Enabled = true;
             TxtInput.Focus();
         }
         else
         {
             Logger?.Error("FrmTcpClient {0} fails to send text: {1}", Id, TxtInput.Text);
             WriteLogToUI("Fail to send text: {0}", TxtInput.Text);
             DisconnectRoutine();
         }
     }
     catch (Exception ex)
     {
         Logger?.Error("Id = {0}", Id);
         Logger?.Error(ex);
     }
 }
Пример #2
0
        private void BtnF2C_Click(object sender, EventArgs e)
        {
            double f = Convert.ToDouble(TxtInput.Text);
            double c = (f - 32) * 5 / 9;

            TxtAns.Text = c.ToString("f2") + "度";
            TxtInput.Focus();
        }
Пример #3
0
 /// <summary>Creates a new instance of <see cref="InputNotification"/>.</summary>
 /// <param name="text">Text to be displayed.</param>
 /// <param name="windowName">Title to be displayed on the Window.</param>
 /// <param name="defaultText">Text to be displayed in the TxtInput TextBox by default.</param>
 public InputNotification(string text, string windowName, string defaultText = "")
 {
     InitializeComponent();
     Title         = windowName;
     TxtPopup.Text = text;
     TxtInput.Text = defaultText;
     TxtInput.Focus();
 }
Пример #4
0
        // Submit button
        //For the user to input what they think is correct
        private void BtnInput_Click(object sender, EventArgs e)
        {
            // for the user to guess
            string UserGuess;

            // to compare user input to word
            UserGuess = TxtInput.Text.ToString();
            bool value = cb.CompareWord(UserGuess);

            // The counter for each round if gussed correctly
            if (value == true)
            {
                // Display message box for right anwser
                MessageBox.Show("You are correct!!", "Correct", MessageBoxButtons.OK);
                {
                    // What radio button is click for each word list: This is Easy
                    if (RbtEasy.Checked)
                    {
                        LblWord.Text = cb.ScrambleEasy();
                        TxtInput.Clear();
                        TxtInput.Focus();
                    }

                    //What radio button is click for each word list: This is Medium
                    if (RbtMedium.Checked)
                    {
                        LblWord.Text = cb.ScrambleMedium();
                        TxtInput.Clear();
                        TxtInput.Focus();
                    }

                    //What radio button is click for each word list: This is Hard
                    if (RbtHard.Checked)
                    {
                        LblWord.Text = cb.ScrambleHard();
                        TxtInput.Clear();
                        TxtInput.Focus();
                    }
                }
                counter++;
            }
            // If the user is incorrect
            else
            {
                // Message box for incorrect
                MessageBox.Show("Wrong, try again!", "Incorrect", MessageBoxButtons.OK);
            }
            // Once counter has reached 5
            if (counter == 5)
            {
                // Hide currect window
                Hide();
                // Move to winner form
                Winner f3 = new Winner();
                f3.ShowDialog();
                Close();
            }
        }
Пример #5
0
        private void CmdFiles_Click(object sender, EventArgs e)
        {
            DialogResult result1 = MessageBox.Show("Αρχείο εισαγωγής στίχων: inverse.txt\nΑρχείο εγγραφής αποτελεσμάτων: outverse.txt\nΝα συνεχίσω ;", "Έγκριση ...", MessageBoxButtons.OKCancel);
            String       message = null;

            ErrorLines = 0;
            TotalLines = 0;

            if (result1 == DialogResult.OK)
            {
                try
                {
                    /*ΑΝΟΙΓΜΑ ΑΡΧΕΙΟΥ ΤΟ ΟΠΟΙΟ ΒΡΙΣΚΕΤΑΙ ΣΤΟ ΣΧΕΤΙΚΟ ΜΟΝΟΠΑΤΙ ΤΟΥ project*/
                    using (StreamReader inputFile = new StreamReader("inverse.txt"))  /*Το using στο τέλος κλείνει το stream*/
                    {
                        /*Εφόσον όλα πήγαν ΟΚ με το άνοιγμα του input file θα δημιουργήσουμε το αρχείο των αποτελεσμάτων*/
                        /*ΑΝΟΙΓΜΑ ΑΡΧΕΙΟΥ ΑΠΟΤΕΛΕΣΜΑΤΩΝ*/
                        using (StreamWriter outputFile = new StreamWriter("outverse.txt"))
                        {
                            LblResult.Text = "Μετρική ανάλυση σε εξέλιξη ..."; //Εμφάνιση μηνύματος στο LblResult
                            LblResult.SelectAll();
                            LblResult.SelectionColor = Color.Black;

                            /*ΔΙΑΒΑΣΜΑ ΓΡΑΜΜΗ-ΓΡΑΜΜΗ ΤΟΥ ΑΡΧΕΙΟΥ ΜΕΧΡΙ ΤΟ EOF*/
                            while ((VerseLine = inputFile.ReadLine()) != null)
                            {
                                //Αύξηση της τιμής του counter των γραμμών
                                TotalLines++;

                                //Μετρική ανάλυση αυτού του στίχου
                                Metrics.DoScansion(ref VerseLine, ref ScansionLine, ref ErrorLines);

                                outputFile.WriteLine(VerseLine);    //Εγγραφή στο αρχείο αποτελεσμάτων του στίχου
                                outputFile.WriteLine(ScansionLine); //και του αποτελέσματος της μετρικής του ανάλυσης
                            }
                        }

                        message = "Η μετρική ανάλυση μέσω αρχείων ολοκληρώθηκε.\nΣύνολο στίχων: " + TotalLines + "\nΣύνολο λαθών: " + ErrorLines;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Λάθος στη διαχείριση των αρχείων !", MessageBoxButtons.OK);
                    LblResult.Clear();
                    TxtInput.Focus();
                    return;
                }
            }
            else
            {
                message = "Η διαδικασία ακυρώθηκε !";
            }

            MessageBox.Show(message, "Τέλος μετρικής ανάλυσης", MessageBoxButtons.OK);
            LblResult.Clear();
            TxtInput.Focus();
        }
Пример #6
0
 public Scrambler()
 {
     // Song we are bringing in
     player.URL = "mario.mp3";
     InitializeComponent();
     // Generates the new scramble class
     cb = new ScrambleClass();
     // To focus the cusor
     TxtInput.Focus();
 }
Пример #7
0
 private void BtnOK_Click(object sender, EventArgs e)
 {
     if (IsValidData())
     {
         decimal salesTax = Convert.ToDecimal(TxtInput.Text);
         Tag = salesTax;
     }
     else
     {
         TxtInput.Clear();
         TxtInput.Focus();
     }
 }
Пример #8
0
 private void BtnF2C_Click(object sender, EventArgs e)
 {
     try
     {
         double f = Convert.ToDouble(TxtInput.Text);
         double c = (f - 32) * 5 / 9;
         TxtAns.Text = c.ToString("f2") + "度";
     }
     catch
     {
         TxtAns.Text = "度數請數入數值!";
         TxtInput.Clear();
     }
     TxtInput.Focus();
 }
Пример #9
0
        public Form1()
        {
            InitializeComponent();

            //Δήλωση του χειριστή συμβάντος (handler) για τη χρήση του "Enter" στο TxtInput RichTextBox
            this.TxtInput.KeyDown += new KeyEventHandler(TxtInput_KeyDown);

            TxtInput.Clear();
            TxtInput.Focus();

            VerseLine    = null;
            ScansionLine = null;
            TotalLines   = 0;
            ErrorLines   = 0;

            Metrics = new metrics();
        }
Пример #10
0
 public InputMessage(string Message)
 {
     InitializeComponent();
     Lable1.Content = Message;
     TxtInput.Focus();
 }
Пример #11
0
 private void Window_Activated(object sender, EventArgs e)
 {
     TxtInput.Focus();
     TxtInput.SelectAll();
 }
Пример #12
0
 private Prompt()
 {
     InitializeComponent();
     TxtInput.Focus();
 }
Пример #13
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     TxtInput.Focus();
     TxtInput.SelectAll();
 }
Пример #14
0
 private void CmdClear_Click(object sender, EventArgs e)
 {
     LblResult.Clear();
     TxtInput.Clear();
     TxtInput.Focus();
 }