public static void Initialize(string windowType) { Testbed.Initialize(); if (windowType == "?" || windowType == "h" || windowType == "help") { MessageBox.Show( "editor - run as physical editor\n" + "coe - run as conservation of energy demo\n" + "testbed - run as physical testbed\n" + "help - show this text", "LSM Prototype commands" ); } else if (windowType == "editor") { editorWindow = new EditorWindow(); window = editorWindow; } else if (windowType == "coe") { coeWindow = new CoeWindow(); window = coeWindow; } else if (windowType == "main") { window = new MainWindow(); } else { testbedWindow = new TestbedWindow(); window = testbedWindow; } }
public static void MakeDataBindingForBody(TestbedWindow window, LsmBody body, int bodyIndex) { // TODO: make this method suitable for N bodies - not only for 2 of them if (window != null && (bodyIndex == 0 || bodyIndex == 1)) { MakeCheckBoxDataBinding(window, "model0" + (bodyIndex + 1) + "DisableCollisions", "Checked", body, "UseWallForce"); MakeCheckBoxDataBinding(window, "model0" + (bodyIndex + 1) + "Freeze", "Checked", body, "Frozen"); } }
static void MakeCheckBoxDataBinding(TestbedWindow window, string checkBoxName, string checkBoxPropertyName, LsmBody body, string bodyPropertyName) { System.Windows.Forms.Control[] controls = window.Controls.Find(checkBoxName, true); if (controls.Length > 0 && controls.GetValue(0) != null && controls.GetValue(0) is System.Windows.Forms.CheckBox) { System.Windows.Forms.CheckBox checkBox = controls.GetValue(0) as System.Windows.Forms.CheckBox; checkBox.DataBindings.Clear(); checkBox.DataBindings.Add(checkBoxPropertyName, body, bodyPropertyName).DataSourceUpdateMode = System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged; } }