public Pose Build(string name = "custompose") { var pose = new Pose(name, _poseThreshold); foreach (var itemState in _stateItems) { var item = itemState.What; var state = itemState.Trigger; int id = pose.AddFlag(); switch (state) { case State.Opened: item.Opened += (s, a) => pose.Flag(id, true); item.Closed += (s, a) => pose.Flag(id, false); break; case State.Closed: item.Closed += (s, a) => pose.Flag(id, true); item.Opened += (s, a) => pose.Flag(id, false); break; case State.Visible: item.Visible += (s, a) => pose.Flag(id, true); item.NotVisible += (s, a) => pose.Flag(id, false); break; case State.NotVisible: item.NotVisible += (s, a) => pose.Flag(id, true); item.Visible += (s, a) => pose.Flag(id, false); break; default: throw new ArgumentOutOfRangeException(); } } foreach (var itemPosition in _positionItems) { var itemA = itemPosition.ItemA; var itemB = itemPosition.ItemB; int id = pose.AddFlag(); var trigger = itemPosition; itemA.Moved += (s, a) => pose.Flag(id, IsCloseEnough(trigger)); itemB.Moved += (s, a) => pose.Flag(id, IsCloseEnough(trigger)); } _positionItems.Clear(); _stateItems.Clear(); return(pose); }
private void BindItemStateEvents(Pose pose) { foreach (var itemState in _stateItems) { var item = itemState.What; var state = itemState.Trigger; int id = pose.AddFlag(); itemState.Id = id; switch (state) { case State.Opened: item.Opened += (s, a) => pose.Flag(id, true); item.Closed += (s, a) => pose.Flag(id, false); break; case State.Closed: item.Closed += (s, a) => pose.Flag(id, true); item.Opened += (s, a) => pose.Flag(id, false); break; case State.Visible: item.Visible += (s, a) => pose.Flag(id, true); item.NotVisible += (s, a) => pose.Flag(id, false); break; case State.NotVisible: item.NotVisible += (s, a) => pose.Flag(id, true); item.Visible += (s, a) => pose.Flag(id, false); break; default: throw new ArgumentOutOfRangeException(); } } }
private void BindItemPositionEvents(Pose pose) { foreach (var itemPosition in _positionItems) { var itemA = itemPosition.ItemA; var itemB = itemPosition.ItemB; int id = pose.AddFlag(); var trigger = itemPosition; itemA.Moved += (s, a) => pose.Flag(id, IsCloseEnough(trigger)); itemB.Moved += (s, a) => pose.Flag(id, IsCloseEnough(trigger)); } }
public Pose Build(string name = "custompose") { var pose = new Pose(name, _poseThreshold); foreach (var itemState in _stateItems) { var item = itemState.What; var state = itemState.Trigger; int id = pose.AddFlag(); switch (state) { case State.Opened: item.Opened += (s, a) => pose.Flag(id, true); item.Closed += (s, a) => pose.Flag(id, false); break; case State.Closed: item.Closed += (s, a) => pose.Flag(id, true); item.Opened += (s, a) => pose.Flag(id, false); break; case State.Visible: item.Visible += (s, a) => pose.Flag(id, true); item.NotVisible += (s, a) => pose.Flag(id, false); break; case State.NotVisible: item.NotVisible += (s, a) => pose.Flag(id, true); item.Visible += (s, a) => pose.Flag(id, false); break; default: throw new ArgumentOutOfRangeException(); } } foreach(var itemPosition in _positionItems) { var itemA = itemPosition.ItemA; var itemB = itemPosition.ItemB; int id = pose.AddFlag(); var trigger = itemPosition; itemA.Moved += (s, a) => pose.Flag(id, IsCloseEnough(trigger)); itemB.Moved += (s, a) => pose.Flag(id, IsCloseEnough(trigger)); } _positionItems.Clear(); _stateItems.Clear(); return pose; }