Results 1 to 17 of 17

Thread: [RESOLVED] Draw circle - Does it what I need?

  1. #1

    Thread Starter
    Hyperactive Member pourkascheff's Avatar
    Join Date
    Apr 2020
    Location
    LocalHost
    Posts
    384

    Resolved [RESOLVED] Draw circle - Does it what I need?

    Hi all.

    Consider your windows form application is going to get/generate a quite important data from serial port/ethernet and put them in different tables and you want to update and inform the user not in an audible way but to animate a large shrinking circle around the mentioned field/control.

    What my nerd lads suggested was to Graphics.Draw um, I'm not a "draw" fan to be honest. I use it only if I have to. I'm looking for something like mouse pointer indicator (Control panel provided feature) by pressing Ctrl button, but smoother. Good point about it is it's a global feature even in games it starts to locate cursor.

    What could be my options people?

  2. #2
    Frenzied Member
    Join Date
    Apr 2016
    Posts
    1,415

    Re: Draw circle - Does it what I need?

    Hi Amir,

    You can draw a circle and reduce the size with a timer? But must it be a circle? What about an error provider? You can change the icon..

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: Draw circle - Does it what I need?

    You don't have great options, especially if you rule out Draw. The only other one that comes to mind is essentially what you were suggesting. If you were to create a series of different size (or shape, or color, or some such) icons, you could swap them out. You could swap out pictures in a PictureBox, too, or perhaps just shrink the size of the PictureBox and let it deal with shrinking the image. Most images won't work well for that, though. A circle might be the best, just because a circle is a circle, whether shrunk or not.

    Personally, I use a small form shown non-modally. The color of the form changes by adding a different, small, prime number to each of the R, G, and B values. When one exceeds 255, I flip the sign, such that it is adding negative numbers until it reaches 0. I've done this a variety of times with differing styles. The result is a hypnotic flow of colors that will theoretically cycle through every color that can be displayed on a computer (eventually, though it will take a very long time). Of course, that doesn't show time to completion, or anything like that, it just shows that progress is being made.
    My usual boring signature: Nothing

  4. #4
    Frenzied Member
    Join Date
    Apr 2016
    Posts
    1,415

    Re: Draw circle - Does it what I need?

    Personally, I use a small form shown non-modally.
    Would you mind sharing that? 🙂

  5. #5

    Thread Starter
    Hyperactive Member pourkascheff's Avatar
    Join Date
    Apr 2020
    Location
    LocalHost
    Posts
    384

    Re: Draw circle - Does it what I need?

    Cause: I encountered drawing graphics with glitches/errors which requires refresh command each time (Based on an old approach which you increase/decrease circle radius, dispose previous then draw new)
    Update: I might be wrong about shrinking. Expanding circles seems much more appropriate.
    Motivation: Indicator controls are labels containing text-based symbols. Their state changing is hard to follow and not obvious as expected. (Left GIF)

    I edited a fake vide doing it on a demo form:
    Note: Circle opacity decrease as they expand. Something more like screen-recorder apps which capture your left-clicks and right-clicks with read and blue circles.
    Note: Form is just an example, actual project is crowded with such controls.

    Name:  Sequence 01.jpg
Views: 415
Size:  12.1 KB
    *Well, VBForums didn't support GIFs so you can watch it here on my google drive.
    Last edited by pourkascheff; Feb 17th, 2023 at 01:47 PM.

  6. #6
    Frenzied Member
    Join Date
    Apr 2016
    Posts
    1,415

    Re: Draw circle - Does it what I need?

    The attachment thingy on vbforums is not working. I think the people who's responsible to fix it may be too busy in the chit chat section 🤣

    Go to advanced > manage attachments and upload it from there. As it is now we can't see it.

  7. #7
    Frenzied Member
    Join Date
    Apr 2016
    Posts
    1,415

    Re: Draw circle - Does it what I need?

    The pictures are the same?

  8. #8

    Thread Starter
    Hyperactive Member pourkascheff's Avatar
    Join Date
    Apr 2020
    Location
    LocalHost
    Posts
    384

    Re: Draw circle - Does it what I need?

    Quote Originally Posted by schoemr View Post
    Hi Amir,
    Hi back.

    Quote Originally Posted by schoemr View Post
    You can draw a circle and reduce the size with a timer?
    Why you're asking? Yes I can, but I was suspected there's a system built-in could be available to does such thing.

    Quote Originally Posted by schoemr View Post
    must it be a circle?
    In an engineering way, Yes it must.
    Excluding shape case, Shaggy suggestion is also good. Color changing. The point is to achieve a sort of emphasis. But in that control-crowded form, it looks a bit psychedelic-trippy for user. Lots of hue changing. Absolute distraction and also annoying. Don't you think?

    Quote Originally Posted by schoemr View Post
    What about an error provider? You can change the icon..
    Frankly speaking, I totally forgot this control to be exist... Very good idea thanks schoemr. Gonna try it now until our mate returns with his VB.NET diaries... =))) kiddin' shaggy hiker
    Last edited by pourkascheff; Feb 17th, 2023 at 02:01 PM.

  9. #9

    Thread Starter
    Hyperactive Member pourkascheff's Avatar
    Join Date
    Apr 2020
    Location
    LocalHost
    Posts
    384

    Re: Draw circle - Does it what I need?

    Quote Originally Posted by schoemr View Post
    The pictures are the same?
    Yes the Left and Right pictures are identical but as you may already noticed, Right one attracts 100% of your concentration.

  10. #10
    Frenzied Member
    Join Date
    Apr 2016
    Posts
    1,415

    Re: Draw circle - Does it what I need?

    Yes you can change the icon of the error provider, you can make it blink at different blink rates (or not blink at all)

  11. #11
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: Draw circle - Does it what I need?

    Quote Originally Posted by schoemr View Post
    The attachment thingy on vbforums is not working. I think the people who's responsible to fix it may be too busy in the chit chat section 🤣

    Go to advanced > manage attachments and upload it from there. As it is now we can't see it.
    No, it's way higher up. This has been an issue for several years, so don't expect it to get better anytime soon. You pretty much have to use the Go Advanced option.
    My usual boring signature: Nothing

  12. #12
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: Draw circle - Does it what I need?

    Quote Originally Posted by schoemr View Post
    Would you mind sharing that? 🙂
    There are many variations. You'd think I'd make one and copy it around, but I really haven't. Here's the relevant code from one such variation:

    Code:
    Public Class Waiting_Form
    
        Private curB As Integer
        Private curR As Integer
        Private curG As Integer
        Private dirB As Integer = 1
        Private dirR As Integer = 1
        Private dirG As Integer = -1
    
        Public Sub New()
           
            InitializeComponent()
            
        End Sub
    
        Public Sub UpdateBackground()
            curB += 13 * dirB
            curR += 7 * dirR
            curG += 11 * dirG
    
            If curB > 255 Then
                curB = 255 - (curB - 255)
                dirB = -1
            ElseIf curB < 0 Then
                curB = -curB
                dirB = 1
            End If
    
            If curR > 255 Then
                curR = 255 - (curR - 255)
                dirR = -1
            ElseIf curR < 0 Then
                curR = -curR
                dirR = 1
            End If
    
            If curG > 255 Then
                curG = 255 - (curG - 255)
                dirG = -1
            ElseIf curG < 0 Then
                curG = -curG
                dirG = 1
            End If
    
            Me.BackColor = System.Drawing.Color.FromArgb(curR, curG, curB)
            Me.Refresh()
        End Sub
        
        Private Sub Waiting_Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim nRnd As New Random
    
            curB = nRnd.Next(0, 256)
            curR = nRnd.Next(0, 256)
            curG = nRnd.Next(0, 256)
           End Sub
    
    End Class
    This requires that Refresh be called on the form periodically from wherever it is shown.
    My usual boring signature: Nothing

  13. #13

    Thread Starter
    Hyperactive Member pourkascheff's Avatar
    Join Date
    Apr 2020
    Location
    LocalHost
    Posts
    384

    Re: Draw circle - Does it what I need?

    Quote Originally Posted by Shaggy Hiker View Post
    You don't have great options.
    Dear shaggy and schoemr, previous replies were massively edited. Please honor me by revisiting through them.

    Quote Originally Posted by schoemr View Post
    You can change the icon..
    I really liked this idea but three questions.

    1) Where does the red (!) symbol come from? It is an information in my case not an error (It is an errorprovider after all). I tried
    Code:
    ErrorProvider1.Icon = SystemIcons.Information
    but they are very large in size and I have to retrieve it back to error in case of an error.

    Update: I used .ToBitmap conversion but exceptions occur with the goal to resize them. But now I'm sure beside that red (!) it should be a normal notification icon.


    2) Several simultaneous errors, warnings and infos require different errorproviders on form right? Is there a way to trick it once for all?

    3) To clear the error provider I used a button. But it clears all error indicating controls. Is there a way to clear/reset them seperately?

  14. #14
    Frenzied Member
    Join Date
    Apr 2016
    Posts
    1,415

    Re: Draw circle - Does it what I need?

    You can change the icon in the properties of the error provider.

    But first get the icon you want to use. If I remember correctly (I'm unable to test atm) it should be of type .ico and 16x16.

    There are many free online websites than can convert an image to an icon for you.

    Once you have the icon that you want to use go to the properties of the errorprovider there should be a "..." button or something to click and then you browse to the icon you want to use.

    Then rename your errorprovider e.g. errorproviderInfo

    So now you have an information errorprovider that you can use for all your controls on the Form.

    You can use one errorprovider for multiple controls.

    For example:

    If TextBox1 is busy updating-

    Code:
    ErrorProviderInfo.SetError(TextBox1, "Busy updating")
    When finished-

    Code:
    ErrorProviderInfo.SetError(TextBox1, "")
    For a real error with the red exclamation, well add another (default) errorprovider to your form.

    To handle multiple controls simultaneously. Here's an example:

    Code:
    Private Sub TextBox1_Validating(sender As Object, e As CancelEventArgs) Handles TextBox1.Validating, TextBox2.Validating, TextBox3.Validating 
    
    Dim textBox As TextBox = DirectCast(sender, TextBox) If textBox.Text = "" Then
    ErrorProvider1.SetError(textBox, "Please enter a value.") e.Cancel = True
    Else ErrorProvider1.SetError(textBox, "") 
    End If 
    End Sub
    In the properties of the errorprovider you can set the blinking properties too. The blink rate, or even disable the blinking. In my project some information is updated at different time intervals so with multiple errorproviders showing it started to look like a Christmas tree on my form so I didn't like it and I set all my errorproviders not to blink...

    Can you also set the position of the errorprovider in relation to the control. Should it be left of it? Above it? Etc. I'm not sure if that's also set in the properties or programmatically. You can just Google it 🙂

    Thinking that, there should be a way to change errorprovider icons programmatically. Maybe someone else know....
    Last edited by schoemr; Feb 18th, 2023 at 10:14 AM.

  15. #15
    Frenzied Member
    Join Date
    Apr 2016
    Posts
    1,415

    Re: Draw circle - Does it what I need?

    Quote Originally Posted by pourkascheff View Post
    Dear shaggy and schoemr, previous replies were massively edited. Please honor me by revisiting through them.


    I really liked this idea but three questions.

    1) Where does the red (!) symbol come from? It is an information in my case not an error (It is an errorprovider after all). I tried
    Code:
    ErrorProvider1.Icon = SystemIcons.Information
    but they are very large in size and I have to retrieve it back to error in case of an error.

    Update: I used .ToBitmap conversion but exceptions occur with the goal to resize them. But now I'm sure beside that red (!) it should be a normal notification icon.


    2) Several simultaneous errors, warnings and infos require different errorproviders on form right? Is there a way to trick it once for all?

    3) To clear the error provider I used a button. But it clears all error indicating controls. Is there a way to clear/reset them seperately?
    Thank you very much Shaggy 🙂 Can't wait to see it

  16. #16
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: Draw circle - Does it what I need?

    Quote Originally Posted by pourkascheff View Post
    In an engineering way, Yes it must.
    Excluding shape case, Shaggy suggestion is also good. Color changing. The point is to achieve a sort of emphasis. But in that control-crowded form, it looks a bit psychedelic-trippy for user. Lots of hue changing. Absolute distraction and also annoying. Don't you think?
    Well, I've always referred to those color changing controls as a 'stoner trap'...
    My usual boring signature: Nothing

  17. #17

    Thread Starter
    Hyperactive Member pourkascheff's Avatar
    Join Date
    Apr 2020
    Location
    LocalHost
    Posts
    384

    Re: Draw circle - Does it what I need?

    Alright, Let's stick to combining ErrorProvider next to HelpProvider and make it done, then handover graphical magikz to WPF...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width