/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Controls_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { /** * 在同屏画面与视频画面切换过程中,不显示的对象需要暂停,以防止出现背景声音在播放 */ if (ImageCapture.Visibility == Visibility.Visible) { if (CaptureDevice != null) { CaptureDevice.Start(); } if (MediaPlayer.Source != null) { MediaPlayer.Pause(); } } else { //ImageCapture.Source = null; if (CaptureDevice != null) { CaptureDevice.Stop(); } if (MediaPlayer.Source != null) { MediaPlayer.Play(); } } }
/// <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(); }