WebCam - draw a border

1 Answer 27 Views
WebCam
David
Top achievements
Rank 1
Iron
Iron
David asked on 30 Mar 2022, 10:17 PM

We would like to draw a red border around the camera stream while video is recording. I tried attaching ot the StartRecording event and modifying the UI internals:

 ((Telerik.WinControls.UI.RadWebCamElement)(radWebCam1.GetChildAt(1))).DrawBorder = true;
 ((Telerik.WinControls.UI.LightVisualElement)(radWebCam1.GetChildAt(2))).BorderBoxStyle = Telerik.WinControls.BorderBoxStyle.SingleBorder;
 ((Telerik.WinControls.UI.LightVisualElement)(radWebCam1.GetChildAt(2))).BorderWidth = 8F;
 ((Telerik.WinControls.UI.LightVisualElement)(radWebCam1.GetChildAt(2))).BorderColor = System.Drawing.Color.Red;

 

and it sortof works.. the border reduces size, and isn;t shown at the bottom. I have the 

 radWebCam1.ControlPanelHeight = 0;

because we are adding custom controls.  but when we StopRecording and I execute

((Telerik.WinControls.UI.RadWebCamElement)(radWebCam1.GetChildAt(1))).DrawBorder = false;

the border is not hidden.

The camera control is docked on teh form next to a collapsible panel, If I expand the panel, the border goes to full size.  But it still doesn't hide when I set DraBorder to false.

 

 

1 Answer, 1 is accepted

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

Hello, David,

According to the provided information, it seems that the DrawBorder property is set to true/false for one element but the border color and width are specified for another element:

I would recommend you to use the following approach accessing the public properties instead of accessing the children at the elements hierarchy:

        private void radWebCam1_RecordingEnded(object sender, EventArgs e)
        {
          this.radWebCam1.CameraBorderElement.BorderWidth = 0F;
        }

        private void radWebCam1_RecordingStarted(object sender, CancelEventArgs e)
        { 
            this.radWebCam1.CameraBorderElement.BorderBoxStyle = Telerik.WinControls.BorderBoxStyle.SingleBorder;
            this.radWebCam1.CameraBorderElement.BorderWidth = 8F;
            this.radWebCam1.CameraBorderElement.BorderColor = System.Drawing.Color.Red;
        }

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
commented on 06 Apr 2022, 03:40 PM

I'm seeing some weird behavior that Iwould like to fix. When we add teh border it does draw full size, but then it appears that the video area overlays it. https://www.screencast.com/t/fV91XOuD0yt  I think I need to adjust some padding or margin somewhere?

 

Also, we are setting the control panel height to zero, and that seems to be hiding the bottom border as well.

Dess | Tech Support Engineer, Principal
Telerik team
commented on 07 Apr 2022, 05:58 AM

Hello, David,

Feel free to set the ControlPanelHeight property to the CameraBorderElement.BorderWidth value.

After the recording is started:

       private void radWebCam1_RecordingStarted(object sender, CancelEventArgs e)
        { 
            this.radWebCam1.CameraBorderElement.BorderBoxStyle = Telerik.WinControls.BorderBoxStyle.SingleBorder;
            this.radWebCam1.CameraBorderElement.BorderWidth = 8F;
            this.radWebCam1.CameraBorderElement.BorderColor = System.Drawing.Color.Red; 
            this.radWebCam1.ControlPanelHeight = (int)this.radWebCam1.CameraBorderElement.BorderWidth;
        }

When the recording is stopped:

        private void radWebCam1_RecordingEnded(object sender, EventArgs e)
        {
            this.radWebCam1.CameraBorderElement.BorderWidth = 0F;
            this.radWebCam1.ControlPanelHeight = (int)this.radWebCam1.CameraBorderElement.BorderWidth;
        }

 

 

David
Top achievements
Rank 1
Iron
Iron
commented on 08 Apr 2022, 09:07 PM

OK, that works, but I am still seeing a small problem with the width of the border and the overlaid video streaming area. I have captured a quick video to show the problem. It looks like only 1 or 2 pixels of the border are showing on top left and right, but if I change the layout (for example opening an adjacent collapsible panel) then the full border is dispalyed.

https://www.screencast.com/t/4XOiTep7EB

 

David
Top achievements
Rank 1
Iron
Iron
commented on 08 Apr 2022, 09:14 PM

never mind!

if I change the controlPanelheight after setting the border, it all draws as it should. I do think there s some issue there where it needs to force the camera to re-draw or something, but my specifc issue is solved

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