Results 1 to 6 of 6

Thread: [RESOLVED] Help With some errors in a class convertion from C# To VB.NET

Threaded View

  1. #1

    Thread Starter
    Lively Member Simonetos The Greek's Avatar
    Join Date
    Mar 2018
    Location
    Athens, Greece
    Posts
    65

    Resolved [RESOLVED] Help With some errors in a class convertion from C# To VB.NET

    Hello guys!!!

    I have found this class which gives shadow on a borderless form. It's written in C# and I had to convert it in VB.NET so to use it in my project. My problem is that the converter can't convert some parts correctly and I get some errors which I can't managed to fix.

    First errors located here...
    vb.net Code:
    1. Public Sub New(f As Form)
    2.     Owner = f
    3.     ShadowRadius = 10
    4.     ShadowColor = Color.Black
    5.  
    6.     'This bit of code makes the form click-through.
    7.     '             So you can click forms that are below it in z-space
    8.  
    9.     Dim wl As Integer = Win32.GetWindowLong(Handle, -20)
    10.     wl = wl Or &H80000 Or &H20
    11.     Win32.SetWindowLong(Handle, -20, wl)
    12.  
    13.     FormBorderStyle = FormBorderStyle.None
    14.  
    15.     ' bind event
    16.     Owner.LocationChanged += UpdateLocation()
    17.     Owner.FormClosing += Function(sender, eventArgs) Close()
    18.     Owner.VisibleChanged += Function(sender, eventArgs)
    19.                                 If Owner IsNot Nothing Then
    20.                                     Visible = Owner.Visible
    21.                                 End If
    22.  
    23.  
    24.                                 'Owner.Activated += (sender, args) => Owner.BringToFront();
    25.                             End Function
    26. End Sub
    Line 16: Error:BC32022 'Public Event LocationChanged As EventHandler' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
    Line 16: Error:BC30491 Expression does not produce a value.
    Line 17: Error:BC32022 'Public Event FormClosing As FormClosingEventHandler' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
    Line 18: Error:BC32022 'Public Event VisibleChanged As EventHandler' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.
    Line 25: Warning:BC42105 Function '<anonymous method>' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used.
    And the rest here...
    vb.net Code:
    1. Private Function DrawShadow() As Bitmap
    2.     ' 窗体的大小
    3.     Dim fw As Integer = Owner.Width + ShadowRadius * 2
    4.     Dim fh As Integer = Owner.Height + ShadowRadius * 2
    5.  
    6.     Dim gp As New GraphicsPath()
    7.  
    8.     gp.AddRectangle(New RectangleF(0, 0, fw, fh))
    9.     'gp.AddEllipse(ClientRectangle);
    10.     'gp.AddRectangle(new RectangleF(ShadowRadius + WithBorderRadius
    11.     '   , ShadowRadius + WithBorderRadius, ow, oh));
    12.  
    13.     Dim pgb As New PathGradientBrush(gp)
    14.  
    15.     pgb.CenterPoint = New PointF(fw / 2.0F, fh / 2.0F)
    16.     pgb.CenterColor = ShadowColor
    17.     pgb.SurroundColors = New() {Color.Transparent}
    18.     'pgb.ScaleTransform(1,1);
    19.  
    20.     Dim bitmap As New Bitmap(fw, fh)
    21.  
    22.     Dim g As Graphics = Graphics.FromImage(bitmap)
    23.  
    24.     'var ctr = new Bitmap(Width, Height, CreateGraphics());
    25.     'g.DrawImage(ctr, new Point(0,0));
    26.     'var g = CreateGraphics();
    27.     g.FillPath(pgb, gp)
    28.  
    29.     pgb.Dispose()
    30.     gp.Dispose()
    31.     '
    32.     Width = fw
    33.     Height = fh
    34.  
    35.     Return bitmap
    36. End Function
    Line 17: Error:BC30182 Type expected.
    Line 17: Error:BC37259 Tuple must contain at least two elements.
    Line 17: Error:BC30311 Value of type '(?, ?)' cannot be converted to 'Color()'.
    Line 17: Error:BC37280 'New' cannot be used with tuple type. Use a tuple literal expression instead.
    If for some reason you need to check the full vb.net converted version of the class, I have uploaded it here. Thank you in advance!!!
    Last edited by Simonetos The Greek; May 5th, 2018 at 09:21 AM. Reason: Title correction

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