本文整理汇总了C#中System.Windows.Forms.PictureBox.Update方法的典型用法代码示例。如果您正苦于以下问题:C# PictureBox.Update方法的具体用法?C# PictureBox.Update怎么用?C# PictureBox.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.PictureBox
的用法示例。
在下文中一共展示了PictureBox.Update方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CenterPictureBox
private void CenterPictureBox(PictureBox picBox, Bitmap picImage)
{
picBox.Image = picImage;
picBox.Location = new Point((picBox.Parent.ClientSize.Width / 2) - (picImage.Width / 2),
(picBox.Parent.ClientSize.Height /2) - (picImage.Height / 2));
picBox.Refresh();
picBox.Update();
}
示例2: updateGUI
private void updateGUI(PictureBox picBox, Bitmap img)
{
picBox.Image = img;
picBox.Invalidate();
picBox.Update();
picBox.Refresh();
Application.DoEvents();
}
示例3: LoadImage
/// <summary>
/// Load an image into a picture box, maintain its aspect ratio...
/// </summary>
/// <param name="a_picturebox">The picture box we're drawing to</param>
/// <param name="a_graphics">The graphics backing the picture box</param>
/// <param name="a_bitmapGraphic">Characteristics of the target</param>
/// <param name="a_bitmap">The source image</param>
private void LoadImage(ref PictureBox a_picturebox, ref Graphics a_graphics, ref Bitmap a_bitmapGraphic, Bitmap a_bitmap)
{
// We want to maintain the aspect ratio...
double fRatioWidth = (double)a_bitmapGraphic.Size.Width / (double)a_bitmap.Width;
double fRatioHeight = (double)a_bitmapGraphic.Size.Height / (double)a_bitmap.Height;
double fRatio = (fRatioWidth < fRatioHeight) ? fRatioWidth : fRatioHeight;
int iWidth = (int)(a_bitmap.Width * fRatio);
int iHeight = (int)(a_bitmap.Height * fRatio);
// Display the image...
a_graphics.FillRectangle(m_brushBackground, m_rectangleBackground);
a_graphics.DrawImage(a_bitmap, new Rectangle(((int)a_bitmapGraphic.Width - iWidth)/2, ((int)a_bitmapGraphic.Height - iHeight)/2, iWidth, iHeight));
a_picturebox.Image = a_bitmapGraphic;
a_picturebox.Update();
}
示例4: PlotBackground
internal void PlotBackground(PictureBox pbox, int order)
{
pbox.Image = new Bitmap(pbox.Width, pbox.Height, PixelFormat.Format24bppRgb);
Bitmap bmp = new Bitmap(pbox.Width, pbox.Height, PixelFormat.Format24bppRgb);
int[,] bgModel = GenerateBackground(order, 1, 0, 0, m_X0, m_Y0, Math.Max(pbox.Width, pbox.Height));
for (int x = 0; x < pbox.Width; x++)
{
for (int y = 0; y < pbox.Height; y++)
{
int clr = Math.Max(0, Math.Min(255, bgModel[x, y]));
bmp.SetPixel(x, y, Color.FromArgb(clr, clr, clr));
}
}
using (Graphics g = Graphics.FromImage(pbox.Image))
{
g.DrawImage(bmp, 0, 0);
g.Save();
}
pbox.Invalidate();
pbox.Update();
}
示例5: UpdateDocumentPreview
private void UpdateDocumentPreview()
{
flpContentItems.Controls.Clear();
foreach (var page in CurrentDocument.Pages)
{
Image source = Image.FromFile(page.Path);
PictureBox box = new PictureBox() { Width = 100, Height = 140, SizeMode = PictureBoxSizeMode.CenterImage };
box.MouseMove += new MouseEventHandler(OnMouseMove);
box.MouseClick += new MouseEventHandler(OnMouseClick);
new ToolTip().SetToolTip(box, Resources.PageToolTip);
Bitmap bitmap = new Bitmap(box.Width, box.Height, PixelFormat.Format32bppPArgb);
Graphics graphics = Graphics.FromImage(bitmap);
graphics = Graphics.FromImage(bitmap);
graphics.CompositingMode = CompositingMode.SourceCopy;
graphics.CompositingQuality = CompositingQuality.HighSpeed;
graphics.InterpolationMode = InterpolationMode.Low;
graphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;
graphics.SmoothingMode = SmoothingMode.HighSpeed;
SolidBrush brush = new SolidBrush(Color.White);
Rectangle rectangle = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
double fRatioWidth = (double)bitmap.Size.Width / (double)source.Width;
double fRatioHeight = (double)bitmap.Size.Height / (double)source.Height;
double fRatio = (fRatioWidth < fRatioHeight) ? fRatioWidth : fRatioHeight;
int iWidth = (int)(source.Width * fRatio);
int iHeight = (int)(source.Height * fRatio);
graphics.FillRectangle(brush, rectangle);
graphics.DrawImage(source, new Rectangle(((int)bitmap.Width - iWidth) / 2, ((int)bitmap.Height - iHeight) / 2, iWidth, iHeight));
box.Image = bitmap;
box.Name = page.Id;
box.Update();
flpContentItems.Controls.Add(box);
}
flpContentItems.Invalidate();
}
示例6: DrawMatrix
private void DrawMatrix(BinImage bi, PictureBox p)
{
// pictureBox1.Dispose();
btp = new Bitmap(bi.Width, bi.Height);
for (int i = 0; i < bi.Width; ++i)
for (int j = 0; j < bi.Height; ++j)
if (bi.matr[i, j] == 1)
btp.SetPixel(i, j, Color.White);
else
btp.SetPixel(i, j, Color.Black);
p.Image = btp;
p.Invalidate();
p.Update();
}
示例7: Zeichne
public void Zeichne(PictureBox pictureBox, int[] feldData)
{
Bitmap ausgabe = new Bitmap(feldBreite * 32 + 32, feldHöhe * 32 + 32, PixelFormat.Format32bppRgb);
Graphics g = Graphics.FromImage(ausgabe);
for (int y = 0; y < feldHöhe; y++)
{
for (int x = 0; x < feldBreite; x++)
{
int f = feldData[x + y * feldBreite];
if ((uint)f < bilder.Length && bilder[f] != null) g.DrawImage(bilder[f], x * 32 + 16, y * 32 + 16);
}
}
pictureBox.Image = ausgabe;
pictureBox.Update();
GC.Collect();
}
示例8: Initialize
public void Initialize(Character _Character, TabControl _SkillTabs)
{
UpdateLabels();
int _Column, _Row;
foreach (TabPage _TabPage in _SkillTabs.TabPages)
{
_Column = 0;
_Row = 0;
foreach (Skill _Skill in _Character.Skills)
{
if (_Skill.TabNumber == _TabPage.Text)
{
PictureBox _SkillBackground = new PictureBox();
PictureBox _SkillIcon = new PictureBox();
PictureBox _PlusIconOn = new PictureBox();
PictureBox _PlusIconOff = new PictureBox();
PictureBox _FirstNumber = new PictureBox();
PictureBox _SecondNumber = new PictureBox();
PictureBox _Slash = new PictureBox();
_SkillBackground.Image = (Image)_ResourceManager.GetObject("SkillBack".Replace(".png", "")); //Grey background to draw all the icons on;
_SkillBackground.Location = new Point(_SkillBackground.Image.Width *
_Column,
(int)_SkillBackground.Image.Height *
_Row);
_SkillBackground.Size = _SkillBackground.Image.Size; //(Background.Width/Tab.Width) * height so it only drops when the tab is full, because that returns 0 unless background's width is same as tab width;
_SkillIcon.Image = (Image)_ResourceManager.GetObject(_Skill.IconName.Replace(".png", "")); //The skill icon;
_SkillIcon.Location = new Point(_SkillBackground.Location.X + 5,
_SkillBackground.Location.Y + 5);
_SkillIcon.Size = _SkillIcon.Image.Size;
_PlusIconOn.Image = (Image)_ResourceManager.GetObject("SkillAddP_N".Replace(".png", "")); //Plus icon to indicate that SP is available and that skill is learnable;
_PlusIconOn.Location = new Point(_SkillBackground.Location.X + 54,
_SkillBackground.Location.Y + 23);
_PlusIconOn.Size = _PlusIconOn.Image.Size;
_PlusIconOff.Image = (Image)_ResourceManager.GetObject("SkillAddP_D".Replace(".png", "")); //Plus icon to indicate that SP is available and that skill is learnable;
_PlusIconOff.Location = new Point(_SkillBackground.Location.X + 54,
_SkillBackground.Location.Y + 23);
_PlusIconOff.Size = _PlusIconOn.Image.Size;
_PlusIconOn.MouseHover += (_Sender, _E) => //Event handler for hovering over the Plus icon;
{
_PlusIconOn.Image = (Image)_ResourceManager.GetObject("SkillAddP_H".Replace(".png", ""));
};
_PlusIconOn.MouseClick += (_Sender, _E) => //Event handler for clicking the Plus icon;
{
_PlusIconOn.Image = (Image)_ResourceManager.GetObject("SkillAddP_C".Replace(".png", ""));
_PlusIconOn.Update();
_Character.SkillPoints--;
_Character.UsedSkillPoints++;
UpdateLabels();
_Skill.CurrentLevel++;
if (_Character.SkillPoints == 0)
foreach (Skill _SkillToDisable in _Character.Skills)
{
_SkillToDisable.Assets.Find(PictureBox => PictureBox.Name == "_PlusIconOn").Enabled = false;
_SkillToDisable.Assets.Find(PictureBox => PictureBox.Name == "_PlusIconOn").Visible = false;
_SkillToDisable.Assets.Find(PictureBox => PictureBox.Name == "_PlusIconOff").BringToFront();
}
else if (_Skill.CurrentLevel == _Skill.MaxLevel)
{
_FirstNumber.Image = (Image)_ResourceManager.GetObject("_" + _Skill.CurrentLevel.ToString().Replace(".png", "") + "_d");
_Slash.Image = (Image)_ResourceManager.GetObject("div_d".Replace(".png", ""));
_SecondNumber.Image = (Image)_ResourceManager.GetObject("_" + _Skill.MaxLevel.ToString().Replace(".png", "") + "_d");
_PlusIconOn.Enabled = false;
_PlusIconOn.Visible = false;
_PlusIconOff.BringToFront();
}
else if (_Skill.CurrentLevel > 9)
{
_FirstNumber.Image = (Image)_ResourceManager.GetObject("_" + _Skill.CurrentLevel.ToString().Replace(".png", ""));
_FirstNumber.Location = new Point(_Slash.Location.X - 14, _Slash.Location.Y);
_FirstNumber.Size = new Size(_FirstNumber.Image.Size.Width, _FirstNumber.Image.Size.Height);
}
else
{
_FirstNumber.Image = (Image)_ResourceManager.GetObject("_" + _Skill.CurrentLevel.ToString().Replace(".png", ""));
System.Threading.Thread.Sleep(40);
_PlusIconOn.Image = (Image)_ResourceManager.GetObject("SkillAddP_H".Replace(".png", ""));
}
};
_PlusIconOn.MouseLeave += (_Sender, _E) => //Event handler for leaving the perimeter of the Plus icon;
{
_PlusIconOn.Image = (Image)_ResourceManager.GetObject("SkillAddP_N".Replace(".png", ""));
};
_Slash.Image = (Image)_ResourceManager.GetObject("div".Replace(".png", "")); //Slash icon to divide the currentLevel and maxLevel;
_Slash.Location = new Point(_SkillBackground.Location.X + 67,
_SkillBackground.Location.Y + 8);
_Slash.Size = _Slash.Image.Size;
_Skill.Assets.Add(_SkillBackground);
_Skill.Assets.Add(_SkillIcon);
_Skill.Assets.Add(_PlusIconOn);
_Skill.Assets.Add(_Slash);
_TabPage.Controls.Add(_SkillBackground); //Adding all the PictureBoxes to the TabControl;
_TabPage.Controls.Add(_SkillIcon);
//.........这里部分代码省略.........
示例9: drawSingleTriangle
public void drawSingleTriangle(Triangle tr,PictureBox p)
{
init();
Bitmap p1 = new Bitmap(MATRIX_SIZE, MATRIX_SIZE);
for (int i = 0; i < MATRIX_SIZE; ++i)
for (int j = 0; j < MATRIX_SIZE; ++j)
{
if (tr.matr[i, j] == 0)
p1.SetPixel(i, j, Color.White);
else
p1.SetPixel(i, j, Color.Black);
}
p.Image = p1;
p.Update();
}
示例10: DrawLineFromComponent
private void DrawLineFromComponent(PictureBox sender, MouseEventArgs e)
{
Bitmap tmp = new Bitmap(imageBeforeDrag);
using (Graphics gr = Graphics.FromImage(tmp))
{
gr.SmoothingMode = SmoothingMode.AntiAlias;
gr.DrawLine(arrowDrawingPen, dragStartingPoint, e.Location);
}
sender.Image = tmp;
sender.Update();
}