示例#1
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);
        }
示例#2
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();
         }
     }
 }
示例#3
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));
     }
 }
示例#4
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;
        }