protected void OnControlDeleted(object sender, ControlGate gate) { Rectangle <int> oldArea = GetGateArea(); DisconnectControl(gate); ControlsChanged(this, new ControlsChangedEventArgs(oldArea, GetGateArea())); }
public override Rectangle <int> GetGateArea() { ControlGate topControl = Controls.Min(), bottomControl = Controls.Max(); int top = topControl != null ? (topControl.FirstRow < FirstRow ? topControl.FirstRow : FirstRow) : FirstRow; int bottom = bottomControl != null ? (bottomControl.FirstRow > LastRow ? bottomControl.FirstRow : LastRow) : LastRow; return(new Rectangle <int>(Column, top, Column, bottom)); }
public void OnDisconnectRequested(object sender, ControlGate gate) { Rectangle <int> oldArea = GetGateArea(); List <ControlGate> controlsToDisconnect = gate.FirstRow < FirstRow? Controls.Where(x => x.FirstRow <= gate.FirstRow).ToList() : Controls.Where(x => x.FirstRow >= gate.FirstRow).ToList(); DisconnectControl(controlsToDisconnect); ControlsChanged(this, new ControlsChangedEventArgs(oldArea, GetGateArea())); }
private void DisconnectControl(ControlGate control) { DetachControlGateEvents(control); Controls.Remove(control); control.Disconnect(); if (Controls.Count > 0) { GateTransformation = Circuit.TransformationReg.Register(Model.Transformation, RelativeControlIndices()); } else { GateTransformation = Model.Transformation; } }
protected void DetachControlGateEvents(ControlGate gate) { gate.DisconnectRequested -= OnDisconnectRequested; gate.ControlDeleted -= OnControlDeleted; }