Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
I was following this tutorial thing (the WPF: Webcam Control Article) on a WPF Webcam control and did the following: I took the c# code and converted it to vb.net using a code converter and entered that as my code. However, I cannot view the designer because "value does not fall withing expected range line 0 column 0". Does anyone know how to fix this? Supposedly I have two contradicting terms someplace but I am very new to this and do not recognize them. If you could help that would be fantastic!
 
Here is a piece of the coding:
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Navigation
Imports System.Windows.Shapes
Imports Microsoft.Expression.Encoder.Devices
Imports WebcamControl
Imports System.IO
Imports System.Drawing.Imaging
 
Namespace WPF_Webcam
    ''' <summary>
    ''' Interaction logic for MainWindow.xaml
    ''' </summary>
    Partial Public Class MainWindow
        Inherits Window
        Private webCamCtrl As Webcam
 
        Public Sub New()
            InitializeComponent()
 
            webCamCtrl = New Webcam()
 
            ' Bind the Video and Audio device properties of the
            ' Webcam control to the SelectedValue property of 
            ' the necessary ComboBox.
            Dim bndg_1 As New Binding("SelectedValue")
            bndg_1.Source = VidDvcsComboBox
            webCamCtrl.SetBinding(Webcam.VideoDeviceProperty, bndg_1)
Posted 16-Nov-12 4:33am
Edited 16-Nov-12 5:14am
Tim Corey81.5K
v3
Comments
Christian Graus at 16-Nov-12 10:39am
   
Being 'new to this', you should learn VB.NET or C#, not play with code samples you don't understand on the net, let alone learning WPF. What line gives the error ? What does the C# code look like ?
FearfulSymmetry at 16-Nov-12 10:52am
   
You are right that I should learn VB.NET or C# but I have no where to learn it. No programming classes are offered at my school and I have searched the net over for help but have found no straight answers. If you know where I can go or have any sources that would help, please share. If not, here is the C# code. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Microsoft.Expression.Encoder.Devices; using WebcamControl; using System.IO; using System.Drawing.Imaging; namespace WPF_Webcam { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { private Webcam webCamCtrl; public MainWindow() { InitializeComponent(); webCamCtrl = new Webcam(); // Bind the Video and Audio device properties of the // Webcam control to the SelectedValue property of // the necessary ComboBox. Binding bndg_1 = new Binding("SelectedValue"); bndg_1.Source = VidDvcsComboBox; webCamCtrl.SetBinding(Webcam.VideoDeviceProperty, bndg_1); Binding bndg_2 = new Binding("SelectedValue"); bndg_2.Source = AudDvcsComboBox; webCamCtrl.SetBinding(Webcam.AudioDeviceProperty, bndg_2); // Create directory for saving video files. string vidPath = @"C:\VideoClips"; if (Directory.Exists(vidPath) == false) { Directory.CreateDirectory(vidPath); } // Create directory for saving image files. string imgPath = @"C:\WebcamSnapshots"; if (Directory.Exists(imgPath) == false) { Directory.CreateDirectory(imgPath); } // Set some properties of the Webcam control webCamCtrl.VideoDirectory = vidPath; webCamCtrl.VidFormat = VideoFormat.wmv; webCamCtrl.ImageDirectory = imgPath; webCamCtrl.PictureFormat = ImageFormat.Jpeg; // Set the Webcam control as the ContentControl's content. ContentControl1.Content = webCamCtrl; // Find a/v devices connected to the machine. FindDevices(); VidDvcsComboBox.SelectedIndex = 0; AudDvcsComboBox.SelectedIndex = 0; } private void FindDevices() { var vidDevices = EncoderDevices.FindDevices(EncoderDeviceType.Video); var audDevices = EncoderDevices.FindDevices(EncoderDeviceType.Audio); foreach (EncoderDevice dvc in vidDevices) { VidDvcsComboBox.Items.Add(dvc.Name); } foreach (EncoderDevice dvc in audDevices) { AudDvcsComboBox.Items.Add(dvc.Name); } } private void StartButton_Click(object sender, RoutedEventArgs e) { try { // Display webcam video on control. webCamCtrl.StartCapture(); } catch (Microsoft.Expression.Encoder.SystemErrorException ex) { MessageBox.Show("Device is in use by another application"); } } private void EndButton_Click(object sender, RoutedEventArgs e) { // Stop the display of webcam video. webCamCtrl.StopCapture(); } private void RecordButton_Click(object sender, RoutedEventArgs e) { // Start recording of webcam video to harddisk. webCamCtrl.StartRecording(); } private void StopRecord
Christian Graus at 16-Nov-12 10:57am
   
And yet here you are on a website full of programming articles and people willing to help. You should use these resources, but set yourself sensible goals. I think everyone should start by writing a basic calculator that works on the console, for example.
FearfulSymmetry at 16-Nov-12 11:09am
   
Ok! I will try writing one. Thanks for the advice.
Christian Graus at 16-Nov-12 11:12am
   
Don't forget, we will love to help if you have a problem and ask questions that show you're trying to do it yourself and just need help. A forum like this is really an awesome chance to learn, if you use it right.
Sergey Alexandrovich Kryukov at 16-Nov-12 12:03pm
   
Who told you that the technology and even science is learned in the class? Most important thing in college or university is the examination, because many students cannot tell the difference between their real knowledge and illusory knowledge, and because, without examinations, there is no a reference point for comparing the skills. Everything else can be learned by books and by practicing, and these days also with Internet. As to examinations, you can instead have your colleagues review your work... I can tell you more: nearly all decent software developers I knew are self-taught. They learned mathematics and other fundamental things in universities, but computer science and practice mostly by themselves. Key thing here is deep interest, hard requirements you apply to yourself, hard work and the habit to think in depth... --SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Shai Vashdi 963
1 Tadit Dash 270
2 Sergey Alexandrovich Kryukov 250
3 OriginalGriff 233
4 Peter Leow 180
0 Sergey Alexandrovich Kryukov 9,435
1 OriginalGriff 5,498
2 Peter Leow 4,230
3 Maciej Los 3,540
4 Abhinav S 3,353


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 16 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid