/// <summary> /// Sets the UI Actions for Objects (WaveEngine) according to the user input /// </summary> private void UpdateUiActions() { if (!this.IsInitialized) return; //Mouse UIElementAction mouseAction = new UIElementAction(); switch (cb_mouseAction.SelectedIndex) { case 0:// Poke mouseAction.ActionType = UIElementAction.EActionType.SetAmp; break; case 1://Set Wall mouseAction.ActionType = UIElementAction.EActionType.SetWall; break; case 2://Del Wall mouseAction.ActionType = UIElementAction.EActionType.DelWall; break; case 3://Set Mass mouseAction.ActionType = UIElementAction.EActionType.SetMass; break; case 4://Del Mass mouseAction.ActionType = UIElementAction.EActionType.DelMass; break; case 5://Create WaveSource mouseAction.ActionType = UIElementAction.EActionType.SetSource; break; } int size = Convert.ToInt32(((ComboBoxItem)cb_mouseSize.SelectedItem).Content); double value = sl_mouseValue.Value; if (mouseAction.ActionType == UIElementAction.EActionType.SetSource) //adjust values for source frequency value = sl_mouseValue.Value/13.0; mouseAction.Size = size; mouseAction.Value = value; //LTO UIElementAction LtoAction = new UIElementAction(); switch (cb_ltoType.SelectedIndex) { case 0://WaveSource LtoAction.ActionType = UIElementAction.EActionType.SetSource; LtoAction.ActionObjectType = typeof(SimWaveSourceObject); break; case 1://Mass LtoAction.ActionType = UIElementAction.EActionType.SetMass; break; case 2://Wall LtoAction.ActionType = UIElementAction.EActionType.SetWall; break; case 3://Plotter LtoAction.ActionType = UIElementAction.EActionType.NULL; LtoAction.ActionObjectType = typeof(SimPlotterObject); break; } switch (cb_ltoShape.SelectedIndex) { case 0: LtoAction.Shape = UIElementAction.EShape.Square; break; case 1: LtoAction.Shape = UIElementAction.EShape.Circle; break; } LtoAction.Size = Convert.ToInt32(((ComboBoxItem)cb_ltoSize.SelectedItem).Content); LtoAction.Value = sl_ltoValue.Value; if (LtoAction.ActionObjectType == typeof(SimWaveSourceObject)) //Adjust wave source value LtoAction.Value = sl_mouseValue.Value/13.0; //TOO UIElementAction tooAction = new UIElementAction(); tooAction.Value = sl_tooValue.Value; switch (cb_tooAktion.SelectedIndex) { case 0:// Elongatioon ~ objectHeight tooAction.ActionType = UIElementAction.EActionType.SetAmp; tooAction.Value = -1; break; case 1://Const Elongation tooAction.ActionType = UIElementAction.EActionType.SetAmp; break; } tooAction.Size = Convert.ToInt32(((ComboBoxItem)cb_tooSize.SelectedItem).Content); _waveTableEngine.UiLtoAction = LtoAction; _waveTableEngine.UiMouseAction = mouseAction; _waveTableEngine.UiTooAction = tooAction; }
/// <summary> /// Sets the UI Actions for Objects (WaveEngine) according to the user input /// </summary> private void UpdateUiActions() { if (!this.IsInitialized) return; //Mouse UIElementAction mouseAction = new UIElementAction(); switch (cb_mouseAction.SelectedIndex) { case 0:// Poke mouseAction.ActionType = UIElementAction.EActionType.SetAmp; break; case 1://Set Wall mouseAction.ActionType = UIElementAction.EActionType.SetWall; break; case 2://Del Wall mouseAction.ActionType = UIElementAction.EActionType.DelWall; break; case 3://Set Mass mouseAction.ActionType = UIElementAction.EActionType.SetMass; break; case 4://Del Mass mouseAction.ActionType = UIElementAction.EActionType.DelMass; break; case 5://Create WaveSource mouseAction.ActionType = UIElementAction.EActionType.SetSource; break; } int size = Convert.ToInt32(((ComboBoxItem)cb_mouseSize.SelectedItem).Content); double value = sl_mouseValue.Value; if (mouseAction.ActionType == UIElementAction.EActionType.SetSource) //adjust values for source frequency value = sl_mouseValue.Value/13.0; mouseAction.Size = size; mouseAction.Value = value; _waveTableEngine.UiMouseAction = mouseAction; }
private SimulationObject AddSimObject(int ObjectID, UIElementAction elementAction, SimulationObject.ETableObjectType TableObjectType) { SimulationObject simObj = new SimulationObject(); if (elementAction.ActionObjectType == typeof(SimPlotterObject)) { simObj = new SimPlotterObject(); } else if (elementAction.ActionObjectType == typeof(SimWaveSourceObject)) { SimWaveSourceObject simwave = new SimWaveSourceObject(); simwave.WaveSourceRef = new SinusWaveSource(); simwave.WaveSourceRef.Frequency = elementAction.Value; simObj = simwave; } simObj.ObjectID = ObjectID; simObj.ObjectValue = UiLtoAction.Value; simObj.TableObjectType = TableObjectType; simObj.PositionOrRotationChange = true; simObj.ObjectSize = elementAction.Size; switch (elementAction.ActionType) { case UIElementAction.EActionType.SetMass: simObj.ObjectType = SimulationObject.EObjectType.Mass; break; case UIElementAction.EActionType.SetWall: simObj.ObjectType = SimulationObject.EObjectType.Wall; break; case UIElementAction.EActionType.SetSource: //nothing to do, everything done before break; case UIElementAction.EActionType.SetAmp: if (simObj.ObjectValue == -1) { simObj.ObjectType = SimulationObject.EObjectType.RelElongation; } else { simObj.ObjectType = SimulationObject.EObjectType.ConstElongation; } break; } switch (elementAction.Shape) { case UIElementAction.EShape.Circle: simObj.ObjectShape = SimulationObject.EObjectShape.Circle; break; case UIElementAction.EShape.Square: simObj.ObjectShape = SimulationObject.EObjectShape.Square; break; case UIElementAction.EShape.NULL: simObj.ObjectShape = SimulationObject.EObjectShape.NULL; break; } TableObject to = _tableManager.TableObjects.Where(o => o.ObjectID == ObjectID).ToArray()[0]; simObj.Position = to.Center; simObj.Position = PositionMapper.GetScreenCoordsfromDepth(simObj.Position); Point screen = new Point(simObj.Position.ScreenX, simObj.Position.ScreenY); simObj.SimPosition = CalculateSimPosition(screen); //If the object is out of bounds (outside the simulation), then dont add it if (simObj.SimPosition.X >= _waveEngine.Width || simObj.SimPosition.Y >= _waveEngine.Height || simObj.SimPosition.Y < 1 || simObj.SimPosition.X < 1) return null; if (to.RotationDefined) simObj.ObjectRotation = to.DirectionVector; lock (_lockSimuObjects) { _simulationObjects.Add(simObj); } return simObj; }