如何点击pictureBox_MouseDown 事件加载硬盘上的图片,显示到pictureBox中

hinada99 2010-12-25 03:29:30
RT
我的代码如下,"D:\\VS08code\\NET_Test\\Draw\\Blackqi.jpg"是真实存在的jpg图片。想实现的效果就是点击一下pictureBox1,pic就会在pictureBox1上显示出来
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
PictureBox pic = new PictureBox();
pic.Size = new System.Drawing.Size(50, 50);
pic.Location = new System.Drawing.Point(e.X, e.Y);
pic.ImageLocation = "D:\\VS08code\\NET_Test\\Draw\\Blackqi.jpg";
this.Controls.Add(pic);
pic.BringToFront();
}
在线等待高手解答
...全文
203 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
lovelan1748 2010-12-25
  • 打赏
  • 举报
回复

[System.Runtime.InteropServices.DllImport("user32.dll", CharSet=CharSet.Auto)]
extern static bool DestroyIcon(IntPtr handle);

private void GetHicon_Example(PaintEventArgs e)
{

// Create a Bitmap object from an image file.
Bitmap myBitmap = new Bitmap(@"c:\FakePhoto.jpg");

// Draw myBitmap to the screen.
e.Graphics.DrawImage(myBitmap, 0, 0);

// Get an Hicon for myBitmap.
IntPtr Hicon = myBitmap.GetHicon();

// Create a new icon from the handle.
Icon newIcon = Icon.FromHandle(Hicon);

// Set the form Icon attribute to the new icon.
this.Icon = newIcon;

// Destroy the Icon, since the form creates
// its own copy of the icon.
DestroyIcon(newIcon.Handle);

}

参考Bitmap.GetHicon()
hinada99 2010-12-25
  • 打赏
  • 举报
回复
提示:
参数“picture”必须是可用作 Icon 的图片。

指向:
Icon icon = new Icon("D:\\VS08code\\NET_Test\\Draw\\Draw\\Blackqi.jpg");
hinada99 2010-12-25
  • 打赏
  • 举报
回复
hinada99 2010-12-25
  • 打赏
  • 举报
回复

//仿写12楼的代码,试图将jpg存成ico
private void button1_Click(object sender, EventArgs e)
{
SaveFileDialog sf = new SaveFileDialog();
if(sf.ShowDialog()==DialogResult.OK)
{
Icon icon = new Icon("D:\\VS08code\\NET_Test\\Draw\\Draw\\Blackqi.jpg");
icon.Save(sf.OpenFile());

}


}
lovelan1748 2010-12-25
  • 打赏
  • 举报
回复

private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
using (OpenFileDialog of = new OpenFileDialog())
{
if (of.ShowDialog() == DialogResult.OK)
{
//pictureBox1.Image = Image.FromFile(of.FileName);
Icon icon = new Icon(of.FileName);
icon.Save(stream);
}
}
}
lovelan1748 2010-12-25
  • 打赏
  • 举报
回复

private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
using (OpenFileDialog of = new OpenFileDialog())
{
if (of.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = Image.FromFile(of.FileName);
}
}

}
hinada99 2010-12-25
  • 打赏
  • 举报
回复
好吧
现在的问题是 如何将 jpg存成 ico
直接改 扩展名 不行~
lovelan1748 2010-12-25
  • 打赏
  • 举报
回复

private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
using (OpenFileDialog of = new OpenFileDialog())
{
if (of.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = Image.FromFile(of.FileName);
}
}

}
CXH_ME 2010-12-25
  • 打赏
  • 举报
回复
把名字改一下,MouseDown会覆盖基类的一个同名函数
另外,不需要那么多代码,如下就行
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
pictureBox1.ImageLocation = "D:\\VS08code\\NET_Test\\Draw\\Blackqi.jpg";
pictureBox1.BringToFront();
}
hinada99 2010-12-25
  • 打赏
  • 举报
回复
Icon ic = new Icon("绝对路径");
Graphics g = Graphics.FromHwnd(this.pictureBox1.Handle);
g.DrawIcon(ic, e.X, e.Y);

这样就行了
qldsrx 2010-12-25
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 hinada99 的回复:]
自己先顶一个
希望 wuqll快点看到我的帖子
[/Quote]
你为啥不自己去用Google之类的搜索引擎?他就是这么搜索了贴链接的,别指望过多的指导,只有链接或者复制别人的代码。

你的思维混乱,this.Controls.Add(pic);这句中,this是Form窗体,
pic.Location = new System.Drawing.Point(e.X, e.Y);中的坐标是相对pictureBox1的坐标,你不转换为相对Form的坐标,让Form怎么能正确摆放你的控件?而且这还涉及到互相覆盖的问题,你已经存在的pictureBox1上面叠加一个pictureBox2的话,谁覆盖谁还未知,显然是思维混乱。
hinada99 2010-12-25
  • 打赏
  • 举报
回复
会4#
挂在mouse_down事件上
Mouse_down的时候,e.X,e.Y位置会被 “红叉和Size(50, 50)”填充,也就是说,加载了图片,但是图片没有显示出来
我直接去路径下 打开图片,图片却能正常显示
lovelan1748 2010-12-25
  • 打赏
  • 举报
回复
逻辑乱七八糟,感觉自己机器好还是怎么的。。。
敢问你的pictureBox1_MouseDown挂在MouseDown事件上了吗
hinada99 2010-12-25
  • 打赏
  • 举报
回复
我的不行呀
图片显示不出来
xingsheng7 2010-12-25
  • 打赏
  • 举报
回复
可以啊,我试了下,可以啊
hinada99 2010-12-25
  • 打赏
  • 举报
回复
自己先顶一个
希望 wuqll快点看到我的帖子
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Diagnostics; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.timer1.Start(); } private void timer1_Tick(object sender, EventArgs e) { this.toolStripStatusLabel1.Text = "当前系统时间是:" + System.DateTime.Now.ToLongTimeString(); } private void Form1_FormClosed(object sender, FormClosedEventArgs e) { this.timer1.Stop(); } private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { //建立进程 Process p = new Process(); p.StartInfo.WorkingDirectory = "c:\\windows\\system32"; p.StartInfo.FileName = "rundll32.exe"; //锁屏命令 p.StartInfo.Arguments = "user32.dll,LockWorkStation"; p.Start(); } else if (e.Button == MouseButtons.Right) { ProcessStartInfo psInfo = new ProcessStartInfo("cmd.exe"); psInfo.RedirectStandardInput = true; psInfo.UseShellExecute = false; psInfo.CreateNoWindow = true; psInfo.RedirectStandardOutput = true; Process proc = new Process(); proc.StartInfo = psInfo; proc.Start(); proc.StandardInput.WriteLine("shutdown -r"); } else { this.Close(); } } private void pictureBox1_Click(object sender, EventArgs e) { } private void Form1_KeyPress(object sender, KeyPressEventArgs e) { MessageBox.Show(Convert.ToInt32(e.KeyChar).ToString()); } private void statusStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { } } }
Option Strict OnImports System.MathPublic Class MandelbrotForm Inherits System.Windows.Forms.Form#Region " Windows Form Designer generated code " Public Sub New() MyBase.New() ‘This call is required by the Windows Form Designer. InitializeComponent() ‘Add any initialization after the InitializeComponent() call End Sub ‘Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub ‘Required by the Windows Form Designer Private components As System.ComponentModel.IContainer ‘NOTE: The following procedure is required by the Windows Form Designer ‘It can be modified using the Windows Form Designer. ‘Do not modify it using the code editor. Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox Friend WithEvents txtMin As System.Windows.Forms.TextBox Friend WithEvents txtMax As System.Windows.Forms.TextBox Friend WithEvents txtColorMin As System.Windows.Forms.TextBox Friend WithEvents txtColorMax As System.Windows.Forms.TextBox Friend WithEvents bttnMandelbrot As System.Windows.Forms.Button Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents Label4 As System.Windows.Forms.Label Friend WithEvents Label5 As System.Windows.Forms.Label Friend WithEvents Label6 As System.Windows.Forms.Label Friend WithEvents bttnViewPrevious As System.Windows.Forms.Button Friend WithEvents bttnViewNext As System.Windows.Forms.Button Private Sub InitializeComponent() Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(MandelbrotForm)) Me.PictureBox1 = New System.Windows.Forms.PictureBox Me.bttnMandelbrot = New System.Windows.Forms.Button Me.bttnViewPrevious = New System.Windows.Forms.Button Me.bttnViewNext = New System.Windows.Forms.Button Me.txtMin = New System.Windows.Forms.TextBox Me.txtMax = New System.Windows.Forms.TextBox Me.txtColorMin = New System.Windows.Forms.TextBox Me.txtColorMax = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.Label3 = New System.Windows.Forms.Label Me.Label4 = New System.Windows.Forms.Label Me.Label5 = New System.Windows.Forms.Label Me.Label6 = New System.Windows.Forms.Label Me.SuspendLayout() ‘ ‘PictureBox1 ‘ Me.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.PictureBox1.Location = New System.Drawing.Point(5, 97) Me.PictureBox1.Name = "PictureBox1" Me.PictureBox1.Size = New System.Drawing.Size(512, 512) Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage Me.PictureBox1.TabIndex = 0 Me.PictureBox1.TabStop = False ‘ ‘bttnMandelbrot ‘ Me.bttnMandelbrot.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.bttnMandelbrot.Location = New System.Drawing.Point(62, 4) Me.bttnMandelbrot.Name = "bttnMandelbrot" Me.bttnMandelbrot.Size = New System.Drawing.Size(399, 30) Me.bttnMandelbrot.TabIndex = 1 Me.bttnMandelbrot.Text = "New Fractal" ‘ ‘bttnViewPrevious ‘ Me.bttnViewPrevious.Image = CType(resources.GetObject("bttnViewPrevious.Image"), System.Drawing.Image) Me.bttnViewPrevious.Location = New System.Drawing.Point(3, 4) Me.bttnViewPrevious.Name = "bttnViewPrevious" Me.bttnViewPrevious.Size = New System.Drawing.Size(50, 30) Me.bttnViewPrevious.TabIndex = 3 ‘ ‘bttnViewNext ‘ Me.bttnViewNext.Image = CType(resources.GetObject("bttnViewNext.Image"), System.Drawing.Image) Me.bttnViewNext.Location = New System.Drawing.Point(470, 4) Me.bttnViewNext.Name = "bttnViewNext" Me.bttnViewNext.Size = New System.Drawing.Size(50, 30) Me.bttnViewNext.TabIndex = 4 ‘ ‘txtMin ‘ Me.txtMin.Font = New System.Drawing.Font("Verdana", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(161, Byte)) Me.txtMin.Location = New System.Drawing.Point(61, 67) Me.txtMin.Name = "txtMin" Me.txtMin.Size = New System.Drawing.Size(46, 26) Me.txtMin.TabIndex = 6 Me.txtMin.Text = "0" ‘ ‘txtMax ‘ Me.txtMax.Font = New System.Drawing.Font("Verdana", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(161, Byte)) Me.txtMax.Location = New System.Drawing.Point(165, 67) Me.txtMax.Name = "txtMax" Me.txtMax.Size = New System.Drawing.Size(46, 26) Me.txtMax.TabIndex = 7 Me.txtMax.Text = "128" ‘ ‘txtColorMin ‘ Me.txtColorMin.Font = New System.Drawing.Font("Verdana", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(161, Byte)) Me.txtColorMin.Location = New System.Drawing.Point(336, 67) Me.txtColorMin.Name = "txtColorMin" Me.txtColorMin.Size = New System.Drawing.Size(46, 26) Me.txtColorMin.TabIndex = 9 Me.txtColorMin.Text = "0" ‘ ‘txtColorMax ‘ Me.txtColorMax.Font = New System.Drawing.Font("Verdana", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(161, Byte)) Me.txtColorMax.Location = New System.Drawing.Point(451, 67) Me.txtColorMax.Name = "txtColorMax" Me.txtColorMax.Size = New System.Drawing.Size(46, 26) Me.txtColorMax.TabIndex = 10 Me.txtColorMax.Text = "512" ‘ ‘Label1 ‘ Me.Label1.Font = New System.Drawing.Font("Verdana", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(161, Byte)) Me.Label1.Location = New System.Drawing.Point(11, 41) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(121, 22) Me.Label1.TabIndex = 11 Me.Label1.Text = "Iterations" ‘ ‘Label2 ‘ Me.Label2.Font = New System.Drawing.Font("Verdana", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(161, Byte)) Me.Label2.Location = New System.Drawing.Point(16, 72) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(39, 16) Me.Label2.TabIndex = 12 Me.Label2.Text = "Min" ‘ ‘Label3 ‘ Me.Label3.Font = New System.Drawing.Font("Verdana", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(161, Byte)) Me.Label3.Location = New System.Drawing.Point(120, 72) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(46, 16) Me.Label3.TabIndex = 13 Me.Label3.Text = "Max" ‘ ‘Label4 ‘ Me.Label4.Font = New System.Drawing.Font("Verdana", 14.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(161, Byte)) Me.Label4.Location = New System.Drawing.Point(285, 41) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(158, 22) Me.Label4.TabIndex = 14 Me.Label4.Text = "Color Range" ‘ ‘Label5 ‘ Me.Label5.Font = New System.Drawing.Font("Verdana", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(161, Byte)) Me.Label5.Location = New System.Drawing.Point(293, 72) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size(39, 16) Me.Label5.TabIndex = 15 Me.Label5.Text = "Min" ‘ ‘Label6 ‘ Me.Label6.Font = New System.Drawing.Font("Verdana", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(161, Byte)) Me.Label6.Location = New System.Drawing.Point(402, 72) Me.Label6.Name = "Label6" Me.Label6.Size = New System.Drawing.Size(46, 16) Me.Label6.TabIndex = 16 Me.Label6.Text = "Max" ‘ ‘MandelbrotForm ‘ Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(524, 620) Me.Controls.Add(Me.Label6) Me.Controls.Add(Me.Label5) Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.txtColorMax) Me.Controls.Add(Me.txtColorMin) Me.Controls.Add(Me.txtMax) Me.Controls.Add(Me.txtMin) Me.Controls.Add(Me.bttnViewNext) Me.Controls.Add(Me.bttnViewPrevious) Me.Controls.Add(Me.bttnMandelbrot) Me.Controls.Add(Me.PictureBox1) Me.KeyPreview = True Me.Name = "MandelbrotForm" Me.Text = "Fractal Generator: The Mandelbrot Set" Me.ResumeLayout(False) End Sub#End Region Dim XMin As Double, XMax As Double Dim YMin As Double, YMax As Double Dim XStart, YStart As Integer Dim XEnd, YEnd As Integer Dim currentFractal As Integer Dim breaknow As Boolean Dim limits As New ArrayList Structure Bounding Dim XMin As Double Dim XMax As Double Dim YMin As Double Dim YMax As Double End Structure Private Sub bttnMandelbrot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnMandelbrot.Click Static IterMin As Integer = 100000 Dim IterMax As Integer = -100000 Dim bmap As Bitmap bmap = New Bitmap(512, 512, Drawing.Imaging.PixelFormat.Format32bppPArgb) PictureBox1.Image = bmap Dim pX, pY As Integer Dim NX As Integer = 512 Dim NY As Integer = 512 Dim MaxIter As Integer Dim X, Y As Double Dim Iterations As Integer Dim minIterations As Integer = CInt(txtMin.Text) Dim maxIterations As Integer = CInt(txtMax.Text) Dim colorMin As Integer Dim colorMax As Integer Dim pixelColor As Color If IsNumeric(txtColorMin.Text) Then colorMin = CInt(txtColorMin.Text) If IsNumeric(txtColorMax.Text) Then colorMax = CInt(txtColorMax.Text) If IsNumeric(txtMin.Text) Then minIterations = CInt(txtMin.Text) If IsNumeric(txtMax.Text) Then maxIterations = CInt(txtMax.Text) If maxIterations <= minIterations Then MsgBox("The number of maximum iterations should be larger " & _ "than the number of minimum iterations") Exit Sub End If If colorMax <= colorMin Then MsgBox("The first color‘s value should be smalled than the last color‘s value") Exit Sub End If For pY = 0 To NY - 1 Y = YMin + pY * (YMax - YMin) / (NY - 1) For pX = 0 To NX - 1 X = (XMin + pX * (XMax - XMin) / (NY - 1)) Iterations = Mandelbrot(X, Y, maxIterations) Dim clr As Integer clr = CInt(colorMin + _ (colorMax - colorMin) / (maxIterations - minIterations) * _ (Iterations - minIterations)) clr = Math.Max(minIterations, clr) pixelColor = PaintPixel(clr) bmap.SetPixel(pX, pY, pixelColor) Next PictureBox1.Invalidate() Application.DoEvents() If breaknow Then breaknow = False Exit Sub End If Next End Sub Private Function PaintPixel(ByVal clr As Integer) As Color Select Case clr Case 0 To 256 - 1 Return Color.FromArgb(clr, 0, 0) Case 256 To 256 * 2 - 1 Return Color.FromArgb(255, clr - 256, 0) Case 256 * 2 To 256 * 3 - 1 Return Color.FromArgb(255, 255, clr - 256 * 2) Case 256 * 3 To 256 * 4 - 1 Return Color.FromArgb(255, clr - 256 * 3, clr - 256 * 3) Case 256 * 4 To 256 * 5 - 1 Return Color.FromArgb(255, 256 * 5 - clr - 1, 255) Case 256 * 5 To 256 * 6 - 1 Return Color.FromArgb(clr - 256 * 5, clr - 256 * 5, clr - 256 * 5) Case Else Return Color.FromArgb(clr Mod 256, clr Mod 256, clr Mod 256) End Select End Function Function Mandelbrot(ByVal Cx As Double, ByVal Cy As Double, ByVal max As Integer) As Integer Dim iter As Integer Dim X2, Y2 As Double Dim X, Y As Double Dim temp As Double Dim currentBounds As Bounding currentBounds = CType(limits.Item(currentFractal), Bounding) XMin = currentBounds.XMin XMax = currentBounds.XMax YMin = currentBounds.YMin YMax = currentBounds.YMax While iter < max And (Sqrt(X2 * X2 + Y2 * Y2) < 100000) temp = X2 - Y2 + Cx Y = 2 * X * Y + Cy X = temp X2 = X * X Y2 = Y * Y * Y iter = iter + 1 End While Return (iter) End Function Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown XStart = e.X YStart = e.Y End Sub Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove If e.Button <> MouseButtons.Left Then Exit Sub PictureBox1.Refresh() Dim newX, newY As Integer newX = e.X newY = e.Y If Math.Abs(newX - XStart) < Math.Abs(newY - YStart) Then newY = YStart + Math.Abs(newX - XStart) Else newX = XStart + Math.Abs(newY - YStart) End If PictureBox1.CreateGraphics.DrawRectangle(Pens.White, XStart, YStart, newX - XStart, newY - YStart) End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load XMin = -1.5 : XMax = 0.5 YMin = -1 : YMax = 1 Dim currentBounds As Bounding currentBounds.XMin = XMin currentBounds.XMax = XMax currentBounds.YMin = YMin currentBounds.YMax = YMax limits.Add(currentBounds) End Sub Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp XEnd = e.X YEnd = e.Y If Math.Abs(XEnd - XStart) < Math.Abs(YEnd - YStart) Then YEnd = YStart + Math.Abs(XEnd - XStart) Else XEnd = XStart + Math.Abs(YEnd - YStart) End If Dim currentBounds As Bounding currentBounds = CType(limits.Item(currentFractal), Bounding) XMin = currentBounds.XMin XMax = currentBounds.XMax YMin = currentBounds.YMin YMax = currentBounds.YMax If XEnd <> 0 And YEnd <> 0 Then Dim DX, DY As Double DX = XMax - XMin DY = YMax - YMin Dim newXMin, newXMax, newYMin, newYMax As Double newXMin = XMin + DX * XStart / PictureBox1.Width newXMax = XMin + DX * XEnd / PictureBox1.Width newYMin = YMin + DY * YStart / PictureBox1.Height newYMax = YMin + DY * YEnd / PictureBox1.Height XMin = newXMin : XMax = newXMax YMin = newYMin : YMax = newYMax currentBounds.XMin = XMin currentBounds.XMax = XMax currentBounds.YMin = YMin currentBounds.YMax = YMax limits.Add(currentBounds) currentFractal = currentFractal + 1 End If End Sub Private Sub bttnViewNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnViewNext.Click Dim currentBounds As Bounding currentBounds.XMin = XMin currentBounds.XMax = XMax currentBounds.YMin = YMin currentBounds.YMax = YMax limits.Add(currentBounds) currentFractal += 1 If currentFractal <= limits.Count Then bttnMandelbrot_Click(sender, e) End If End Sub Private Sub bttnViewPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnViewPrevious.Click currentFractal = currentFractal - 1 If currentFractal >= 0 Then bttnMandelbrot_Click(sender, e) Else currentFractal = 0 End If End Sub Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp If e.KeyCode = Keys.Escape Then breaknow = True End If End SubEnd Class

110,502

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧