Exemplo n.º 1
0
        private void SearchButton_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                // Update device list
                if (ArenaNETSystem.UpdateDevices(1000))
                {
                    // if at least one device found, open it
                    if (ArenaNETSystem.Devices.Count != 0)
                    {
                        // if at least one device found, open it
                        Device = ArenaNETSystem.CreateDevice(ArenaNETSystem.Devices[0]);

                        // Update information
                        ConsoleView.Text += $"{ArenaNETSystem.Devices.Count } devices found. - {DateTime.Now}" + Environment.NewLine;
                        ConsoleView.Text += $"First camera opened. - {DateTime.Now}" + Environment.NewLine;

                        SearchButton.IsEnabled = false;
                        OpenButton.IsEnabled   = true;
                    }
                    else
                    {
                        ConsoleView.Text += $"Devices not found. - {DateTime.Now}" + Environment.NewLine;
                    }
                }
                else
                {
                    ConsoleView.Text += $"Devices not found. - {DateTime.Now}" + Environment.NewLine;
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Exemplo n.º 2
0
        private void CloseButton_OnClick(object sender, RoutedEventArgs e)
        {
            try
            {
                // Stop polling task and wait it stopped
                ImagePollingCancellationTokenSource.Cancel(true);
                PollingTask.Wait(PollingImageTimeout);

                // Stop stream
                Device.StopStream();

                // Release resources
                ArenaNETSystem.DestroyDevice(Device);
                ArenaNET.Arena.CloseSystem(ArenaNETSystem);

                InitializeButton.IsEnabled = true;
                CloseButton.IsEnabled      = false;
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }