Скроллинг
возник вопрос.. как можно допилить это приложение так, чтобы при скроллинге не было видно черной рамки вокруг изображения.
то есть чтобы при касании рамки бокса границ изображения- перемещение не производилось
вот код
Код:
public partial class Form1 : Form
{
bool Selected;
int xS, yS, X0, Y0;
Bitmap Bmp = new Bitmap(Properties.Resources.Koala);
public Form1()
{
InitializeComponent();
PB.MouseWheel += new System.Windows.Forms.MouseEventHandler(PB_MouseWheel);
PB.Image = new Bitmap(PB.Width, PB.Height);
using (Graphics Gr = Graphics.FromImage(PB.Image)) Gr.DrawImage(Bmp, 0, 0);
}
private void PB_MouseDown(object sender, MouseEventArgs e)
{
Selected = true;
xS = e.X;
yS = e.Y;
}
private void PB_MouseUp(object sender, MouseEventArgs e)
{
Selected = false;
}
private void PB_MouseMove(object sender, MouseEventArgs e)
{
if (Selected)
{
X0 -= xS - e.Location.X;
Y0 -= yS - e.Location.Y;
xS = e.Location.X;
yS = e.Location.Y;
using (Graphics Gr = Graphics.FromImage(PB.Image))
{
Gr.Clear(Color.Black);
Gr.DrawImage(Bmp, X0, Y0);
PB.Refresh();
}
}
}
private void PB_MouseEnter(object sender, EventArgs e)
{
PB.Focus();
}
}
{
bool Selected;
int xS, yS, X0, Y0;
Bitmap Bmp = new Bitmap(Properties.Resources.Koala);
public Form1()
{
InitializeComponent();
PB.MouseWheel += new System.Windows.Forms.MouseEventHandler(PB_MouseWheel);
PB.Image = new Bitmap(PB.Width, PB.Height);
using (Graphics Gr = Graphics.FromImage(PB.Image)) Gr.DrawImage(Bmp, 0, 0);
}
private void PB_MouseDown(object sender, MouseEventArgs e)
{
Selected = true;
xS = e.X;
yS = e.Y;
}
private void PB_MouseUp(object sender, MouseEventArgs e)
{
Selected = false;
}
private void PB_MouseMove(object sender, MouseEventArgs e)
{
if (Selected)
{
X0 -= xS - e.Location.X;
Y0 -= yS - e.Location.Y;
xS = e.Location.X;
yS = e.Location.Y;
using (Graphics Gr = Graphics.FromImage(PB.Image))
{
Gr.Clear(Color.Black);
Gr.DrawImage(Bmp, X0, Y0);
PB.Refresh();
}
}
}
private void PB_MouseEnter(object sender, EventArgs e)
{
PB.Focus();
}
}
никто не знает что ли?