Exemple #1
0
        /// <summary>
        /// Window Loaded
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Log.InfoFormat("Window Loaded");

            string bgUrl = "background/background.jpg";

            if (File.Exists(bgUrl))
            {
                Uri         uri = new Uri(bgUrl, UriKind.RelativeOrAbsolute);
                BitmapImage bg  = new BitmapImage(uri);
                this.Background = new ImageBrush(bg);
            }
            else
            {
                Log.WarnFormat("不存在背景图像:{0}", bgUrl);
            }

            int rotation = 0;

            if (ConfigurationManager.AppSettings["CaptureDeviceRotation"] != null)
            {
                rotation = Convert.ToInt32(ConfigurationManager.AppSettings["CaptureDeviceRotation"]);
            }

            CaptureDevice = new AForgeCaptureDevice(CaptureDeviceName, ImageCapture, (Rotation)rotation);
            CaptureDevice.SetFrameResolution(FrameSize, FrameRectangle);
            CaptureDevice.Start();
        }
Exemple #2
0
        /// <inheritdoc/>
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            if (CaptureDevice != null)
            {
                CaptureDevice.Dispose();
                CaptureDevice = null;
            }

            if (TcpServer != null)
            {
                HPSocketExtension.DisposeServer(TcpServer);
                TcpServer = null;
            }
            if (UdpServer != null)
            {
                HPSocketExtension.DisposeServer(UdpServer);
                UdpServer = null;
            }

            Log.InfoFormat("Window Closing");
        }