Jump to content

Using Images to run codes?

- - - - -

  • Please log in to reply
7 replies to this topic

#1
pittpitu

pittpitu

    Newbie

  • Members
  • PipPip
  • 17 posts
Hi guys,

So I started with my internship and went through the VB tutorial which was awesome btw.
But I don't know where to start, :( I fully understand what the application has to do but don't know how I am going to start with it.

The application is for multiple casino's, where t hey open the app create a floor map of where the machines are located and should be able to add/move/delete machines afterwards. When the floor plan is done and up to date you should be able to click on one of the machines and it will give you the properties of the machines. All the info needed to be displayed is in a database that already exists.

What I was thinking is how can I make a toolbar so that the users can create the floor map and how do I attach code to each one of those machines.
Can I use images? to represent the machines when creating the floor plan? Maybe a small Icon and I drag and drop it and give each one of them a number so that I can tie them to the actual machines?

That is what I think would be easiest but again you guys are the experts.. any insight, ideas and help will be much appreciated

So what the application has to do is:
Basic key functions:
The user of the application should be able to: open the app, create a floor map, edit the map if needed, view location of machines using the floor plan,
be able to see if any of the machines has a big winning player, request information for the selected machine, delete/disable machines.



Attached File  projectexample.jpg   83.22K   12 downloads

Thx in advance

#2
RHankinsJr

RHankinsJr

    Newbie

  • Members
  • Pip
  • 8 posts
This task seems like a lot for a intern who is Green to VB.NET. However, it is very possible to do using vb.net.

The first place you need to start your knowledge search is on custom user controls.

You will want to make a custom user control that represents a machine. This user control will encapsulate everything that has to do with one machine ( all of it's settings, groupings, polling, etc... ). I can not suggest a specific book for this task, I would go to the book store and scour each of them until you find one that is best for your style of learning. You can never own too many books on your language of choice.

But break the project down into milestones and focus on getting each milestone completed. Your whole project is based around "machines" so that is where I would start.

#3
pittpitu

pittpitu

    Newbie

  • Members
  • PipPip
  • 17 posts
hahah Exactly my thoughts, about the too much for an intern.. or is there anyway I can change the buttons to images and it will then be a button underneath?
Could you be a bit more specific about the custom user controls? what they are for? is it for the images create custom controls when they are clicked on?

#4
RHankinsJr

RHankinsJr

    Newbie

  • Members
  • Pip
  • 8 posts
User controls are custom items you can reuse in your projects. It would be in your toolbox just like a text box or label is when you are done.

For more info on User Controls:
User Control Components in VB.NET
VB .NET Custom Controls - O'Reilly Media

Like i said, it is not novice stuff. That is why I suggested scouring the local book store for .net books with meaty chapters on the subject.

If you Google "vb.net custom control" you'll find 100s upon 100s of articles about creating custom user controls, why they are used and how they are used. A quick search of the forum returned no results of interest to you, but you might try to search the forum as well with a more meticulous search.

If you want to skip the whole custom control thing, you can just use picture boxes which require less advanced work but will result in your work not being easily ported to other projects (IMO).

I would highly suggest bookmarking the MSDN site, at your stage it will be your biggest friend ( in addition to your books you will purchase ).
PictureBox Class

You would work with the click just as you would on any other part.

#5
pittpitu

pittpitu

    Newbie

  • Members
  • PipPip
  • 17 posts
ok, I am doing a lot of reading on the custom controls and pictureboxes. and I got a new idea don't know if it's easier.
What about making a form that consist of ALOT of pictureboxes all alligned like cells next and around each other.
Then asking user to enter which location he wants to add a machine add and changing background color and if clicked on it get's some value for the machine that is located in that location
Per example,

Attached File  floorplan made with squares.jpg   113.07K   15 downloads

I am just trying to use the easiest method available since I am the only one in the office I am at with some VB experience.
The one in charge of helping me with my internship doesn't know anything about it so the easier I could make it the better since I am only using the forums and internet docs to help me out!

#6
RHankinsJr

RHankinsJr

    Newbie

  • Members
  • Pip
  • 8 posts
That might well be the easiest way to do it for someone at your level. Load time will be significant depending on the size of the grid you are using. More controls = More overhead during load\resize.

Again you would just use the _click to handle everything.

If you have a public library you can find many books as well, and best of all they are free. I live in a Podunk town in the middle of nowhere and our public library has a decent starter selection of .net books.

#7
pittpitu

pittpitu

    Newbie

  • Members
  • PipPip
  • 17 posts
I found a few video's on Youtube from Aardaerimus, who uses tiles to do almost the same thing I want to do.
His video's are more based on gaming programming but it serves my needs. So I am going to try it out using his
codes and examples and adapt it to mine. After I get mos of the code working I will post the code in the thread

#8
pittpitu

pittpitu

    Newbie

  • Members
  • PipPip
  • 17 posts
On a msdn forum A user named Acamar, posted some code for the project I am doing
It does a lot now I need to ceate a class of objects and make an array to store the location and add a machineId to each location.
So each time it draws something it will give me a popup asking for machineID and using the location will store it in a table.
Then Use the machineID to draw more information for each machine. Since you can only draw information about each machine at a time.
Cannot use next or previous to scroll to all of them. So I think.... I will only need 1 sql statement as it will always grab the same info

[FONT=Courier new][COLOR=#0000ff]Public[/COLOR] [COLOR=#0000ff]Class[/COLOR] Form1

    [COLOR=#0000ff]Dim[/COLOR] SizeW [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = 20
    [COLOR=#0000ff]Dim[/COLOR] SizeH [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = 20
    [COLOR=#0000ff]Dim[/COLOR] Plan(SizeW - 1, SizeH - 1) [COLOR=#0000ff]As[/COLOR] CellValue
    [COLOR=#0000ff]Dim[/COLOR] Command [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = -1
    [COLOR=#0000ff]Dim[/COLOR] RND [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]New[/COLOR] Random
    [COLOR=#0000ff]Private[/COLOR] [COLOR=#0000ff]Sub[/COLOR] btnClear_Click([COLOR=#0000ff]ByVal[/COLOR] sender [COLOR=#0000ff]As[/COLOR] System.Object, [COLOR=#0000ff]ByVal[/COLOR] e [COLOR=#0000ff]As[/COLOR] System.EventArgs) [COLOR=#0000ff]Handles[/COLOR] btnClear.Click
        Command = 0
    [COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Sub

[/COLOR]    [COLOR=#0000ff]Private[/COLOR] [COLOR=#0000ff]Sub[/COLOR] btnAdd_Click([COLOR=#0000ff]ByVal[/COLOR] sender [COLOR=#0000ff]As[/COLOR] System.Object, [COLOR=#0000ff]ByVal[/COLOR] e [COLOR=#0000ff]As[/COLOR] System.EventArgs) [COLOR=#0000ff]Handles[/COLOR] btnAdd.Click
        Command = 1
    [COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Sub

[/COLOR]    [COLOR=#0000ff]Private[/COLOR] [COLOR=#0000ff]Sub[/COLOR] PictureBox1_Click([COLOR=#0000ff]ByVal[/COLOR] sender [COLOR=#0000ff]As[/COLOR] System.Object, [COLOR=#0000ff]ByVal[/COLOR] e [COLOR=#0000ff]As[/COLOR] System.EventArgs) [COLOR=#0000ff]Handles[/COLOR] PictureBox1.Click
        [COLOR=#0000ff]Dim[/COLOR] CellW [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = PictureBox1.Width \ SizeW
        [COLOR=#0000ff]Dim[/COLOR] CellH [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = PictureBox1.Height \ SizeH
        [COLOR=#0000ff]Dim[/COLOR] P [COLOR=#0000ff]As[/COLOR] Point = PointToClient(MousePosition)
        [COLOR=#0000ff]Dim[/COLOR] X [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = (P.X - PictureBox1.Left) \ CellW
        [COLOR=#0000ff]Dim[/COLOR] Y [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = (P.Y - PictureBox1.Top) \ CellH

        [COLOR=#0000ff]If[/COLOR] Command <> -1 [COLOR=#0000ff]Then
[/COLOR]            [COLOR=#0000ff]If[/COLOR] Plan(X, Y) [COLOR=#0000ff]Is[/COLOR] [COLOR=#0000ff]Nothing[/COLOR] [COLOR=#0000ff]Then[/COLOR] Plan(X, Y) = [COLOR=#0000ff]New[/COLOR] CellValue
            [COLOR=#0000ff]Select[/COLOR] [COLOR=#0000ff]Case[/COLOR] Command
                [COLOR=#0000ff]Case[/COLOR] 0 : Plan(X, Y).CellShape = 0
                [COLOR=#0000ff]Case[/COLOR] 1
                    [COLOR=#0000ff]If[/COLOR] rbnCircle.Checked [COLOR=#0000ff]Then
[/COLOR]                        Plan(X, Y).CellShape = Shape.Circle
                    [COLOR=#0000ff]Else
[/COLOR]                        Plan(X, Y).CellShape = Shape.Square
                    [COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]If
[/COLOR]            [COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Select
[/COLOR]            Plan(X, Y).CellName = TextBox1.Text
            Plan(X, Y).CellColor = Color.FromArgb(255, RND.Next(1, 256), RND.Next(1, 256), RND.Next(1, 256))
            PictureBox1.Invalidate()
            Command = -1   [COLOR=#008000]'One click only per selection
[/COLOR]        [COLOR=#0000ff]Else
[/COLOR]            [COLOR=#0000ff]If[/COLOR] [COLOR=#0000ff]Not[/COLOR] Plan(X, Y) [COLOR=#0000ff]Is[/COLOR] [COLOR=#0000ff]Nothing[/COLOR] [COLOR=#0000ff]Then
[/COLOR]                TextBox1.Text = Plan(X, Y).CellName
            [COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]If
[/COLOR]        [COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]If

[/COLOR]    [COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Sub

[/COLOR]    [COLOR=#0000ff]Private[/COLOR] [COLOR=#0000ff]Sub[/COLOR] PictureBox1_Paint([COLOR=#0000ff]ByVal[/COLOR] sender [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Object[/COLOR], [COLOR=#0000ff]ByVal[/COLOR] e [COLOR=#0000ff]As[/COLOR] System.Windows.Forms.PaintEventArgs) [COLOR=#0000ff]Handles[/COLOR] PictureBox1.Paint
        [COLOR=#0000ff]Dim[/COLOR] W [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = PictureBox1.Width
        [COLOR=#0000ff]Dim[/COLOR] H [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = PictureBox1.Height
        [COLOR=#0000ff]Dim[/COLOR] CellW [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = W \ SizeW
        [COLOR=#0000ff]Dim[/COLOR] CellH [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = H \ SizeH
        [COLOR=#0000ff]Dim[/COLOR] P [COLOR=#0000ff]As[/COLOR] Pen = [COLOR=#0000ff]New[/COLOR] Pen(Color.Gray, 1)
        [COLOR=#0000ff]For[/COLOR] I [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = 0 [COLOR=#0000ff]To[/COLOR] W [COLOR=#0000ff]Step[/COLOR] CellW
            e.Graphics.DrawLine(P, I, 0, I, H)
        [COLOR=#0000ff]Next
[/COLOR]        [COLOR=#0000ff]For[/COLOR] I [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = 0 [COLOR=#0000ff]To[/COLOR] H [COLOR=#0000ff]Step[/COLOR] CellH
            e.Graphics.DrawLine(P, 0, I, W, I)
        [COLOR=#0000ff]Next

[/COLOR]        [COLOR=#0000ff]For[/COLOR] i [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = 0 [COLOR=#0000ff]To[/COLOR] SizeW - 1
            [COLOR=#0000ff]For[/COLOR] j [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = 0 [COLOR=#0000ff]To[/COLOR] SizeH - 1
                [COLOR=#0000ff]If[/COLOR] [COLOR=#0000ff]Not[/COLOR] Plan(i, j) [COLOR=#0000ff]Is[/COLOR] [COLOR=#0000ff]Nothing[/COLOR] [COLOR=#0000ff]Then
[/COLOR]                    fillcell(e.Graphics, i, j, Plan(i, j).CellColor, Plan(i, j).CellShape)
                [COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]If
[/COLOR]            [COLOR=#0000ff]Next
[/COLOR]        [COLOR=#0000ff]Next
[/COLOR]    [COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Sub

[/COLOR]    [COLOR=#0000ff]Private[/COLOR] [COLOR=#0000ff]Sub[/COLOR] fillcell([COLOR=#0000ff]ByVal[/COLOR] g [COLOR=#0000ff]As[/COLOR] Graphics, [COLOR=#0000ff]ByVal[/COLOR] I [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR], [COLOR=#0000ff]ByVal[/COLOR] j [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR], [COLOR=#0000ff]ByVal[/COLOR] C [COLOR=#0000ff]As[/COLOR] Color, [COLOR=#0000ff]ByVal[/COLOR] S [COLOR=#0000ff]As[/COLOR] Shape)
        [COLOR=#0000ff]Dim[/COLOR] CellW [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = PictureBox1.Width \ SizeW
        [COLOR=#0000ff]Dim[/COLOR] CellH [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = PictureBox1.Height \ SizeH
        [COLOR=#0000ff]Dim[/COLOR] x [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = I * CellW
        [COLOR=#0000ff]Dim[/COLOR] y [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Integer[/COLOR] = j * CellH
        [COLOR=#0000ff]Select[/COLOR] [COLOR=#0000ff]Case[/COLOR] S
            [COLOR=#0000ff]Case[/COLOR] Shape.Blank [COLOR=#008000]' Do Nothing
[/COLOR]            [COLOR=#0000ff]Case[/COLOR] Shape.Square
                g.FillRectangle([COLOR=#0000ff]New[/COLOR] SolidBrush(C), [COLOR=#0000ff]New[/COLOR] Rectangle(x, y, CellW, CellH))
            [COLOR=#0000ff]Case[/COLOR] Shape.Circle
                g.FillEllipse([COLOR=#0000ff]New[/COLOR] SolidBrush(C), [COLOR=#0000ff]New[/COLOR] Rectangle(x, y, CellW, CellH))
        [COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Select
[/COLOR]    [COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Sub

End[/COLOR] [COLOR=#0000ff]Class

Friend[/COLOR] [COLOR=#0000ff]Class[/COLOR] CellValue
    [COLOR=#0000ff]Public[/COLOR] CellColor [COLOR=#0000ff]As[/COLOR] Color = Color.White
    [COLOR=#0000ff]Public[/COLOR] CellShape [COLOR=#0000ff]As[/COLOR] Shape = Shape.Blank
    [COLOR=#0000ff]Public[/COLOR] CellName [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]String[/COLOR] = [COLOR=#a31515]""
[/COLOR][COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Class

Friend[/COLOR] [COLOR=#0000ff]Enum[/COLOR] Shape
    Blank
    Square
    Circle
[COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Enum[/COLOR][/FONT]





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users