A KinectSensorItem maintains a bit of state about a KinectSensor and manages showing/closing a KinectWindow associated with the KinectSensor.
Inheritance: INotifyPropertyChanged
 public KinectWindow(WriteableBitmap _colorBitmap, String _name, String _data, KinectSensorItem _kinect)
 {
     InitializeComponent();
     this.colorBitmap = _colorBitmap;
     Title = _name;
     data = _data;
     name = _name;
     kinect = _kinect;
 }
Example #2
0
        private void ShowStatus(KinectSensor kinectSensor, KinectStatus kinectStatus)
        {
            sensorStatusChanges.Text += kinectSensor.DeviceConnectionId + " " + kinectStatus + "\n";

            KinectSensorItem sensorItem;

            this.sensorItems.SensorLookup.TryGetValue(kinectSensor, out sensorItem);
            switch (kinectStatus)
            {
            case KinectStatus.Disconnected:
            case KinectStatus.NotPowered:
                if (sensorItem != null)
                {
                    this.sensorItems.Remove(sensorItem);
                    if (sensorItem.Window != null)
                    {
                        sensorItem.Window.Close();
                        sensorItem.Window = null;
                    }
                }

                break;

            default:
                if (sensorItem == null)
                {
                    sensorItem = new KinectSensorItem
                    {
                        Window = null,
                        Sensor = kinectSensor,
                        Status = kinectSensor.Status
                    };
                    this.sensorItems.Add(sensorItem);
                }

                // show a window, if one isn't already shown, unless we are initializing
                if (sensorItem.Window == null && kinectStatus != KinectStatus.Initializing)
                {
                    var kinectWindow = new KinectWindow {
                        Kinect = kinectSensor
                    };
                    kinectWindow.Show();

                    sensorItem.Window = kinectWindow;
                }

                if (sensorItem.Window != null)
                {
                    sensorItem.Window.StatusChanged();
                }

                sensorItem.Status = kinectStatus;
                break;
            }
        }
        private void ShowStatus(KinectSensor kinectSensor, KinectStatus kinectStatus)
        {
            this.statusItems.Add(new KinectStatusItem
            {
                Id       = (null == kinectSensor) ? null : kinectSensor.DeviceConnectionId,
                Status   = kinectStatus,
                DateTime = DateTime.Now
            });


            this.sensorItems.SensorLookup.TryGetValue(kinectSensor, out sensorItem);

            if (KinectStatus.Disconnected == kinectStatus)
            {
                if (sensorItem != null)
                {
                    this.sensorItems.Remove(sensorItem);
                    sensorItem.CloseWindow();
                }
            }
            else
            {
                if (sensorItem == null)
                {
                    sensorItem        = new KinectSensorItem(kinectSensor, kinectSensor.DeviceConnectionId, postureIndex);
                    sensorItem.Status = kinectStatus;
                    ///sensorItem.OnChildReturnEvent += new KinectSensorItem.OnChildReturnEvent;

                    this.sensorItems.Add(sensorItem);
                }
                else
                {
                    sensorItem.Status = kinectStatus;
                }

                if (KinectStatus.Connected == kinectStatus)
                {
                    // show a window
                    sensorItem.tempCallBack = WindowClosed1;

                    //sensorItem.OnChildReturnEvent +=new KinectSensorItem.OnChildReturnValueInKinectSensorItem(OnChildReturnEvent);

                    sensorItem.ShowWindow();

                    //sensorItem.callBack
                    //sensorItem.Window.Closed += WindowClosedForKinectCamera;
                }
                else
                {
                    sensorItem.CloseWindow();
                }
            }
        }
Example #4
0
        private void ShowStatus(KinectSensor kinectSensor, KinectStatus kinectStatus)
        {
            this.statusItems.Add(new KinectStatusItem
            {
                Id       = (null == kinectSensor) ? null : kinectSensor.DeviceConnectionId,
                Status   = kinectStatus,
                DateTime = DateTime.Now
            });

            KinectSensorItem sensorItem;

            this.sensorItems.SensorLookup.TryGetValue(kinectSensor, out sensorItem);

            if (KinectStatus.Disconnected == kinectStatus)
            {
                if (sensorItem != null)
                {
                    this.sensorItems.Remove(sensorItem);
                    sensorItem.CloseWindow();
                }
            }
            else
            {
                if (sensorItem == null)
                {
                    sensorItem        = new KinectSensorItem(kinectSensor, kinectSensor.DeviceConnectionId);
                    sensorItem.Status = kinectStatus;

                    this.sensorItems.Add(sensorItem);
                }
                else
                {
                    sensorItem.Status = kinectStatus;
                }

                if (KinectStatus.Connected == kinectStatus)
                {
                    // show a window
                    sensorItem.ShowWindow();
                }
                else
                {
                    sensorItem.CloseWindow();
                }
            }
        }
        private void ShowStatus(KinectSensor kinectSensor, KinectStatus kinectStatus)
        {
            this.statusItems.Add(new KinectStatusItem 
            { 
                Id = (null == kinectSensor) ? null : kinectSensor.DeviceConnectionId,
                Status = kinectStatus,
                DateTime = DateTime.Now
            });

            KinectSensorItem sensorItem;
            this.sensorItems.SensorLookup.TryGetValue(kinectSensor, out sensorItem);

            if (KinectStatus.Disconnected == kinectStatus)
            {
                if (sensorItem != null)
                {
                    this.sensorItems.Remove(sensorItem);
                    sensorItem.CloseWindow();
                }
            }
            else
            {
                if (sensorItem == null)
                {
                    sensorItem = new KinectSensorItem(kinectSensor, kinectSensor.DeviceConnectionId);
                    sensorItem.Status = kinectStatus;

                    this.sensorItems.Add(sensorItem);
                }
                else
                {
                    sensorItem.Status = kinectStatus;
                }

                if (KinectStatus.Connected == kinectStatus)
                {
                    // show a window
                    sensorItem.ShowWindow();
                }
                else
                {
                    sensorItem.CloseWindow();
                }
            }
        }
        private void ShowStatus(KinectSensor kinectSensor, KinectStatus kinectStatus)
        {
            KinectSensorItem sensorItem;
            this.sensorItems.SensorLookup.TryGetValue(kinectSensor, out sensorItem);

            //kinect is gestopt
            if (KinectStatus.Disconnected == kinectStatus)
            {
                if (sensorItem != null)
                {
                    sensorItem.StreamingStatus = "Stopped";
                    this.sensorItems.Remove(sensorItem);
                    sensorItem.Close();
                }
            }
            else
            {
                //kinect is niew
                if (sensorItem == null)
                {
                    sensorItem = new KinectSensorItem(this, kinectSensor, kinectSensor.DeviceConnectionId, nrOfKinects);
                    sensorItem.Status = kinectStatus;

                    this.sensorItems.Add(sensorItem);
                }
                //kinect heeft een update
                else
                {
                    sensorItem.Status = kinectStatus;
                }
                //eens connected: show window
                if (KinectStatus.Connected == kinectStatus )
                {
                    // show a window by default: off
                    //sensorItem.ShowWindow();
                }
                //indien disconnected: close
                else
                {
                  //  sensorItem.Close();
                }
            }

            this.statusItems.Add(new KinectStatusItem
            {
                Id = (null == kinectSensor) ? null : kinectSensor.DeviceConnectionId,
                Status = kinectStatus,
                DateTime = DateTime.Now,
                Name = (sensorItem != null) ? sensorItem.Name : "Loading...",
                StreamingStatus = (sensorItem != null) ? sensorItem.StreamingStatus : "Not Ready"

            });
        }
Example #7
0
        private void ShowStatus(KinectSensor kinectSensor, KinectStatus kinectStatus)
        {
            sensorStatusChanges.Text += kinectSensor.DeviceConnectionId + " " + kinectStatus + "\n";

            KinectSensorItem sensorItem;
            this.sensorItems.SensorLookup.TryGetValue(kinectSensor, out sensorItem);
            switch (kinectStatus)
            {
                case KinectStatus.Disconnected:
                case KinectStatus.NotPowered:
                    if (sensorItem != null)
                    {
                        this.sensorItems.Remove(sensorItem);
                        if (sensorItem.Window != null)
                        {
                            sensorItem.Window.Close();
                            sensorItem.Window = null;
                        }
                    }

                    break;
                default:
                    if (sensorItem == null)
                    {
                        sensorItem = new KinectSensorItem
                        {
                            Window = null,
                            Sensor = kinectSensor,
                            Status = kinectSensor.Status
                        };
                        this.sensorItems.Add(sensorItem);
                    }

                    // show a window, if one isn't already shown, unless we are initializing
                    if (sensorItem.Window == null && kinectStatus != KinectStatus.Initializing)
                    {
                        var kinectWindow = new KinectWindow { Kinect = kinectSensor };
                        kinectWindow.Show();

                        sensorItem.Window = kinectWindow;
                    }

                    if (sensorItem.Window != null)
                    {
                        sensorItem.Window.StatusChanged();
                    }

                    sensorItem.Status = kinectStatus;
                    break;
            }
        }