/// <summary>
        /// Used to set correct variables based on the winner
        /// then calls to set a winner
        /// </summary>
        /// <param name="con">All controls in the form</param>
        /// <param name="winner"></param>
        public static void EvaluateWinner(Control.ControlCollection con, string winner) // New name??
        {
            // Gets the controls
            playerOneName  = con.Find("textPlayerOneName", false).FirstOrDefault();
            playerTwoName  = con.Find("textPlayerTwoName", false).FirstOrDefault();
            playerOneLabel = con.Find("labelPlayerOneScoreShow", false).FirstOrDefault();
            playerTwoLabel = con.Find("labelPlayerTwoScoreShow", false).FirstOrDefault();

            // Based on winner X,O
            if (winner == "X")
            {
                if (playerOneName.Text == "")
                {
                    winnerName = winner;
                }
                else
                {
                    winnerName = playerOneName.Text;
                }
                DisplayWinner(playerOneLabel, playerOneName, winnerName);
            }
            if (winner == "O")
            {
                if (playerTwoName.Text == "")
                {
                    winnerName = winner;
                }
                else
                {
                    winnerName = playerTwoName.Text;
                }
                DisplayWinner(playerTwoLabel, playerTwoName, winnerName);
            }
        }
Esempio n. 2
0
 public static void SetDateCtrlValue(Control.ControlCollection controls, string name, string value)
 {
     try
     {
         name = name + "DateTimePicker";
         if (controls.Find(name, false).Count() > 0)
         {
             ((System.Windows.Forms.DateTimePicker)(controls.Find(name, false)[0])).Value = StringToDate(value);
         }
     }
     catch (Exception ex) { }
 }
Esempio n. 3
0
 public static void SetComBoxCtrlValue(Control.ControlCollection controls, string name, string value)
 {
     try
     {
         name = name + "ComboBox";
         if (controls.Find(name, false).Count() > 0)
         {
             ((System.Windows.Forms.ComboBox)(controls.Find(name, false)[0])).Text = value;
         }
     }
     catch (Exception ex) { }
 }
Esempio n. 4
0
 public static void SetDateCtrlValue(Control.ControlCollection controls, string name, string value)
 {
     try
     {
         name = name + "DateTimePicker";
         if (controls.Find(name, false).Count() > 0)
         {
             ((DevComponents.Editors.DateTimeAdv.DateTimeInput)(controls.Find(name, false)[0])).Value = StringToDate(value);
         }
     }
     catch (Exception ex) {
         LogHelper.LogError(ex);
     }
 }
Esempio n. 5
0
 public static void SetComBoxCtrlValue(Control.ControlCollection controls, string name, string value)
 {
     try
     {
         name = name + "ComboBox";
         if (controls.Find(name, false).Count() > 0)
         {
             ((DevComponents.DotNetBar.Controls.ComboBoxEx)(controls.Find(name, false)[0])).Text = value;
         }
     }
     catch (Exception ex) {
         LogHelper.LogError(ex);
     }
 }
Esempio n. 6
0
 public static void SetTextBoxCtrlValue(Control.ControlCollection controls, string name, string value)
 {
     try
     {
         name = name + "TextBox";
         if (controls.Find(name, false).Count() > 0)
         {
             ((System.Windows.Forms.TextBox)(controls.Find(name, false)[0])).Text = value;
         }
     }
     catch (Exception ex) {
         LogHelper.LogError(ex);
     }
 }
Esempio n. 7
0
 public static void RemoveControlByKey(string key, Control.ControlCollection controlCollection)
 {
     if (Forms.RobotAutomationHelper.Log)
     {
         Console.WriteLine(@"RemoveControlByKey " + key);
     }
     if (Forms.RobotAutomationHelper.Log)
     {
         Console.WriteLine(key + @" = " + controlCollection.Find(key, false).Length);
     }
     while (controlCollection.Find(key, false).Length != 0)
     {
         controlCollection.RemoveByKey(key);
     }
 }
Esempio n. 8
0
        public void Result()
        {
            Hand playerHand = playerHandEvaluator.EvaluateHand();
            Hand pcHand     = pcHandEvaluator.EvaluateHand();

            Label myLabel    = Control.Find("Result", true).FirstOrDefault() as Label;
            Label combo      = Control.Find("Combo", true).FirstOrDefault() as Label;
            Label RobotCombo = Control.Find("label9", true).FirstOrDefault() as Label;

            combo.Text      = playerHand.ToString();
            RobotCombo.Text = pcHand.ToString();
            Label   myRobotLabel = Control.Find("RobotHelp", true).FirstOrDefault() as Label;
            TextBox AllTexB      = Control.Find("textBox3", true).FirstOrDefault() as TextBox;

            myRobotLabel.Text = pcHandEvaluator.HandValues.Aut.ToString();
            if (playerHand > pcHand)
            {
                myLabel.Text = "Player WIN!\n  Player's hand: " + playerHand + " \nComputer's hand: " + pcHand;
            }
            else if (playerHand < pcHand)
            {
                myLabel.Text = "PC WIN!  \n Player's hand: " + playerHand + " \n Computer's hand: " + pcHand;
            }
            else // if hands are the same
            {
                if (playerHandEvaluator.HandValues.Total > pcHandEvaluator.HandValues.Total)
                {
                    myLabel.Text = "Player WIN!   Player's hand: " + playerHand + "  \nTotal: " + playerHandEvaluator.HandValues.Total + " \n Computer's hand: " + pcHand + "\n Total: " + pcHandEvaluator.HandValues.Total;
                }
                else if (playerHandEvaluator.HandValues.Total < pcHandEvaluator.HandValues.Total)
                {
                    myLabel.Text = "PC WIN!   Player's hand: " + playerHand + "\n Total: " + playerHandEvaluator.HandValues.Total + " \n Computer's hand: " + pcHand + "\n Total: " + pcHandEvaluator.HandValues.Total;
                }
                else
                if (playerHandEvaluator.HandValues.HighCard > pcHandEvaluator.HandValues.HighCard)
                {
                    myLabel.Text = "Player WIN!  \nPlayer's hand: " + playerHand + "\n Total: " + playerHandEvaluator.HandValues.Total + "\n High card: " + playerHandEvaluator.HandValues.HighCard + " \n Computer's hand: " + pcHand + " \nTotal: " + pcHandEvaluator.HandValues.Total + " \nHigh card: " + pcHandEvaluator.HandValues.HighCard;
                }
                else if (playerHandEvaluator.HandValues.HighCard < pcHandEvaluator.HandValues.HighCard)
                {
                    myLabel.Text = "PC WIN!\n   Player's hand: " + playerHand + "\n Total: " + playerHandEvaluator.HandValues.Total + "\n High card: " + playerHandEvaluator.HandValues.HighCard + " \n Computer's hand: " + pcHand + " \nHigh card: " + pcHandEvaluator.HandValues.HighCard;
                }
                else
                {
                    myLabel.Text = "NO ONE WIN!  \nPlayer's hand: " + playerHand + "  Computer's hand: " + pcHand;
                }
            }
        }
Esempio n. 9
0
        /// <summary>
        ///
        /// </summary>
        public override void FillGridWithJavascriptData(ref DataGridView dataGridCurrent, ref DataTable dTableCurrent, string sJavascriptData, TabControl tabData)
        {
            string sMatchAnswersLength = "answers[";
            int    iAnswersLength      = sJavascriptData.LastIndexOf(sMatchAnswersLength);
            int    iNumAnswersEnd      = sJavascriptData.IndexOf("]", iAnswersLength + sMatchAnswersLength.Length);
            string sAnswersLength      = sJavascriptData.Substring(iAnswersLength + sMatchAnswersLength.Length, iNumAnswersEnd - (iAnswersLength + sMatchAnswersLength.Length));

            for (int i = 0; (sAnswersLength.Length > 0) && (i < (Convert.ToInt32(sAnswersLength) + 1)); i++)
            {
                string sQuestionMatch     = "questions[" + i.ToString() + "]=\"";
                int    iNextQuestionBegin = sJavascriptData.IndexOf(sQuestionMatch);
                int    iNextQuestionEnd   = sJavascriptData.IndexOf("\"", iNextQuestionBegin + sQuestionMatch.Length);
                string sNextQuestion      = sJavascriptData.Substring(iNextQuestionBegin + sQuestionMatch.Length, iNextQuestionEnd - (iNextQuestionBegin + sQuestionMatch.Length));

                string sAnswerMatch     = "answers[" + i.ToString() + "]=\"";
                int    iNextAnswerBegin = sJavascriptData.IndexOf(sAnswerMatch);
                int    iNextAnswerEnd   = sJavascriptData.IndexOf("\"", iNextAnswerBegin + sAnswerMatch.Length);
                string sNextAnswer      = sJavascriptData.Substring(iNextAnswerBegin + sAnswerMatch.Length, iNextAnswerEnd - (iNextAnswerBegin + sAnswerMatch.Length));

                DataRow drNewData = dTableCurrent.NewRow();
                drNewData["Column1"] = sNextQuestion;
                drNewData["Column2"] = sNextAnswer;
                dTableCurrent.Rows.Add(drNewData);
            }

            string sCardMatch = "optionCardFontSize=\"";
            int    iCardBegin = sJavascriptData.LastIndexOf(sCardMatch);
            int    iCardEnd   = sJavascriptData.IndexOf("\"", iCardBegin + sCardMatch.Length);
            string sCard      = sJavascriptData.Substring(iCardBegin + sCardMatch.Length, iCardEnd - (iCardBegin + sCardMatch.Length));


            Control.ControlCollection ocTabPageJsOptions = tabData.Controls.Find("tabPageJsOptionsDd", false)[0].Controls;

            ((ComboBox)ocTabPageJsOptions.Find("comboBoxDdCardFontSize", false)[0]).Text = sCard;
        }
Esempio n. 10
0
File: Form2.cs Progetto: xianrui69/-
 public static void loadSetting(Control.ControlCollection c)
 {
     for (int i = 0; i < ConfigurationManager.AppSettings.Count; i++)
     {
         var key   = ConfigurationManager.AppSettings.AllKeys[i];
         var val   = new CfgHelper(ConfigurationManager.AppSettings.AllKeys[i]).Value;
         var finds = c.Find(key, false);
         if (finds != null && finds.Length > 0)
         {
             var find = finds[0];
             if (find is TextBox)
             {
                 (find as TextBox).Text = val;
             }
             else if (find is CheckBox)
             {
                 (find as CheckBox).Checked = bool.Parse(val);
             }
             else if (find is ComboBox)
             {
                 try
                 {
                     (find as ComboBox).SelectedValue = (val);
                 }
                 catch (Exception e)
                 {
                     (find as ComboBox).SelectedText = (val);
                 }
             }
         }
     }
 }
Esempio n. 11
0
        private static object FindControl(string name, Control.ControlCollection c)
        {
            Control control = c.Find(name, true).FirstOrDefault();

            if (control != null)
            {
                return(control);
            }
            foreach (MenuStrip menu in c.OfType <MenuStrip>())
            {
                var item = menu.Items.Find(name, true).FirstOrDefault();
                if (item != null)
                {
                    return(item);
                }
            }
            foreach (ContextMenuStrip strip in FindContextMenuStrips(c.OfType <Control>()))
            {
                var item = strip.Items.Find(name, true).FirstOrDefault();
                if (item != null)
                {
                    return(item);
                }
            }
            return(null);
        }
Esempio n. 12
0
 private static void RemoveCardButtons(Control.ControlCollection controls)
 {
     foreach (var control in controls.Find(CardButtonName, true))
     {
         controls.Remove(control);
     }
 }
Esempio n. 13
0
        private void CreateImageFromApp(string FullPath2SaveImage, Control Cntrl)
        {
            mMainForm.Show();
            mMainForm.Focus();
            mMainForm.Refresh();

            if (Cntrl.Name == "grobxCycles")
            {
                Control.ControlCollection cntrlCls = mMainForm.Controls;

                TabControl ttt = cntrlCls.Find("mTabs", true)[0] as TabControl;
                ttt.TabPages["tabPage5"].Show();
                ttt.TabPages["tabPage5"].Refresh();
            }

            Cntrl.Show();
            Cntrl.Refresh();

            Graphics g         = Cntrl.CreateGraphics();
            Bitmap   picBitMap = new Bitmap(Cntrl.Width, Cntrl.Height, g);

            Cntrl.DrawToBitmap(picBitMap, System.Drawing.Rectangle.FromLTRB(0, 0, Cntrl.Width, Cntrl.Height));

            picBitMap.Save(FullPath2SaveImage, System.Drawing.Imaging.ImageFormat.Png);
        }
Esempio n. 14
0
 /// <summary>
 /// Extracts text data out of the "fields" buttons controls
 /// and puts it into a PlayField Data Type.
 /// Used for checking for a winner aswell as in deciding the AI's movess
 /// </summary>
 /// <param name="con"></param>
 public PlayField(Control.ControlCollection con) //Control.ControlCollection controls String[] Text
 {
     // Places the text from the created array into the playField.
     field[0, 0] = con.Find("buttonField1", false).FirstOrDefault().Text;
     field[0, 1] = con.Find("buttonField2", false).FirstOrDefault().Text;
     field[0, 2] = con.Find("buttonField3", false).FirstOrDefault().Text;
     field[1, 0] = con.Find("buttonField4", false).FirstOrDefault().Text;
     field[1, 1] = con.Find("buttonField5", false).FirstOrDefault().Text;
     field[1, 2] = con.Find("buttonField6", false).FirstOrDefault().Text;
     field[2, 0] = con.Find("buttonField7", false).FirstOrDefault().Text;
     field[2, 1] = con.Find("buttonField8", false).FirstOrDefault().Text;
     field[2, 2] = con.Find("buttonField9", false).FirstOrDefault().Text;
 }
Esempio n. 15
0
        public static string GetTextBoxCtrlValue(Control.ControlCollection controls, string name)
        {
            string value = string.Empty;

            try
            {
                name = name + "TextBox";
                if (controls.Find(name, false).Count() > 0)
                {
                    value = ((System.Windows.Forms.TextBox)(controls.Find(name, false)[0])).Text;
                }
                return(value);
            }
            catch (Exception ex) {
                return(value);
            }
        }
Esempio n. 16
0
        /// <summary>
        ///
        /// </summary>
        public override void FillGridWithJavascriptData(ref DataGridView dataGridCurrent, ref DataTable dTableCurrent, string sJavascriptData, TabControl tabData)
        {
            AcceptChanges(dataGridCurrent);
            string sMatchQuestionsLength = "questions.length=";
            int    iQuestionsLength      = sJavascriptData.LastIndexOf(sMatchQuestionsLength);
            int    iNumQuestionsEnd      = sJavascriptData.IndexOf(";", iQuestionsLength + sMatchQuestionsLength.Length);
            string sQuestionsLength      = sJavascriptData.Substring(iQuestionsLength + sMatchQuestionsLength.Length, iNumQuestionsEnd - (iQuestionsLength + sMatchQuestionsLength.Length));

            for (int i = 0; i < Convert.ToInt32(sQuestionsLength); i++)
            {
                string sQuestionMatch     = "questions[" + (i + 1).ToString() + "]=new Question(\"";
                int    iNextQuestionBegin = sJavascriptData.IndexOf(sQuestionMatch);
                int    iNextQuestionEnd   = sJavascriptData.IndexOf("\"", iNextQuestionBegin + sQuestionMatch.Length);
                string sNextQuestion      = sJavascriptData.Substring(iNextQuestionBegin + sQuestionMatch.Length, iNextQuestionEnd - (iNextQuestionBegin + sQuestionMatch.Length));

                string sPosition = sJavascriptData.Substring(iNextQuestionEnd + 3, 1);

                string sAnswerMatch     = "answers[\"" + sPosition + "\"]=\"";
                int    iNextAnswerBegin = sJavascriptData.IndexOf(sAnswerMatch);
                int    iNextAnswerEnd   = sJavascriptData.IndexOf("\"", iNextAnswerBegin + sAnswerMatch.Length);
                string sNextAnswer      = sJavascriptData.Substring(iNextAnswerBegin + sAnswerMatch.Length, iNextAnswerEnd - (iNextAnswerBegin + sAnswerMatch.Length));

                DataRow drNewData = dTableCurrent.NewRow();
                drNewData["Column1"] = sNextQuestion;
                drNewData["Column2"] = sPosition;
                drNewData["Column3"] = sNextAnswer;
                dTableCurrent.Rows.Add(drNewData);
            }

            string sColumnsMatch = "iResultsWidth=";
            int    iColumnsBegin = sJavascriptData.LastIndexOf(sColumnsMatch);
            int    iColumnsEnd   = sJavascriptData.IndexOf(";", iColumnsBegin + sColumnsMatch.Length);
            string sColumns      = sJavascriptData.Substring(iColumnsBegin + sColumnsMatch.Length, iColumnsEnd - (iColumnsBegin + sColumnsMatch.Length));

            string sRowsMatch = "iResultsHeight=";
            int    iRowsBegin = sJavascriptData.LastIndexOf(sRowsMatch);
            int    iRowsEnd   = sJavascriptData.IndexOf(";", iRowsBegin + sRowsMatch.Length);
            string sRows      = sJavascriptData.Substring(iRowsBegin + sRowsMatch.Length, iRowsEnd - (iRowsBegin + sRowsMatch.Length));



            Control.ControlCollection ocTabPageJsOptions = tabData.Controls.Find("tabPageJsOptionsMa", false)[0].Controls;

            ((TextBox)ocTabPageJsOptions.Find("textBoxMaResultsCols", false)[0]).Text = sColumns;
            ((TextBox)ocTabPageJsOptions.Find("textBoxMaResultsRows", false)[0]).Text = sRows;
        }
Esempio n. 17
0
 public static void UpdateClientControls(Client client, Control.ControlCollection controls)
 {
     UpdateLabelsForType(typeof(Name), client, controls);
     UpdateLabelsForType(typeof(Address), client, controls);
     if (controls.Find("Номер", false)[0] is MaskedTextBox phoneControl)
     {
         phoneControl.Text = client.PhoneNumber;
     }
 }
Esempio n. 18
0
        /// <summary>
        /// Присваивааем значения компонентам формы (или другого компонента-контейнера Panel, TabControl).
        /// </summary>
        /// <param name="componentValues">Компоненты формы и их значения в виде строки. Так как они записываются в базу данных.</param>
        /// <param name="controls">Масив компонентов формы</param>
        /// <returns></returns>
        public static bool SetComponentValues(string componentValues, Control.ControlCollection controls)
        {
            if (componentValues == "")
            {
                return(false);
            }
            string[] dotArray = componentValues.Split('\n');
            for (int i = 0; i < dotArray.Count(); i++)
            {
                string s = dotArray[i].Trim();
                int    n = s.IndexOf(':');
                if (n == -1)
                {
                    continue;
                }
                string  controlName  = s.Substring(0, n);
                string  controlValue = s.Substring(n + 1);
                Control control      = controls.Find(controlName, true).FirstOrDefault();
                if (control != null)
                {
                    string compType = control.GetType().ToString();
                    compType = compType.Replace("System.Windows.Forms.", "");
                    compType = compType.Replace("FBA.", "");
                    compType = compType.Replace("FBA", "");

                    if (compType == "TextBox")
                    {
                        control.Text = controlValue.Base64ToString();
                    }
                    else
                    if (compType == "CheckBox")
                    {
                        ((System.Windows.Forms.CheckBox)control).Checked = controlValue.ToBool();
                    }
                    else
                    if (compType == "ComboBox")
                    {
                        control.Text = controlValue.Base64ToString();
                    }
                    else
                    if (compType == "RadioButton")
                    {
                        ((System.Windows.Forms.CheckBox)control).Checked = controlValue.ToBool();
                    }
                    else
                    if (compType == "TabControl")
                    {
                        ((System.Windows.Forms.TabControl)control).SelectedIndex = controlValue.ToInt();
                    }
                    else
                    {
                        control.Text = controlValue.Base64ToString(); //При этом присвоении вызовется ControlValueChanged автоматически.
                    }
                }
            }
            return(true);
        }
Esempio n. 19
0
        /// <summary>
        ///
        /// </summary>
        public override void FillGridWithJavascriptData(ref DataGridView dataGridCurrent, ref DataTable dTableCurrent, string sJavascriptData, TabControl tabData)
        {
            int iAnswerCount = 0;

            string sNumQuestions = GetLastMatchedString(sJavascriptData, "numQues=", ";");

            for (int i = 0; (sNumQuestions.Length > 0) && (i < Convert.ToInt32(sNumQuestions)); i++)
            {
                string sInputCount   = GetLastMatchedString(sJavascriptData, "OrigQuestions[" + i.ToString() + "][0]=", ";");
                string sNextQuestion = GetLastMatchedString(sJavascriptData, "OrigQuestions[" + i.ToString() + "][1]=\"", "\"");
                //Should Convert sNextQuestion's <inputX> to <input> here in the future so user doesn't have to type number X
                string sNextAnswer = "";
                for (int j = 0; j < Convert.ToInt32(sInputCount); j++)
                {
                    sNextAnswer = sNextAnswer + GetLastMatchedString(sJavascriptData, "OrigAnswers[" + iAnswerCount.ToString() + "]=\"", "\"") + ";";
                    iAnswerCount++;
                }
                DataRow drNewData = dTableCurrent.NewRow();
                // Format for %'s in Netscape 6 - %25's from javascript file must become %'s
                sNextQuestion = sNextQuestion.Replace("%25", "%");
                sNextAnswer   = sNextAnswer.Replace("%25", "%");
                // Format for %'s in Netscape 6 - %25's from javascript file must become %'s
                drNewData["Column1"] = sNextQuestion;
                drNewData["Column2"] = sNextAnswer;
                dTableCurrent.Rows.Add(drNewData);
            }

            string sChoices = GetLastMatchedString(sJavascriptData, "PossibleAnswers=\"", "\"");

            // Format for textbox - <br>, <br/>, <br />, <br  /> all become \n
            sChoices = sChoices.Replace("<br>", "\r\n");
            sChoices = sChoices.Replace("<br/>", "\r\n");
            sChoices = sChoices.Replace("<br />", "\r\n");
            sChoices = sChoices.Replace("<br  />", "\r\n");

            string sArrangement = GetLastMatchedString(sJavascriptData, "bOnePerPage=", ";");

            string sColumns             = GetLastMatchedString(sJavascriptData, "iResultsWidth=", ";");
            string sRows                = GetLastMatchedString(sJavascriptData, "iResultsHeight=", ";");
            string sShowQuestionNumbers = GetLastMatchedString(sJavascriptData, "bShowQuestionNumbers=", ";");
            string sPageWidth           = GetLastMatchedString(sJavascriptData, "iTotalPageWidth=", ";");
            string sTypeQuiz            = GetLastMatchedString(sJavascriptData, "bTypeQuiz=", ";");

            Control.ControlCollection ocTabPageJsOptions = tabData.Controls.Find("tabPageJsOptionsFi", false)[0].Controls;

            ((TextBox)ocTabPageJsOptions.Find("textBoxFiResultsCols", false)[0]).Text            = sColumns;
            ((TextBox)ocTabPageJsOptions.Find("textBoxFiResultsRows", false)[0]).Text            = sRows;
            ((RadioButton)ocTabPageJsOptions.Find("radioButtonFiQuestionAll", false)[0]).Checked = sArrangement.Equals("true");
            ((RadioButton)ocTabPageJsOptions.Find("radioButtonFiQuestionOne", false)[0]).Checked = sArrangement.Equals("false");
            ((TextBox)ocTabPageJsOptions.Find("textBoxJsOptionsFiChoices", false)[0]).Text       = sChoices;
            ((TextBox)ocTabPageJsOptions.Find("textBoxFiPageWidth", false)[0]).Text        = sPageWidth;
            ((CheckBox)ocTabPageJsOptions.Find("checkBoxFiShowNumbers", false)[0]).Checked = sShowQuestionNumbers.Equals("true");
            ((CheckBox)ocTabPageJsOptions.Find("checkBoxFiTypeQuiz", false)[0]).Checked    = sTypeQuiz.Equals("true");
        }
Esempio n. 20
0
 public static void SetCheckBoxCtrlValue(Control.ControlCollection controls, string name, string value)
 {
     try
     {
         name = name + "CheckBox";
         if (controls.Find(name, false).Count() > 0)
         {
             if (value.StartsWith("1"))
             {
                 ((System.Windows.Forms.CheckBox)(controls.Find(name, false)[0])).Checked = true;
             }
             else
             {
                 ((System.Windows.Forms.CheckBox)(controls.Find(name, false)[0])).Checked = false;
             }
         }
     }
     catch (Exception ex) { }
 }
Esempio n. 21
0
        private static void SetBestTime(Control.ControlCollection controls)
        {
            var lastBestTime = controls.Find(BestTimeLabelName, true).FirstOrDefault();
            var elapsed      = StopwatchControl.Elapsed();

            if (lastBestTime != null && elapsed.CompareTo(lastBestTime.Text.TimerStringToTimestamp()) == -1)
            {
                lastBestTime.Text = elapsed.TimespanToTimerString();
            }
        }
Esempio n. 22
0
        private Control GetFirstChildByName(Control.ControlCollection controls, String name)
        {
            Control[] result = controls.Find(name, true);
            if (result.Length > 0)
            {
                return(result[0]);
            }

            return(null);
        }
Esempio n. 23
0
        public static string GetDateCtrlValue(Control.ControlCollection controls, string name)
        {
            string value = string.Empty;

            try
            {
                name = name + "DateTimePicker";
                if (controls.Find(name, false).Count() > 0)
                {
                    DateTime dt = ((System.Windows.Forms.DateTimePicker)(controls.Find(name, false)[0])).Value;
                    value = dt.ToString("yyyy-MM-dd");
                }
                return(value);
            }
            catch (Exception ex)
            {
                return(value);
            }
        }
Esempio n. 24
0
 public void Result()
 {
     if (who == "Player")
     {
         TextBox PCTexB  = Control.Find("textBox2", true).FirstOrDefault() as TextBox;
         TextBox AllTexB = Control.Find("textBox3", true).FirstOrDefault() as TextBox;
         if (AllTexB.Text == "")
         {
             AllTexB.Text = "0";
         }
         PCTexB.Text = Convert.ToString(Convert.ToInt32(PCTexB.Text) + Convert.ToInt32(AllTexB.Text));
         Button flopbutton  = Control.Find("FlopButton", true).FirstOrDefault() as Button;
         Button TernButton  = Control.Find("TernButton", true).FirstOrDefault() as Button;
         Button RiverButton = Control.Find("RiverButton", true).FirstOrDefault() as Button;
         AllTexB.Text        = "";
         flopbutton.Enabled  = true;
         flopbutton.Visible  = true;
         TernButton.Visible  = false;
         RiverButton.Visible = false;
         //  fold = true;
         DrawCards.VisibleCards();
     }
     else if (who == "Robot")
     {
         TextBox PlayerTexB = Control.Find("textBox1", true).FirstOrDefault() as TextBox;
         TextBox AllTexB    = Control.Find("textBox3", true).FirstOrDefault() as TextBox;
         if (AllTexB.Text == "")
         {
             AllTexB.Text = "0";
         }
         PlayerTexB.Text = Convert.ToString(Convert.ToInt32(PlayerTexB.Text) + Convert.ToInt32(AllTexB.Text));
         Button flopbutton  = Control.Find("FlopButton", true).FirstOrDefault() as Button;
         Button TernButton  = Control.Find("TernButton", true).FirstOrDefault() as Button;
         Button RiverButton = Control.Find("RiverButton", true).FirstOrDefault() as Button;
         AllTexB.Text        = "";
         flopbutton.Enabled  = true;
         flopbutton.Visible  = true;
         TernButton.Visible  = false;
         RiverButton.Visible = false;
         //  fold = true;
         DrawCards.VisibleCards();
     }
 }
Esempio n. 25
0
        public static string GetCheckBoxCtrlValue(Control.ControlCollection controls, string name)
        {
            string value = string.Empty;

            try
            {
                name = name + "CheckBox";
                if (controls.Find(name, false).Count() > 0)
                {
                    bool bCheck = ((System.Windows.Forms.CheckBox)(controls.Find(name, false)[0])).Checked;
                    value = bCheck ? "1" : "0";
                }
                return(value);
            }
            catch (Exception ex)
            {
                return(value);
            }
        }
Esempio n. 26
0
        public static string GetComBoxCtrlValue(Control.ControlCollection controls, string name)
        {
            string value = string.Empty;

            try
            {
                name = name + "ComboBox";
                if (controls.Find(name, false).Count() > 0)
                {
                    value = ((DevComponents.DotNetBar.Controls.ComboBoxEx)(controls.Find(name, false)[0])).Text;
                }
                return(value);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex);
                return(value);
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Match the PlayField coordinates with the correct - Form Button Control
        /// and checks the field is empty
        /// </summary>
        /// <param name="controls">All form controls</param>
        /// <param name="pos">PlayField xypos</param>
        public static void ControlMove(Control.ControlCollection con, int[] pos)
        {
            // Set a variable with the control to make a move on
            if (pos[0] == 0 && pos[1] == 0)
            {
                moveCon = con.Find("buttonField1", false).FirstOrDefault();
            }
            if (pos[0] == 0 && pos[1] == 1)
            {
                moveCon = con.Find("buttonField2", false).FirstOrDefault();
            }
            if (pos[0] == 0 && pos[1] == 2)
            {
                moveCon = con.Find("buttonField3", false).FirstOrDefault();
            }
            if (pos[0] == 1 && pos[1] == 0)
            {
                moveCon = con.Find("buttonField4", false).FirstOrDefault();
            }
            if (pos[0] == 1 && pos[1] == 1)
            {
                moveCon = con.Find("buttonField5", false).FirstOrDefault();
            }
            if (pos[0] == 1 && pos[1] == 2)
            {
                moveCon = con.Find("buttonField6", false).FirstOrDefault();
            }
            if (pos[0] == 2 && pos[1] == 0)
            {
                moveCon = con.Find("buttonField7", false).FirstOrDefault();
            }
            if (pos[0] == 2 && pos[1] == 1)
            {
                moveCon = con.Find("buttonField8", false).FirstOrDefault();
            }
            if (pos[0] == 2 && pos[1] == 2)
            {
                moveCon = con.Find("buttonField9", false).FirstOrDefault();
            }

            if (moveCon.Text == "")
            {
                validate = true;
                return;
            }

            return;
        }
Esempio n. 28
0
        /// <summary>
        /// </summary>
        /// <param name="controlName"></param>
        /// <param name="Controls"></param>
        /// <returns></returns>
        public static Control GetUniqueControl(string controlName, Control.ControlCollection Controls)
        {
            var controls = Controls.Find(controlName, true);

            if (controls.Length > 0)
            {
                return(controls[0]);
            }
            return(null);
        }
Esempio n. 29
0
        /// <summary>
        /// Finds a control with the given key
        /// </summary>
        /// <typeparam name="T">Type of control</typeparam>
        /// <param name="controls">List of controls</param>
        /// <param name="key">Key</param>
        /// <returns>Control if found, null otherwise</returns>
        protected T FindControl <T>(Control.ControlCollection controls, string key) where T : Control
        {
            if (controls == null || string.IsNullOrEmpty(key))
            {
                return(null);
            }

            Control[] ctrls = controls.Find(key, true);

            return(ctrls.Length > 0 ? (T)ctrls[0] : null);
        }
Esempio n. 30
0
        public static string GetDateCtrlValue(Control.ControlCollection controls, string name)
        {
            string value = string.Empty;

            try
            {
                name = name + "DateTimePicker";
                if (controls.Find(name, false).Count() > 0)
                {
                    DateTime dt = ((DevComponents.Editors.DateTimeAdv.DateTimeInput)(controls.Find(name, false)[0])).Value;
                    value = dt.ToString("yyyy-MM-dd");
                }
                return(value);
            }
            catch (Exception ex)
            {
                LogHelper.LogError(ex);
                return(value);
            }
        }