Example #1
0
 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();
         }
     }
 }
Example #2
0
 public Pose Build(string name = "custompose") {
     var pose = new Pose(name, _poseThreshold);
     BindItemStateEvents(pose);
     BindItemPositionEvents(pose);
     SetInitialState(pose);
      _stateItems.Clear();
     _positionItems.Clear();
     return pose;
 }
Example #3
0
        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;
        }
Example #4
0
 private void SetInitialState(Pose pose) {
     foreach (var itemState in _stateItems) {
         var item = itemState.What;
         var state = itemState.Trigger;
         var id = itemState.Id;
         switch (state) {
             case State.Opened:
                 pose.Flag(id, item.IsOpen);
                 break;
             case State.Closed:
                 pose.Flag(id, !item.IsOpen);
                 break;
             case State.Visible:
                 pose.Flag(id, item.IsVisible);
                 break;
             case State.NotVisible:
                 pose.Flag(id, !item.IsVisible);
                 break;
             default:
                 throw new ArgumentOutOfRangeException();
         }
     }
 }
Example #5
0
 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));
     }
 }