/// <summary>
 /// starts the cam, representated by the given device string and registers the capture handle methode
 /// </summary>
 /// <param name="device"></param>
 public void StartCam(string device)
 {
     if (SelectedWebcam != null && device.Equals(SelectedWebcam.MonikerString))
     {
         SelectedWebcam.Start();
     }
     else
     {
         SelectedWebcam = new CapDevice("")
         {
             MonikerString = device
         };
     }
     //register output change eventhandler
     SelectedWebcam.NewBitmapReady += newCamEstablished;
 }
示例#2
0
        private void RecycleDevice()
        {
            bool isEnabled = _dispatcherTimer.IsEnabled;

            _dispatcherTimer.Stop();
            _capturer = null;
            _images.Clear();
            MainPlayer.Device = null;
            while (_capDevice.IsRunning)
            {
                Thread.Sleep(100);
            }
            _capDevice        = new CapDevice(CapDevice.DeviceMonikers[0].MonikerString);
            MainPlayer.Device = _capDevice;

            if (isEnabled)
            {
                _dispatcherTimer.Start();
            }
        }
示例#3
0
        public MainWindow()
        {
            InitializeComponent();
            MainPlayer.Flip   = true;
            _capDevice        = new CapDevice(CapDevice.DeviceMonikers[0].MonikerString);
            MainPlayer.Device = _capDevice;

            _dispatcherTimer.Interval = TimeSpan.FromMilliseconds(150);
            _dispatcherTimer.Tick    += dispatcherTimer_Tick;

            string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            _dataPath = Path.Combine(directoryName, "Data");

            if (!Directory.Exists(_dataPath))
            {
                Directory.CreateDirectory(_dataPath);
            }

            var hotSpotsFileName = Path.Combine(directoryName, "hotspots.txt");

            if (File.Exists(hotSpotsFileName))
            {
                using (StreamReader reader = new StreamReader(hotSpotsFileName))
                {
                    while (!reader.EndOfStream)
                    {
                        string   line    = reader.ReadLine();
                        string[] data    = line.Split(',');
                        Rect     rect    = new Rect(Convert.ToDouble(data[0]), Convert.ToDouble(data[1]), Convert.ToDouble(data[2]), Convert.ToDouble(data[3]));
                        HotSpot  hotSpot = new HotSpot(rect);
                        AddHotSpot(hotSpot);
                    }
                }
            }

            this.Closed += MainWindow_Closed;
        }