Solved

Splash form - two triangles that go from Green to Blue

Posted on 2006-07-23
5
236 Views
Last Modified: 2010-07-27
I need to have the background color for my splash form go from Green (0 to 255) to Blue (255 to 0). I found the code in a previous post but it doesn't work. It still displays what was produced when I tried to make the splash form. The code I used is this:

Private Sub frmSplash_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

        Dim rect As Rectangle = New Rectangle(20, 20, 200, 100)
        Dim path As GraphicsPath
        Dim region As Region
        Dim brush As LinearGradientBrush

        path = New GraphicsPath(FillMode.Alternate)
        path.AddLine(rect.Left, rect.Bottom, rect.Left, rect.Top)
        path.AddLine(rect.Left, rect.Top, rect.Right, rect.Top)
        path.AddLine(rect.Right, rect.Top, rect.Left, rect.Bottom)

        region = New Region(path)
        brush = New LinearGradientBrush(rect, Color.Black, Color.Green, LinearGradientMode.Horizontal)

        e.Graphics.Clip = region
        e.Graphics.FillRectangle(brush, rect)


        path = New GraphicsPath(FillMode.Alternate)
        path.AddLine(rect.Right, rect.Top, rect.Right, rect.Bottom)
        path.AddLine(rect.Right, rect.Bottom, rect.Left, rect.Bottom)
        path.AddLine(rect.Left, rect.Bottom, rect.Right, rect.Top)

        region = New Region(path)
        brush = New LinearGradientBrush(rect, Color.Blue, Color.Black, LinearGradientMode.Horizontal)

        e.Graphics.Clip = region
        e.Graphics.FillRectangle(brush, rect)

        brush = New LinearGradientBrush(rect, Color.Blue, Color.Black, LinearGradientMode.Horizontal)
        brush.GammaCorrection = True          ' add this line
    End Sub

  What this produces are rectangles, two green then one blue. The rectangles then have diamond shapes inside of them. Any help would be greatly appreciated!
0
Comment
Question by:smstrks
5 Comments
 
LVL 19

Accepted Solution

by:
arif_eqbal earned 500 total points
ID: 17166102
>> I need to have the background color for my splash form go from Green (0 to 255) to Blue (255 to 0)
If you want just that, I don't think you need to create Rectangles and color them, Also what do you mean "GO FROM"
do you want it turn gradually say in a few seconds from Green to Blue ?
If yes you need a Timer

On Form Load have this....

        Dim ColorTimer As New Timer
        ColorTimer.Interval = 100
        BackColor = Color.FromArgb(0, 255, 0)
        AddHandler ColorTimer.Tick, AddressOf ColorTimer_Tick
        ColorTimer.Start()

Then have this Event Handler....

       Private Sub ColorTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If BackColor.G <= 0 Then
            CType(sender, Timer).Stop()
            Exit Sub
        End If

Run and wait for a 10-15 secs to see the effect

        BackColor = Color.FromArgb(0, BackColor.G - 1, BackColor.B + 1)
    End Sub

0
 

Author Comment

by:smstrks
ID: 17400043
Sorry! My computer crashed and I could not remember the url for this website!
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now