将VB代码转换为C# [英] converting VB code into C#

查看:108
本文介绍了将VB代码转换为C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以将下面的VB代码转换为C#吗?预先感谢

can you please convert the below VB code into C#? thanx in advance

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)

推荐答案

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();
    }
}


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


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:通过 converter.telerik




PS: via converter.telerik


,您可以尝试一些在线转换器,例如: http://converter.telerik.com/ [
You can try some online converters, for example: http://converter.telerik.com/[^]


尝试此站点,这可能对您有帮助...

http://www.developerfusion.com/tools/convert/vb-to-csharp/
try out this site, this might help you...

http://www.developerfusion.com/tools/convert/vb-to-csharp/


这篇关于将VB代码转换为C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆