Solved

WPF C# application to Visual Basic

Posted on 2008-10-23
7
375 Views
Last Modified: 2013-11-26
Hi to all,

I am working with the following application on codeproject:
http://www.codeproject.com/KB/WPF/MarsaX.aspx

This is a great post and application. The bad thing for me is that it is in C#. I am a visual basic programmer and was wondering if someone can translate the code below to VB for me. The online tools available is not of any help and I really don't want to go and learn C# to be able to use this application.

I am trying to accomplish the same kind of look, but with all the items in my database. These items have a picture name and I want to display them the same way.

If I can't translate the application, how would I go about in getting the same look and feel to a WPF Visual Basic type application.

Thanks
private ModelUIElement3D CreateModel(string imageUri, int row, int col)

        {

            //Get a VisualBrush for the Url

            VisualBrush vBrush = GetVisualBrush(imageUri);
 

            //Create the model

            ModelUIElement3D model3D = new ModelUIElement3D

            {

                Model = new GeometryModel3D

                {

                    Geometry = new MeshGeometry3D

                    {

                        TriangleIndices = new Int32Collection(

                            new int[] { 0, 1, 2, 2, 3, 0 }),

                        TextureCoordinates = new PointCollection(

                            new Point[] 

                            { 

                                new Point(0, 1), 

                                new Point(1, 1), 

                                new Point(1, 0), 

                                new Point(0, 0) 

                            }),

                        Positions = new Point3DCollection(

                            new Point3D[] 

                            { 

                                new Point3D(-0.5, -0.5, 0), 

                                new Point3D(0.5, -0.5, 0), 

                                new Point3D(0.5, 0.5, 0), 

                                new Point3D(-0.5, 0.5, 0) 

                            })

                    },

                    Material = new DiffuseMaterial

                    {

                        Brush = vBrush

                    },

                    BackMaterial = new DiffuseMaterial

                    {

                        Brush = Brushes.Black

                    },

                    Transform = CreateGroup(row, col)

                }

            };

            //hook up mouse events, and add to lookup and return the ModelUIElement3D

            model3D.MouseEnter += ModelUIElement3D_MouseEnter;

            model3D.MouseDown += model3D_MouseDown;

            modelToImageLookUp.Add(model3D, imageUri);

            return model3D;

        }

Open in new window

0
Comment
Question by:ALawrence007
  • 3
  • 3
7 Comments
 
LVL 16

Expert Comment

by:Gyanendra Singh
ID: 22784896
use this tool to convert C# code to vb.net

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

Expert Comment

by:Gyanendra Singh
ID: 22784901
find yr converted code
Private Function CreateModel(imageUri As String, row As Integer, col As Integer) As ModelUIElement3D 

    'Get a VisualBrush for the Url 

    Dim vBrush As VisualBrush = GetVisualBrush(imageUri) 

    

    'Create the model 

    Dim model3D As New ModelUIElement3D() 

    'hook up mouse events, and add to lookup and return the ModelUIElement3D 

    model3D.MouseEnter += ModelUIElement3D_MouseEnter 

    model3D.MouseDown += model3D_MouseDown 

    modelToImageLookUp.Add(model3D, imageUri) 

    Return model3D 

End Function 

Open in new window

0
 

Author Comment

by:ALawrence007
ID: 22784938
That is the tool I have been using, but it skips the code below and I can't get the application to work.



{

                Model = new GeometryModel3D

                {

                    Geometry = new MeshGeometry3D

                    {

                        TriangleIndices = new Int32Collection(

                            new int[] { 0, 1, 2, 2, 3, 0 }),

                        TextureCoordinates = new PointCollection(

                            new Point[]

                            {

                                new Point(0, 1),

                                new Point(1, 1),

                                new Point(1, 0),

                                new Point(0, 0)

                            }),

                        Positions = new Point3DCollection(

                            new Point3D[]

                            {

                                new Point3D(-0.5, -0.5, 0),

                                new Point3D(0.5, -0.5, 0),

                                new Point3D(0.5, 0.5, 0),

                                new Point3D(-0.5, 0.5, 0)

                            })

                    },

                    Material = new DiffuseMaterial

                    {

                        Brush = vBrush

                    },

                    BackMaterial = new DiffuseMaterial

                    {

                        Brush = Brushes.Black

                    },

                    Transform = CreateGroup(row, col)

                }

            };

Open in new window

0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 16

Expert Comment

by:Gyanendra Singh
ID: 22784999
check this
'Error: Converting Properties 
 

Private Function CreateModel(ByVal imageUri As String, ByVal row As Integer, ByVal col As Integer) As ModelUIElement3D

            'Get a VisualBrush for the Url

            Dim vBrush As VisualBrush =  GetVisualBrush(imageUri) 

 

            'Create the model

            ModelUIElement3D model3D = New ModelUIElement3D

            {

                Model = New GeomeTryModel3D

                {

                    GeomeTry = New MeshGeomeTry3D

                    {

                        TriangleIndices = New Int32Collection(

                            New Integer() 

                            {

                            	 0, 1, 2, 2, 3, 0 

                            }

),

                        TextureCoordinates = New PointCollection(

                            New Point() 

                            { 

                                New Point(0, 1), 

                                New Point(1, 1), 

                                New Point(1, 0), 

                                New Point(0, 0) 

                            }

),

                        Positions = New Point3DCollection(

                            New Point3D() 

                            { 

                                New Point3D(-0.5, -0.5, 0), 

                                New Point3D(0.5, -0.5, 0), 

                                New Point3D(0.5, 0.5, 0), 

                                New Point3D(-0.5, 0.5, 0) 

                            }

)

                    }

,

                    Material = New DiffuseMaterial

                    {

                        Brush = vBrush

                    }

,

                    BackMaterial = New DiffuseMaterial

                    {

                        Brush = Brushes.Black

                    }

,

                    Transform = CreateGroup(row, col)

                }

            }
 

            'hook up mouse events, and add to lookup and return the ModelUIElement3D

            model3D.MouseEnter += ModelUIElement3D_MouseEnter

            model3D.MouseDown += model3D_MouseDown

            modelToImageLookUp.Add(model3D, imageUri)

            Return model3D

End Function

Open in new window

0
 

Author Comment

by:ALawrence007
ID: 22787311
Nope, still gives me errors... It looks like we just added the C# part to the VB and not translated it.
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 22788348
*** I don't work with WPF ****

Soooo....there may some new fancy syntax shortcuts that I don't know yet...   =\

Does this work?
    Private Function CreateModel(ByVal imageUri As String, ByVal row As Integer, ByVal col As Integer) As ModelUIElement3D

        Dim geometry As New MeshGeometry3D

        geometry.TriangleIndices = New Int32Collection(New Integer() {0, 1, 2, 2, 3, 0})

        geometry.TextureCoordinates = New PointCollection( _

            New Point() { _

                New Point(0, 1), _

                New Point(1, 1), _

                New Point(1, 0), _

                New Point(0, 0) _

            })

        geometry.Positions = New Point3DCollection( _

            New Point3D() { _

                New Point3D(-0.5, -0.5, 0), _

                New Point3D(0.5, -0.5, 0), _

                New Point3D(0.5, 0.5, 0), _

                New Point3D(-0.5, 0.5, 0) _

            })
 

        Dim model As New GeometryModel3D

        model.Geometry = geometry

        model.Material = New DiffuseMaterial(GetVisualBrush(imageUri))

        model.BackMaterial = New DiffuseMaterial(Brushes.Black)

        model.Transform = CreateGroup(row, col)
 

        Dim model3D As New ModelUIElement3D()

        model3D.Model = model

        AddHandler model3D.MouseEnter, AddressOf (ModelUIElement3D_MouseEnter)

        AddHandler model3D.MouseDown, AddressOf model3D_MouseDown

        modelToImageLookUp.Add(model3D, imageUri)

        Return model3D

    End Function

Open in new window

0
 

Author Comment

by:ALawrence007
ID: 22788587
Thank you SO much Idle_Mind!

That did the trick!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

910 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

23 Experts available now in Live!

Get 1:1 Help Now