//private DrawingTest dt;
        public MainWindow()
        {
            DataContext = this;
            InitializeComponent();

            this.Show();
            this.Topmost = true;

            drawingController = new DrawingController();
            drawingStatus = new DrawingStatus();

            drawingStatus.eye.x = 0.0f;
            drawingStatus.eye.y = 5.0f;
            drawingStatus.eye.z = 25.0f;

            drawingStatus.kinect.x = 0.0f;
            drawingStatus.kinect.y = 0.34f;
            drawingStatus.kinect.z = 0.0f;

            drawingController.ChangeStatus(drawingStatus);

            // initialize kinect
            InitKinect();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="GestureEventArgs"/> class.
 /// </summary>
 /// <param name="type">The gesture type.</param>
 /// <param name="trackingID">The tracking ID.</param>
 /// <param name="userID">The user ID.</param>
 public DrawingControllerEventArgs(DrawingStatus status)
 {
     this.DrawingStatus = status;
 }
        /// <summary>
        /// Parallel move from focused object to others.
        /// </summary>
        /// <param name="move">Which direction</param>
        /// <param name="status">Status of eye or kinect..etc..</param>
        /// <returns>New focused object</returns>
        private BuildingObjectLib3DS GetObjectByParallelMovement(DrawingEnumTypes.Movement move, DrawingStatus status)
        {
            XmlTextWriter writer = null;
            writer = new XmlTextWriter (Console.Out);

            if (this.Father.Childs.Count <= 1)
                return this;

            int count = Father.Childs.Count - 1;
            BuildingObjectLib3DS rnt = null;

            double shita = Math.Atan((status.eye.x - this.Coordinate.x) / (status.eye.z + this.Coordinate.y));
            Matrix<double> matrix = new Matrix<double>(1, 2);
            matrix.SetValue(0);
            matrix.Data[0, 0] = this.Coordinate.x;
            matrix.Data[0, 1] = -this.Coordinate.y;
            Matrix<double> _matrix = new Matrix<double>(2, 2);
            _matrix.SetValue(0);
            _matrix.Data[0, 0] = Math.Cos(shita);
            _matrix.Data[0, 1] = -Math.Sin(shita);
            _matrix.Data[1, 0] = Math.Sin(shita);
            _matrix.Data[1, 1] = Math.Cos(shita);

            Matrix<double> otherChilds = new Matrix<double>(1, 2);
            otherChilds.SetValue(0);
            double MinIn = 99999.0f;
            double MinOut = 99999.0f;
            double MinLeft = 99999.0f;
            double MinRight = 99999.0f;
            foreach(BuildingObjectLib3DS ThisObj in Father.Childs.Values)
            {
                if(ThisObj.Equals(this))
                    continue;

                otherChilds.Data[0, 0] = ThisObj.Coordinate.x;
                otherChilds.Data[0, 1] = -ThisObj.Coordinate.y;
                otherChilds = (otherChilds - matrix) * _matrix;
                switch (move)
                {
                    case DrawingEnumTypes.Movement.MoveIn:
                        if(otherChilds.Data[0, 1] < 0 &&
                            Math.Abs(otherChilds.Data[0, 1]) < MinIn)
                        {
                            rnt = ThisObj;
                            MinIn = Math.Abs(otherChilds.Data[0, 1]);
                        }
                        break;
                    case DrawingEnumTypes.Movement.MoveOut:
                        if (otherChilds.Data[0, 1] > 0 &&
                            Math.Abs(otherChilds.Data[0, 1]) < MinOut)
                        {
                            rnt = ThisObj;
                            MinOut = Math.Abs(otherChilds.Data[0, 1]);
                        }
                        break;
                    case DrawingEnumTypes.Movement.MoveLeft:
                        if (otherChilds.Data[0, 0] < 0 &&
                            Math.Abs(otherChilds.Data[0, 0]) < MinLeft)
                        {
                            rnt = ThisObj;
                            MinLeft = Math.Abs(otherChilds.Data[0, 0]);
                        }
                        break;
                    case DrawingEnumTypes.Movement.MoveRight:
                        if (otherChilds.Data[0, 0] > 0 &&
                            Math.Abs(otherChilds.Data[0, 0]) < MinRight)
                        {
                            rnt = ThisObj;
                            MinRight = Math.Abs(otherChilds.Data[0, 0]);
                        }
                        break;
                    default:
                        return this;
                }
            }

            // If we find the object
            if (rnt != null)
            {
                return rnt;
            }

            // Do not find....
            return this;
        }
        /// <summary>
        /// Move focused (this object) to others. 
        /// </summary>
        /// <param name="move">Which direction</param>
        /// <param name="status">Status of eye or kinect..etc..</param>
        /// <returns>New focused object</returns>
        public BuildingObjectLib3DS Move(DrawingEnumTypes.Movement move, DrawingStatus status)
        {
            switch (move)
            {
                case DrawingEnumTypes.Movement.MenuIn:
                    if (this.Type == BuildingObjectType.Outside)
                    {
                        if (Father.Childs == null || Father.Childs.Count == 0)
                            return this;

                        foreach (BuildingObjectLib3DS value in Father.Childs.Values)
                        {
                            if (value.GetBuildingType() == BuildingObjectType.Outside)
                                continue;

                            return value;
                        }
                    }
                    else if (this.Type == BuildingObjectType.Building)
                    {
                        if(this.Childs.Contains("0"))
                            return (this.Childs["0"] as BuildingObjectLib3DS);
                        return this;
                    }
                    else if (this.Type == BuildingObjectType.Object)
                    {
                        return this;
                    }
                    else
                    {
                        foreach (BuildingObjectLib3DS value in this.Childs.Values)
                        {
                            if (value != null)
                                return value;
                        }
                        return this;
                    }
                    break;
                case DrawingEnumTypes.Movement.MenuOut:
                    if (this.Type == BuildingObjectType.Floor)
                    {
                        return Father.Childs["0"] as BuildingObjectLib3DS;
                    }
                    else if (this.Type == BuildingObjectType.Building)
                    {
                        return this;
                    }
                    else
                    {
                        return this.Father;
                    }
                case DrawingEnumTypes.Movement.MoveDown:
                    if (this.Type == BuildingObjectType.Floor)
                    {
                        if (Father.Childs.Contains((Id - 1).ToString()))
                        {
                            return Father.Childs[(Id - 1).ToString()] as BuildingObjectLib3DS;
                        }
                    }
                    return this;
                case DrawingEnumTypes.Movement.MoveUp:
                    if (this.Type == BuildingObjectType.Floor)
                    {
                        if (Father.Childs.Contains((Id + 1).ToString()))
                        {
                            return Father.Childs[(Id + 1).ToString()] as BuildingObjectLib3DS;
                        }
                    }
                    return this;
                case DrawingEnumTypes.Movement.MoveIn:
                case DrawingEnumTypes.Movement.MoveOut:
                case DrawingEnumTypes.Movement.MoveRight:
                case DrawingEnumTypes.Movement.MoveLeft:
                    if (this.Type == BuildingObjectType.Room || this.Type == BuildingObjectType.Object)
                    {
                        return GetObjectByParallelMovement(move, status);
                    }
                    return this;
                default:
                    break;
            }
            return this;
        }
예제 #5
0
 public void ChangeStatus(DrawingStatus new_status)
 {
     projectorWin.status = new_status;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GestureEventArgs"/> class.
 /// </summary>
 /// <param name="type">The gesture type.</param>
 /// <param name="trackingID">The tracking ID.</param>
 /// <param name="userID">The user ID.</param>
 public DrawingControllerEventArgs(DrawingStatus status)
 {
     this.DrawingStatus = status;
 }
 public void ChangeStatus(DrawingStatus new_status)
 {
     projectorWin.status = new_status;
 }