Esempio n. 1
0
 public Task2D(Task2D tk)
 {
     Name = "copy of " + tk.Name;
     additionalInput = new List<InputDevice>(tk.additionalInput);
     endCondition = tk.endCondition.returnNew();
     primaryInput = tk.primaryInput.returnNew();
     regionEnabled = tk.regionEnabled;
     rand = new Random();
     region = new Region(tk.region);
 }
Esempio n. 2
0
 private void buttonCreate_Click(object sender, EventArgs e)
 {
     Task newTask;
     Form newTaskForm;
     switch (listBoxTasks.SelectedIndex)
     {
         case 0:
             newTask = new DialogTask();
             newTaskForm = new FormDialogTask((DialogTask) newTask);
             break;
         case 1:
             newTask = new Task2D();
             newTaskForm = new Form2DTask((Task2D) newTask);
             break;
         case 2:
             newTask = new RepeatTask();
             newTaskForm = new FormRepeatTask((RepeatTask) newTask);
             break;
         default:
             return;
     }
     this.Visible = false;
     newTaskForm.Tag = this.Tag;
     DialogResult result = newTaskForm.ShowDialog();
     if (result == DialogResult.OK)
     {
         //if the task name is left empty then set it to a generic name based on the task type
         if (newTask.Name == null || newTask.Name.Length == 0)
         {
             switch (listBoxTasks.SelectedIndex)
             {
                 case 0:
                     newTask.Name = "Dialog Task";
                     break;
                 case 1:
                     newTask.Name = "2D Task";
                     break;
                 case 2:
                     newTask.Name = "Repeat Task";
                     break;
                 default:
                     newTask.Name = "Task Name";
                     return;
             }
         }
         therapy.addTask(newTask);
         this.DialogResult = DialogResult.OK;
     }
     else
         this.DialogResult = DialogResult.Cancel;
     this.Close();
 }
Esempio n. 3
0
        public Form2DTask(Task2D t)
        {
            InitializeComponent();
            comboBoxInputDevice.DataSource = Input2D.GetPossibleInputs();
            comboBoxInputHandling.DataSource = InputHandlingNames.InputHandlingStrings;
            comboBoxPerformanceMetric.DataSource = PerformanceMetrics.PerformanceMetricStrings;
            comboBoxEndButton.DataSource = ButtonEndCondition.ButtonText;
            comboBoxShape.DataSource = new ShapeType[] { ShapeType.Rectangle, ShapeType.Ellipse, ShapeType.Hoop };
            SpecifierLabel[] SpecifierLabels = new SpecifierLabel[]
            {
                SpecifierLabel.Static, SpecifierLabel.Dynamic,
                SpecifierLabel.Random
            };
            comboBoxPosX.BindingContext = new BindingContext();
            comboBoxPosX.DataSource = SpecifierLabels;
            comboBoxPosX.Tag = t.region.rParams[regPT.X];
            comboBoxPosY.BindingContext = new BindingContext();
            comboBoxPosY.DataSource = SpecifierLabels;
            comboBoxPosY.Tag = t.region.rParams[regPT.Y];
            comboBoxSizeX.BindingContext = new BindingContext();
            comboBoxSizeX.DataSource = SpecifierLabels;
            comboBoxSizeY.BindingContext = new BindingContext();
            comboBoxSizeY.DataSource = SpecifierLabels;

            // Load Form from task data
            task = t;
            textBoxName.Text = task.Name;

            // Input loading
            comboBoxInputDevice.SelectedIndex = Input2D.GetInputIndex(task.primaryInput);
            additionalInputs = new List<InputDevice>();
            additionalInputs.AddRange(task.additionalInput);
            listBoxAdditionalInputs.DataSource = additionalInputs;

            // Input handling load
            comboBoxInputHandling.SelectedIndex = (int)task.inputHandling;

            // Performance Metric load
            comboBoxPerformanceMetric.SelectedIndex = (int)task.performanceMetric;

            //Region Loading
            if (t.regionEnabled)
            {
                groupBox1.Enabled = true;
                checkBoxEnableRegion.Checked = true;
            }
            else
            {
                groupBox1.Enabled = false;
                checkBoxEnableRegion.Checked = false;
            }
            if (t.region.Shape != ShapeType.NONE)
            {
                comboBoxShape.SelectedItem = t.region.Shape;
                comboBoxPosX.SelectedItem  = ((RegionParameter)comboBoxPosX.Tag).SL_pos;
                comboBoxPosY.SelectedItem  = ((RegionParameter)comboBoxPosY.Tag).SL_pos;
                comboBoxSizeX.SelectedItem = ((RegionParameter)comboBoxPosX.Tag).SL_size;
                comboBoxSizeY.SelectedItem = ((RegionParameter)comboBoxPosY.Tag).SL_size;
                numericUpDownPosX1.Value   = (decimal)((RegionParameter)comboBoxPosX.Tag).pos[0];
                numericUpDownPosX2.Value   = (decimal)((RegionParameter)comboBoxPosX.Tag).pos[1];
                numericUpDownPosY1.Value   = (decimal)((RegionParameter)comboBoxPosY.Tag).pos[0];
                numericUpDownPosY2.Value   = (decimal)((RegionParameter)comboBoxPosY.Tag).pos[1];
                numericUpDownSizeX1.Value  = (decimal)((RegionParameter)comboBoxPosX.Tag).size[0];
                numericUpDownSizeX2.Value  = (decimal)((RegionParameter)comboBoxPosX.Tag).size[1];
                numericUpDownSizeY1.Value  = (decimal)((RegionParameter)comboBoxPosY.Tag).size[0];
                numericUpDownSizeY2.Value  = (decimal)((RegionParameter)comboBoxPosY.Tag).size[1];
            }

            // End Condition Loading
            if (task.endCondition.GetType() == typeof(ButtonEndCondition))
            {
                buttonEnd = (ButtonEndCondition)task.endCondition;
                timeEnd = new TimeLimitEndCondition();
                comboBoxEndCondition.SelectedIndex = 0;

            }
            else
            {
                buttonEnd = new ButtonEndCondition();
                timeEnd = (TimeLimitEndCondition)task.endCondition;
                if(((TimeLimitEndCondition)task.endCondition).Type == TimeLimitType.TotalTime)
                    comboBoxEndCondition.SelectedIndex = 1;
                else if(((TimeLimitEndCondition)task.endCondition).Type == TimeLimitType.TimeInRegion)
                    comboBoxEndCondition.SelectedIndex = 2;
                else if (((TimeLimitEndCondition)task.endCondition).Type == TimeLimitType.TimeOutRegion)
                    comboBoxEndCondition.SelectedIndex = 3;
            }
            numericUpDownEndSeconds.Value = (decimal)timeEnd.TimeLimit;
            comboBoxEndButton.SelectedIndex = (int)buttonEnd.Button;
        }