using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CategoryTheory;
using DiagramUI;
using DataPerformer;
using Motion6D;
namespace MotionUI
{
public partial class FormFrameData : Form, IUpdatableForm
{
private IObjectLabel label;
private ReferenceFrameData frame;
private ComboBox[] boxes;
private FormFrameData()
{
InitializeComponent();
}
public FormFrameData(IObjectLabel label)
{
InitializeComponent();
ResourceService.Resources.LoadControlResources(this);
this.label = label;
Text = label.Name;
frame = label.Object as ReferenceFrameData;
boxes = new ComboBox[] { comboBoxX, comboBoxY, comboBoxZ, comboBoxQ0, comboBoxQ1, comboBoxQ2, comboBoxQ3 };
fill();
}
#region IUpdatableForm Members
void IUpdatableForm.UpdateFormUI()
{
Text = label.Name;
}
#endregion
void fill()
{
List<string> p = frame.Parameters;
List<string> l = frame.AllMeasurements;
for (int i = 0; i < boxes.Length; i++ )
{
ComboBox box = boxes[i];
DefaultForm.FillCombo(box, l);
if (i < p.Count)
{
string s = p[i];
DefaultForm.SelectCombo(box, s);
}
}
}
void accept()
{
List<string> p = new List<string>();
foreach (ComboBox box in boxes)
{
string s = box.SelectedItem + "";
if (s.Length == 0)
{
MessageBox.Show("Undefined parameter");
return;
}
p.Add(s);
}
frame.Parameters = p;
}
private void buttonAccept_Click(object sender, EventArgs e)
{
accept();
}
}
}