webcam settings dialog

1 Answer 114 Views
WebCam
David
Top achievements
Rank 1
Iron
Iron
Iron
David asked on 22 Mar 2022, 03:53 AM

Hello,

is it possible to modify the presentation of the dettings in teh WebCam Settings dialog? My client would like to have the settings shown in a collapsible panel on the form, they do not like the dialog window. What options do we have for overriding this UI?

 

thanks!

-David

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Mar 2022, 01:59 PM

Hello, David,

The settings dialog that RadWebCam offers is designed to be displayed as a standalone form. Even though it is possible to host a Form in another control, the CameraSettingsDialog relies on the internal MediaSettingsViewModel and the internal WebCamPresenter. It is specifically implemented in such a way that we don't have public access to these fields and classes. 

The possible solution that I can suggest is to simulate showing the dialog so we can access the initialized dialog and add the respective controls to the collapsible panel. I have prepared a sample project for your reference. Please give it a try and see how it works for your scenario:  

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

David
Top achievements
Rank 1
Iron
Iron
Iron
commented on 24 Mar 2022, 10:25 PM

Ok, we can work with that. Is there a way to move the panel where the buttons are hosted to the right side? I've looked at all the properties and cannot see anything.
Dess | Tech Support Engineer, Principal
Telerik team
commented on 25 Mar 2022, 09:16 AM

Hello, David,

You can move the RadCollapsiblePanel in the designer and put it on the right side of RadWebCam. Then, set the radCollapsiblePanel.ExpandDirection property to Right:

David
Top achievements
Rank 1
Iron
Iron
Iron
commented on 25 Mar 2022, 03:27 PM

Sorry, I meant the camera controls - snapshot buttons, settings button - but I think I found that answer in a previous forum post.
David
Top achievements
Rank 1
Iron
Iron
Iron
commented on 28 Mar 2022, 05:30 AM

We have used the sample you gave us and it does show the controls in the panel, but when I try to adjust any of the camera settings we get this error. (we also get this error when running the sample project)

   at Telerik.Windows.MediaFoundation.BaseMediaFoundationPresenter.SettingsViewModel_ItemPropertyChanged(Object sender, ItemPropertyChangedEventArgs e)
   at Telerik.Windows.MediaFoundation.MediaSettingsViewModel.CollectionItemPropertyChanged(Object sender, ItemPropertyChangedEventArgs e)
   at Telerik.Windows.MediaFoundation.SettingsViewModelBase.OnItemPropertyChanged(ItemPropertyChangedEventArgs e)
   at Telerik.Windows.MediaFoundation.SettingsViewModelBase.CollectionItemPropertyChanged(Object sender, PropertyChangedEventArgs e)
   at Telerik.Windows.MediaFoundation.SettingItemModelBase.OnPropertyChanged(String name)
   at Telerik.Windows.MediaFoundation.SettingItemModelBase.set_Value(Int32 value)
   at Telerik.WinControls.UI.CameraSetting.RadTrackBarValue_Scroll(Object sender, ScrollEventArgs e)
   at System.Windows.Forms.ScrollableControl.OnScroll(ScrollEventArgs se)
   at Telerik.WinControls.UI.RadTrackBar.trackBarElement_Scroll(Object sender, ScrollEventArgs e)
   at Telerik.WinControls.UI.RadTrackBarElement.OnScroll(ScrollEventArgs e)
   at Telerik.WinControls.UI.RadTrackBarElement.FireScrollEvent(Int32 oldValue)
   at Telerik.WinControls.UI.TrackBarBodyElement.PerformMouseClick(MouseEventArgs e)
   at Telerik.WinControls.UI.TrackBarBodyElement.OnMouseDown(MouseEventArgs e)
   at Telerik.WinControls.RadElement.OnCLREventsRise(RoutedEventArgs args)
   at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
   at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
   at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
   at Telerik.WinControls.RadElement.DoMouseDown(MouseEventArgs e)
   at Telerik.WinControls.RadElement.CallDoMouseDown(MouseEventArgs e)
   at Telerik.WinControls.ComponentInputBehavior.OnMouseDown(MouseEventArgs e)
   at Telerik.WinControls.RadControl.OnMouseDown(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at Telerik.WinControls.RadControl.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)
   at Interop.User32.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.Interop.Mso.IMsoComponentManager.FPushMessageLoop(UIntPtr dwComponentID, msoloop uReason, Void* pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(msoloop reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(msoloop reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at DuncanCamApp2.Program.Main() in C:\Users\david\source\repos\DuncanCamApp2\InitialConcepts-Camera\master\DuncanCamApp2\Program.cs:line 17
Dess | Tech Support Engineer, Principal
Telerik team
commented on 28 Mar 2022, 10:00 AM

Hello, David,

I believe that the following forum post would help you for achieving the custom requirement with camera buttons on the right side:
https://www.telerik.com/forums/custom-buttons-for-webcam#5393811 

As to the error message, I was unable to observe similar behavior on my end. Please refer to the attached gif file illustrating the behavior on my end with the specified version.

I have attached my sample project. Please give it a try and see how it works on your end. Am I missing something? Could you please specify the exact steps how to reproduce the problem? Thank you in advance. 

I am looking forward to your reply.
David
Top achievements
Rank 1
Iron
Iron
Iron
commented on 28 Mar 2022, 05:05 PM

I have found that the erorr happens only if we call radWebCam1.Initialize. We are setting auto-start to False, callign .Initialize to set the device and format (no audio), and then calling .Start.  The camera starts, but if we then click on any of the slider controls we get that error.  If we do not call .Initialize and let it default to the internal camera (this is currently the only camera I have attached) and default format, it works without error.
David
Top achievements
Rank 1
Iron
Iron
Iron
commented on 29 Mar 2022, 03:48 PM

After some experimentation, I found that I need to manipulate the settings controls AFTER calling .Initialize on teh camera control, now it is working. I wil be connecting a second camera later today and trying to change those settings so hopefully it is all smooth sailing now.
Dess | Tech Support Engineer, Principal
Telerik team
commented on 30 Mar 2022, 12:02 PM

Hello, David,

As you have already found out, if the AutoStart property is set to false, it is necessary to initialize the camera with a specific device:
https://docs.telerik.com/devtools/winforms/controls/webcam/connect-to-camera-device

Then, start the camera and call the ShowSettingsDialog method to force creating the settings controls. The appropriate way to do it is the form's Load event:

        public RadForm1()
        {
            InitializeComponent();
            this.radWebCam1.SettingsDialogShowing += radWebCam1_SettingsDialogShowing; 
            this.radWebCam1.AutoStart = false; 

        }
        private void RadForm1_Load(object sender, EventArgs e)
        {
            ReadOnlyCollection<MediaFoundationDeviceInfo> videoDevices = RadWebCam.GetVideoCaptureDevices();
            ReadOnlyCollection<MediaFoundationVideoFormatInfo> videoFormats = RadWebCam.GetVideoFormats(videoDevices[0], true);
            ReadOnlyCollection<MediaFoundationDeviceInfo> audioDevices = RadWebCam.GetAudioCaptureDevices();
            radWebCam1.Initialize(videoDevices[0], videoFormats[9], null);

            radWebCam1.Start();
            this.radWebCam1.ShowSettingsDialog();
            this.radWebCam1.WebCamElement.SettingsButton.Visibility = ElementVisibility.Collapsed;

        } 

 
Tags
WebCam
Asked by
David
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or