1 Replies - 345 Views - Last Post: 26 December 2012 - 01:03 PM Rate Topic: -----

#1 jtabel  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 26-December 12

Shuffle problem!

Posted 26 December 2012 - 12:49 PM

I am having a problem with my program, I am trying to shuffle a bunch of picture boxes and then unshuffle them I have tried the Fisher–Yates shuffle with no luck. please show me an example.I am using a standard form with a panel on it, A picturebox, textbox and three buttons.

Imports System.Drawing
Imports System.Windows.Forms

Public Class Form1
    Private Sub TestSplit()
        Dim fr_bm As New Bitmap(PictureBox1.Image)
        Dim wid As Integer = PictureBox1.Image.Width \ 8
        Dim hgt As Integer = PictureBox1.Image.Height \ 6
        Dim colnum, rownum As Integer
        For rownum = 0 To 5
            For colnum = 0 To 7
                Dim to_bm As New Bitmap(PictureBox1.Image)
                Dim gr As Graphics = Graphics.FromImage(to_bm)
                Dim fr_rect As New Rectangle(colnum * wid, rownum * hgt, hgt, hgt)
                Dim to_rect As New Rectangle(0, 0, wid, hgt)
                gr.DrawImage(fr_bm, to_rect, fr_rect, GraphicsUnit.Pixel)
                Dim MyPictureBox As New PictureBox
                MyPictureBox.Height = hgt
                MyPictureBox.Width = wid
                MyPictureBox.Left = colnum * hgt
                MyPictureBox.Top = rownum * wid
                MyPictureBox.BorderStyle = BorderStyle.FixedSingle
                'MyPictureBox.SizeMode = PictureBoxSizeMode.Normal
                MyPictureBox.Image = to_bm
                MyPictureBox.Name = "PicBox" & rownum & colnum
                Panel1.Controls.Add(MyPictureBox)
            Next
        Next
    End Sub
    Private Sub OpenButt_Click(sender As System.Object, e As System.EventArgs) Handles OpenButt.Click
        Using O As New OpenFileDialog With {.Filter = "(Image Files)|*.jpg;*.png;*.bmp;*.gif;*.ico|Jpg, | *.jpg|Png, | *.png|Bmp, | *.bmp|Gif, | *.gif|Ico | *.ico", .Multiselect = False, .Title = "Select image"}
            If O.ShowDialog = 1 Then
                TextBox1.Text = O.FileName
                PictureBox1.Image = Image.FromFile(O.FileName)
                PictureBox1.SizeMode = PictureBoxSizeMode.Zoom
            Else
                TextBox1.Clear()
            End If

        End Using
    End Sub

    Private Sub BoardButt_Click(sender As System.Object, e As System.EventArgs) Handles BoardButt.Click
        TestSplit()
    End Sub

    Private Sub ShuffleButt_Click(sender As System.Object, e As System.EventArgs) Handles ShuffleButt.Click

    End Sub
End Class


Is This A Good Question/Topic? 0
  • +

Replies To: Shuffle problem!

#2 lucky3  Icon User is offline

  • Friend lucky3 As IHelpable
  • member icon

Reputation: 231
  • View blog
  • Posts: 765
  • Joined: 19-October 11

Re: Shuffle problem!

Posted 26 December 2012 - 01:03 PM

I just added this shuffle snippet 6 days ago... and it seems I forgot to check for negative number as optional parameter... will fix that.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1