Results 1 to 37 of 37

Thread: WinForms Bootstrap Theme

  1. #1

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,593

    WinForms Bootstrap Theme

    This is a work in progress, but here is a library that I've been working on that mimics twitter-bootstrap 4.3.

    Control
    • Base Class
    • Rounded edge control
    • Function to calculate REM


    Alert
    • Dismissable - i.e. a close icon appears in the upper-right hand corner, once the close icon is clicked it destroys the control.
    • Fadable - i.e. when the Dismiss method is called, it slowly causes the control to fade away.


    Button
    • IsOutline - Allows the button to just contain a border
    • MouseOver, MouseEnter, and Disabled styles the button


    Long story short, I started doing a lot of web development and realized how crappy WinForm applications look.

    Here is a screenshots of the work in progress:
    Name:  tempsnip.jpg
Views: 1828
Size:  15.9 KB

    Code was too large to include in a post, here is the file: Bootstrap.vb

    UPDATE
    I'll keep the original file, but please note that I've moved this project to GitHub: https://github.com/dday9/win-forms-bootstrap
    Last edited by dday9; Jun 30th, 2020 at 11:09 PM.

  2. #2
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,430

    Re: WinForms Bootstrap Theme

    Very Nice Dd, I love this kind of stuff!!

  3. #3
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,530

    Re: WinForms Bootstrap Theme

    Have you considered doing a TextBox with a focus glow like shown below?

    Name:  F1.png
Views: 1075
Size:  37.3 KB

  4. #4

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,593

    Re: WinForms Bootstrap Theme

    Yep, I’m actually moving onto form inputs next.

  5. #5
    PowerPoster
    Join Date
    Feb 2016
    Location
    Tennessee
    Posts
    2,430

    Re: WinForms Bootstrap Theme

    Nice Job dday... You always do good! And of course you too Karen

  6. #6
    New Member
    Join Date
    Dec 2015
    Location
    India
    Posts
    10

    Re: WinForms Bootstrap Theme

    better you can provide full sample project

  7. #7
    Junior Member
    Join Date
    May 2020
    Posts
    30

    Re: WinForms Bootstrap Theme

    I liked the topic very much, but I do not know how to use the attached class .. I wish clarification steps

  8. #8

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,593

    Re: WinForms Bootstrap Theme

    Quote Originally Posted by vbxprogrammer View Post
    I liked the topic very much, but I do not know how to use the attached class .. I wish clarification steps
    1. Add the file to your project
    2. Build the solution
    3. You can either drag and drop the controls onto your form using the form designer or you can create new instances of the controls via code

  9. #9
    Junior Member
    Join Date
    May 2020
    Posts
    30

    Re: WinForms Bootstrap Theme

    Quote Originally Posted by dday9 View Post
    1. Add the file to your project
    2. Build the solution
    3. You can either drag and drop the controls onto your form using the form designer or you can create new instances of the controls via code
    You are awesome and thank you very much ..
    I know your time is short and you may be too busy .. But
    I have hope and ambition ... that you will help me to show the tools as in the picture on the topic above ... because I did not understand what is meant by : (( you can create new instances of the controls via code )) !!
    waiting your answer ...

  10. #10

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,593

    Re: WinForms Bootstrap Theme

    The steps to create a new instance of the control via code (as opposed to just using the form designer) would be to:
    1. (optional) Import the namespace of the file (Bootstrap, Bootstrap.Control, etc.)
    2. Generate the Form's Load event or New constructor
    3. Declare a new instance of one of the controls
    4. Add the control to the form


    An example using the Button control that's included:
    Code:
    Public Class Form1
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
            Dim btn As New Bootstrap.Control.Button() With {
                .Location = New Point(5, 5),
                .Size = New Size(150, 150),
                .StyleType = Bootstrap.Control.Button.StyleType.Primary,
                .Text = "Click Me"
            }
            Me.Controls.Add(btn)
        End Sub
    End Class

  11. #11
    Junior Member
    Join Date
    May 2020
    Posts
    30

    Re: WinForms Bootstrap Theme

    Quote Originally Posted by dday9 View Post
    The steps to create a new instance of the control via code (as opposed to just using the form designer) would be to:
    1. (optional) Import the namespace of the file (Bootstrap, Bootstrap.Control, etc.)
    2. Generate the Form's Load event or New constructor
    3. Declare a new instance of one of the controls
    4. Add the control to the form


    An example using the Button control that's included:
    Code:
    Public Class Form1
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
            Dim btn As New Bootstrap.Control.Button() With {
                .Location = New Point(5, 5),
                .Size = New Size(150, 150),
                .StyleType = Bootstrap.Control.Button.StyleType.Primary,
                .Text = "Click Me"
            }
            Me.Controls.Add(btn)
        End Sub
    End Class
    Wonderful .. beautiful .. .. remains a question:
    How to change the design of the form in the same way. And increase the shadow of the textbox limit

  12. #12
    Junior Member
    Join Date
    May 2020
    Posts
    30

    Re: WinForms Bootstrap Theme

    The topic is great, and it benefited me a lot .. Thank you and I hope an important thing as an addition:
    A very important addition. I hope that you will help me add it to the button specifically: Add a picture or image of the button .. what the code ??? and where set it ???? i wait

  13. #13

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,593

    Re: WinForms Bootstrap Theme

    All of the controls inherit from the base .NET class, Control. You're still able to set the BackgroundImage property of the Bootstrap Button.

  14. #14
    Junior Member
    Join Date
    May 2020
    Posts
    30

    Re: WinForms Bootstrap Theme

    Quote Originally Posted by dday9 View Post
    All of the controls inherit from the base .NET class, Control. You're still able to set the BackgroundImage property of the Bootstrap Button.
    I hit the target .. this is because you are creative .. but I am very sad because I tried to Working the BackgroundImage property of the Bootstrap Button .. Without success, this BackgroundImage property for Button did not work and tried more than one code without success .. I would be grateful ... and thank you if you helped me put a picture of the buttons

  15. #15
    Junior Member
    Join Date
    May 2020
    Posts
    30

    Re: WinForms Bootstrap Theme

    helped me put a picture of the buttons

  16. #16
    Addicted Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    212

    Re: WinForms Bootstrap Theme

    Hello ,

    I tested this new custom class on Vb.net 2017. It's nice, I like it.

    I noted 2 strange behaviors :
    The background image works for the default control and the alert but not for the button. For the button, sometime, the image seems to appear but is replaced quickly by the background color but generally, the image doesn't appear at all.
    For the alert, it seems that the fading doesn't work. When I click, I have a delay then the alert disappear quickly (so no fading).

    (I tested it with just a form and a control of each)

    regards
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  17. #17
    Junior Member
    Join Date
    May 2020
    Posts
    30

    Re: WinForms Bootstrap Theme

    Quote Originally Posted by Delaney View Post
    Hello ,

    I tested this new custom class on Vb.net 2017. It's nice, I like it.

    I noted 2 strange behaviors :
    The background image works for the default control and the alert but not for the button. For the button, sometime, the image seems to appear but is replaced quickly by the background color but generally, the image doesn't appear at all.
    For the alert, it seems that the fading doesn't work. When I click, I have a delay then the alert disappear quickly (so no fading).

    (I tested it with just a form and a control of each)

    regards
    This is what I mentioned and I told friends about it and I hope that it will be done quickly .. We need the intervention of friends to amend and the ability to add a picture of the button

  18. #18
    Junior Member
    Join Date
    May 2020
    Posts
    30

    Re: WinForms Bootstrap Theme

    Quote Originally Posted by Delaney View Post
    Hello ,

    I tested this new custom class on Vb.net 2017. It's nice, I like it.

    I noted 2 strange behaviors :
    The background image works for the default control and the alert but not for the button. For the button, sometime, the image seems to appear but is replaced quickly by the background color but generally, the image doesn't appear at all.
    For the alert, it seems that the fading doesn't work. When I click, I have a delay then the alert disappear quickly (so no fading).

    (I tested it with just a form and a control of each)

    regards
    This is what I mentioned and I told friends about it and I hope that it will be done quickly .. We need the intervention of friends to amend and the ability to add a picture of the button

  19. #19
    Addicted Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    212

    Re: WinForms Bootstrap Theme

    No need to post a second time the same post just to bump the subject.

    Dday9 will do what he wants, when he wants and if he wants to about his code.

    As the codes in code banks are free of use, feel free to correct it yourself if you need it so urgently

    Regards
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  20. #20
    Junior Member
    Join Date
    May 2020
    Posts
    30

    Re: WinForms Bootstrap Theme

    Quote Originally Posted by Delaney View Post
    No need to post a second time the same post just to bump the subject.

    Dday9 will do what he wants, when he wants and if he wants to about his code.

    As the codes in code banks are free of use, feel free to correct it yourself if you need it so urgently

    Regards
    I apologize for that and it was not intended ..
    And I wait @Dday9 very quickly ... because I couldn't really modify the code .. I hope for help from @Dday9 and I thank him very much

  21. #21

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,593

    Re: WinForms Bootstrap Theme

    It's worth mentioning that I have a repository on GitHub here: https://github.com/dday9/win-forms-bootstrap

    If anyone would like to implement bug fixes, feel free to do so and submit a pull request. I'll review it and merge it into master if it passes my scrutiny.

  22. #22

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,593

    Re: WinForms Bootstrap Theme

    Quote Originally Posted by Delaney View Post
    The background image works for the default control and the alert but not for the button. For the button, sometime, the image seems to appear but is replaced quickly by the background color but generally, the image doesn't appear at all.
    The issue stems from the fact that I'm using the Graphics::Clear method. This gives it the visual styles you'd expect a button to have when hovering over the button, pressing down on the mouse, or releasing the mouse.

    If you comment out line 489 (per the GitHub repo, not the source code above), rebuild the project, and set the BackgroundImage then the image displays when the project is running but it does not display in the designer.

    I'm really not sure how I can get around this issue. I'll ask the question in the main VB.NET forum to see if some more senior developers can pitch in.

    Quote Originally Posted by Delaney View Post
    For the alert, it seems that the fading doesn't work. When I click, I have a delay then the alert disappear quickly (so no fading).
    I don't experience the same thing. Do you have both the Dismissable and the Fadable properties set? If you have just the former set to true, then it would disappear quickly without any fading whereas if you have both true then it should fade slowly until it ultimately disappears.

    Edit - I recorded a GIF to show you what I'm seeing:
    Name:  Form1-2020-06-30-23-12-46.jpg
Views: 67
Size:  6.5 KB

    Edit #2 - Apparently the animated GIF in my signature is supported, but not in a thread. That's odd.
    Last edited by dday9; Jun 30th, 2020 at 11:18 PM.

  23. #23
    Junior Member
    Join Date
    May 2020
    Posts
    30

    Re: WinForms Bootstrap Theme

    Quote Originally Posted by dday9 View Post
    It's worth mentioning that I have a repository on GitHub here: https://github.com/dday9/win-forms-bootstrap

    If anyone would like to implement bug fixes, feel free to do so and submit a pull request. I'll review it and merge it into master if it passes my scrutiny.
    I tried to send a message to you without success..I hope you can help me add a picture to the button..I thank you very much for your effort and I wish you happiness

  24. #24

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,593

    Re: WinForms Bootstrap Theme

    Did you see my comment here: http://www.vbforums.com/showthread.p...=1#post5485090

    Would this suffice for now while I investigate how to preserve the visual styles while simultaneously supporting BackgroundImage support?

  25. #25
    Addicted Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    212

    Re: WinForms Bootstrap Theme

    Hi Dday9,

    Thanks for the investigation and comments, I will try tonight. I have thinking also of something and I will check that.

    for the gif, it seems the picture is converted into a JPG (that's what you get if you try to save it). And for the gif into you signature, it is working because it is already a bug
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  26. #26
    Junior Member
    Join Date
    May 2020
    Posts
    30

    Re: WinForms Bootstrap Theme

    Quote Originally Posted by dday9 View Post
    Did you see my comment here: http://www.vbforums.com/showthread.p...=1#post5485090

    Would this suffice for now while I investigate how to preserve the visual styles while simultaneously supporting BackgroundImage support?
    Dear friend..Thank you .. It seems that I have burdened you and annoyed you .. I apologize .. The problem is that I started in one of the programs and used these buttons .. Now unfortunately I will be forced, and I am very sad to delete the entire project and re-work on it with buttons Different .. Once again thank you I apologize if I bothered you

  27. #27

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,593

    Re: WinForms Bootstrap Theme

    Mais bruh, you're good! I'm not burdened or annoyed. If you have a lot of effort put into your existing project but would like to switch from using these custom buttons to using a different button, you can do it fairly easily without having to start completely over. In the Solution Explorer, click on Show All Files, open up the *.designer.vb file for the Form, and then replace any reference of Bootstrap.Controls.Button with just System.Windows.Forms.Button (or whatever control you're replacing it with).

  28. #28
    Addicted Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    212

    Re: WinForms Bootstrap Theme

    Quote Originally Posted by dday9 View Post
    Mais bruh,
    Long time since I read some Cajun
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  29. #29
    Junior Member
    Join Date
    May 2020
    Posts
    30

    Re: WinForms Bootstrap Theme

    Quote Originally Posted by dday9 View Post
    Mais bruh, you're good! I'm not burdened or annoyed. If you have a lot of effort put into your existing project but would like to switch from using these custom buttons to using a different button, you can do it fairly easily without having to start completely over. In the Solution Explorer, click on Show All Files, open up the *.designer.vb file for the Form, and then replace any reference of Bootstrap.Controls.Button with just System.Windows.Forms.Button (or whatever control you're replacing it with).
    Thank you for your response and communicating with interest .. I wish there was a solution soon to the problem of inserting a picture of the buttons

  30. #30

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    9,593

    Re: WinForms Bootstrap Theme

    What about my suggestion from earlier, here: http://www.vbforums.com/showthread.p...=1#post5485090
    If you comment out line 489 (per the GitHub repo, not the source code above), rebuild the project, and set the BackgroundImage then the image displays when the project is running but it does not display in the designer.
    It has the unintended side effect of losing the visual styles when your mouse is over the control but it'd solve your immediate issue of need to support the BackgroundImage.

  31. #31
    Junior Member
    Join Date
    May 2020
    Posts
    30

    Re: WinForms Bootstrap Theme

    Quote Originally Posted by dday9 View Post
    What about my suggestion from earlier, here: http://www.vbforums.com/showthread.p...=1#post5485090


    It has the unintended side effect of losing the visual styles when your mouse is over the control but it'd solve your immediate issue of need to support the BackgroundImage.
    I did not understand it and did not understand what you meant by it .. I wish you could simply explain it so that I can follow it in steps

  32. #32
    Addicted Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    212

    Re: WinForms Bootstrap Theme

    @vbxprogrammer : open the Bootstrap.vb file, go to the line 490 and put under comment this line : e.Graphics.Clear(backColor).

    @Dday9, for the fadable stuff, I have both the Dismissable and the Fadable properties set on true, so I will investigate

    By the way I love the ToggleSwitch
    Last edited by Delaney; Jul 1st, 2020 at 04:49 PM.
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  33. #33
    Addicted Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    212

    Re: WinForms Bootstrap Theme

    concerning the fadable,

    I test it again and I can't make it work. I tested the idea on an other application with this code
    Code:
     Do
        Button3.BackColor = Color.FromArgb(Button3.BackColor.A - 1, Button3.BackColor.R, Button3.BackColor.G, Button3.BackColor.B)
        Refresh()
       Threading.Thread.Sleep(Byte.MaxValue \ 150)
    Loop Until Button3.BackColor.A = 0
    And it works only if I add the refresh() command, so I add it in you class like that :

    Code:
    Me.Invoke(New MethodInvoker(Sub()
                                    refresh()
                                    End Sub))
    And I still don't have the fadable effect

    By the way there is a funny property : Isdismissed, if you put it to true, that's remove the control from the form
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  34. #34
    Addicted Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    212

    Re: WinForms Bootstrap Theme

    Ok Dday9,
    I am a big Moron!

    The fadable effect works perfectly : in my application test, I put a background image so, of course, I can't see the effect as the picture hide it

    by the way, I noted that the cross is a bit outside the click zone.
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  35. #35
    Addicted Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    212

    Re: WinForms Bootstrap Theme

    Quote Originally Posted by dday9 View Post
    What about my suggestion from earlier, here: http://www.vbforums.com/showthread.p...=1#post5485090


    It has the unintended side effect of losing the visual styles when your mouse is over the control but it'd solve your immediate issue of need to support the BackgroundImage.
    the alternative is to use the control "control" as a button, it allows the background image (but not the text, but who need it if you have a background image) and has the click event
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  36. #36
    Junior Member
    Join Date
    May 2020
    Posts
    30

    Re: WinForms Bootstrap Theme

    Quote Originally Posted by Delaney View Post
    the alternative is to use the control "control" as a button, it allows the background image (but not the text, but who need it if you have a background image) and has the click event
    background image Not Work

  37. #37
    Addicted Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    212

    Re: WinForms Bootstrap Theme

    Yes it is ...
    here is an example : new_button.zip

    I didn't change anything to the custom class (ie, i didn't put under comment the line 490).
    just click on the button and on the control...
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

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