/// <summary> /// Initializes the D3DRenderer control /// </summary> private void InitializeD3DVideo() { if (m_videoImage != null) { return; } /* Create our Image and it's D3DImage source */ m_videoImage = new Image(); m_videoImage.Name = "videoImage"; m_videoImage.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.Fant); RenderOptions.SetBitmapScalingMode(m_videoImage, BitmapScalingMode.Fant); m_d3dImage = new D3DImage(); m_d3dImage.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.Fant); RenderOptions.SetBitmapScalingMode(m_d3dImage, BitmapScalingMode.Fant); /* We hook into this event to handle when a D3D device is lost */ D3DImage.IsFrontBufferAvailableChanged += D3DImageIsFrontBufferAvailableChanged; /* Set our default stretch value of our video */ m_videoImage.Stretch = (Stretch)StretchProperty.DefaultMetadata.DefaultValue; m_videoImage.StretchDirection = (StretchDirection)StretchProperty.DefaultMetadata.DefaultValue; /* Our source of the video image is the D3DImage */ m_videoImage.Source = D3DImage; /* Register the Image as a visual child */ //Grid g = new Grid(); //g.Margin = new Thickness(0); //g.Children.Add(m_videoImage); //var l = new TextBlock(); //l.HorizontalAlignment = HorizontalAlignment.Left; //l.VerticalAlignment = VerticalAlignment.Top; //l.SetValue(Panel.ZIndexProperty, 1000); //l.Width = 200; //l.Height = 30; //l.Background = Brushes.White; //l.Foreground = Brushes.Black; //l.FontFamily = new FontFamily("Arial"); //l.FontSize = 16; //var b = new Binding("ActualWidth"); //b.Source = m_videoImage; //BindingOperations.SetBinding(l, TextBlock.TextProperty, b); //g.Children.Add(l); //grid = g; AddVisualChild(m_videoImage); ///* Bind the horizontal alignment dp of this control to that of the video image */ //var horizontalAlignmentBinding = new Binding("HorizontalAlignment") { Source = this }; //m_videoImage.SetBinding(HorizontalAlignmentProperty, horizontalAlignmentBinding); ///* Bind the vertical alignment dp of this control to that of the video image */ //var verticalAlignmentBinding = new Binding("VerticalAlignment") { Source = this }; //m_videoImage.SetBinding(VerticalAlignmentProperty, verticalAlignmentBinding); ToggleDeeperColorEffect((bool)DeeperColorProperty.DefaultMetadata.DefaultValue); }