public void SetCurrentState(CamViewState state) { if (this.activeState == state) { return; } if (this.activeState != null) { this.activeState.OnLeaveState(); } this.activeState = state; if (this.activeState != null) { if (this.stateSelector.Items.Count == 0) { this.InitStateSelector(); } this.stateSelector.SelectedIndex = this.stateSelector.Items.IndexOf(this.stateSelector.Items.Cast <StateEntry>().FirstOrDefault(e => e.StateType == this.activeState.GetType())); } else { this.stateSelector.SelectedIndex = -1; } // No glControl yet? We're not initialized properly and this is the initial state. Enter the state later. if (this.glControl != null) { if (this.activeState != null) { this.activeState.OnEnterState(); } this.glControl.Invalidate(); } }
public CamView(int runtimeId, string initStateTypeName = null) { this.InitializeComponent(); this.loadTempState = initStateTypeName; this.oldColorDialogColor = Color.FromArgb(64, 64, 64); this.selectedColorDialogColor = this.oldColorDialogColor; this.Text = Properties.CamViewRes.MenuItemName_CamView + " #" + runtimeId; this.runtimeId = runtimeId; this.toolbarCamera.Renderer = new Duality.Editor.Controls.ToolStrip.DualitorToolStripProfessionalRenderer(); var camViewStateTypeQuery = from t in DualityEditorApp.GetAvailDualityEditorTypes(typeof(CamViewState)) where !t.IsAbstract select t; foreach (Type t in camViewStateTypeQuery) { CamViewState state = t.CreateInstanceOf() as CamViewState; state.View = this; this.availStates.Add(t, state); } var camViewLayerTypeQuery = from t in DualityEditorApp.GetAvailDualityEditorTypes(typeof(CamViewLayer)) where !t.IsAbstract select t; foreach (Type t in camViewLayerTypeQuery) { CamViewLayer layer = t.CreateInstanceOf() as CamViewLayer; layer.View = this; this.availLayers.Add(t, layer); } }
protected override void PostPerformAction(IEnumerable<CamViewState.SelObj> selObjEnum, CamViewState.ObjectAction action) { base.PostPerformAction(selObjEnum, action); if (action == ObjectAction.Move) { DualityEditorApp.NotifyObjPropChanged( this, new ObjectSelection(selObjEnum.Select(s => (s.ActualObject as GameObject).Transform)), ReflectionInfo.Property_Transform_RelativePos); } else if (action == ObjectAction.Rotate) { DualityEditorApp.NotifyObjPropChanged( this, new ObjectSelection(selObjEnum.Select(s => (s.ActualObject as GameObject).Transform)), ReflectionInfo.Property_Transform_RelativePos, ReflectionInfo.Property_Transform_RelativeAngle); } else if (action == ObjectAction.Scale) { DualityEditorApp.NotifyObjPropChanged( this, new ObjectSelection(selObjEnum.Select(s => (s.ActualObject as GameObject).Transform)), ReflectionInfo.Property_Transform_RelativePos, ReflectionInfo.Property_Transform_RelativeScale); } }
protected override void PostPerformAction(IEnumerable<CamViewState.SelObj> selObjEnum, CamViewState.ObjectAction action) { base.PostPerformAction(selObjEnum, action); SelShape[] selShapeArray = selObjEnum.OfType<SelShape>().ToArray(); // Update the body directly after modifying it if (this.selectedBody != null) this.selectedBody.SynchronizeBodyShape(); // Notify property changes DualityEditorApp.NotifyObjPropChanged(this, new ObjectSelection(this.selectedBody), ReflectionInfo.Property_RigidBody_Shapes); DualityEditorApp.NotifyObjPropChanged(this, new ObjectSelection(selShapeArray.Select(s => s.ActualObject))); }
protected override void OnEndAction(CamViewState.ObjectAction action) { base.OnEndAction(action); bool shapeAction = action != ObjectAction.RectSelect && action != ObjectAction.None; if (this.selectedBody != null && shapeAction) { this.selectedBody.EndUpdateBodyShape(); } if (this.createAction) { this.createAction = false; UndoRedoManager.EndMacro(UndoRedoManager.MacroDeriveName.FromFirst); } }
protected override void OnBeginAction(CamViewState.ObjectAction action) { base.OnBeginAction(action); bool shapeAction = action != ObjectAction.RectSelect && action != ObjectAction.None; if (this.selectedBody != null && shapeAction) this.selectedBody.BeginUpdateBodyShape(); }
public StateEntry(Type stateType, CamViewState state) { this.stateType = stateType; this.state = state; }
public StateEntry(Type stateType, CamViewState state) { this.stateType = stateType; this.state = state; }
public void SetCurrentState(CamViewState state) { if (this.activeState == state) return; if (this.activeState != null) this.activeState.OnLeaveState(); this.activeState = state; if (this.activeState != null) { if (this.stateSelector.Items.Count == 0) this.InitStateSelector(); this.stateSelector.SelectedIndex = this.stateSelector.Items.IndexOf(this.stateSelector.Items.Cast<StateEntry>().FirstOrDefault(e => e.StateType == this.activeState.GetType())); } else this.stateSelector.SelectedIndex = -1; // No glControl yet? We're not initialized properly and this is the initial state. Enter the state later. if (this.glControl != null) { if (this.activeState != null) this.activeState.OnEnterState(); this.glControl.Invalidate(); } }