예제 #1
0
        private KinectSensor sensor;                                //Kinect sensor attached to the system


        public MainWindow()
        {
            InitializeComponent();
            gp = new gestureProcessor();

            /*This code creates the paint canvas, adjusts its size to that of the underlying display size and
             * adds the grey background color to it */
            Color           c = Color.FromRgb(108, 108, 108);
            SolidColorBrush s = new SolidColorBrush();

            s.Color                = c;
            name.Background        = s;
            name.Width             = SystemParameters.PrimaryScreenWidth;
            PaintCanvas.Background = s;
            PaintCanvas.Height     = SystemParameters.PrimaryScreenHeight;
            PaintCanvas.Width      = SystemParameters.PrimaryScreenWidth;
            UNCCLearning.Content   = PaintCanvas;

            //Load node data from the database
            loadData data = new loadData();

            //Group the nodes by discipline, and assign them to the five cluster objects
            subtype = new string[5] {
                "sec", "hci", "sw", "hcip", "iis"
            };
            reorderClusters(subtype);

            //Draw the re-cluster information button on the screen
            MainWindow.drawButton(120, 950);

            //Set a 5 second timer
            timer          = new System.Windows.Threading.DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(5);      //Set the interval period here.
            timer.Tick    += new EventHandler(timer_Tick); // After every 5 seconds this event handler is called
            timer.Start();
        }
예제 #2
0
        /*
         * This function deals with the skeleton frame data as soon as it is ready
         */
        private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            Skeleton[] skeletons = new Skeleton[0];
            //copy all the available skeleton frames
            using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
            {
                if (skeletonFrame != null)
                {
                    skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                    skeletonFrame.CopySkeletonDataTo(skeletons);
                }
            }

            //if the number of skeletons is greater than 0
            if (skeletons.Length != 0)
            {
                //check if any skeleton is being tracked, i.e., it is within the kinect sensor's range,
                //choose this skeleton as the active one
                for (int s = 0; s < skeletons.Length; s++)
                {
                    skel = skeletons[s];

                    if (skel.TrackingState == SkeletonTrackingState.Tracked)
                    {
                        break;
                    }
                }
                //check if this skeleton is being tracked
                if (skel.TrackingState == SkeletonTrackingState.Tracked)
                {
                    //Switch the system to active mode
                    if (activestate == 0)
                    {
                        //disable color stream and stop displaying video
                        this.sensor.ColorStream.Disable();
                        PaintCanvas.Children.Remove(im);

                        PaintCanvas.Children.Clear();

                        //stop timer
                        timer.Stop();
                        //all nodes should now be in the default state
                        c1.changeClusterState("default");
                        c2.changeClusterState("default");
                        c3.changeClusterState("default");
                        c4.changeClusterState("default");
                        c5.changeClusterState("default");
                        //display the five clusters on screen
                        MainWindow.c1.displayCluster(defNodeProp, 100, 80, 20, false);
                        MainWindow.c2.displayCluster(defNodeProp, 550, 1150, 20, false);
                        MainWindow.c3.displayCluster(defNodeProp, 550, 80, 20, false);
                        MainWindow.c4.displayCluster(defNodeProp, 100, 1150, 20, false);
                        MainWindow.c5.displayCluster(defNodeProp, 440, 650, 20, false);
                        activestate = 1;                  //system is now in the active state
                        gestureProcessor.RframeCount = 0; //reset left and right hand frame counters
                        gestureProcessor.LframeCount = 0;
                        drawButton(120, 700);             //draw the change information layout button
                    }
                    //Change the default system description text from "Get Involved" to "Explore the SIS Department"
                    if (PaintCanvas.Children.Contains(name))
                    {
                        PaintCanvas.Children.Remove(name);
                        name.FontSize   = 60;
                        name.Opacity    = 0.5;
                        name.Content    = "Explore The SIS Department!";
                        name.Visibility = System.Windows.Visibility.Visible;
                        PaintCanvas.Children.Add(name);
                    }
                    else
                    {
                        name.Content    = "Explore The SIS Department!";
                        name.FontSize   = 60;
                        name.Opacity    = 0.5;
                        name.Visibility = System.Windows.Visibility.Visible;
                        PaintCanvas.Children.Add(name);
                    }
                    //Start detecting gestures
                    gp.gestureDetector();
                }
                //if the skeleton is not being tracked i.e., out of the sensor's range, switch the system to standby mode
                else if (skel.TrackingState == SkeletonTrackingState.NotTracked)
                {
                    //start timer
                    timer.Start();
                    //system is not active
                    activestate = 0;
                    //reset the gesture processor
                    gp = new gestureProcessor();
                    gestureProcessor.state = "";
                    //remove all visual elements except video and system title
                    for (int i = 0; i < PaintCanvas.Children.Count; i++)
                    {
                        if (PaintCanvas.Children[i] != im && PaintCanvas.Children[i] != name)
                        {
                            PaintCanvas.Children.RemoveAt(i);
                        }
                    }
                    //enable color stream
                    this.sensor.ColorStream.Enable();
                }
            }
        }