/// <summary> /// Called when the user releases the mouse button on a hotspot /// </summary> /// <param name="hotSpot"></param> /// <param name="view"></param> public override void OnHotSpotDragEnd(HotSpotBase hotSpot, VisionViewBase view) { if (hotSpot == _hotSpotSizeX) { if (_hotSpotSizeX.HasChanged) { float fNewSize = _hotSpotSizeX.CurrentDistance; this.BoxSizeX = _hotSpotSizeX.StartDistance; // set old value for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "BoxSizeX", fNewSize)); // send an action which sets the property from old value to new one } } if (hotSpot == _hotSpotSizeY) { if (_hotSpotSizeY.HasChanged) { float fNewSize = _hotSpotSizeY.CurrentDistance; this.BoxSizeY = _hotSpotSizeY.StartDistance; // set old value for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "BoxSizeY", fNewSize)); // send an action which sets the property from old value to new one } } if (hotSpot == _hotSpotSizeZ) { if (_hotSpotSizeZ.HasChanged) { float fNewSize = _hotSpotSizeZ.CurrentDistance; this.BoxSizeZ = _hotSpotSizeZ.StartDistance; // set old value for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "BoxSizeZ", fNewSize)); // send an action which sets the property from old value to new one } } }
public override void OnHotSpotDragEnd(HotSpotBase hotSpot, VisionViewBase view) { base.OnHotSpotDragEnd(hotSpot, view); if (hotSpot == _hotSpotWindSpeed) { Vector3F vNewSpeed = _hotSpotWindSpeed.CurrentPosition; Vector3F vOldSpeed = _hotSpotWindSpeed.StartPosition; if (WindInLocalSpace) { Matrix3F rot = Matrix3F.Transpose(RotationMatrix); vNewSpeed = Matrix3F.Transform(rot, vNewSpeed); vOldSpeed = Matrix3F.Transform(rot, vOldSpeed); } WindSpeed = vOldSpeed; // set old value for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "WindSpeed", vNewSpeed)); // send an action which sets the property from old value to new one } else if (hotSpot == _hotSpotLightSamplingOffset) { Vector3F vNewOffset = _hotSpotLightSamplingOffset.CurrentPosition; Vector3F vOldOffset = _hotSpotLightSamplingOffset.StartPosition; LightSamplingOffset = vOldOffset; // set old value for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "LightSamplingOffset", vNewOffset)); // send an action which sets the property from old value to new one } }
/// <summary> /// Overridden function /// </summary> public override void PerformRelevantOperation(string name, int iShapeIndex, int iShapeCount) { if (name == "Activate Postprocessing") { Activate(); return; } if (name == ShapeObject3D.RELEVANTOP_SHAPENAME_AS_KEY) { // start a group if (iShapeIndex == 0) { EditorManager.Actions.StartGroup("Name as Key"); } EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "Key", ShapeName)); // close group action if (iShapeIndex == iShapeCount - 1) { EditorManager.Actions.EndGroup(); } return; } base.PerformRelevantOperation(name, iShapeIndex, iShapeCount); }
public override IShapeVisitor.VisitResult Visit(CSharpFramework.Shapes.ShapeBase shape) { if (!shape.Modifiable) { return(VisitResult.VisitOk); } bool bAddAction = false; if (shape is EntityShape) { if (!((EntityShape)shape).CastDynamicShadows) { bAddAction = true; } } if (shape is StaticMeshShape) { if (!((StaticMeshShape)shape).CastDynamicShadows) { bAddAction = true; } } if (bAddAction) { Action.Add(SetPropertyAction.CreateSetPropertyAction(shape, "CastDynamicShadows", true)); } return(VisitResult.VisitOk); }
public override void OnClicked(VisionViewBase view) { base.OnClicked(view); if (TerrainEditor.CurrentSelection == null) { return; } ITerrainClipboardObject data = (EditorManager.ActiveComponent.Clipboard == null) ? null : EditorManager.ActiveComponent.Clipboard.Data as ITerrainClipboardObject; if (data == null) { return; } TerrainSelectionShape selShape = (TerrainSelectionShape)this.Owner; float fRadX = data.OriginalExtent.GetSizeX() * 0.5f; float fRadY = data.OriginalExtent.GetSizeY() * 0.5f; GroupAction action = new GroupAction("adjust selection size"); action.Add(SetPropertyAction.CreateSetPropertyAction(selShape, "MinX", fRadX)); // min values are also positive action.Add(SetPropertyAction.CreateSetPropertyAction(selShape, "MinY", fRadY)); action.Add(SetPropertyAction.CreateSetPropertyAction(selShape, "MaxX", fRadX)); action.Add(SetPropertyAction.CreateSetPropertyAction(selShape, "MaxY", fRadY)); EditorManager.Actions.Add(action); }
public void Properties() { SetPropertyAction a = new SetPropertyAction(); // default Assert.AreEqual("", a.Property, "A1"); Assert.AreEqual("", a.PropertyKey, "A2"); Assert.AreEqual("", a.Value, "A3"); Assert.AreEqual("setProperty", a.TagName, "A4"); // getter/setter a.Property = "property"; Assert.AreEqual("property", a.Property, "A5"); a.PropertyKey = "propertykey"; Assert.AreEqual("propertykey", a.PropertyKey, "A6"); a.Value = "value"; Assert.AreEqual("value", a.Value, "A7"); // setting to null a.Property = null; Assert.AreEqual("", a.Property, "A8"); a.PropertyKey = null; Assert.AreEqual("", a.PropertyKey, "A9"); a.Value = null; Assert.AreEqual("", a.Value, "A10"); }
public void IsTypeDescriptorClosed() { SetPropertyAction a = new SetPropertyAction(); ScriptTypeDescriptor desc = ((IScriptObject)a).GetTypeDescriptor(); desc.AddEvent(new ScriptEventDescriptor("testEvent", true)); }
public void TypeDescriptor() { SetPropertyAction a = new SetPropertyAction(); ScriptTypeDescriptor desc = ((IScriptObject)a).GetTypeDescriptor(); Assert.AreEqual(a, desc.ScriptObject, "A1"); // events IEnumerable <ScriptEventDescriptor> events = desc.GetEvents(); Assert.IsNotNull(events, "A2"); IEnumerator <ScriptEventDescriptor> ee = events.GetEnumerator(); Assert.IsTrue(ee.MoveNext()); DoEvent(ee.Current, "propertyChanged", true); Assert.IsFalse(ee.MoveNext()); // methods IEnumerable <ScriptMethodDescriptor> methods = desc.GetMethods(); Assert.IsNotNull(methods, "A3"); IEnumerator <ScriptMethodDescriptor> me = methods.GetEnumerator(); Assert.IsFalse(me.MoveNext()); // properties IEnumerable <ScriptPropertyDescriptor> props = desc.GetProperties(); Assert.IsNotNull(props, "A4"); IEnumerator <ScriptPropertyDescriptor> pe = props.GetEnumerator(); Assert.IsTrue(pe.MoveNext(), "A5"); DoProperty(pe.Current, "bindings", ScriptType.Array, true, "Bindings"); Assert.IsTrue(pe.MoveNext(), "A6"); DoProperty(pe.Current, "dataContext", ScriptType.Object, false, ""); Assert.IsTrue(pe.MoveNext(), "A7"); DoProperty(pe.Current, "id", ScriptType.String, false, "ID"); Assert.IsTrue(pe.MoveNext(), "A8"); DoProperty(pe.Current, "eventArgs", ScriptType.Object, false, ""); Assert.IsTrue(pe.MoveNext(), "A9"); DoProperty(pe.Current, "result", ScriptType.Object, false, ""); Assert.IsTrue(pe.MoveNext(), "A10"); DoProperty(pe.Current, "sender", ScriptType.Object, false, ""); Assert.IsTrue(pe.MoveNext(), "A11"); DoProperty(pe.Current, "sequence", ScriptType.Enum, false, "Sequence"); Assert.IsTrue(pe.MoveNext(), "A12"); DoProperty(pe.Current, "target", ScriptType.Object, false, "Target"); Assert.IsTrue(pe.MoveNext(), "A13"); DoProperty(pe.Current, "property", ScriptType.String, false, "Property"); Assert.IsTrue(pe.MoveNext(), "A14"); DoProperty(pe.Current, "propertyKey", ScriptType.String, false, "PropertyKey"); Assert.IsTrue(pe.MoveNext(), "A15"); DoProperty(pe.Current, "value", ScriptType.String, false, "Value"); Assert.IsFalse(pe.MoveNext(), "A16"); }
public override void PerformRelevantOperation(string name, int iShapeIndex, int iShapeCount) { base.PerformRelevantOperation(name, iShapeIndex, iShapeCount); if (name == RO_ADJUST_BBOX) { ShapeLink src = GetVisibilityLinkSource(); if (src == null || src.Links.Count == 0) { return; } BoundingBox newbbox = new BoundingBox(); foreach (LinkTarget tgt in src.Links) { BoundingBox bbox = tgt.OwnerShape.AbsoluteBoundingBox; if (bbox != null && bbox.Valid) { newbbox.AddBox(bbox); } } if (newbbox.Valid) { EditorManager.Actions.StartGroup(RO_ADJUST_BBOX); Vector3F size = new Vector3F(newbbox.SizeX, newbbox.SizeY, newbbox.SizeZ); EditorManager.Actions.Add(new MoveShapeAction(this, this.Position, newbbox.Center)); EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "BoxSize", size)); EditorManager.Actions.EndGroup(); } } if (name == RO_LINK_TO_TOUCHING_SHAPES || name == RO_LINK_TO_SHAPES_INSIDE) { EvaluateBBoxLinksVisitor visitor = new EvaluateBBoxLinksVisitor(this, name == RO_LINK_TO_TOUCHING_SHAPES); foreach (Layer layer in EditorManager.Scene.Layers) { if (layer.Modifiable) { layer.Root.RunVisitor(visitor); } } if (visitor.RelevantTargets.Count > 0) { LinkSource linkSrc = GetVisibilityLinkSource(); EditorManager.Actions.StartGroup(name); foreach (LinkTarget target in visitor.RelevantTargets) { EditorManager.Actions.Add(new LinkAction(linkSrc, target)); } EditorManager.Actions.EndGroup(); } } }
public void Execute_WithNullContext_Throws() { // Arrange SetPropertyAction action = new SetPropertyAction("Name", "Value"); IRewriteContext context = null; // Act/Assert ExceptionAssert.Throws<ArgumentNullException>(() => action.Execute(context)); }
public void Execute_WithNullContext_Throws() { // Arrange SetPropertyAction action = new SetPropertyAction("Name", "Value"); IRewriteContext context = null; // Act/Assert ExceptionAssert.Throws <ArgumentNullException>(() => action.Execute(context)); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { if (!_isModified && _oldIsLockAspect == _imageControl.IsLockAspect) { return; } SetPropertyAction = new SetPropertyAction(_imageControl, _oldWidth, _oldHeight, _oldAngle, _oldIsLockAspect, _oldTranslateX, _oldTranslateY, _imageControl.Width, _imageControl.Height, _rotateTransform.Angle, _imageControl.IsLockAspect, _translateTransform.X, _translateTransform.Y ); }
/// <summary> /// API to update the object model from the UI /// Creates an action and registers it with the action manager /// This is the interesting part of the demo /// </summary> void SetProperty(string propertyName, object propertyValue) { if (reentrancyGuard) { return; } SetPropertyAction action = new SetPropertyAction(joe, propertyName, propertyValue); actionManager.RecordAction(action); UpdateUndoRedoButtons(); }
/// <summary> /// Called when the user releases the mouse button on a hotspot /// </summary> /// <param name="hotSpot"></param> /// <param name="view"></param> public override void OnHotSpotDragEnd(HotSpotBase hotSpot, VisionViewBase view) { if (hotSpot == _hotSpotHeight) { if (_hotSpotHeight.HasChanged) { float fNewHeight = _hotSpotHeight.CurrentDistance; Height = _hotSpotHeight.StartDistance; // set old value for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "Height", fNewHeight)); // send an action which sets the property from old value to new one } } }
public void Constructor_SetsNameAndValue() { // Arrange string propertyName = "PropertyName"; string propertyValue = "PropertyValue"; // Act SetPropertyAction action = new SetPropertyAction(propertyName, propertyValue); // Assert Assert.AreEqual(propertyName, action.Name); Assert.AreEqual(propertyValue, action.Value); }
public void SetPropertyActionWorks() { var instance = new Exception(); SetPropertyAction action = new SetPropertyAction(instance, "Source", "foo"); ActionManager am = new ActionManager(); am.RecordAction(action); Assert.AreEqual("foo", instance.Source); am.Undo(); Assert.AreEqual(null, instance.Source); am.Redo(); Assert.AreEqual("foo", instance.Source); }
public void SetProperty(Authentication authentication, string propertyName, object value) { if (this.isEnabled == false) { return; } var action = new SetPropertyAction() { UserID = authentication.ID, PropertyName = propertyName, Value = value, AcceptTime = authentication.SignatureDate.DateTime }; this.Post(action); }
/// <summary> /// Overridden function /// </summary> /// <param name="hotSpot"></param> /// <param name="view"></param> public override void OnHotSpotDragEnd(CSharpFramework.View.HotSpotBase hotSpot, VisionViewBase view) { if (hotSpot == _hotSpotVolume) { if (_hotSpotVolume.HasChanged) { float fNewVal = _hotSpotVolume.CurrentDistance; Volume = _hotSpotVolume.StartDistance; // set old value for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "Volume", fNewVal)); } } if (hotSpot == _hotSpotFadeMin) { if (_hotSpotFadeMin.HasChanged) { float fNewVal = _hotSpotFadeMin.CurrentDistance; MinDistance = _hotSpotFadeMin.StartDistance; // set old value for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "MinDistance", fNewVal)); } } if (hotSpot == _hotSpotFadeMax) { if (_hotSpotFadeMax.HasChanged) { float fNewVal = _hotSpotFadeMax.CurrentDistance; MaxDistance = _hotSpotFadeMax.StartDistance; // set old value for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "MaxDistance", fNewVal)); } } if (hotSpot == _hotSpotOuterCone) { if (_hotSpotOuterCone.HasChanged) { float fNewAngle = _hotSpotOuterCone.CurrentAngle; ConeOutside = _hotSpotOuterCone.StartAngle; // set old angle for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "ConeOutside", fNewAngle)); } } if (hotSpot == _hotSpotInnerCone) { if (_hotSpotInnerCone.HasChanged) { float fNewAngle = _hotSpotInnerCone.CurrentAngle; ConeInside = _hotSpotInnerCone.StartAngle; // set old angle for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "ConeInside", fNewAngle)); } } }
/// <summary> /// Overridden function /// </summary> /// <param name="hotSpot"></param> /// <param name="view"></param> public override void OnHotSpotDragEnd(CSharpFramework.View.HotSpotBase hotSpot, VisionViewBase view) { if (hotSpot == _hotSpotConeAngleX) { if (_hotSpotConeAngleX.HasChanged) { float fNewAngle = _hotSpotConeAngleX.CurrentAngle; ConeAngleX = _hotSpotConeAngleX.StartAngle; // set old angle for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "ConeAngleX", fNewAngle)); } } if (hotSpot == _hotSpotConeAngleY) { if (_hotSpotConeAngleY.HasChanged) { float fNewAngle = _hotSpotConeAngleY.CurrentAngle; ConeAngleY = _hotSpotConeAngleY.StartAngle; // set old angle for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "ConeAngleY", fNewAngle)); } } if (hotSpot == _hotSpotLength) { if (_hotSpotLength.HasChanged) { float fNewDist = _hotSpotLength.CurrentDistance; Length = _hotSpotLength.StartDistance; // set old angle for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "Length", fNewDist)); } } if (hotSpot == _hotSpotFadeOutDist1) { if (_hotSpotFadeOutDist1.HasChanged) { float fNewDist = _hotSpotFadeOutDist1.CurrentDistance - _hotSpotLength.CurrentDistance; FadeOutDistance = _hotSpotFadeOutDist1.StartDistance - _hotSpotLength.CurrentDistance;; EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "FadeOutDistance", fNewDist)); } } if (hotSpot == _hotSpotFadeOutDist2) { if (_hotSpotFadeOutDist2.HasChanged) { float fNewDist = _hotSpotLength.CurrentDistance - _hotSpotFadeOutDist2.CurrentDistance; FadeOutDistance = _hotSpotLength.CurrentDistance - _hotSpotFadeOutDist2.StartDistance; EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "FadeOutDistance", fNewDist)); } } }
public override void OnHotSpotDragEnd(HotSpotBase hotSpot, VisionViewBase view) { base.OnHotSpotDragEnd(hotSpot, view); if (hotSpot == _hotSpotStartPoint) { Vector3F vNewPos = _hotSpotStartPoint.CurrentPosition + Position; _vStartPoint = _hotSpotStartPoint.StartPosition; // set old value for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "StartPoint", vNewPos)); // send an action which sets the property from old value to new one } else if (hotSpot == _hotSpotEndPoint) { Vector3F vNewPos = _hotSpotEndPoint.CurrentPosition + Position; _vEndPoint = _hotSpotEndPoint.StartPosition; // set old value for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "EndPoint", vNewPos)); // send an action which sets the property from old value to new one } }
public void Execute_SetsProperty_ReturnsContinueProcessing() { // Arrange string propertyName = "PropertyName"; string propertyValue = "PropertyValue"; SetPropertyAction action = new SetPropertyAction(propertyName, propertyValue); IRewriteContext context = new MockRewriteContext(); // Act RewriteProcessing result = action.Execute(context); // Assert Assert.AreEqual(RewriteProcessing.ContinueProcessing, result); CollectionAssert.Contains(context.Properties.Keys, propertyName); Assert.AreEqual(propertyValue, context.Properties[propertyName]); }
public override void Perform2DViewAction(Scene2DView view, GroupAction parent, string action) { base.Perform2DViewAction(view, parent, action); BoundingBox box = view.SelectionMarqueeWorldBox; if (action == VA_AS_SELECTION && box.Valid) { Vector3F center = box.Center; float fRadX = box.SizeX * 0.5f; float fRadY = box.SizeY * 0.5f; parent.Add(new MoveShapeAction(this, this.Position, center)); parent.Add(SetPropertyAction.CreateSetPropertyAction(this, "MinX", fRadX)); // min values are also positive parent.Add(SetPropertyAction.CreateSetPropertyAction(this, "MinY", fRadY)); parent.Add(SetPropertyAction.CreateSetPropertyAction(this, "MaxX", fRadX)); parent.Add(SetPropertyAction.CreateSetPropertyAction(this, "MaxY", fRadY)); } }
public void testClassNameUndo() { LoadEntityShapeTestScene(); // verify that undoing EntityClass modifications does correctly restore the EntityProperties object oldEntityProperties = _entityShape.EntityProperties; IAction myAction = SetPropertyAction.CreateSetPropertyAction(_entityShape, "EntityClass", "CubeMapHandle_cl"); myAction.Do(); Assert.IsTrue(!object.ReferenceEquals(_entityShape.EntityProperties, oldEntityProperties)); object newEntityProperties = _entityShape.EntityProperties; myAction.Undo(); Assert.AreSame(oldEntityProperties, _entityShape.EntityProperties); myAction.Do(); Assert.AreSame(newEntityProperties, _entityShape.EntityProperties); }
/// <summary> /// Overridden function /// </summary> /// <param name="hotSpot"></param> /// <param name="view"></param> public override void OnHotSpotDragEnd(CSharpFramework.View.HotSpotBase hotSpot, VisionViewBase view) { if (hotSpot == _hotSpotGravity) { if (_hotSpotGravity.HasChanged) { float fNewVal = _hotSpotGravity.CurrentDistance; Gravity = _hotSpotGravity.StartDistance; // set old value for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "Gravity", fNewVal)); } } if (hotSpot == _hotSpotLightGridOfs) { Vector3F vNewPos = _hotSpotLightGridOfs.CurrentPosition; LightGridSampleOfs = _hotSpotLightGridOfs.StartPosition; // set old value for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "LightGridSampleOfs", vNewPos)); // send an action which sets the property from old value to new one } }
public void ProvisionTaxonomyFieldRequest_Test_GetCorrectRequest_WithoutParentId() { ProvisionTaxonomyFieldRequest request = new ProvisionTaxonomyFieldRequest("site-id", "web-id", "field-id", "", Guid.Parse("1e1a939f-60b2-2000-98a6-d25d3d400a3a"), Guid.Parse("740c6a0b-85e2-48a0-a494-e0f1759d4aa7")); var requests = request.GetRequest(new IteratorIdProvider()); var actionRequests = requests.Select(r => r.Action).ToList(); var identities = requests.Select(r => r.ObjectPath).Where(id => id != null).ToList(); SetPropertyAction setTermStoreId = actionRequests[0] as SetPropertyAction; SetPropertyAction setTermSetId = actionRequests[1] as SetPropertyAction; SetPropertyAction setTargetTemplate = actionRequests[2] as SetPropertyAction; SetPropertyAction setAnchorId = actionRequests[3] as SetPropertyAction; MethodAction updateAction = actionRequests[4] as MethodAction; Identity id = identities[0]; Assert.AreEqual("SspId", setTermStoreId.Name); Assert.AreEqual(2, setTermStoreId.Id); Assert.AreEqual("1", setTermStoreId.ObjectPathId); Assert.AreEqual("1e1a939f-60b2-2000-98a6-d25d3d400a3a", setTermStoreId.SetParameter.Value.ToString()); Assert.AreEqual("TermSetId", setTermSetId.Name); Assert.AreEqual(3, setTermSetId.Id); Assert.AreEqual("1", setTermSetId.ObjectPathId); Assert.AreEqual("740c6a0b-85e2-48a0-a494-e0f1759d4aa7", setTermSetId.SetParameter.Value.ToString()); Assert.AreEqual("TargetTemplate", setTargetTemplate.Name); Assert.AreEqual(4, setTargetTemplate.Id); Assert.AreEqual("1", setTargetTemplate.ObjectPathId); Assert.AreEqual("", setTargetTemplate.SetParameter.Value.ToString()); Assert.AreEqual("AnchorId", setAnchorId.Name); Assert.AreEqual(5, setAnchorId.Id); Assert.AreEqual("1", setAnchorId.ObjectPathId); Assert.AreEqual("00000000-0000-0000-0000-000000000000", setAnchorId.SetParameter.Value.ToString()); Assert.AreEqual("Update", updateAction.Name); Assert.AreEqual(6, updateAction.Id); Assert.AreEqual("1", updateAction.ObjectPathId); Assert.AreEqual("1e1a939f-60b2-2000-98a6-d25d3d400a3a|740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:site-id:web:web-id:field:field-id", id.Name); Assert.AreEqual(1, id.Id); }
public void SetPropertyAction_Test_SetGuidProperty() { SetPropertyAction action = new SetPropertyAction() { Id = 1, ObjectPathId = "11", Name = "SspId", SetParameter = new Parameter() { Value = Guid.Parse("1e1a939f-60b2-2000-98a6-d25d3d400a3a"), Type = typeof(Guid).Name } }; string expectedString = "<SetProperty Id=\"1\" ObjectPathId=\"11\" Name=\"SspId\"><Parameter Type=\"Guid\">{1e1a939f-60b2-2000-98a6-d25d3d400a3a}</Parameter></SetProperty>"; string actualString = action.ToString(); Assert.AreEqual(expectedString, actualString); }
public void TestRestoreLinks() { // load a different scene for this test TestManager.Helpers.OpenSceneFromFile(Path.Combine(TestManager.Helpers.TestDataDir, @"EntityShapeTest\RestoreLink.scene")); EntityShape entity = EditorManager.Scene.FindShapeByName("Entity") as EntityShape; Assert.IsNotNull(entity); // the map has an anim entity which is attached to a path Assert.AreEqual(entity.EntityClass, "AnimEntity_cl"); Assert.AreEqual(entity.LinkSources.Count, 1); Assert.AreEqual(entity.LinkTargets.Count, 0); Assert.AreEqual(entity.LinkBidirections.Count, 0); // verify the link is there LinkSource linkSrc = (LinkSource)entity.LinkSources[0]; Assert.AreEqual(linkSrc.Links.Count, 1); LinkTarget linkTgt = (LinkTarget)linkSrc.Links[0]; PathShape pathShape = linkTgt.OwnerShape as PathShape; Assert.IsNotNull(pathShape); Assert.AreEqual(pathShape.LinkTargets.Count, 1); Assert.AreEqual(pathShape.LinkTargets[0].Links.Count, 1); // setting a new entity class removes the link IAction myAction = SetPropertyAction.CreateSetPropertyAction(entity, "EntityClass", "VisBaseEntity_cl"); myAction.Do(); Assert.AreEqual(entity.LinkSources.Count, 0); Assert.AreEqual(pathShape.LinkTargets.Count, 1); Assert.AreEqual(pathShape.LinkTargets[0].Links.Count, 0); // not conected to entity anymore // now the link should be restored again myAction.Undo(); Assert.AreEqual(entity.LinkSources.Count, 1); Assert.AreEqual(entity.LinkSources[0].Links.Count, 1); Assert.AreEqual(entity.LinkSources[0].Links[0].OwnerShape, pathShape); Assert.AreEqual(pathShape.LinkTargets.Count, 1); Assert.AreEqual(pathShape.LinkTargets[0].Links.Count, 1); }
/// <summary> /// Overridden function /// </summary> /// <param name="hotSpot"></param> /// <param name="view"></param> public override void OnHotSpotDragEnd(CSharpFramework.View.HotSpotBase hotSpot, VisionViewBase view) { if (hotSpot == _hotSpotReverbMin) { if (_hotSpotReverbMin.HasChanged) { float fNewVal = _hotSpotReverbMin.CurrentDistance; MinDistance = _hotSpotReverbMin.StartDistance; // set old value for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "MinDistance", fNewVal)); } } if (hotSpot == _hotSpotReverbMax) { if (_hotSpotReverbMax.HasChanged) { float fNewVal = _hotSpotReverbMax.CurrentDistance; MaxDistance = _hotSpotReverbMax.StartDistance; // set old value for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "MaxDistance", fNewVal)); } } }
/// <summary> /// Overridden function /// </summary> /// <param name="hotSpot"></param> /// <param name="view"></param> public override void OnHotSpotDragEnd(CSharpFramework.View.HotSpotBase hotSpot, VisionViewBase view) { if (hotSpot == _hotSpotSizeX) { if (_hotSpotSizeX.HasChanged) { float fNewVal = _hotSpotSizeX.CurrentDistance; SizeX = _hotSpotSizeX.StartDistance; // set old value for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "SizeX", fNewVal)); } } if (hotSpot == _hotSpotSizeY) { if (_hotSpotSizeY.HasChanged) { float fNewVal = _hotSpotSizeY.CurrentDistance; SizeY = _hotSpotSizeY.StartDistance; // set old value for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "SizeY", fNewVal)); } } }
/// <summary> /// Called when the user releases the mouse button on a hotspot /// </summary> /// <param name="hotSpot"></param> /// <param name="view"></param> public override void OnHotSpotDragEnd(HotSpotBase hotSpot, VisionViewBase view) { if (hotSpot == _hotSpotX) { if (_hotSpotX.HasChanged) { float fNewX = _hotSpotX.CurrentDistance; Size = new Vector2F(_hotSpotX.StartDistance, Size.Y); // set old value for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "Size", new Vector2F(fNewX, Size.Y))); // send an action which sets the property from old value to new one } } if (hotSpot == _hotSpotY) { if (_hotSpotY.HasChanged) { float fNewY = _hotSpotY.CurrentDistance; Size = new Vector2F(Size.X, _hotSpotY.StartDistance); // set old value for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "Size", new Vector2F(Size.X, fNewY))); // send an action which sets the property from old value to new one } } if (hotSpot == _hotSpotXY) { if (_hotSpotXY.HasChanged) { float ratio = Size.Y / Size.X; //compute old value float oldX = _hotSpotXY.StartDistance / (float)System.Math.Sqrt(ratio * ratio + 1.0f); float oldY = oldX * ratio; Size = new Vector2F(oldX, oldY); // set old value for the action //compute new value float newX = _hotSpotXY.CurrentDistance / (float)System.Math.Sqrt(ratio * ratio + 1.0f); float newY = ratio * newX; EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "Size", new Vector2F(newX, newY))); // send an action which sets the property from old value to new one } } }
/// <summary> /// Overridden function /// </summary> /// <param name="hotSpot"></param> /// <param name="view"></param> public override void OnHotSpotDragEnd(CSharpFramework.View.HotSpotBase hotSpot, VisionViewBase view) { if (hotSpot == _hotSpotConeAngleX) { if (_hotSpotConeAngleX.HasChanged) { float fNewAngle = _hotSpotConeAngleX.CurrentAngle; CameraAngleX = _hotSpotConeAngleX.StartAngle; // set old angle for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "CameraAngleX", fNewAngle)); } } if (hotSpot == _hotSpotConeAngleY) { if (_hotSpotConeAngleY.HasChanged) { float fNewAngle = _hotSpotConeAngleY.CurrentAngle; CameraAngleY = _hotSpotConeAngleY.StartAngle; // set old angle for the action EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "CameraAngleY", fNewAngle)); } } if (hotSpot == _hotSpotNearClip) { if (_hotSpotNearClip.HasChanged) { float fNewDist = _hotSpotNearClip.CurrentDistance; this.NearClipDistance = _hotSpotNearClip.StartDistance; EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "NearClipDistance", fNewDist)); } } if (hotSpot == _hotSpotFarClip) { if (_hotSpotFarClip.HasChanged) { float fNewDist = _hotSpotFarClip.CurrentDistance; this.FarClipDistance = _hotSpotFarClip.CurrentDistance; EditorManager.Actions.Add(SetPropertyAction.CreateSetPropertyAction(this, "FarClipDistance", fNewDist)); } } }