// we allow DOM nodes to be locked and unlocked by tracking when this changes, and // not considering such changes to be modifications /// <summary> /// Performs custom actions on attribute changing events</summary> /// <param name="sender">Validation context</param> /// <param name="e">Event args</param> protected virtual void OnAttributeChanging(object sender, AttributeEventArgs e) { if (Validating) { m_locked = m_lockingContext.IsLocked(e.DomNode); } }
void OnAttributeChanged(object sender, AttributeEventArgs e) { if (e.AttributeInfo.Equivalent(Schema.envUtilityType.SunAngleAttribute)) { float newAngle = (float)(SunAngle * Math.PI / 180.0f); // We must get the axis of sun movement (which is actually a property of // the terrain), and then move the sun light to a position along this // axis). var sun = SunNode; if (sun == null) return; var sceneMan = XLEBridgeUtils.NativeManipulatorLayer.SceneManager; float sunPathAngle = GUILayer.EditorInterfaceUtils.GetSunPathAngle(sceneMan); var x = (float)(Math.Sin(newAngle) * Math.Cos(sunPathAngle)); var y = (float)(Math.Sin(newAngle) * Math.Sin(sunPathAngle)); var z = (float)Math.Cos(newAngle); const float distance = 100.0f; // (distance away from the origin -- actually doesn't matter) sun.SetAttribute( Schema.transformObjectType.translateAttribute, new float[3] { distance * x, distance * y, distance * z }); } }
void node_AttributeChanged(object sender, AttributeEventArgs e) { // process events only for the DomNode attached to this adapter. if (this.DomNode != e.DomNode) return; UpdateNativeProperty(e.AttributeInfo); }
/// <summary> /// Performs actions after attribute changed to validate events and intervals</summary> /// <param name="sender">Sender</param> /// <param name="e">AttributeEventArgs containing event data</param> protected override void OnAttributeChanged(object sender, AttributeEventArgs e) { BaseEvent _event = e.DomNode.As<BaseEvent>(); if (_event != null) { if (e.AttributeInfo.Equivalent(Schema.eventType.startAttribute)) { float value = (float)e.NewValue; float constrained = Math.Max(value, 0); // >= 0 constrained = (float)MathUtil.Snap(constrained, 1.0); // snapped to nearest integral frame number if (constrained != value) throw new InvalidTransactionException(Localizer.Localize("Timeline events must have a positive integer start time")); return; } Interval interval = _event.As<Interval>(); if (interval != null) { if (e.AttributeInfo.Equivalent(Schema.intervalType.lengthAttribute)) { float value = (float)e.NewValue; float constrained = Math.Max(value, 1); // >= 1 constrained = (float)MathUtil.Snap(constrained, 1.0); // snapped to nearest integral frame number if (constrained != value) throw new InvalidTransactionException(Localizer.Localize("Timeline intervals must have an integer length")); return; } } } }
/// <summary> /// Raises the AttributeChanged event and performs custom processing</summary> /// <param name="sender">Event sender</param> /// <param name="e">AttributeEventArgs containing event data</param> protected override void OnAttributeChanged(object sender, AttributeEventArgs e) { if (Validating) m_layoutInvalid = true; base.OnAttributeChanged(sender, e); }
protected override void OnAttributeChanging(object sender, AttributeEventArgs e) { if (Validating) { m_visible = m_visibilityContext.IsVisible(e.DomNode); } base.OnAttributeChanging(sender, e); }
private void DomNode_AttributeChanged(object sender, AttributeEventArgs e) { if (!m_manipulating && e.AttributeInfo.Equivalent(Schema.controlPointType.translateAttribute)) { Curve curve = GetParentAs<Curve>(); if (curve != null) curve.ComputeTranslation(); } }
public static bool Equals(AttributeEventArgs e1, AttributeEventArgs e2) { if (e1 == null || e2 == null) return (e1 == e2); return e1.DomNode == e2.DomNode && e1.AttributeInfo == e2.AttributeInfo && object.Equals(e1.OldValue, e2.OldValue) && object.Equals(e1.NewValue, e2.NewValue); }
private void DomNode_AttributeChanged(object sender, AttributeEventArgs e) { SchemaLoader schemaTypeLoader = Globals.MEFContainer.GetExportedValue<SchemaLoader>(); string filePath = Uri.LocalPath; FileMode fileMode = File.Exists(filePath) ? FileMode.Truncate : FileMode.OpenOrCreate; using (FileStream stream = new FileStream(filePath, fileMode)) { var writer = new DomXmlWriter(schemaTypeLoader.TypeCollection); writer.Write(DomNode, stream, Uri); } }
private void DomNode_AttributeChanged(object sender, AttributeEventArgs e) { if (e.DomNode.Type == Schema.transitionType.Type) { if (e.AttributeInfo.Equivalent(Schema.transitionType.sourceAttribute)) { m_routingInvalid = true; } else if (e.AttributeInfo.Equivalent(Schema.transitionType.destinationAttribute)) { m_routingInvalid = true; } } }
protected override void OnAttributeChanged(object sender, AttributeEventArgs e) { if (Validating) { bool visible = m_visibilityContext.IsVisible(e.DomNode); if (m_visible == visible) { base.OnAttributeChanged(sender, e); } } else { base.OnAttributeChanged(sender, e); } }
private void OnAttributeChanged(object sender, AttributeEventArgs e) { if (e.AttributeInfo.Equivalent(Schema.transformObjectType.pivotAttribute)) {// Update translation to keep object pinned when moving pivot Matrix4F L0 = m_transformable.Transform; Matrix4F L1 = TransformUtils.CalcTransform( m_transformable.Translation, m_transformable.Rotation, m_transformable.Scale, m_transformable.Pivot); Vec3F deltaTranslation = L0.Translation - L1.Translation; m_transformable.Translation = m_transformable.Translation + deltaTranslation; } if (IsTransformAttribute(e.AttributeInfo)) { ComputeTransform(); } }
private void DomNode_AttributeChanged(object sender, AttributeEventArgs e) { if (e.DomNode == this.DomNode || !e.DomNode.Is<IGameObject>()) return; if (!e.AttributeInfo.Equivalent(e.DomNode.Type.IdAttribute)) { IGameObject gob = e.DomNode.Cast<IGameObject>(); string originalName = m_intsToOriginal[e.DomNode]; ObjectOverride objectOverride; m_overridesMap.TryGetValue(originalName, out objectOverride); if (objectOverride == null) { objectOverride = ObjectOverride.Create(originalName); m_overrideList.Add(objectOverride); m_overridesMap.Add(originalName, objectOverride); } AttributeOverride attrOverride = objectOverride.GetOrCreateByName(e.AttributeInfo.Name); attrOverride.AttribValue = e.AttributeInfo.Type.Convert(e.NewValue); } }
void DomNode_AttributeChanged(object sender, AttributeEventArgs e) { if (IsLayerItem(e.DomNode)) ItemChanged.Raise(this, new ItemChangedEventArgs<object>(e.DomNode)); }
/// <summary> /// Performs custom actions after an attribute in the DOM node subtree changed</summary> /// <param name="sender">Sender (root DOM node)</param> /// <param name="e">Attribute change event args</param> protected override void OnAttributeChanged(object sender, AttributeEventArgs e) { if (Validating && !m_undoingOrRedoing) { if (e.DomNode.Parent.Is<Group>() && e.AttributeInfo == ElementLabelAttribute) { var subGraph = e.DomNode.Parent.Cast<Group>(); if (e.DomNode.Is<Element>()) { // the name of a sub-node has changed, needs to update group pin names that are not manually set SyncGroupPinNamesFromModuleName(subGraph, e.DomNode); } } else if (e.DomNode.Is<GroupPin>() && e.AttributeInfo == PinNameAttributeAttribute) { if (e.DomNode.Parent != null) { var subGraph = e.DomNode.Parent.Cast<Group>(); // ensure group pin names are unique at local level UniqueNamer uniqueName = new UniqueNamer(); GroupPin childGrpPin = e.DomNode.Cast<GroupPin>(); foreach (var pin in subGraph.Inputs) { var grpPin = pin.Cast<GroupPin>(); if (grpPin != childGrpPin) uniqueName.Name(grpPin.Name); } foreach (var pin in subGraph.Outputs) { var grpPin = pin.Cast<GroupPin>(); if (grpPin != childGrpPin) uniqueName.Name(grpPin.Name); } string unique = uniqueName.Name(childGrpPin.Name); if (unique != childGrpPin.Name) childGrpPin.Name = unique; // try to reset IsDefaultName childGrpPin.IsDefaultName = childGrpPin.Name == childGrpPin.DefaultName(childGrpPin.IsInputSide); UpdateParentGroupPinName(childGrpPin.IsInputSide, childGrpPin); } } } base.OnAttributeChanged(sender,e); }
/// <summary> /// AttributeChanged event handler for document DomNode</summary> /// <param name="sender">Sender (root DOM node)</param> /// <param name="e">Attribute change event args</param> protected virtual void OnDocumentNodeAttributeChanged(object sender, AttributeEventArgs e) { var group = e.DomNode.As<Group>(); if (group != null && (group.IsNameAttribute(e.AttributeInfo))) { // update ControlInfo.Name for all group controls foreach (var circuitControl in m_circuitNodeControls) { if (circuitControl.Key.Is<Group>()) { circuitControl.Value.Second.Name = CircuitUtil.GetGroupPath(circuitControl.Key.Cast<Group>()); } } } }
private void CollectionAttributeChanged(object sender, AttributeEventArgs e) { if (e.DomNode.Type != SledSchema.SledProjectFilesBreakpointType.Type) return; var bp = e.DomNode.As<SledProjectFilesBreakpointType>(); if (e.AttributeInfo == SledSchema.SledProjectFilesBreakpointType.enabledAttribute) { var bOldValue = e.OldValue == null ? (bool)e.AttributeInfo.DefaultValue : (bool)e.OldValue; var bNewValue = (bool)e.NewValue; if (bOldValue != bNewValue) { var changeType = bNewValue ? SledBreakpointChangeType.Enabled : SledBreakpointChangeType.Disabled; var ea = new SledBreakpointServiceBreakpointChangingEventArgs(changeType, bp); // Fire event OnBreakpointChanged(ea); // Assure open document's breakpoints are drawn correctly var sd = bp.File.SledDocument; if (sd != null) sd.Control.Refresh(); } } else if (e.AttributeInfo == SledSchema.SledProjectFilesBreakpointType.conditionenabledAttribute) { var bOldValue = e.OldValue == null ? (bool)e.AttributeInfo.DefaultValue : (bool)e.OldValue; var bNewValue = (bool)e.NewValue; if (bOldValue != bNewValue) { var changeType = bNewValue ? SledBreakpointChangeType.ConditionEnabled : SledBreakpointChangeType.ConditionDisabled; var ea = new SledBreakpointServiceBreakpointChangingEventArgs(changeType, bp); // Fire event OnBreakpointChanged(ea); // Assure open document's breakpoints are drawn correctly var sd = bp.File.SledDocument; if (sd != null) sd.Control.Refresh(); } } else if (e.AttributeInfo == SledSchema.SledProjectFilesBreakpointType.conditionresultAttribute) { var bOldValue = e.OldValue == null ? (bool)e.AttributeInfo.DefaultValue : (bool)e.OldValue; var bNewValue = (bool)e.NewValue; if (bOldValue != bNewValue) { var changeType = bNewValue ? SledBreakpointChangeType.ConditionResultTrue : SledBreakpointChangeType.ConditionResultFalse; var ea = new SledBreakpointServiceBreakpointChangingEventArgs(changeType, bp); // Fire event OnBreakpointChanged(ea); // Assure open document's breakpoints are drawn correctly var sd = bp.File.SledDocument; if (sd != null) sd.Control.Refresh(); } } else if (e.AttributeInfo == SledSchema.SledProjectFilesBreakpointType.conditionAttribute) { var oldValue = e.OldValue as string; var newValue = e.NewValue as string; if (string.Compare(oldValue, newValue) != 0) { const SledBreakpointChangeType changeType = SledBreakpointChangeType.Condition; var ea = new SledBreakpointServiceBreakpointChangingEventArgs(changeType, bp, oldValue, newValue); // Fire event OnBreakpointChanged(ea); // Assure open document's breakpoints are drawn correctly var sd = bp.File.SledDocument; if (sd != null) sd.Control.Refresh(); } } else if (e.AttributeInfo == SledSchema.SledProjectFilesBreakpointType.usefunctionenvironmentAttribute) { var bOldValue = e.OldValue == null ? (bool)e.AttributeInfo.DefaultValue : (bool)e.OldValue; var bNewValue = (bool)e.NewValue; if (bOldValue != bNewValue) { var changeType = bNewValue ? SledBreakpointChangeType.UseFunctionEnvironmentTrue : SledBreakpointChangeType.UseFunctionEnvironmentFalse; var ea = new SledBreakpointServiceBreakpointChangingEventArgs(changeType, bp); // Fire event OnBreakpointChanged(ea); } } }
private void DomNode_AttributeChanged(object sender, AttributeEventArgs e) { Event _event = e.DomNode.As<Event>(); if (_event != null) { ItemChanged.Raise(this, new ItemChangedEventArgs<object>(_event)); } }
private void DomNode_AttributeChanged(object sender, AttributeEventArgs e) { OnObjectChanged(new ItemChangedEventArgs <object>(e.DomNode)); }
private void DomNode_AttributeChanged(object sender, AttributeEventArgs e) { Resource resource = e.DomNode.As<Resource>(); if (resource != null) { ItemChanged.Raise(this, new ItemChangedEventArgs<object>(resource)); } }
public void TestAttributeChangedEvents() { DomNodeType type = new DomNodeType("type"); AttributeInfo stringTypeInfo = GetStringAttribute("string"); AttributeInfo intTypeInfo = GetIntAttribute("int"); type.Define(stringTypeInfo); type.Define(intTypeInfo); DomNode test = new DomNode(type); test.AttributeChanging += new EventHandler<AttributeEventArgs>(test_AttributeChanging); test.AttributeChanged += new EventHandler<AttributeEventArgs>(test_AttributeChanged); AttributeEventArgs expected; // test for no value change if setting to the default value and attribute is already the default AttributeChangingArgs = null; AttributeChangedArgs = null; test.SetAttribute(stringTypeInfo, stringTypeInfo.DefaultValue); Assert.Null(AttributeChangingArgs); Assert.Null(AttributeChangedArgs); test.SetAttribute(intTypeInfo, intTypeInfo.DefaultValue); Assert.Null(AttributeChangingArgs); Assert.Null(AttributeChangedArgs); // test for value change, string type test = new DomNode(type); test.AttributeChanging += new EventHandler<AttributeEventArgs>(test_AttributeChanging); test.AttributeChanged += new EventHandler<AttributeEventArgs>(test_AttributeChanged); AttributeChangingArgs = null; AttributeChangedArgs = null; object oldValue = test.GetAttribute(stringTypeInfo); test.SetAttribute(stringTypeInfo, "foo"); expected = new AttributeEventArgs(test, stringTypeInfo, oldValue, "foo"); Assert.True(Equals(AttributeChangingArgs, expected)); Assert.True(Equals(AttributeChangedArgs, expected)); oldValue = test.GetAttribute(stringTypeInfo); test.SetAttribute(stringTypeInfo, "foobar"); expected = new AttributeEventArgs(test, stringTypeInfo, oldValue, "foobar"); Assert.True(Equals(AttributeChangingArgs, expected)); Assert.True(Equals(AttributeChangedArgs, expected)); // test for value change, int type AttributeChangingArgs = null; AttributeChangedArgs = null; oldValue = test.GetAttribute(intTypeInfo); test.SetAttribute(intTypeInfo, 5); expected = new AttributeEventArgs(test, intTypeInfo, oldValue, 5); Assert.True(Equals(AttributeChangingArgs, expected)); Assert.True(Equals(AttributeChangedArgs, expected)); oldValue = test.GetAttribute(intTypeInfo); test.SetAttribute(intTypeInfo, 7); expected = new AttributeEventArgs(test, intTypeInfo, oldValue, 7); Assert.True(Equals(AttributeChangingArgs, expected)); Assert.True(Equals(AttributeChangedArgs, expected)); // test for no value change test.SetAttribute(stringTypeInfo, "foo"); AttributeChangingArgs = null; AttributeChangedArgs = null; test.SetAttribute(stringTypeInfo, "foo"); Assert.Null(AttributeChangingArgs); Assert.Null(AttributeChangedArgs); test.SetAttribute(intTypeInfo, 9); AttributeChangingArgs = null; AttributeChangedArgs = null; test.SetAttribute(intTypeInfo, 9); Assert.Null(AttributeChangingArgs); Assert.Null(AttributeChangedArgs); }
void test_AttributeChanged(object sender, AttributeEventArgs e) { AttributeChangedArgs = e; }
private void DomNode_AttributeChanged(object sender, AttributeEventArgs e) { if (CheckTransaction()) AddOperation(new AttributeChangedOperation(e)); }
/// <summary> /// Performs custom actions after an attribute in the DOM subtree changes</summary> /// <param name="sender">Sender (root DOM node)</param> /// <param name="e">Attribute change event args</param> protected override void OnAttributeChanged(object sender, AttributeEventArgs e) { if (Validating && !m_naming) { if (e.AttributeInfo.Equivalent(e.DomNode.Type.IdAttribute)) { // only store the first renaming of the node, as we only need the original id if (!m_renamed.ContainsKey(e.DomNode)) m_renamed.Add(e.DomNode, e.OldValue.ToString()); } } }
private string AnalyzeAttributeChanged(AttributeEventArgs e) { return(AnalyzeListeners(e.DomNode.GetAttributeChangedHandlers())); }
private void root_AttributeChanged(object sender, AttributeEventArgs e) { ItemChanged.Raise(this, new ItemChangedEventArgs <object>(e.DomNode)); }
private void DomNode_AttributeChanging(object sender, AttributeEventArgs e) { ITimelineObject item = e.DomNode.As<ITimelineObject>(); if (item != null) { if (!IsEditable(item, e.AttributeInfo)) { if (ActiveDocument.Cast<ITransactionContext>().InTransaction) throw new InvalidTransactionException("timeline object can't be edited"); else return; } // Check if a URI on a timeline reference has changed, so we can unload // old document and load new document. if (e.AttributeInfo.Equivalent(Schema.timelineRefType.refAttribute)) { UnloadSubDocument((Uri)e.OldValue); LoadSubDocument((Uri)e.NewValue); } } }
private void DomNode_AttributeChanged(object sender, AttributeEventArgs e) { if (IsPrototypeItem(e.DomNode, e.DomNode.Parent)) ItemChanged.Raise(this, new ItemChangedEventArgs<object>(e.DomNode)); }
/// <summary> /// Performs custom actions on DomNode.AttributeChanged events</summary> /// <param name="sender">Event sender</param> /// <param name="e">Event args</param> private void m_root_AttributeChanged(object sender, AttributeEventArgs e) { string analysis = m_analysisEnabled ? AnalyzeAttributeChanged(e) : string.Empty; m_data.AddDomEvent(DataType.AttributeChanged, e, analysis); }
/// <summary> /// Performs custom actions on DOM node AttributeChanged events</summary> /// <param name="sender">Sender</param> /// <param name="e">Event args</param> void DomNode_AttributeChanged(object sender, AttributeEventArgs e) { var adapter = m_context.LastSelectedObject.As<DomNodeAdapter>(); if (adapter != null && e.DomNode == adapter.DomNode && m_context.Descriptor.Is<AttributePropertyDescriptor>() && e.AttributeInfo == m_context.Descriptor.As<AttributePropertyDescriptor>().AttributeInfo) OnItemChanged(e.DomNode, e.NewValue); }
/// <summary> /// Raises the TransactionFinishedAttributeChanged event</summary> /// <param name="attributeEventArgs">Attribute event arguments</param> protected virtual void OnTransactionFinishedAttributeChanged(AttributeEventArgs attributeEventArgs) { TransactionFinishedAttributeChanged.Raise(this, attributeEventArgs); }
private void DomNode_AttributeChanged(object sender, AttributeEventArgs e) { if (!IsHandledType(e.DomNode)) return; if (!InTransaction) return; ItemChanged.Raise(this, new ItemChangedEventArgs<object>(e.DomNode)); if (!IsMasterContext) { MasterContext.DomNode_AttributeChanged(sender, e); } }
private void root_AttributeChanged(object sender, AttributeEventArgs e) { Event.Raise<ItemChangedEventArgs<object>>(ItemChanged, this, new ItemChangedEventArgs<object>(e.DomNode)); // because references use the name of the referenced item as their label, we should // update all references to this DomNode. Fortunately, we can use the ReferenceValidator // which is attached to this (root) node to get all the references. if (e.AttributeInfo.Equivalent(UISchema.UIObjectType.nameAttribute)) { ReferenceValidator validator = this.As<ReferenceValidator>(); foreach (Pair<DomNode, AttributeInfo> reference in validator.GetReferences(e.DomNode)) { if ((reference.First.Type == UISchema.UIRefType.Type) && (reference.Second.Equivalent(UISchema.UIRefType.refAttribute))) { Event.Raise<ItemChangedEventArgs<object>>( ItemChanged, this, new ItemChangedEventArgs<object>(reference.First)); } } } }
private void DomNode_AttributeChanged(object sender, AttributeEventArgs e) { ItemChanged.Raise(this, new ItemChangedEventArgs<object>(e.DomNode)); }
/// <summary> /// Constructor</summary> /// <param name="e">Event args</param> public AttributeChangedOperation(AttributeEventArgs e) { m_node = e.DomNode; m_attributeInfo = e.AttributeInfo; m_oldValue = e.OldValue; m_newValue = e.NewValue; }