Inheritance: INotifyPropertyChanged
Ejemplo n.º 1
0
        //Event fires whenever a Kinect on the computer changes, this is used to keep the list of available Kinects up to date
        void KinectSensors_StatusChanged(object sender, StatusChangedEventArgs e)
        {
            for (int i = 0; i < availableKinects.Count; i++)
            {
                if (availableKinects[i].ConnectionID == e.Sensor.DeviceConnectionId)
                {
                    if (e.Sensor.Status != KinectStatus.Disconnected)
                    {
                        availableKinects[i].Status = e.Sensor.Status;
                        if (e.Sensor.Status != KinectStatus.Connected)
                        {
                            availableKinects[i].UseKinect = false;
                        }
                    }
                    else
                    {
                        availableKinects[i].PropertyChanged -= useKinect_PropertyChanged;
                        availableKinects.RemoveAt(i);

                        renumberKinectIDs();
                    }
                    kinectsAvailableDataGrid.Items.Refresh();
                    return;
                }
            }

            AvailableKinectData tempData = new AvailableKinectData();

            tempData.ConnectionID     = e.Sensor.DeviceConnectionId;
            tempData.KinectID         = null;
            tempData.UseKinect        = false;
            tempData.PropertyChanged += useKinect_PropertyChanged;
            tempData.Status           = e.Sensor.Status;
            availableKinects.Add(tempData);
            kinectsAvailableDataGrid.Items.Refresh();
        }
Ejemplo n.º 2
0
        private void Window_Initialized(object sender, EventArgs e)
        {
            //Setup the timer to update the GUI with the server runtime
            uptimeUpdateTimer = new System.Timers.Timer();
            uptimeUpdateTimer.Interval = 500;
            uptimeUpdateTimer.Elapsed += new System.Timers.ElapsedEventHandler(uptimeUpdateTimer_Elapsed);

            MasterSettings tempSettings = new MasterSettings();

            //Create the server core (this does NOT start the server)
            server = new ServerCore(verbose, tempSettings, this);

            //Set all the data for the data grids
            VoiceButtonDataGrid.ItemsSource = server.serverMasterOptions.voiceButtonCommands;
            VoiceTextDataGrid.ItemsSource = server.serverMasterOptions.voiceTextCommands;

            KinectStatusBlock.Text = "1";

            if (startupFile != null && startupFile != "")
            {
                try
                {
                    server.serverMasterOptions = HelperMethods.LoadSettings(startupFile);
                    UpdateGUISettings();
                }
                catch
                {
                    MessageBox.Show("Error: The startup settings file failed to load!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    HelperMethods.WriteToLog("Startup settings (" + startupFile + ") failed to load.");
                }
            }

            //TODO: Handle starting Kinects based on the loaded settings file
            //Initialize the data for the available Kinects
            for (int i = 0; i < KinectSensor.KinectSensors.Count; i++)
            {
                AvailableKinectData tempData = new AvailableKinectData();
                tempData.ConnectionID = KinectSensor.KinectSensors[i].DeviceConnectionId;
                tempData.Status = KinectSensor.KinectSensors[i].Status;
                if (i == 0 && tempData.Status == KinectStatus.Connected)
                {
                    tempData.UseKinect = true;
                    tempData.KinectID = 0;
                    server.serverMasterOptions.kinectOptionsList.Add(new KinectSettings(tempData.ConnectionID, (int)tempData.KinectID));
                    server.kinects.Add(new KinectCore(server, this, (int)tempData.KinectID));
                    tempData.ServerStatus = "Running";
                }
                else
                {
                    tempData.UseKinect = false;
                    tempData.KinectID = null;
                }
                tempData.PropertyChanged += useKinect_PropertyChanged;
                availableKinects.Add(tempData);
            }
            kinectsAvailableDataGrid.ItemsSource = availableKinects;
            UpdatePageListing();
            GenerateImageSourcePickerLists();
            KinectSensor.KinectSensors.StatusChanged += KinectSensors_StatusChanged;

            //Populate the skeleton data and set the binding for the data grid
            GenerateSkeletonDataGridData();
            SkeletonSettingsDataGrid.ItemsSource = server.serverMasterOptions.skeletonOptions.individualSkeletons;

            //Populate and setup the voice recognition lists
            GenerateVoiceRecogEngineList();
            GenerateAudioSourceList();
            VoiceKinectComboBox.SelectedIndex = 0;

            //Set defaults where needed
            FeedbackJointTypeComboBox.SelectedIndex = 0;
            SkelSortModeComboBox.SelectedIndex = 5;

            if (startOnLaunch)
            {
                startServerButton_Click(this, new RoutedEventArgs());
            }
        }
Ejemplo n.º 3
0
        private void Window_Initialized(object sender, EventArgs e)
        {
            //Setup the timer to update the GUI with the server runtime
            uptimeUpdateTimer          = new System.Timers.Timer();
            uptimeUpdateTimer.Interval = 500;
            uptimeUpdateTimer.Elapsed += new System.Timers.ElapsedEventHandler(uptimeUpdateTimer_Elapsed);

            MasterSettings tempSettings = new MasterSettings();

            //Create the server core (this does NOT start the server)
            server = new ServerCore(verbose, tempSettings, this);

            //Set all the data for the data grids
            VoiceButtonDataGrid.ItemsSource = server.serverMasterOptions.voiceButtonCommands;
            VoiceTextDataGrid.ItemsSource   = server.serverMasterOptions.voiceTextCommands;

            KinectStatusBlock.Text = "1";

            if (startupFile != null && startupFile != "")
            {
                try
                {
                    server.serverMasterOptions = HelperMethods.LoadSettings(startupFile);
                    UpdateGUISettings();
                }
                catch
                {
                    MessageBox.Show("Error: The startup settings file failed to load!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    HelperMethods.WriteToLog("Startup settings (" + startupFile + ") failed to load.");
                }
            }

            //TODO: Handle starting Kinects based on the loaded settings file
            //Initialize the data for the available Kinects
            for (int i = 0; i < KinectSensor.KinectSensors.Count; i++)
            {
                AvailableKinectData tempData = new AvailableKinectData();
                tempData.ConnectionID = KinectSensor.KinectSensors[i].DeviceConnectionId;
                tempData.Status       = KinectSensor.KinectSensors[i].Status;
                if (i == 0 && tempData.Status == KinectStatus.Connected)
                {
                    tempData.UseKinect = true;
                    tempData.KinectID  = 0;
                    server.serverMasterOptions.kinectOptions.Add(new KinectSettings(tempData.ConnectionID, (int)tempData.KinectID));
                    server.kinects.Add(new KinectCore(server, this, (int)tempData.KinectID));
                }
                else
                {
                    tempData.UseKinect = false;
                    tempData.KinectID  = null;
                }
                tempData.PropertyChanged += useKinect_PropertyChanged;
                availableKinects.Add(tempData);
            }
            kinectsAvailableDataGrid.ItemsSource = availableKinects;
            UpdatePageListing();
            GenerateImageSourcePickerLists();
            KinectSensor.KinectSensors.StatusChanged += KinectSensors_StatusChanged;

            //Populate the skeleton data and set the binding for the data grid
            GenerateSkeletonDataGridData();
            SkeletonSettingsDataGrid.ItemsSource = server.serverMasterOptions.skeletonOptions.individualSkeletons;

            //Populate and setup the voice recognition lists
            GenerateVoiceRecogEngineList();
            GenerateAudioSourceList();
            VoiceKinectComboBox.SelectedIndex = 0;

            //Set defaults where needed
            FeedbackJointTypeComboBox.SelectedIndex = 0;
            SkelSortModeComboBox.SelectedIndex      = 5;

            if (startOnLaunch)
            {
                startServerButton_Click(this, new RoutedEventArgs());
            }
        }
Ejemplo n.º 4
0
        //Event fires whenever a Kinect on the computer changes, this is used to keep the list of available Kinects up to date
        void KinectSensors_StatusChanged(object sender, StatusChangedEventArgs e)
        {
            for (int i = 0; i < availableKinects.Count; i++)
            {
                if (availableKinects[i].ConnectionID == e.Sensor.DeviceConnectionId)
                {
                    if (e.Sensor.Status != KinectStatus.Disconnected)
                    {
                        availableKinects[i].Status = e.Sensor.Status;
                        if (e.Sensor.Status != KinectStatus.Connected)
                        {
                            availableKinects[i].UseKinect = false;
                        }
                    }
                    else
                    {
                        availableKinects[i].PropertyChanged -= useKinect_PropertyChanged;
                        availableKinects.RemoveAt(i);

                        renumberKinectIDs();
                    }
                    kinectsAvailableDataGrid.Items.Refresh();
                    return;
                }
            }

            AvailableKinectData tempData = new AvailableKinectData();
            tempData.ConnectionID = e.Sensor.DeviceConnectionId;
            tempData.KinectID = null;
            tempData.UseKinect = false;
            tempData.PropertyChanged += useKinect_PropertyChanged;
            tempData.Status = e.Sensor.Status;
            availableKinects.Add(tempData);
            kinectsAvailableDataGrid.Items.Refresh();
        }
Ejemplo n.º 5
0
        private void Window_Initialized(object sender, EventArgs e)
        {
            //Report to the log which Kinect versions are unavaliable
            if (!avaliableDLLs.HasKinectV1)
            {
                HelperMethods.WriteToLog("Warning: Kinect v1 support is unvaliable due to missing DLLs!", this);
            }
            if (!avaliableDLLs.HasKinectV2)
            {
                HelperMethods.WriteToLog("Warning: Kinect v2 support is unvaliable due to missing DLLs!", this);
            }
            if (!avaliableDLLs.HasNetworkedKinect)
            {
                HelperMethods.WriteToLog("Warning: Networked Kinect support is unvaliable due to missing DLLs!", this);
                //Remove the option to add a networked kinect if the dll isn't avaliable
                nkStackPanel.Visibility = System.Windows.Visibility.Collapsed;
                AddNKButton.IsEnabled = false;
            }

            //Setup the timer to update the GUI with the server runtime
            uptimeUpdateTimer = new System.Timers.Timer();
            uptimeUpdateTimer.Interval = 500;
            uptimeUpdateTimer.Elapsed += new System.Timers.ElapsedEventHandler(uptimeUpdateTimer_Elapsed);

            KinectBase.MasterSettings tempSettings = new KinectBase.MasterSettings();

            //Create the server core (this does NOT start the server)
            server = new ServerCore(verbose, tempSettings, this);

            //Set all the data for the data grids
            VoiceButtonDataGrid.ItemsSource = server.serverMasterOptions.voiceButtonCommands;
            VoiceTextDataGrid.ItemsSource = server.serverMasterOptions.voiceTextCommands;

            if (startupFile != null && startupFile != "")
            {
                try
                {
                    server.serverMasterOptions = HelperMethods.LoadSettings(startupFile);
                    UpdateGUISettings();
                }
                catch
                {
                    MessageBox.Show("Error: The startup settings file failed to load!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    HelperMethods.WriteToLog("Startup settings (" + startupFile + ") failed to load.");
                }
            }

            //TODO: Handle starting Kinects based on the loaded settings file
            //Initialize the data for the available Kinect v1s
            if (avaliableDLLs.HasKinectV1)
            {
                KinectV1Wrapper.StatusEventArgs[] currentStatuses = KinectV1Wrapper.StatusHelper.GetAllKinectsStatus();
                for (int i = 0; i < currentStatuses.Length; i++)
                {
                    AvailableKinectData tempData = new AvailableKinectData();

                    tempData.UniqueID = currentStatuses[i].UniqueKinectID;
                    tempData.Status = currentStatuses[i].Status;
                    tempData.KinectTypeString = GetKinectTypeString(currentStatuses[i].Status, currentStatuses[i].isXBox360Kinect);
                    tempData.kinectType = KinectVersion.KinectV1;

                    if (i == 0 && tempData.Status == KinectStatus.Connected)
                    {
                        tempData.UseKinect = true;
                        tempData.KinectID = 0;
                        server.serverMasterOptions.kinectOptionsList.Add((IKinectSettings)(new KinectV1Wrapper.Settings(tempData.UniqueID, (int)tempData.KinectID)));
                        server.kinects.Add((new KinectV1Wrapper.Core(ref server.serverMasterOptions, true, (int)tempData.KinectID)));
                        tempData.ServerStatus = "Running";
                    }
                    else
                    {
                        tempData.UseKinect = false;
                        tempData.KinectID = null;
                    }
                    tempData.PropertyChanged += useKinect_PropertyChanged;
                    availableKinects.Add(tempData);
                }
            }

            //Initialize the data for the available Kinect v2s
            if (avaliableDLLs.HasKinectV2)
            {
                KinectV2Wrapper.StatusHelper.StartKinectV2Service();
                KinectV2Wrapper.StatusEventArgs[] currentStatuses2 = KinectV2Wrapper.StatusHelper.GetAllKinectsStatus();
                for (int i = 0; i < currentStatuses2.Length; i++)
                {
                    AvailableKinectData tempData = new AvailableKinectData();

                    tempData.UniqueID = currentStatuses2[i].UniqueKinectID;
                    tempData.Status = currentStatuses2[i].Status;
                    tempData.KinectTypeString = "Kinect v2";
                    tempData.kinectType = KinectVersion.KinectV2;
                    //Note: Unlike the Kinect v1, we don't automatically launch a Kinect v2
                    tempData.UseKinect = false;
                    tempData.KinectID = null;
                    tempData.PropertyChanged += useKinect_PropertyChanged;
                    availableKinects.Add(tempData);
                }
            }

            KinectStatusBlock.Text = availableKinects.Count.ToString();
            kinectsAvailableDataGrid.ItemsSource = availableKinects;
            UpdatePageListing();
            GenerateImageSourcePickerLists();

            if (avaliableDLLs.HasKinectV1)
            {
                //Subscribe to the v1 status changed event
                KinectV1Wrapper.StatusHelper v1StatusHelper = new KinectV1Wrapper.StatusHelper();
                v1StatusHelper.StatusChanged += v1StatusHelper_KinectV1StatusChanged;
            }
            if (avaliableDLLs.HasKinectV2)
            {
                //Subscribe to the v2 status changed event
                KinectV2Wrapper.StatusHelper v2StatusHelper = new KinectV2Wrapper.StatusHelper();
                v2StatusHelper.StatusChanged += v2StatusHelper_KinectV2StatusChanged;
            }

            //Populate the skeleton data and set the binding for the data grid
            GenerateSkeletonDataGridData();
            SkeletonSettingsDataGrid.ItemsSource = server.serverMasterOptions.mergedSkeletonOptions.individualSkeletons;

            //Populate and setup the voice recognition lists
            GenerateVoiceRecogEngineList();
            GenerateAudioSourceList();
            VoiceKinectComboBox.SelectedIndex = 0;

            //Set defaults where needed
            FeedbackJointTypeComboBox.SelectedIndex = 0;
            SkelSortModeComboBox.SelectedIndex = 5;

            //Set the items source for the servers display grid
            ServersDataGrid.ItemsSource = configuredServers;

            //Set the initial shader for the depth image
            depthEffect = new Shaders.NoScalingEffect();
            DepthImage.Effect = depthEffect;

            if (startOnLaunch)
            {
                startServerButton_Click(this, new RoutedEventArgs());
            }
        }
Ejemplo n.º 6
0
        void v2StatusHelper_KinectV2StatusChanged(object sender, KinectV2Wrapper.StatusEventArgs e)
        {
            bool kinectFound = false;

            for (int i = 0; i < availableKinects.Count; i++)
            {
                //Check the Kinect by version, not by ID, because the ID is not preserved when the Kinect is disconnected
                if (availableKinects[i].kinectType == KinectVersion.KinectV2)
                {
                    if (e.Status != KinectStatus.Disconnected)
                    {
                        availableKinects[i].Status = e.Status;
                        availableKinects[i].KinectTypeString = "Kinect v2";
                        availableKinects[i].kinectType = KinectVersion.KinectV2;

                        if (e.Status != KinectStatus.Connected)
                        {
                            availableKinects[i].UseKinect = false;
                        }
                    }
                    else
                    {
                        availableKinects[i].UseKinect = false;
                        availableKinects[i].PropertyChanged -= useKinect_PropertyChanged;
                        availableKinects.RemoveAt(i);

                        renumberKinectIDs();
                    }
                    kinectsAvailableDataGrid.Items.Refresh();
                    kinectFound = true;
                }
            }

            if (!kinectFound && e.Status != KinectStatus.Disconnected)
            {
                AvailableKinectData tempData = new AvailableKinectData();
                tempData.UniqueID = e.UniqueKinectID;
                tempData.KinectID = null;
                tempData.UseKinect = false;
                tempData.KinectTypeString = "Kinect v2";
                tempData.kinectType = KinectVersion.KinectV2;
                tempData.PropertyChanged += useKinect_PropertyChanged;
                tempData.Status = e.Status;
                availableKinects.Add(tempData);
                kinectsAvailableDataGrid.Items.Refresh();
            }

            //Update the number of Kinects attached to the computer
            KinectStatusBlock.Text = availableKinects.Count.ToString();
        }
Ejemplo n.º 7
0
        void v1StatusHelper_KinectV1StatusChanged(object sender, KinectV1Wrapper.StatusEventArgs e)
        {
            bool kinectFound = false;

            for (int i = 0; i < availableKinects.Count; i++)
            {
                if (availableKinects[i].UniqueID == e.UniqueKinectID)
                {
                    if (e.Status != KinectStatus.Disconnected)
                    {
                        availableKinects[i].Status = e.Status;
                        availableKinects[i].KinectTypeString = GetKinectTypeString(e.Status, e.isXBox360Kinect);
                        availableKinects[i].kinectType = KinectVersion.KinectV1;

                        if (e.Status != KinectStatus.Connected)
                        {
                            availableKinects[i].UseKinect = false;
                        }
                    }
                    else
                    {
                        availableKinects[i].UseKinect = false;
                        availableKinects[i].PropertyChanged -= useKinect_PropertyChanged;
                        availableKinects.RemoveAt(i);

                        renumberKinectIDs();
                    }
                    kinectsAvailableDataGrid.Items.Refresh();
                    kinectFound = true;
                }
            }

            if (!kinectFound)
            {
                AvailableKinectData tempData = new AvailableKinectData();
                tempData.KinectID = null;
                tempData.UseKinect = false;
                tempData.KinectTypeString = GetKinectTypeString(e.Status, e.isXBox360Kinect);
                tempData.kinectType = KinectVersion.KinectV1;
                tempData.PropertyChanged += useKinect_PropertyChanged;
                tempData.Status = e.Status;
                tempData.UniqueID = e.UniqueKinectID;
                availableKinects.Add(tempData);
                kinectsAvailableDataGrid.Items.Refresh();
            }

            //Update the number of Kinects attached to the computer
            KinectStatusBlock.Text = availableKinects.Count.ToString();
        }
Ejemplo n.º 8
0
        //Manually add a network kinect to the list of avaliable kinects
        private void AddNKButton_Click(object sender, RoutedEventArgs e)
        {
            if (avaliableDLLs.HasNetworkedKinect)
            {
                NetworkKinectWrapper.NKAddDialog dialog = new NetworkKinectWrapper.NKAddDialog(this);
                if ((bool)dialog.ShowDialog())
                {
                    AvailableKinectData nkData = new AvailableKinectData();
                    nkData.KinectID = null;
                    nkData.UseKinect = false;
                    nkData.KinectTypeString = "Network Kinect";
                    nkData.kinectType = KinectVersion.NetworkKinect;
                    nkData.PropertyChanged += useKinect_PropertyChanged;
                    nkData.Status = KinectStatus.Connected;  //TODO: The network kinects don't really check to see if they are connected or not...
                    nkData.UniqueID = dialog.UniqueID;
                    availableKinects.Add(nkData);
                    kinectsAvailableDataGrid.Items.Refresh();

                    nkData.UseKinect = true;  //This has to be changed to true after everything else is setup to trigger the GUI updating
                }
            }
        }