当前位置: 首页>>代码示例>>C#>>正文


C# VideoBrush.SetSource方法代码示例

本文整理汇总了C#中System.Windows.Media.VideoBrush.SetSource方法的典型用法代码示例。如果您正苦于以下问题:C# VideoBrush.SetSource方法的具体用法?C# VideoBrush.SetSource怎么用?C# VideoBrush.SetSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.VideoBrush的用法示例。


在下文中一共展示了VideoBrush.SetSource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NullSource

		public void NullSource ()
		{
			VideoBrush vb = new VideoBrush ();
			Assert.Throws<NullReferenceException> (delegate {
				vb.SetSource ((MediaElement) null);
			}, "MediaElement");
			Assert.Throws<NullReferenceException> (delegate {
				vb.SetSource ((CaptureSource) null);
			}, "CaptureSource");
		}
开发者ID:dfr0,项目名称:moon,代码行数:10,代码来源:VideoBrushTest.cs

示例2: OnNavigatedTo

      protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
      {
         base.OnNavigatedTo(e);

         // Delayed due to Camera init bug in WP71 SDK Beta 2
         // See http://forums.create.msdn.com/forums/p/85830/516843.aspx
         Dispatcher.BeginInvoke(() =>
                                {

                                   // Initialize the webcam
                                   photoCamera = new PhotoCamera();
                                   photoCamera.Initialized += PhotoCameraInitialized;
                                   CameraButtons.ShutterKeyHalfPressed += PhotoCameraButtonHalfPress;
                                   isInitialized = false;
                                   isDetecting = false;

                                   // Fill the Viewport Rectangle with the VideoBrush
                                   var vidBrush = new VideoBrush();
                                   vidBrush.SetSource(photoCamera);
                                   Viewport.Fill = vidBrush;

                                   // Start timer
                                   dispatcherTimer = new DispatcherTimer {Interval = TimeSpan.FromMilliseconds(50)};
                                   dispatcherTimer.Tick += (sender, e1) => Detect();
                                   dispatcherTimer.Start();
                                });
      }
开发者ID:amoldeshpande,项目名称:slartoolkit,代码行数:27,代码来源:MainPage.xaml.cs

示例3: Load

        void Load()
        {
            if (CaptureDeviceConfiguration.AllowedDeviceAccess ||
                            CaptureDeviceConfiguration.RequestDeviceAccess())
            {
                var devices = CaptureDeviceConfiguration.GetAvailableVideoCaptureDevices();

                foreach (var device in devices)
                {
                    var videoItem = new VideoItem();
                    videoItem.Name = device.FriendlyName;

                    var source = new CaptureSource();
                    source.VideoCaptureDevice = device;
                    var videoBrush = new VideoBrush();
                    videoBrush.SetSource(source);
                    videoItem.Brush = videoBrush;
                    this.sources.Add(source);
                    this.sourceItems.Add(videoItem);
                }

                this.videoItems.ItemsSource = this.sourceItems;
                this.StartAll();
            }
        }
开发者ID:kindohm,项目名称:silverlight-app-does-what,代码行数:25,代码来源:MainPage.xaml.cs

示例4: StartWebCam

        public void StartWebCam()
        {
            _captureSource = new CaptureSource();
            _captureSource.CaptureImageCompleted += new EventHandler<CaptureImageCompletedEventArgs>(_captureSource_CaptureImageCompleted);
            _captureSource.VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();

            try
            {
                // Start capturing
                if (_captureSource.State != CaptureState.Started)
                {
                    // Create video brush and fill the WebcamVideo rectangle with it
                    var vidBrush = new VideoBrush();
                    vidBrush.Stretch = Stretch.Uniform;
                    vidBrush.SetSource(_captureSource);
                    WebcamVideo.Fill = vidBrush;

                    // Ask user for permission and start the capturing
                    if (CaptureDeviceConfiguration.RequestDeviceAccess())
                    {
                        _captureSource.Start();
                    }
                }
            }
            catch (InvalidOperationException)
            {
                InfoTextBox.Text = "Web Cam already started - if not, I can't find it...";
            }
            catch (Exception)
            {
                InfoTextBox.Text = "Could not start web cam, do you have one?";
            }
        }
开发者ID:al-main,项目名称:CloudyBank,代码行数:33,代码来源:ImageTaker.xaml.cs

示例5: MainPage_Loaded

        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            
            captureSource = new CaptureSource
                                {
                                    VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice()
                                };

            var videoBrush = new VideoBrush();
            videoBrush.SetSource(captureSource);
            Viewport.Fill = videoBrush;

            markerDetector = new CaptureSourceMarkerDetector();
            var marker = Marker.LoadFromResource("Bola.pat", 64, 64, 80);
            markerDetector.Initialize(captureSource, 1d, 4000d, marker);

            markerDetector.MarkersDetected += (obj, args) =>
                                                  {
                                                      Dispatcher.BeginInvoke(() =>
                                                                                 {
                                                                                     var results = args.DetectionResults;
                                                                                     if (results.HasResults)
                                                                                     {
                                                                                         var centerAtOrigin =
                                                                                             Matrix3DFactory.
                                                                                                 CreateTranslation(
                                                                                                     -Imagem.ActualWidth*
                                                                                                     0.5,
                                                                                                     -Imagem.
                                                                                                          ActualHeight*
                                                                                                     0.5, 0);
                                                                                         var scale =
                                                                                             Matrix3DFactory.CreateScale
                                                                                                 (0.5, -0.5, 0.5);
                                                                                         var world = centerAtOrigin*
                                                                                                     scale*
                                                                                                     results[0].
                                                                                                         Transformation;
                                                                                         var vp =
                                                                                             Matrix3DFactory.
                                                                                                 CreateViewportTransformation
                                                                                                 (Viewport.ActualWidth,
                                                                                                  Viewport.ActualHeight);
                                                                                         var m =
                                                                                             Matrix3DFactory.
                                                                                                 CreateViewportProjection
                                                                                                 (world,
                                                                                                  Matrix3D.Identity,
                                                                                                  markerDetector.
                                                                                                      Projection, vp);
                                                                                         Imagem.Projection =
                                                                                             new Matrix3DProjection
                                                                                                 {ProjectionMatrix = m};
                                                                                     }
                                                                                 });
                                                  };
        }
开发者ID:joaolimiere,项目名称:Artigos,代码行数:57,代码来源:MainPage.xaml.cs

示例6: UserControl_Loaded

      private void UserControl_Loaded(object sender, RoutedEventArgs e)
      {
         // Initialize the webcam
         captureSource = new CaptureSource();
         captureSource.VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();

         // Fill the Viewport Rectangle with the VideoBrush
         var vidBrush = new VideoBrush();
         vidBrush.SetSource(captureSource);
         Viewport.Fill = vidBrush;
      }
开发者ID:amoldeshpande,项目名称:slartoolkit,代码行数:11,代码来源:MainPage.xaml.cs

示例7: MainPage

        // Constructor
        public MainPage()
        {
            InitializeComponent();
            c = new CaptureSource();
            c.VideoCaptureDevice = CaptureDeviceConfiguration.GetAvailableVideoCaptureDevices().First();

            var vidBrush = new VideoBrush();
            vidBrush.SetSource(c);
            ViewPort.Fill = vidBrush;         
                        
        }
开发者ID:nitzo,项目名称:MegaStarz,代码行数:12,代码来源:MainPage.xaml.cs

示例8: LoadCamera

 public void LoadCamera(ICameraCaptureDevice camera)
 {
     if (VideoBrush == null && camera != null)
     {
         RunOnUIThread(() =>
         {
             VideoBrush = new VideoBrush();
             VideoBrush.Stretch = Stretch.Uniform;
             VideoBrush.SetSource(camera);
             Rectangle.Fill = VideoBrush;
         });
     }
 }
开发者ID:QuickBlox,项目名称:quickblox-dotnet-sdk,代码行数:13,代码来源:VideoRenderProvider.cs

示例9: ConnectWebcamToDevice

        private void ConnectWebcamToDevice()
        {
            if (!CaptureDeviceConfiguration.AllowedDeviceAccess)
            {
                if(!CaptureDeviceConfiguration.RequestDeviceAccess())
                    return;
            }

            _cam.VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
            var brush = new VideoBrush {Stretch = Stretch.Uniform};
            brush.SetSource(_cam);

            CamDisplay.Fill = brush;
        }
开发者ID:ericschultz,项目名称:BarcodeCapturer,代码行数:14,代码来源:MainPage.xaml.cs

示例10: GetVideoBrush

 /// <summary>
 /// 获得VideoBrush对象
 /// </summary>
 /// <returns></returns>
 public VideoBrush GetVideoBrush()
 {
     VideoBrush vBrush = new VideoBrush();
     if (_vcDevice != null)
     {
         _cSource.VideoCaptureDevice = _vcDevice;
         vBrush.SetSource(_cSource);//注意,不能在这里直接开启摄像头,必须等到所有设置准备就绪
     }
     else
     {
         Console.WriteLine("尚未找到捕捉设备!请确保设备正确安装!");
     }
     return vBrush;
 }
开发者ID:hoshealee,项目名称:balabalaDemo,代码行数:18,代码来源:Camera.cs

示例11: InitializeVideoRecorder

        public void InitializeVideoRecorder()
        {
            try
            {
                //fileName = string.Format(@"\Purposecode\Video{0}.mp4", DateTime.Now.ToString("yyyyMMddHHmmss"));
                fileName = string.Format("Video{0}.mp4", DateTime.Now.ToString("yyyyMMddHHmmss"));

                if (captureSource == null)
                {
                    // Create the VideoRecorder objects.
                    captureSource = new CaptureSource();
                    fileSink = new FileSink();

                    videoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();

                    // Add eventhandlers for captureSource.
                    captureSource.CaptureFailed += new EventHandler<ExceptionRoutedEventArgs>(OnCaptureFailed);

                    // Initialize the camera if it exists on the device.
                    if (videoCaptureDevice != null)
                    {
                        // Create the VideoBrush for the viewfinder.
                        videoRecorderBrush = new VideoBrush();
                        videoRecorderBrush.SetSource(captureSource);

                        // Display the viewfinder image on the rectangle.
                        viewfinderRectangle.Fill = videoRecorderBrush;
                        StopPlaybackRecording.IsEnabled = false;
                        // Start video capture and display it on the viewfinder.
                        captureSource.Start();

                        // Set the button state and the message.
                        UpdateUI(ButtonState.Initialized, "Tap record to start recording...");
                    }
                    else
                    {
                        // Disable buttons when the camera is not supported by the device.
                        UpdateUI(ButtonState.CameraNotSupported, "Camera is not supported..");
                    }
                }

            }
            catch (Exception ex)
            {
                var test = ex.Message;
            }
        } //InitializeVideoRecorder()
开发者ID:praveenmohanmm,项目名称:PurposeColor_Bkp_Code,代码行数:47,代码来源:VideoCamera.xaml.cs

示例12: StartRecordig

        private void StartRecordig()
        {
            if (m_captureSource == null)
            {
                m_captureSource = new CaptureSource();
                m_captureSource.VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
                m_captureSource.AudioCaptureDevice = CaptureDeviceConfiguration.GetDefaultAudioCaptureDevice();

                m_sink = new FileSink();
                m_sink.CaptureSource = m_captureSource;
                m_sink.IsolatedStorageFileName = m_capturedFileName;
            }

            VideoBrush brush = new VideoBrush();
            brush.SetSource(m_captureSource);
            CameraPreview.Fill = brush;

            m_captureSource.Start();
        }
开发者ID:adirzim,项目名称:MegaStarz---WP7,代码行数:19,代码来源:KaraokePage.xaml.cs

示例13: StartCapture_Click

        private void StartCapture_Click(object sender, RoutedEventArgs e)
        {
            _captureSource.VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
            _captureSource.AudioCaptureDevice = CaptureDeviceConfiguration.GetDefaultAudioCaptureDevice();

            VideoBrush videoBrush = new VideoBrush();
            videoBrush.Stretch = Stretch.Uniform;
            videoBrush.SetSource(_captureSource);

            _videoStream = new MemoryStream();
            RiffAviFileWriter aviFileWriter = new RiffAviFileWriter(_videoStream);
            _videoSink = new BufferQueueVideoSink(aviFileWriter)
            {
                CaptureSource = _captureSource
            };

            if (CaptureDeviceConfiguration.AllowedDeviceAccess || CaptureDeviceConfiguration.RequestDeviceAccess())
                _captureSource.Start();
            Video.Fill = videoBrush;
        }
开发者ID:bkama,项目名称:presentations,代码行数:20,代码来源:MainPage.xaml.cs

示例14: displayPreview

        public void displayPreview(String camName, Rectangle videoPanel)
        {
            // create a new VideoBrush
            videoBrush = null;
            videoBrush = new VideoBrush();
            videoBrush.Stretch = Stretch.Uniform;

            // connect the new VideoBrush to the new device
            foreach (Webcam wc in webcams)
            {
                if (wc.toString().Equals(camName))
                {
                    videoBrush.SetSource(wc.getSrc()());
                    break;
                }
            }

            // connect the VideoPanel to the new VideoBrush
            videoPanel.Fill = videoBrush;
        }
开发者ID:brettcrowell,项目名称:wcSilverlight,代码行数:20,代码来源:Lapse.cs

示例15: InitializeVideoRecorder

        private void InitializeVideoRecorder()
        {
            if (_captureSource == null)
            {
                _captureSource = new CaptureSource();
                _fileSink = new FileSink();

                _videoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
                _captureSource.CaptureFailed += OnCaptureSourceOnCaptureFailed;
                _captureSource.CaptureImageCompleted += CaptureSourceOnCaptureImageCompleted;

                if (_videoCaptureDevice != null)
                {
                    _videoBrush = new VideoBrush();
                    _videoBrush.SetSource(_captureSource);

                    ViewFinderRectangle.Fill = _videoBrush;
                    _captureSource.Start();
                }
            }
        }
开发者ID:Trifectgaming,项目名称:PantsOnFire,代码行数:21,代码来源:MainPage.xaml.cs


注:本文中的System.Windows.Media.VideoBrush.SetSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。