Click here to Skip to main content
15,912,069 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Design Question Pin
Mycroft Holmes19-Apr-20 12:20
professionalMycroft Holmes19-Apr-20 12:20 
GeneralRe: Design Question Pin
Kevin Marois19-Apr-20 14:09
professionalKevin Marois19-Apr-20 14:09 
GeneralRe: Design Question Pin
Mycroft Holmes20-Apr-20 12:20
professionalMycroft Holmes20-Apr-20 12:20 
QuestionMVVM: DataGrid Cell BeginEdit Pin
Kevin Marois13-Apr-20 9:10
professionalKevin Marois13-Apr-20 9:10 
AnswerRe: MVVM: DataGrid Cell BeginEdit Pin
Richard Deeming14-Apr-20 0:36
mveRichard Deeming14-Apr-20 0:36 
GeneralRe: MVVM: DataGrid Cell BeginEdit Pin
Kevin Marois14-Apr-20 6:15
professionalKevin Marois14-Apr-20 6:15 
GeneralRe: MVVM: DataGrid Cell BeginEdit Pin
Richard Deeming14-Apr-20 6:28
mveRichard Deeming14-Apr-20 6:28 
GeneralRe: MVVM: DataGrid Cell BeginEdit Pin
Kevin Marois14-Apr-20 6:39
professionalKevin Marois14-Apr-20 6:39 
QuestionProblem in designer while creating a new window in a WPF project in Visual Studio 2010. Pin
priyamtheone13-Apr-20 3:38
priyamtheone13-Apr-20 3:38 
AnswerRe: Problem in designer while creating a new window in a WPF project in Visual Studio 2010. Pin
Gerry Schmitz13-Apr-20 6:59
mveGerry Schmitz13-Apr-20 6:59 
GeneralRe: Problem in designer while creating a new window in a WPF project in Visual Studio 2010. Pin
priyamtheone14-Apr-20 1:36
priyamtheone14-Apr-20 1:36 
QuestionDP Firing Order Pin
Kevin Marois30-Mar-20 7:43
professionalKevin Marois30-Mar-20 7:43 
AnswerRe: DP Firing Order Pin
Dave Simon31-Mar-20 9:35
Dave Simon31-Mar-20 9:35 
QuestionHow can a class from a class library manipulate XAML/UI Pin
httitb30-Mar-20 3:32
httitb30-Mar-20 3:32 
AnswerRe: How can a class from a class library manipulate XAML/UI Pin
Gerry Schmitz30-Mar-20 8:19
mveGerry Schmitz30-Mar-20 8:19 
GeneralRe: How can a class from a class library manipulate XAML/UI Pin
httitb30-Mar-20 8:31
httitb30-Mar-20 8:31 
QuestionPrism doesn't load all modules in the ModulePath Pin
hapy71018-Mar-20 16:39
hapy71018-Mar-20 16:39 
QuestionInstaller Project Problem Pin
Kevin Marois13-Mar-20 13:08
professionalKevin Marois13-Mar-20 13:08 
AnswerRe: Installer Project Problem Pin
Mycroft Holmes14-Mar-20 12:17
professionalMycroft Holmes14-Mar-20 12:17 
GeneralRe: Installer Project Problem Pin
Kevin Marois16-Mar-20 6:36
professionalKevin Marois16-Mar-20 6:36 
AnswerRe: Installer Project Problem Pin
Richard Deeming16-Mar-20 9:37
mveRichard Deeming16-Mar-20 9:37 
GeneralRe: Installer Project Problem Pin
Kevin Marois16-Mar-20 10:57
professionalKevin Marois16-Mar-20 10:57 
GeneralRe: Installer Project Problem Pin
Mycroft Holmes16-Mar-20 11:05
professionalMycroft Holmes16-Mar-20 11:05 
QuestionAForge VideoSourcePlayer Pin
Kevin Marois11-Mar-20 13:56
professionalKevin Marois11-Mar-20 13:56 
I'm trying to get the AForge VideoSourcePlayer to work in a WPF app. It's a WinForms control hosted in a WindowsFormsHost. I can't get this to work ina WinForms app either, but I'm targeting WPF in the end.

XAML
<Grid>

<pre>
<Grid.RowDefinitions>
    <RowDefinition Height="Auto"/>
    <RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
    <ColumnDefinition Width="Auto"/>
    <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>

<Button Grid.Row="0" 
        Grid.Column="0"
        x:Name="connectBt"
        Height="32"
        Width="100"
        Margin="10,0,2,0"
        Click="ConnectBt_Click"
        Content="Connect"/>

<Button Grid.Row="0" 
        Grid.Column="1"
        x:Name="disconnectBt"
        Height="32"
        Width="100"
        Margin="2,10,10,10"
        Click="DisconnectBt_Click"
        Content="Disconnect"/>

<wfi:WindowsFormsHost Grid.Row="1"
                        Grid.Column="0"
                        Grid.ColumnSpan="2">
    <aforge:VideoSourcePlayer x:Name="videoSourcePlayer" 
                                Dock="Fill"/>
</wfi:WindowsFormsHost>



Code Behind
public partial class MainWindow : Window
{
    #region CTOR
    public MainWindow()
    {
        InitializeComponent();

        this.DataContext = this;

        videoSourcePlayer.NewFrame += VideoSourcePlayer_NewFrame;
        videoSourcePlayer.Height = 320;
        videoSourcePlayer.Width = 320;
    }
    #endregion

    #region Private Methods
    private void Connect()
    {
        FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

        if (videoDevices.Count == 0)
        {
            throw new ApplicationException();
        }

        var selectdDevice = videoDevices[0].MonikerString;
        VideoCaptureDevice videoSource = new VideoCaptureDevice(selectdDevice);

        OpenVideoSource(videoSource);
    }

    private void Disconnect()
    {
        if (videoSourcePlayer.VideoSource != null)
        {
            videoSourcePlayer.SignalToStop();
            videoSourcePlayer.WaitForStop();
        }
    }

    private void HandleNewFrame(ref Bitmap image)
    {
        //TODO: handle this later
    }

    private void OpenVideoSource(IVideoSource source)
    {
        videoSourcePlayer.SignalToStop();
        videoSourcePlayer.WaitForStop();
        videoSourcePlayer.VideoSource = source;
        videoSourcePlayer.Start();
    }
    #endregion

    #region Event Handlers
    private void Window_Unloaded(object sender, RoutedEventArgs e)
    {
        Disconnect();
    }

    private void ConnectBt_Click(object sender, RoutedEventArgs e)
    {
        Connect();
    }

    private void DisconnectBt_Click(object sender, RoutedEventArgs e)
    {
        Disconnect();
    }

    private void VideoSourcePlayer_NewFrame(object sender, ref Bitmap image)
    {
        HandleNewFrame(ref image);
    }
    #endregion
}
When I run this, the VideoSourcePlayer displays "Connecting..." but i never does. The camera moniker string is "@device:pnp:\\?\usb#vid_046d&pid_082d&mi_00#6&39ab8351&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global". it's a Logitech USB camera. 
Anyone have any experience with this?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

AnswerRe: AForge VideoSourcePlayer Pin
Member 1578352130-Sep-22 19:27
Member 1578352130-Sep-22 19:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.