public int SetCharacterRotate(bool reftSpin) { if (reftSpin) { directionValue -= 90; } else { directionValue += 90; } if (directionValue == 0) { nowDirection = UserDirection.North; } else if (directionValue == 90) { nowDirection = UserDirection.East; } else if (directionValue == 180) { nowDirection = UserDirection.South; } else { nowDirection = UserDirection.West; } return(directionValue); }
public override void configureControls(UserDirection direction) { //turn off the skip controls getQM().getMainForm().setSkipControlsInvisible(); label = new Label(); //set font size setFontSize(label); //the question Text shown to the user label.Text = Val; int labelXpos = getWidgetXpos(); int labelYpos = getWidgetYpos(); //position of the Label label.Location = new Point(labelXpos, labelYpos); label.Size = new Size(getWidgetWidth(), getWidgetHeight()); label.ForeColor = GlobalColours.mainTextColour; //getForm().Controls.Add(label); getQM().getPanel().Controls.Add(label); }
public bool CheckIfDestinationAsRequired(UserDirection userDirection) { for (int i = 1; i < ListOfResults.Count; i++) { IJavaScriptExecutor jse = (IJavaScriptExecutor)_driver; Actions actions = new Actions(_driver); _wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementExists(By.XPath(SearchResultPageConstatnts.ClickableDivPath + (i - 1).ToString() + "']"))); var elem = ListOfResults[i].FindElement(By.XPath(SearchResultPageConstatnts.ClickableDivPath + (i - 1).ToString() + "']")); actions.MoveToElement(elem).Perform(); jse.ExecuteScript("arguments[0].click()", elem); _wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementExists(By.XPath(SearchResultPageConstatnts.ListResPath + "[" + i + "]" + SearchResultPageConstatnts.ListOfDetails))); var numOfStations = ListOfResults[i].FindElements(By.XPath(SearchResultPageConstatnts.ListResPath + "[" + i + "]" + SearchResultPageConstatnts.ListOfDetails)).Count; var source = GetStringNameForFlight(SearchResultPageConstatnts.SourceStringPath, i, 1); var dest = GetStringNameForFlight(SearchResultPageConstatnts.DestinationStringPath, i, numOfStations); if (source != userDirection.StartPoint || dest != userDirection.Destination) { return(false); } } return(true); }
public void Start() { instance = this; UpdateText(); }
public override void configureControls(UserDirection direction) { //direction is either 'forward' or 'reverse' //turn the skip controls on again getQM().getMainForm().setSkipControlsVisible(); //create a label and textbox control label = new Label(); textbox = new TextBox(); //trap any keypress to deselect the skip-controls textbox.KeyPress += new KeyPressEventHandler(button_click); //the question Text shown to the user label.Text = Val; int labelXpos = getWidgetXpos(); int labelYpos = getWidgetYpos(); //position the text box under the label, i.e. at the same xpos but an increased ypos int textBoxXpos = labelXpos + 600; //int textBoxYpos = labelYpos + 50; //MessageBox.Show("gap is:" + LabelToBoxGap); int labelsYpos = labelYpos + 50; int controlsYpos = labelsYpos + 50; //position of the main Label label.Location = new Point(labelXpos, labelYpos); label.Size = new Size(getWidgetWidth(), getWidgetHeight()); //position of the textbox textbox.Location = new Point(textBoxXpos, controlsYpos); textbox.Size = new Size(300, 50); //labels for days, months, years labelDays = new Label(); labelDays.Text = "Days"; labelDays.Location = new Point(labelXpos + 10, labelsYpos); labelDays.AutoSize = true; labelDays.ForeColor = GlobalColours.mainTextColour; labelMonths = new Label(); labelMonths.Text = "Months"; labelMonths.Location = new Point(labelXpos + 180, labelsYpos); labelMonths.AutoSize = true; labelMonths.ForeColor = GlobalColours.mainTextColour; labelYears = new Label(); labelYears.Text = "Years"; labelYears.Location = new Point(labelXpos + 350, labelsYpos); labelYears.AutoSize = true; labelYears.ForeColor = GlobalColours.mainTextColour; labelResult = new Label(); labelResult.Text = "Result"; labelResult.Location = new Point(labelXpos + 700, labelsYpos); labelResult.AutoSize = true; labelResult.ForeColor = GlobalColours.mainTextColour; //select boxes for day, month, year selectDays = new ComboBox(); selectMonths = new ComboBox(); selectYears = new ComboBox(); //set font size setFontSize(label, textbox, labelResult, labelDays, labelMonths, labelYears, selectDays, selectMonths, selectYears); //event handlers //trap any keypress to deselect the skip-controls selectDays.Click += new EventHandler(button_click); selectMonths.Click += new EventHandler(button_click); selectYears.Click += new EventHandler(button_click); //stop user being able to type in the combobox selectDays.DropDownStyle = ComboBoxStyle.DropDownList; selectMonths.DropDownStyle = ComboBoxStyle.DropDownList; selectYears.DropDownStyle = ComboBoxStyle.DropDownList; //show only 5 items at a time in drop-down list selectMonths.IntegralHeight = false; //won't work unless this is set to false selectMonths.MaxDropDownItems = 5; selectDays.IntegralHeight = false; //won't work unless this is set to false selectDays.MaxDropDownItems = 5; selectYears.IntegralHeight = false; //won't work unless this is set to false selectYears.MaxDropDownItems = 5; selectDays.BackColor = GlobalColours.controlBackColour; selectMonths.BackColor = GlobalColours.controlBackColour; selectYears.BackColor = GlobalColours.controlBackColour; selectDays.Location = new Point(labelXpos, controlsYpos); selectDays.Size = new Size(160, 20); selectMonths.Location = new Point(labelXpos + 170, controlsYpos); selectMonths.Size = new Size(160, 20); selectYears.Location = new Point(labelXpos + 340, controlsYpos); selectYears.Size = new Size(160, 20); //array of days string[] days = new string[32]; days[0] = "Don't Know"; for (int i = 1; i <= 31; i++) { days[i] = i.ToString(); } selectDays.Items.AddRange(days); //array of months selectMonths.Items.AddRange(months); //get the current year. int currentYear = DateTime.Now.Year; //first year should also be don't know selectYears.Items.Add("Don't Know"); for (int i = currentYear; i >= 1900; i--) { selectYears.Items.Add(i); } if (PageSeen) { //extract the day, months, years. if (processedData != null) { //processedData is the value component //the date is stored in SD string date = getSD().Get(Code + "_DATE"); //Match match = Regex.Match(processedData, @"(.+)/(.+)/(.+):(.+)"); Match match = Regex.Match(date, @"(.+)/(.+)/(.+)"); string pDays, pMonths, pYears; if (match.Success) { pDays = match.Groups[1].Value; pMonths = match.Groups[2].Value; pYears = match.Groups[3].Value; //pText = match.Groups[4].Value; textbox.Text = processedData; if (pDays == "0") { pDays = "Don't Know"; } selectDays.SelectedItem = pDays; //convert month from integer to string form. pMonths = months[Convert.ToInt32(pMonths)]; selectMonths.SelectedItem = pMonths; if (pYears == "0") { selectYears.SelectedItem = "Don't Know"; } else { //years must be numeric rather than string, otherwise won't be recognised by selectbox selectYears.SelectedItem = Convert.ToInt32(pYears); } } } } //add to the form //getForm().Controls.Add(label); //getForm().Controls.Add(textbox); //colours for controls label.ForeColor = GlobalColours.mainTextColour; textbox.BackColor = GlobalColours.controlBackColour; //add controls to the panel getQM().getPanel().Controls.Add(label); getQM().getPanel().Controls.Add(textbox); //add to the form getQM().getPanel().Controls.Add(labelDays); getQM().getPanel().Controls.Add(labelMonths); getQM().getPanel().Controls.Add(labelYears); getQM().getPanel().Controls.Add(labelResult); getQM().getPanel().Controls.Add(selectDays); getQM().getPanel().Controls.Add(selectMonths); getQM().getPanel().Controls.Add(selectYears); textbox.Focus(); //set the console radio buttons setSkipSetting(); }
public override void configureControls(UserDirection direction) { //turn the skip controls on again getQM().getMainForm().setSkipControlsVisible(); radioGroup = new GroupBox(); radioGroup.ForeColor = GlobalColours.mainTextColour; setFontSize(radioGroup); //position the group box under the label, i.e. at the same xpos but an increased ypos int groupBoxXpos = getWidgetXpos(); int groupBoxYpos = getWidgetYpos(); //position of the groupbox radioGroup.Location = new Point(groupBoxXpos, groupBoxYpos); radioGroup.Size = new Size(getWidgetWidth(), getWidgetHeight()); //label: this needs to be calcuated if (LabelGeneratorFunc == "DisplayBMI") { string label; //get the precalculated BMI string BMI = getSD().Get("BMI"); if (BMI == null) { label = "BMI is unavailable. Please select 'No', below"; } else { label = "BMI calculated as: " + BMI + ". Is this correct?"; } radioGroup.Text = Val + " " + label; } else { throw new Exception(); } //create the RadioButton objects that we need, i.e. one for each option. RadioButton rb; //create a radiobutton for each option foreach (Option op in optionList) { //create a radiobutton rb = new RadioButton(); //trap the click rb.Click += new EventHandler(button_click); rb.ForeColor = GlobalColours.mainTextColour; rb.Text = op.getText(); //rb.Tag = op.getValue(); rb.Tag = op; rb.Location = new Point(op.getWidgetXpos(), op.getWidgetYpos()); rb.Size = new Size(op.getWidgetWidth(), op.getWidgetHeight()); if (!PageSeen) { if (op.Default) { rb.Checked = true; } } else { //page has been seen, set the previous data if (op.getValue() == processedData) { rb.Checked = true; } } radioGroup.Controls.Add(rb); } //add controls to the form //getForm().Controls.Add(radioGroup); getQM().getPanel().Controls.Add(radioGroup); setSkipSetting(); }
//called only in child classes //public abstract bool isSectionExit(Dictionary<string, string> questionToSectionMap); public abstract void configureControls(UserDirection direction);
public override void configureControls(UserDirection direction) { //direction is either 'forward' or 'reverse' //create a label and textbox control label = new Label(); label.ForeColor = GlobalColours.mainTextColour; textbox = new TextBox(); textbox.BackColor = GlobalColours.controlBackColour; checkBoxLabel = new Label(); checkBoxLabel.ForeColor = GlobalColours.mainTextColour; checkbox = new CheckBox(); //the question Text shown to the user label.Text = Val; int labelXpos = getWidgetXpos(); int labelYpos = getWidgetYpos(); //position the text box under the label, i.e. at the same xpos but an increased ypos int textBoxXpos = labelXpos; int textBoxYpos = labelYpos + 50; //position of the Label label.Location = new Point(labelXpos, labelYpos); label.Size = new Size(getWidgetWidth(), getWidgetHeight()); //position of the textbox textbox.Location = new Point(textBoxXpos, textBoxYpos); textbox.Size = new Size(500, 50); //label for the checkbox checkBoxLabel.Location = new Point(labelXpos + 20, labelYpos + 100); checkBoxLabel.Size = new Size(300, 50); checkBoxLabel.Text = CheckBoxLabel; //checkBox checkbox.Location = new Point(labelXpos, labelYpos + 100); checkbox.Size = new Size(20, 20); //if page seen before, populate the control with the previously entered text if (PageSeen) { //check for the special value which means user did not know if (userData == CheckBoxCheckCode) { //check the checkbox checkbox.Checked = true; } else { textbox.Text = userData; } } //add to the form getQM().getPanel().Controls.Add(label); getQM().getPanel().Controls.Add(textbox); getQM().getPanel().Controls.Add(checkbox); getQM().getPanel().Controls.Add(checkBoxLabel); textbox.Focus(); }
public override void configureControls(UserDirection direction) { //direction is either 'forward' or 'reverse' //turn the skip controls on again getQM().getMainForm().setSkipControlsVisible(); //create a label and textbox control and a button label = new Label(); label.ForeColor = GlobalColours.mainTextColour; textbox = new TextBox(); textbox.BackColor = GlobalColours.controlBackColour; textbox.KeyPress += new KeyPressEventHandler(button_click); button = new Button(); button.BackColor = GlobalColours.mainButtonColour; //set font size setFontSize(label, textbox, button); //the question Text shown to the user label.Text = Val; int labelXpos = getWidgetXpos(); int labelYpos = getWidgetYpos(); //position the text box under the label, i.e. at the same xpos but an increased ypos int textBoxXpos = labelXpos; int textBoxYpos = labelYpos + 50; //position of the Label label.Location = new Point(labelXpos, labelYpos); label.Size = new Size(getWidgetWidth(), getWidgetHeight()); //position of the textbox textbox.Location = new Point(textBoxXpos, textBoxYpos); textbox.Size = new Size(500, 50); //position of the button button.Text = "click here when you want to record the time"; button.Location = new Point(textBoxXpos, textBoxYpos + 50); button.Size = new Size(500, 50); button.Click += new EventHandler(button_click2); //if page seen before, populate the control with the previously entered text if (PageSeen) { textbox.Text = userData; } //add to the form getQM().getPanel().Controls.Add(label); getQM().getPanel().Controls.Add(textbox); getQM().getPanel().Controls.Add(button); setSkipSetting(); }
public override void configureControls(UserDirection direction) { //direction is either 'forward' or 'reverse' //turn the skip controls on again getQM().getMainForm().setSkipControlsVisible(); //create a label and textbox control label = new Label(); textbox = new TextBox(); //set font size setFontSize(label, textbox); //trap any keypress to deselect the skip-controls textbox.KeyPress += new KeyPressEventHandler(button_click); //the question Text shown to the user label.Text = Val; int labelXpos = getWidgetXpos(); int labelYpos = getWidgetYpos(); //position the text box under the label, i.e. at the same xpos but an increased ypos int textBoxXpos = labelXpos; //int textBoxYpos = labelYpos + 50; //MessageBox.Show("gap is:" + LabelToBoxGap); int textBoxYpos = labelYpos + LabelToBoxGap + 50; //position of the Label label.Location = new Point(labelXpos, labelYpos); label.Size = new Size(getWidgetWidth(), getWidgetHeight()); //position of the textbox textbox.Location = new Point(textBoxXpos, textBoxYpos); //is this a textarea ? if (HasTextArea) { textbox.Multiline = true; textbox.Size = new Size(700, 300); } else { //1 line textbox textbox.Size = new Size(500, 50); } if (PageSeen) { textbox.Text = userData; } //add to the form //getForm().Controls.Add(label); //getForm().Controls.Add(textbox); //colours for controls label.ForeColor = GlobalColours.mainTextColour; textbox.BackColor = GlobalColours.controlBackColour; //add controls to the panel getQM().getPanel().Controls.Add(label); getQM().getPanel().Controls.Add(textbox); textbox.Focus(); //set the console radio buttons setSkipSetting(); }
public override void configureControls(UserDirection direction) { //turn the skip controls on again getQM().getMainForm().setSkipControlsVisible(); //create a label label = new Label(); //the question Text shown to the user label.Text = Val; label.ForeColor = GlobalColours.mainTextColour; int labelXpos = getWidgetXpos(); int labelYpos = getWidgetYpos(); //position of the Label label.Location = new Point(labelXpos, labelYpos); //label.AutoSize = true; label.Size = new Size(getWidgetWidth(), getWidgetHeight()); selectBox = new ComboBox(); //set font size setFontSize(label, selectBox); //event handlers //trap any keypress to deselect the skip-controls selectBox.Click += new EventHandler(button_click); //stop user being able to type in the combobox selectBox.DropDownStyle = ComboBoxStyle.DropDownList; selectBox.BackColor = GlobalColours.controlBackColour; selectBox.Location = new Point(labelXpos, labelYpos + getWidgetHeight()); selectBox.Size = new Size(SelectLength, 20); Option previouslySelectedOption = null; //add items to combobox foreach (Option op in optionList) { //selectBox.Items.Add(op.getText()); selectBox.Items.Add(op); //is this option the one that was selected previously ? if (processedData != null) { if (processedData == op.getValue()) { previouslySelectedOption = op; } } } if (PageSeen && (processedData != null)) { if (previouslySelectedOption != null) { selectBox.SelectedItem = previouslySelectedOption; } } //add to the form getQM().getPanel().Controls.Add(label); getQM().getPanel().Controls.Add(selectBox); setSkipSetting(); }
public override void configureControls(UserDirection direction) { //turn the skip controls on again getQM().getMainForm().setSkipControlsVisible(); radioGroup = new GroupBox(); radioGroup.ForeColor = GlobalColours.mainTextColour; setFontSize(radioGroup); //position the group box under the label, i.e. at the same xpos but an increased ypos int groupBoxXpos = getWidgetXpos(); int groupBoxYpos = getWidgetYpos(); //position of the groupbox radioGroup.Location = new Point(groupBoxXpos, groupBoxYpos); radioGroup.Size = new Size(getWidgetWidth(), getWidgetHeight()); radioGroup.Text = Val; //create the RadioButton objects that we need, i.e. one for each option. RadioButton rb; //create a radiobutton for each option foreach (Option op in optionList) { //create a radiobutton rb = new RadioButton(); //trap the click rb.Click += new EventHandler(button_click); rb.ForeColor = GlobalColours.mainTextColour; rb.Text = op.getText(); //rb.Tag = op.getValue(); rb.Tag = op; rb.Location = new Point(op.getWidgetXpos(), op.getWidgetYpos()); rb.Size = new Size(op.getWidgetWidth(), op.getWidgetHeight()); if (! PageSeen) { if (op.Default) { rb.Checked = true; } } else { //page has been seen, set the previous data if (op.getValue() == processedData) { rb.Checked = true; } } radioGroup.Controls.Add(rb); } //add controls to the form //getForm().Controls.Add(radioGroup); getQM().getPanel().Controls.Add(radioGroup); setSkipSetting(); }
// Use this for initialization void Start() { nowDirection = UserDirection.East; }
public override void configureControls(UserDirection direction) { //direction is either 'forward' or 'reverse' //turn the skip controls on again getQM().getMainForm().setSkipControlsVisible(); //are we using a connected GPS unit or a stand-alone unit ? if (getQM().getMainForm().isGPSconnected()) { //connected GPS dongle //create a label and textbox control label = new Label(); label.ForeColor = GlobalColours.mainTextColour; textboxLat = new TextBox(); textboxLat.BackColor = GlobalColours.controlBackColour; textboxLong = new TextBox(); textboxLong.BackColor = GlobalColours.controlBackColour; //trap any keypress to deselect the skip-controls textboxLat.KeyPress += new KeyPressEventHandler(button_click); textboxLong.KeyPress += new KeyPressEventHandler(button_click); setLocationButton = new Button(); setLocationButton.BackColor = GlobalColours.mainButtonColour; longLabel = new Label(); longLabel.ForeColor = GlobalColours.mainTextColour; latLabel = new Label(); latLabel.ForeColor = GlobalColours.mainTextColour; helpLabel = new Label(); helpLabel.ForeColor = GlobalColours.mainTextColour; //set font size setFontSize(label, textboxLat, textboxLong, setLocationButton, longLabel, latLabel, helpLabel); //the question Text shown to the user label.Text = Val; int labelXpos = getWidgetXpos(); int labelYpos = getWidgetYpos(); //position the text box under the label, i.e. at the same xpos but an increased ypos //position of the Label label.Location = new Point(labelXpos, labelYpos); label.Size = new Size(getWidgetWidth(), getWidgetHeight()); //position of the longitude/latitude labels longLabel.Location = new Point(labelXpos, labelYpos + 40); longLabel.Size = new Size(250, 50); longLabel.Text = "Longitude"; latLabel.Location = new Point(labelXpos + 300, labelYpos + 40); latLabel.Size = new Size(250, 50); latLabel.Text = "Latitude"; //help label helpLabel.Location = new Point(labelXpos, labelYpos + 150); helpLabel.Size = new Size(800, 80); helpLabel.Text = "Note: Click the button even if the GPS is disconnected or unavailable. You might need to click 'GPS connect' first."; //position of the textboxes textboxLong.Location = new Point(labelXpos, labelYpos + 80); textboxLong.Size = new Size(250, 50); textboxLat.Location = new Point(labelXpos + 300, labelYpos + 80); textboxLat.Size = new Size(250, 50); setLocationButton.Text = "click here when you want to record the GPS position"; //setLocationButton.Location = new Point(labelXpos, labelYpos + 120); setLocationButton.Location = new Point(labelXpos + 600, labelYpos - 10); setLocationButton.Size = new Size(200, 150); setLocationButton.Click += new EventHandler(button_click2); //if page seen before, populate the control with the previously entered text if (PageSeen) { textboxLat.Text = latitude; textboxLong.Text = longitude; } //add controls to the panel getQM().getPanel().Controls.Add(label); getQM().getPanel().Controls.Add(textboxLong); getQM().getPanel().Controls.Add(textboxLat); getQM().getPanel().Controls.Add(setLocationButton); getQM().getPanel().Controls.Add(latLabel); getQM().getPanel().Controls.Add(longLabel); getQM().getPanel().Controls.Add(helpLabel); } else { //separate GPS unit //create a label and textbox control label = new Label(); label.ForeColor = GlobalColours.mainTextColour; textboxLat = new TextBox(); textboxLat.BackColor = GlobalColours.controlBackColour; textboxLong = new TextBox(); textboxLong.BackColor = GlobalColours.controlBackColour; //extra boxes for second entry: textboxLat2 = new TextBox(); textboxLat2.BackColor = GlobalColours.controlBackColour; textboxLong2 = new TextBox(); textboxLong2.BackColor = GlobalColours.controlBackColour; //trap any keypress to deselect the skip-controls textboxLat.KeyPress += new KeyPressEventHandler(button_click); textboxLong.KeyPress += new KeyPressEventHandler(button_click); textboxLat2.KeyPress += new KeyPressEventHandler(button_click); textboxLong2.KeyPress += new KeyPressEventHandler(button_click); labelFirstEntry = new Label(); labelFirstEntry.ForeColor = GlobalColours.mainTextColour; labelSecondEntry = new Label(); labelSecondEntry.ForeColor = GlobalColours.mainTextColour; //set font size setFontSize(label, textboxLat, textboxLong, textboxLat2, textboxLong2 , labelFirstEntry, labelSecondEntry); //the question Text shown to the user label.Text = Val; int labelXpos = getWidgetXpos(); int labelYpos = getWidgetYpos(); //position the text box under the label, i.e. at the same xpos but an increased ypos //position of the Label label.Location = new Point(labelXpos, labelYpos); label.Size = new Size(getWidgetWidth(), getWidgetHeight()); //position of the first entry label labelFirstEntry.Location = new Point(labelXpos, labelYpos + 70); labelFirstEntry.Size = new Size(600, 50); labelFirstEntry.Text = "First Entry: Longitude Latitude"; //position of second entry label labelSecondEntry.Location = new Point(labelXpos, labelYpos + 130); labelSecondEntry.Size = new Size(600, 50); labelSecondEntry.Text = "Second Entry: Longitude Latitude"; //position of the textboxes textboxLong.Location = new Point(labelXpos + 290, labelYpos + 70); textboxLong.Size = new Size(120, 50); textboxLat.Location = new Point(labelXpos + 540, labelYpos + 70); textboxLat.Size = new Size(120, 50); textboxLong2.Location = new Point(labelXpos + 290, labelYpos + 130); textboxLong2.Size = new Size(120, 50); textboxLat2.Location = new Point(labelXpos + 540, labelYpos + 130); textboxLat2.Size = new Size(120, 50); //if page seen before, populate the control with the previously entered text if (PageSeen) { textboxLat.Text = latitude; textboxLong.Text = longitude; textboxLat2.Text = latitude; textboxLong2.Text = longitude; } //add controls to the panel getQM().getPanel().Controls.Add(label); getQM().getPanel().Controls.Add(textboxLong); getQM().getPanel().Controls.Add(textboxLat); getQM().getPanel().Controls.Add(textboxLong2); getQM().getPanel().Controls.Add(textboxLat2); getQM().getPanel().Controls.Add(labelFirstEntry); getQM().getPanel().Controls.Add(labelSecondEntry); } setSkipSetting(); }