Click here to Skip to main content
16,004,782 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hi, can you please convert the below VB code into C#? thanx in advance

VB
Private Sub Clock1_HourHandPainting(ByVal sender As Object, _
        ByVal e As AnalogClock.PaintEventArgs) Handles Clock1.HourHandPainting
        'Make sure the hour hand's graphics path contains more than 2 points.
        If Me.Clock1.HourHand.Path.PointCount > 2 Then
            'Make the hour hand gradient
            Dim br As New Drawing2D.PathGradientBrush(Me.Clock1.HourHand.Path)
            br.CenterColor = Color.White
            br.SurroundColors = New Color() {Me.Clock1.HourHand.Color}
            e.Brush = br
            br.Dispose()
        End If
    End Sub
    Private Sub Clock1_TimeChanged(ByVal sender As System.Object, _
     ByVal e As System.EventArgs) Handles Clock1.TimeChanged
        'Set UTC offset to the system utc offset every time clock time changes.
        'If the property has the same value it will do nothing.
        Me.Clock1.UtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now)
    End Sub

 Dim cdt As DateTime = CDate("#17:20:35#")  'Some custom start time for the clock.
        Dim utcDt As DateTime = DateTime.UtcNow  'The current UTC dateTime.
        'This is needed because the clock internal works with UTC dateTime.
        Me.Clock1.UtcOffset = New TimeSpan(0, cdt.Hour - utcDt.Hour, _
                                 cdt.Minute - utcDt.Minute, cdt.Second - utcDt.Second)
Posted
Comments
bbirajdar 16-Aug-12 5:56am    
I am afraid , codeproject.com is not a 'outsource your work for free' kind of site. There are thousands of code converters online. Try them. And yes, Google is free. You can use it to search the code converters.

C#
private void Clock1_HourHandPainting(object sender, AnalogClock.PaintEventArgs e)
{
        if (this.Clock1.HourHand.Path.PointCount > 2) {
        Drawing2D.PathGradientBrush br = new Drawing2D.PathGradientBrush(this.Clock1.HourHand.Path);
        br.CenterColor = Color.White;
        br.SurroundColors = new Color[] { this.Clock1.HourHand.Color };
        e.Brush = br;
        br.Dispose();
    }
}

C#
private void Clock1_TimeChanged(System.Object sender, System.EventArgs e)
{
    this.Clock1.UtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);
}

C#
DateTime cdt = Convert.ToDateTime("#17:20:35#");
DateTime utcDt = DateTime.UtcNow;
this.Clock1.UtcOffset = new TimeSpan(0, cdt.Hour - utcDt.Hour, cdt.Minute - utcDt.Minute, cdt.Second - utcDt.Second);



PS: via converter.telerik
 
Share this answer
 
You can try some online converters, for example: http://converter.telerik.com/[^]
 
Share this answer
 
try out this site, this might help you...

http://www.developerfusion.com/tools/convert/vb-to-csharp/
 
Share this answer
 
C#
private void Clock1_HourHandPainting(object sender, AnalogClock.PaintEventArgs e)
{
    //Make sure the hour hand's graphics path contains more than 2 points.
    if (this.Clock1.HourHand.Path.PointCount > 2) {
        //Make the hour hand gradient
        Drawing2D.PathGradientBrush br = new Drawing2D.PathGradientBrush(this.Clock1.HourHand.Path);
        br.CenterColor = Color.White;
        br.SurroundColors = new Color[] { this.Clock1.HourHand.Color };
        e.Brush = br;
        br.Dispose();
    }
}
private void Clock1_TimeChanged(System.Object sender, System.EventArgs e)
{
    //Set UTC offset to the system utc offset every time clock time changes.
    //If the property has the same value it will do nothing.
    this.Clock1.UtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);
}

DateTime cdt = Convert.ToDateTime("#17:20:35#");
//Some custom start time for the clock.
DateTime utcDt = DateTime.UtcNow;
//The current UTC dateTime.
//This is needed because the clock internal works with UTC dateTime.
this.Clock1.UtcOffset = new TimeSpan(0, cdt.Hour - utcDt.Hour, cdt.Minute - utcDt.Minute, cdt.Second - utcDt.Second);
 
Share this answer
 
hii,
use some online converters
here is one of them
http://www.developerfusion.com/tools/convert/vb-to-csharp/[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900