using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private Image imgOriginal;
private void Form1_Load(object sender, EventArgs e)
{
zoomSlider.Minimum = 1;
zoomSlider.Maximum = 5;
zoomSlider.SmallChange = 1;
zoomSlider.LargeChange = 1;
zoomSlider.UseWaitCursor = false;
this.DoubleBuffered = true;
}
public Image PictureBoxZoom(Image img, Size size)
{
imgOriginal = Image.FromFile(openFileDialog1.FileName);
Bitmap bm = new Bitmap(imgOriginal, Convert.ToInt32(imgOriginal.Width * size.Width), Convert.ToInt32(imgOriginal.Height * size.Height));
Graphics grap = Graphics.FromImage(bm);
return bm;
}
private void zoomSlider_Scroll(object sender, EventArgs e)
{
if (zoomSlider.Value > 0)
{
picBox.Image = null;
picBox.Image = PictureBoxZoom(imgOriginal, new Size(zoomSlider.Value, zoomSlider.Value));
}
}
private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
DialogResult res = MessageBox.Show("Message", "Try", MessageBoxButtons.YesNo);
if (res == DialogResult.Yes)
{
string imagepath = openFileDialog1.FileName;
picBox.ImageLocation = imagepath;
}
else
{
MessageBox.Show("picture cancelled", "message");
}
}
}
}