写真を表示するアプリを作っていきます。「削除」機能を追加したいのですが、問題が発生しました。問題は写真間のギャップです。それらを削除したい。
例えば:
私はこのような配列を持っています:
{1 = image_1, 2 = image_2, 3 = image_3}
image_2 を削除すると、次のようになります。
{1 = image_1, 2 = nil, 3 = image_3}
私が欲しい:
{1 = image_1, 2 = Image_3}
コード:
Public Class Form1
Dim latestImageId As Integer = 0
Dim dispPictureId As Integer = 0
Dim images(128) As Image
Private Sub CapturePic(sender As Object, e As EventArgs) Handles TestToolStripMenuItem.Click
If My.Computer.Clipboard.ContainsImage() Then
latestImageId = (latestImageId + 1)
images(latestImageId) = My.Computer.Clipboard.GetImage()
If dispPictureId = 0 Then
Label1.Text = dispPictureId
dispPictureId = 1
PictureBox1.Image = images(dispPictureId)
End If
End If
Label1.Text = dispPictureId
End Sub
Private Sub Nex_Click(sender As Object, e As EventArgs) Handles Nex.Click
If Not images(dispPictureId + 1) Is Nothing Then
PictureBox1.Image = images(dispPictureId + 1)
Else
Exit Sub
End If
dispPictureId = (dispPictureId + 1) Mod images.Length
Label1.Text = dispPictureId
End Sub
Private Sub Pre_Click(sender As Object, e As EventArgs) Handles Pre.Click
If Not images(dispPictureId - 1) Is Nothing Then
PictureBox1.Image = images(dispPictureId - 1)
Else
Exit Sub
End If
dispPictureId = (dispPictureId - 1) Mod images.Length
Label1.Text = dispPictureId
End Sub
Private Sub Del_Click(sender As Object, e As EventArgs) Handles Del.Click
images(dispPictureId) = Nothing
If images(dispPictureId) Is Nothing Then
dispPictureId = dispPictureId - 1
End If
dispPictureId = 1
Label1.Text = dispPictureId
End Sub
End Class