private void DomNodeOnChildRemoving(object sender, ChildEventArgs e) { if (Validating) { // removing a module from a sub-circuit? Element element = e.Child.As<Element>(); SubCircuit subCircuit = e.Parent.As<SubCircuit>(); if (element != null && subCircuit != null) { ICircuitElementType type = element.Type; // todo: this test isn't quite right, because not all circuit elements // necessarily have both inputs and outputs. For example, if the Speaker // element from the Circuit Editor sample app is the only element in a Master, // and then it is deleted, that will trigger this exception. if (type.Inputs.Count + type.Outputs.Count == 1) { // Ensures that sub-circuit inputs/outputs aren't added or removed, as this would // invalidate wiring on instances of them. throw new InvalidTransactionException( "Can't remove connectors from sub-circuits".Localize()); } } } }
private void DomNode_ChildInserting(object sender, ChildEventArgs e) { // check pseudo-state constraints StateBase state = e.Child.As<StateBase>(); if (state != null && state.IsPseudoState) { Statechart statechart = e.Parent.As<Statechart>(); CheckUniqueness(statechart, state.Type); } else { // check state transition constraints Transition transition = e.Child.As<Transition>(); if (transition != null) { if (transition.FromState.IsPseudoState) { if (transition.FromState.Type == StateType.Final) { throw new InvalidTransactionException( "Can't have a transition from the final state".Localize()); } } if (transition.ToState.IsPseudoState) { if (transition.ToState.Type == StateType.Start) { throw new InvalidTransactionException( "Can't have a transition to the start state".Localize()); } } } } }
private void DomNode_ChildRemoved(object sender, ChildEventArgs e) { if (CheckTransaction()) { AddOperation(new ChildRemovedOperation(e)); } }
private void DomNodeStructureChanged(object sender, ChildEventArgs e) { if (!m_updating && e.ChildInfo.Equivalent(Schema.prefabInstanceType.gameObjectChild)) { throw new InvalidTransactionException("Structure of PrefabInstance cannot be changesd"); } }
/// <summary> /// Performs custom actions after a child is inserted into the DOM subtree</summary> /// <param name="sender">Sender (root DOM node)</param> /// <param name="e">Child event args</param> protected override void OnChildInserted(object sender, ChildEventArgs e) { // if it's a ref, make sure the referenced resource is in this package UIRef uiRef = e.Child.As<UIRef>(); if (uiRef != null) m_referenceInserts.Add(e); }
private void DomNode_ChildRemoved(object sender, ChildEventArgs e) { if (IsTemplateItem(e.Child, e.Parent)) { ItemRemoved.Raise(this, new ItemRemovedEventArgs <object>(e.Index, e.Child, e.Parent)); } }
private void DomNode_ChildRemoved(object sender, ChildEventArgs e) { if (e.Child.Type == Schema.transitionType.Type) { m_routingInvalid = true; } }
/// <summary> /// Raises the ChildRemoved event and performs custom processing</summary> /// <param name="sender">Event sender</param> /// <param name="e">ChildEventArgs containing event data</param> protected override void OnChildRemoved(object sender, ChildEventArgs e) { if (Validating) m_layoutInvalid = true; base.OnChildRemoved(sender, e); }
/// <summary> /// Performs custom actions after a child is removed from the DOM subtree</summary> /// <param name="sender">Sender (root DOM node)</param> /// <param name="e">Child event args</param> protected override void OnChildRemoved(object sender, ChildEventArgs e) { if (Validating) { m_childChanges.Add(new Pair <Pair <DomNode, DomNode>, ChildInfo>(new Pair <DomNode, DomNode>(e.Parent, e.Child), e.ChildInfo)); } }
private void root_ChildRemoved(object sender, ChildEventArgs e) { if (m_lastRemoveIndex >= 0) { ItemRemoved.Raise(this, new ItemRemovedEventArgs <object>(m_lastRemoveIndex, e.Child, e.Parent)); } }
/// <summary> /// Performs custom actions after a child is removed from the DOM subtree</summary> /// <param name="sender">Sender (root DOM node)</param> /// <param name="e">Child event args</param> protected override void OnChildRemoved(object sender, ChildEventArgs e) { if (Validating) { m_modified.Add(e.Child); } }
/// <summary> /// Default constructor</summary> /// <param name="e">Event args</param> public ChildRemovedOperation(ChildEventArgs e) { m_parent = e.Parent; m_child = e.Child; m_childInfo = e.ChildInfo; m_index = e.Index; }
private void DomNode_ChildRemoved(object sender, ChildEventArgs e) { if (e.Parent == DomNode) { CheckScaleFlags(); } }
private void root_ChildInserted(object sender, ChildEventArgs e) { int index = GetChildIndex(e.Child, e.Parent); if (index >= 0) { ItemInserted.Raise(this, new ItemInsertedEventArgs <object>(index, e.Child, e.Parent)); } }
public static bool Equals(ChildEventArgs e1, ChildEventArgs e2) { if (e1 == null || e2 == null) return (e1 == e2); return e1.Parent == e2.Parent && e1.ChildInfo == e2.ChildInfo && e1.Child == e2.Child && e1.Index == e2.Index; }
private void OnChildrenChanged(ChildEventArgs e, NotifyCollectionChangedAction action) { if (e.ChildInfo.IsEquivalent(m_childInfo) && e.Parent == m_node) { T adapter = e.Child.As <T>(); System.Diagnostics.Debug.Assert(adapter != null); OnCollectionChanged(new NotifyCollectionChangedEventArgs(action, adapter, e.Index)); OnPropertyChanged(s_countPropertyChangedArgs); OnPropertyChanged(s_indexerPropertyChangedArgs); } }
protected sealed override void OnChildRemoved(object sender, ChildEventArgs childEventArgs) { if (m_inTransaction) { // Clear out any attribute-changed events previously set for this DomNode (or any of its children). var dictionaryCleanup = new List <Pair <DomNode, AttributeInfo> >(); foreach (DomNode removedNode in childEventArgs.Child.Subtree) { foreach (var changedAttributePair in m_attributeChanges) //this search might be slow { if (changedAttributePair.Key.First == removedNode) { dictionaryCleanup.Add(changedAttributePair.Key); m_events[changedAttributePair.Value] = new Pair <EventType, EventArgs>(EventType.None, null); } } if (dictionaryCleanup.Count > 0) { foreach (var changedAttributePair in dictionaryCleanup) { m_attributeChanges.Remove(changedAttributePair); } dictionaryCleanup.Clear(); } } // Check if this DomNode was previously inserted. If so, clear the previous insertion // event and ignore this new ChildRemoved event. int eventIndex; if (m_inserted.TryGetValue(childEventArgs.Child, out eventIndex)) { m_events[eventIndex] = new Pair <EventType, EventArgs>(EventType.None, null); m_inserted.Remove(childEventArgs.Child); return; } foreach (DomNode ancestor in childEventArgs.Parent.Lineage) { if (m_inserted.ContainsKey(ancestor)) { return; } } // Record this child removed event. m_events.Add(new Pair <EventType, EventArgs>(EventType.ChildRemoved, childEventArgs)); } else { OnTransactionFinishedChildRemoved(childEventArgs); } }
private void DomNodeChildInserting(object sender, ChildEventArgs e) { if (Validating) { // inserting an instance of a sub-circuit into itself? SubCircuitInstance subCircuitInstance = e.Child.As<SubCircuitInstance>(); SubCircuit subCircuit = e.Parent.As<SubCircuit>(); if (subCircuitInstance != null && subCircuit != null && subCircuitInstance.SubCircuit == subCircuit) { throw new InvalidTransactionException( "Can't use a sub-circuit inside itself".Localize()); } } }
private void DomNode_ChildInserted(object sender, ChildEventArgs e) { if (e.Parent != DomNode) { return; } var args = e.ChildInfo.GetTagLocal <PropertyChangedEventArgsCollection>(); if (args != null) { foreach (var arg in args) { OnPropertyChanged(arg); } } }
protected sealed override void OnChildInserted(object sender, ChildEventArgs childEventArgs) { if (m_inTransaction) { // Ignore if any ancestor was previously inserted. foreach (DomNode ancestor in childEventArgs.Parent.Lineage) { if (m_inserted.ContainsKey(ancestor)) { return; } } m_inserted[childEventArgs.Child] = m_events.Count; // Record this child inserted event. m_events.Add(new Pair <EventType, EventArgs>(EventType.ChildInserted, childEventArgs)); } else { OnTransactionFinishedChildInserted(childEventArgs); } }
private void DomNode_ChildRemoved(object sender, ChildEventArgs e) { // if a template is deleted, turn template references into copy-instances if (!IsMovingItems && e.Child.Is<Template>()) { // we can use the ReferenceValidator which is attached to this (root) node to get all the references. // note reference validation will happen later at the end of the transaction to remove the dangling references var refValidator = this.As<ReferenceValidator>(); DomNode target = e.Child.Cast<Template>().Target; foreach (var reference in refValidator.GetReferences(target)) { var targetCopies = DomNode.Copy(new[] { target }); // DOM deep copy var copyInstance = targetCopies[0].Cast<Element>(); var templateInstance = reference.First.Cast<Element>(); copyInstance.Position = templateInstance.Position; var circuitContainer = reference.First.Parent.Cast<ICircuitContainer>(); circuitContainer.Elements.Add(copyInstance); // reroute original edges foreach (var wire in circuitContainer.Wires) { if (wire.InputElement == templateInstance) { wire.InputElement = copyInstance; wire.InputPin = copyInstance.Type.Inputs[wire.InputPin.Index]; wire.SetPinTarget(); } if (wire.OutputElement == templateInstance) { wire.OutputElement = copyInstance; wire.OutputPin = copyInstance.Type.Outputs[wire.OutputPin.Index]; wire.SetPinTarget(); } } } } }
void DomNode_ChildRemoved(object sender, ChildEventArgs e) { if (IsLayerItem(e.Child)) ItemRemoved.Raise(this, new ItemRemovedEventArgs<object>(e.Index, e.Child, e.Parent)); }
void test_ChildInserted(object sender, ChildEventArgs e) { ChildInsertedArgs = e; }
private void root_ChildInserted(object sender, ChildEventArgs e) { int index = GetChildIndex(e.Child, e.Parent); if (index >= 0) { ItemInserted.Raise(this, new ItemInsertedEventArgs<object>(index, e.Child, e.Parent)); } }
void DomNode_ChildInserted(object sender, ChildEventArgs e) { ItemInserted.Raise(this, new ItemInsertedEventArgs<object>(e.Index, e.Child, e.Parent)); }
/// <summary> /// Raises the TransactionFinishedChildRemoved event</summary> /// <param name="childEventArgs"></param> protected virtual void OnTransactionFinishedChildRemoved(ChildEventArgs childEventArgs) { TransactionFinishedChildRemoved.Raise(this, childEventArgs); }
private void Node_ChildInserted(object sender, ChildEventArgs e) { OnChildrenChanged(e, NotifyCollectionChangedAction.Add); }
private void root_ChildRemoved(object sender, ChildEventArgs e) { if (m_lastRemoveIndex >= 0) { ItemRemoved.Raise(this, new ItemRemovedEventArgs<object>(m_lastRemoveIndex, e.Child, e.Parent)); } }
private void DomNode_ChildRemoved(object sender, ChildEventArgs e) { Resource resource = e.Child.As<Resource>(); if (resource != null) { ItemRemoved.Raise(this, new ItemRemovedEventArgs<object>(e.Index, resource)); } }
void test_ChildRemoved(object sender, ChildEventArgs e) { ChildRemovedArgs = e; }
void test_ChildRemoving(object sender, ChildEventArgs e) { ChildRemovingArgs = e; }
public void TestChildRemoveEvents() { DomNodeType type = new DomNodeType("type"); ChildInfo info = new ChildInfo("child", type); ChildInfo infoList = new ChildInfo("childList", type, true); type.Define(info); type.Define(infoList); DomNode test = new DomNode(type); test.ChildRemoving += new EventHandler<ChildEventArgs>(test_ChildRemoving); test.ChildRemoved += new EventHandler<ChildEventArgs>(test_ChildRemoved); // test child DomNode child = new DomNode(type); test.SetChild(info, child); ChildRemovingArgs = null; ChildRemovedArgs = null; test.SetChild(info, null); ChildEventArgs expected = new ChildEventArgs(test, info, child, 0); Assert.True(Equals(ChildRemovingArgs, expected)); Assert.True(Equals(ChildRemovedArgs, expected)); // test inserting a child when there is one there already test.SetChild(info, child); DomNode newChild = new DomNode(type); ChildRemovingArgs = null; ChildRemovedArgs = null; test.SetChild(info, newChild); expected = new ChildEventArgs(test, info, child, 0); Assert.True(Equals(ChildRemovingArgs, expected)); Assert.True(Equals(ChildRemovedArgs, expected)); // test child list IList<DomNode> list = test.GetChildList(infoList); DomNode child2 = new DomNode(type); list.Add(child2); DomNode child3 = new DomNode(type); list.Add(child3); ChildRemovingArgs = null; ChildRemovedArgs = null; list.Remove(child3); expected = new ChildEventArgs(test, infoList, child3, 1); Assert.True(Equals(ChildRemovingArgs, expected)); Assert.True(Equals(ChildRemovedArgs, expected)); ChildRemovingArgs = null; ChildRemovedArgs = null; list.Remove(child2); expected = new ChildEventArgs(test, infoList, child2, 0); Assert.True(Equals(ChildRemovingArgs, expected)); Assert.True(Equals(ChildRemovedArgs, expected)); }
private void DomNode_ChildInserted(object sender, ChildEventArgs e) { if (IsPrototypeItem(e.Child, e.Parent)) ItemInserted.Raise(this, new ItemInsertedEventArgs<object>(e.Index, e.Child, e.Parent)); }
private void Node_ChildRemoved(object sender, ChildEventArgs e) { OnChildrenChanged(e, NotifyCollectionChangedAction.Remove); }
private void DomNode_ChildRemoved(object sender, ChildEventArgs e) { OnObjectRemoved(new ItemRemovedEventArgs <object>(GetChildIndex(e), e.Child, e.Parent)); }
private string AnalyzeInserted(ChildEventArgs e) { return(AnalyzeListeners(e.Parent.GetChildInsertedHandlers())); }
private void CollectionChildRemoving(object sender, ChildEventArgs e) { if (e.Child.Type != SledSchema.SledProjectFilesBreakpointType.Type) return; var bp = e.Child.As<SledProjectFilesBreakpointType>(); // Fire event OnBreakpointRemoving(new SledBreakpointServiceBreakpointEventArgs(bp)); if (m_bPreserveOpenDocumentBreakpoints) return; // Try and remove breakpoints from the // corresponding open document (if any) var sd = bp.File.SledDocument; if (sd == null) return; // Preserve previous value var bValue = m_bAddingOrRemoving; // Make sure SledDocument breakpoint events won't fire m_bAddingOrRemoving = true; // Verify breakpoint on line in open document & remove if so if (sd.IsBreakpointSet(bp.Line)) sd.Editor.Breakpoint(bp.Line, false); // Reset to previous value m_bAddingOrRemoving = bValue; }
/// <summary> /// Performs custom actions on DomNode.ChildInserted events</summary> /// <param name="sender">Event sender</param> /// <param name="e">Event args</param> private void m_root_ChildInserted(object sender, ChildEventArgs e) { string analysis = m_analysisEnabled ? AnalyzeInserted(e) : string.Empty; m_data.AddDomEvent(DataType.ChildAdded, e, analysis); }
private void DomNode_ChildRemoved(object sender, ChildEventArgs e) { Event _event = e.Child.As<Event>(); if (_event != null) { ItemRemoved.Raise(this, new ItemRemovedEventArgs<object>(e.Index, _event)); } }
private void root_ChildRemoving(object sender, ChildEventArgs e) { m_lastRemoveIndex = GetChildIndex(e.Child, e.Parent); }
/// <summary> /// Performs custom actions after a child is removed from the DOM node subtree</summary> /// <param name="sender">Sender (root DOM node)</param> /// <param name="e">Child event args</param> protected override void OnChildRemoved(object sender, ChildEventArgs e) { RemoveSubtree(e.Child); if (!m_undoingOrRedoing && e.Child.Is<Wire>()) UpdateGroupPinConnectivity(e.Child.Cast<Wire>()); }
private void DomNode_ChildRemoved(object sender, ChildEventArgs e) { if (!IsHandledType(e.Child)) return; ItemRemoved.Raise(this, new ItemRemovedEventArgs<object>(-1, e.Child, e.Parent)); if (!IsMasterContext) { MasterContext.DomNode_ChildRemoved(sender,e); } }
/// <summary> /// Allows override of index for inserted/removed children</summary> /// <remarks> /// The default behavior is to return the child list index for the dom node /// However there are many situations where this is incorrect e.g. /// If this ListContext combines DomNodes from a variety of child lists on the /// parent node. In this case we need to recalculate the child index taking into /// account these mutliple lists</remarks> /// <param name="e">ChildEventArgs of inserted/removed child</param> /// <returns>Index of child in this view</returns> protected virtual int GetChildIndex(ChildEventArgs e) { return(e.Index); }
private void docNode_ChildRemoved(object sender, ChildEventArgs e) { if (e.Child.Is<Group>()) { CloseEditingContext(e.Child.As<CircuitEditingContext>()); } }
private void DomNode_ChildRemoved(object sender, ChildEventArgs e) { ItemRemoved.Raise(this, new ItemRemovedEventArgs<object>(e.Index, e.Child, e.Parent)); }
void node_ChildRemoved(object sender, ChildEventArgs e) { Remove(e.Parent, e.Child, e.ChildInfo); }
void node_ChildInserted(object sender, ChildEventArgs e) { Insert(e.Parent, e.Child, e.ChildInfo, e.Index); }
private void CollectionChildInserted(object sender, ChildEventArgs e) { if (e.Child.Type != SledSchema.SledProjectFilesBreakpointType.Type) return; var bp = e.Child.As<SledProjectFilesBreakpointType>(); // Fire event OnBreakpointAdded(new SledBreakpointServiceBreakpointEventArgs(bp)); }