Beispiel #1
0
        public MainWindow()
        {
            InitializeComponent();

            this._Puzzle = new DotPuzzle();
            this._Puzzle.Dots.Add(new Point(200, 300));
            this._Puzzle.Dots.Add(new Point(1600, 300));
            this._Puzzle.Dots.Add(new Point(1650, 400));
            this._Puzzle.Dots.Add(new Point(1600, 500));
            this._Puzzle.Dots.Add(new Point(1000, 500));
            this._Puzzle.Dots.Add(new Point(1000, 600));
            this._Puzzle.Dots.Add(new Point(1200, 700));
            this._Puzzle.Dots.Add(new Point(1150, 800));
            this._Puzzle.Dots.Add(new Point(750, 800));
            this._Puzzle.Dots.Add(new Point(700, 700));
            this._Puzzle.Dots.Add(new Point(900, 600));
            this._Puzzle.Dots.Add(new Point(900, 500));
            this._Puzzle.Dots.Add(new Point(200, 500));
            this._Puzzle.Dots.Add(new Point(150, 400));

            this._PuzzleDotIndex = -1;

            this.Loaded += (s, e) =>
            {
                KinectSensor.KinectSensors.StatusChanged += KinectSensors_StatusChanged;
                this.KinectDevice = KinectSensor.KinectSensors.FirstOrDefault(x => x.Status == KinectStatus.Connected);

                DrawPuzzle(this._Puzzle);
            };
        }
        public MainWindow()
        {
            InitializeComponent();
            myStageControl.Initialize();
            _myStage = myStageControl.Stage;
            this._MoveStage += new MoveStageEx(MoveStage);
            this._StopStage += new StopStageEx(StopStage);
            this._Puzzle = new DotPuzzle();
            this._Puzzle.Dots.Add(new Point(200, 300));
             //           this._Puzzle.Dots.Add(new Point(1600, 300));
            //this._Puzzle.Dots.Add(new Point(1650, 400));
            //this._Puzzle.Dots.Add(new Point(1600, 500));
            //this._Puzzle.Dots.Add(new Point(1000, 500));
            //this._Puzzle.Dots.Add(new Point(1000, 600));
            //this._Puzzle.Dots.Add(new Point(1200, 700));
            //this._Puzzle.Dots.Add(new Point(1150, 800));
            //this._Puzzle.Dots.Add(new Point(750, 800));
            //this._Puzzle.Dots.Add(new Point(700, 700));
            //this._Puzzle.Dots.Add(new Point(900, 600));
            //this._Puzzle.Dots.Add(new Point(900, 500));
            //this._Puzzle.Dots.Add(new Point(200, 500));
            //this._Puzzle.Dots.Add(new Point(150, 400));

            this._PuzzleDotIndex = -1;

            this.Loaded += (s,e) =>
            {
                KinectSensor.KinectSensors.StatusChanged += KinectSensors_StatusChanged;
                this.KinectDevice = KinectSensor.KinectSensors.FirstOrDefault(x => x.Status == KinectStatus.Connected);

                DrawPuzzle(this._Puzzle);
            };
        }
Beispiel #3
0
        // Listing 4-10
        private void DrawPuzzle(DotPuzzle puzzle)
        {
            PuzzleBoardElement.Children.Clear();

            if (puzzle != null)
            {
                for (int i = 0; i < puzzle.Dots.Count; i++)
                {
                    Grid dotContainer = new Grid();
                    dotContainer.Width  = 50;
                    dotContainer.Height = 50;
                    dotContainer.Children.Add(new Ellipse {
                        Fill = Brushes.Gray
                    });

                    TextBlock dotLabel = new TextBlock();
                    dotLabel.Text                = (i + 1).ToString();
                    dotLabel.Foreground          = Brushes.White;
                    dotLabel.FontSize            = 24;
                    dotLabel.HorizontalAlignment = HorizontalAlignment.Center;
                    dotLabel.VerticalAlignment   = VerticalAlignment.Center;
                    dotContainer.Children.Add(dotLabel);

                    //Position the UI element centered on the dot point
                    Canvas.SetTop(dotContainer, puzzle.Dots[i].Y - (dotContainer.Height / 2));
                    Canvas.SetLeft(dotContainer, puzzle.Dots[i].X - (dotContainer.Width / 2));
                    PuzzleBoardElement.Children.Add(dotContainer);
                }
            }
        }
        // Listing 4-10
        private void DrawPuzzle(DotPuzzle puzzle)
        {
            PuzzleBoardElement.Children.Clear();

            if(puzzle != null)
            {
                Grid dotContainer   = new Grid();
                dotContainer.Width  = 175;
                dotContainer.Height = 175;
                dotContainer.Children.Add(new Ellipse { Fill = Brushes.Green });

                TextBlock dotLabel              = new TextBlock();
                dotLabel.Text                   = "START";
                dotLabel.Foreground             = Brushes.White;
                dotLabel.FontSize               = 40;
                dotLabel.HorizontalAlignment    = HorizontalAlignment.Center;
                dotLabel.VerticalAlignment      = VerticalAlignment.Center;
                dotContainer.Children.Add(dotLabel);

                //Position the UI element centered on the dot point
                Canvas.SetTop(dotContainer, puzzle.Dots[0].Y - (dotContainer.Height / 2) );
                Canvas.SetLeft(dotContainer, puzzle.Dots[0].X - (dotContainer.Width / 2));
                PuzzleBoardElement.Children.Add(dotContainer);

                //Grid dotContainerStop = new Grid();
                //dotContainerStop.Width = 175;
                //dotContainerStop.Height = 175;
                //dotContainerStop.Children.Add(new Ellipse { Fill = Brushes.Red });

                //TextBlock dotLabelStop = new TextBlock();
                //dotLabelStop.Text = "STOP";
                //dotLabelStop.Foreground = Brushes.White;
                //dotLabelStop.FontSize = 40;
                //dotLabelStop.HorizontalAlignment = HorizontalAlignment.Center;
                //dotLabelStop.VerticalAlignment = VerticalAlignment.Center;
                //dotContainerStop.Children.Add(dotLabelStop);

                ////Position the UI element centered on the dot point
                //Canvas.SetTop(dotContainerStop, puzzle.Dots[1].Y - (dotContainer.Height / 2));
                //Canvas.SetLeft(dotContainerStop, puzzle.Dots[1].X - (dotContainer.Width / 2));
                //PuzzleBoardElement.Children.Add(dotContainerStop);

            }
        }