1

I am wonder if a PopUp can be A LayeredWindow.

I am using Encoder 4 and there is a property that allows the program to not capture layered window.

Here is my code to show the feed in a tooltip

public class MyToolTip : ToolTip
{

    protected override void OnTemplateChanged(ControlTemplate oldTemplate, ControlTemplate newTemplate)
    {
        if (newTemplate != null)
        {
            this.Visibility = Visibility.Collapsed;
            this.IsOpen = true;
            Popup popup = GetPopupFromVisualChild(this);
            if (popup != null)
            {
                popup.AllowsTransparency = false;
            }
            this.IsOpen = false;
            this.Visibility = Visibility.Visible;
        }
    }

    private static Popup GetPopupFromVisualChild(Visual child)
    {
        Visual parent = child;
        FrameworkElement visualRoot = null;
        while (parent != null)
        {
            visualRoot = parent as FrameworkElement;
            parent = VisualTreeHelper.GetParent(parent) as Visual;
        }

        Popup popup = null;
        if (visualRoot != null)
        {
            popup = visualRoot.Parent as Popup;
        }
        //popup.
        return popup;
    }
}

Wpf :

<Grid>
        <Button Width="10" Height="10" Click="Button_Click">
        <Button.ToolTip>
            <w:MyToolTip Height="500" Width="550" StaysOpen="True">
                    <WindowsFormsHost x:Name="wrapper" Margin="0,0,0,0" Background="{x:Null}">
                    <wf:Panel x:Name="previewScreen"  BackColor="Transparent"  Size="500,500" >
                            <wf:Panel.Controls>
                            <wf:Panel x:Name="PreviewScreen2" BackColor="Transparent"  Size="500,500"></wf:Panel>
                            </wf:Panel.Controls>
                            </wf:Panel>
                    </WindowsFormsHost>
            </w:MyToolTip>
        </Button.ToolTip>
    </Button>
</Grid>

This issue is Encoder 4, only accept a HandleRef for the preview window.

This is what i DO with Encoder : MediaSource is a LiveDeviceSource

if (mediaSource != null && mediaSource.PreviewWindow == null)
                mediaSource.PreviewWindow =
                        new PreviewWindow(new HandleRef(PreviewWindow.PreviewScreen2, PreviewWindow.PreviewScreen2.Handle));

What i want is to have a tooltip that shows the webcam preview but not being recorded with the screen.

If I Don't use the Popup, the feed doesn't show. Altought Encoder understand it's a LayeredWindow and doesn't record it.

If I use the popup the feed shows but it's being recorded. Somehow it's not a layeredWindow anymore even if it's in a tooltip.

Some help would be greatly apprecied, and rewarded =)

Jonathan
  • 163
  • 2
  • 4
  • 13

0 Answers0