本文整理汇总了C#中System.Windows.Forms.Form.Refresh方法的典型用法代码示例。如果您正苦于以下问题:C# Form.Refresh方法的具体用法?C# Form.Refresh怎么用?C# Form.Refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Form
的用法示例。
在下文中一共展示了Form.Refresh方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowDialog
public static string ShowDialog(string text, string caption, List<string> comboitems)
{
prompt = new Form();
prompt.SizeChanged += new System.EventHandler(SimpleCombo_SizeChanged);
prompt.AutoSizeMode = AutoSizeMode.GrowOnly;
prompt.Padding = new Padding(50);
prompt.Text = caption;
textLabel = new Label() { Text = text, AutoSize = true};
textLabel.Left = (int)Math.Ceiling((double)(prompt.Width - textLabel.Width) * 0.5);
textLabel.Top = (int)Math.Ceiling((double)(prompt.Height - textLabel.Height) * 0.25);
comboBox = new ComboBox() { DataSource = comboitems, MinimumSize = new System.Drawing.Size(500,20)};
comboBox.Left = (int)Math.Ceiling((double)(prompt.Width - comboBox.Width) * 0.5);
comboBox.Top = (int)Math.Ceiling((double)(prompt.Height - comboBox.Height) * 0.5);
confirmation = new Button() {Text = "OK" };
confirmation.Left = (int)Math.Ceiling((double)(prompt.Width - confirmation.Width) * 0.5);
confirmation.Top = (int)Math.Ceiling((double)(prompt.Height - confirmation.Height) * 0.75);
confirmation.Click += (sender, e) => { prompt.Close(); };
prompt.Controls.Add(confirmation);
prompt.Controls.Add(textLabel);
prompt.Controls.Add(comboBox);
prompt.AcceptButton = confirmation;
prompt.AutoSize = true;
prompt.Refresh();
prompt.ShowDialog();
return comboBox.SelectedItem.ToString();
}
示例2: setPermission
/// <summary>
///
/// </summary>
/// <param name="mainForm"></param>
/// <param name="clientInfo"></param>
public static void setPermission(Form mainForm,ClientInfo clientInfo)
{
MenuStrip mainMenu = mainForm.MainMenuStrip;
setPermission(clientInfo.LoggedUser, ref mainMenu, clientInfo.MenuPermissions);
mainForm.Invalidate();
mainForm.Refresh();
mainMenu.Refresh();
}
示例3: FadeIn
public static void FadeIn(Form frm)
{
float FadeIn;
for (FadeIn = 0.0f; FadeIn <= 1.1; FadeIn += 0.1f)
{
frm.Opacity = FadeIn;
frm.Refresh();
System.Threading.Thread.Sleep(100);
}
}
示例4: FadeOut
public static void FadeOut(Form frm)
{
float FadeOut;
for (FadeOut = 90; FadeOut >= 10; FadeOut += -10)
{
frm.Opacity = FadeOut / 100;
frm.Refresh();
System.Threading.Thread.Sleep(100);
}
}
示例5: AttachForm
public static void AttachForm(Form form)
{
Action<string> handler = msg => form.BeginInvoke((Action)(() =>
{
form.Text = msg;
form.Refresh();
}));
MessageSanded += handler;
form.Closed += (s, e) => MessageSanded -= handler;
}
示例6: FadeOut
public void FadeOut(Form TargetForm, double FadeStep)
{
if (TargetForm.Visible == false)
{
return;
}
for (_i = 1; _i >= _MinOpacity; _i -= FadeStep)
{
TargetForm.Opacity = _i;
TargetForm.Refresh();
}
}
示例7: FadeIn
public void FadeIn(Form TargetForm, double FadeStep)
{
if (TargetForm.Visible == false)
{
TargetForm.Opacity = 0;
TargetForm.Visible = true;
}
for (_i = 0; _i <= _MaxOpacity; _i += FadeStep)
{
TargetForm.Opacity = _i;
TargetForm.Refresh();
}
}
示例8: SpawnAnimationThread
public static void SpawnAnimationThread(LayoutEngine layoutEngine, Form form, int interFrameSleepTimeMillis)
{
BackgroundWorker animationThread = new BackgroundWorker();
animationThread.WorkerReportsProgress = true;
animationThread.WorkerSupportsCancellation = true;
animationThread.DoWork += new DoWorkEventHandler(delegate(object sender, DoWorkEventArgs e)
{
while (true)
{
layoutEngine.incrementLayout();
Thread.Sleep(interFrameSleepTimeMillis);
//Console.Out.WriteLine("Animating " + i);
animationThread.ReportProgress(0);
}
});
animationThread.ProgressChanged += new ProgressChangedEventHandler(delegate(object sender, ProgressChangedEventArgs e)
{
form.Refresh();
});
animationThread.RunWorkerAsync();
}
示例9: CardQuizzer
//https://stackoverflow.com/questions/5427020/prompt-dialog-in-windows-forms
public static void CardQuizzer(string caption, string text)
{
Form prompt = new Form();
prompt.Width = 500;
prompt.Height = 500;
prompt.FormBorderStyle = FormBorderStyle.FixedDialog;
prompt.Text = caption;
prompt.StartPosition = FormStartPosition.CenterScreen;
Label textLabel = new Label() { Left = 50, Top = 20, Text = text };
TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 };
Button confirmation = new Button() { Text = "Confirm", Left = 300, Width = 100, Top = 70, DialogResult = DialogResult.OK };
Button denial = new Button() { Text = "Update", Left = 200, Width = 100, Top = 70};
confirmation.Click += (sender, e) => { prompt.Close(); };
denial.Click += (sender, e) => { prompt.Refresh(); }; //maybe refreshes form, build method to [.Refresh() or .Update()]
//prompt.Controls.Add(textBox);
prompt.Controls.Add(confirmation);
prompt.Controls.Add(denial);
prompt.Controls.Add(textLabel);
//prompt.AcceptButton = confirmation;
prompt.ShowDialog();
}
示例10: FadeForm
/// <summary>
/// Function used to fade out a form using a user defined number
/// of steps.
/// </summary>
/// <param name="f">The Windows form to fade out</param>
/// <param name="NumberOfSteps">The number of steps used to fade the form</param>
public static void FadeForm(Form form, byte NumberOfSteps, bool fadeIn)
{
float StepVal = (float)(100f / NumberOfSteps);
float fOpacity = 0;
if (!fadeIn)
{
fOpacity = 100f;
}
for (byte b = 0; b < NumberOfSteps; b++)
{
form.Opacity = fOpacity / 100;
form.Refresh();
if (fadeIn)
{
fOpacity += StepVal;
}
else
{
fOpacity -= StepVal;
}
}
}
示例11: OffscreenGrab
/// <summary>
/// Gets an image snapshot of the specified control, which does not have to be
/// mapped to a <see cref="System.Windows.Forms.Form"/> and does not have to be
/// fully visible.
/// </summary>
/// <param name="control">The control to get an image snapshot of.</param>
/// <returns>An image snapshot of the control.</returns>
public static Image OffscreenGrab(Control control) {
// Save the old parent and location.
Control oldParent = control.Parent;
Point oldLocation = control.Location;
// Create a form offscreen
Form transpForm = new Form();
transpForm.StartPosition = FormStartPosition.Manual;
transpForm.Location = new Point(Screen.PrimaryScreen.Bounds.Right + 10, 0);
transpForm.ClientSize = new Size(control.Width + 10, control.Height + 10);
// Make the form semi-transparent so windows turns on layering.
transpForm.Opacity = .8;
// Add the control.
transpForm.Controls.Add(control);
control.Location = new Point(0, 0);
// Show the form (offscreen).
transpForm.Show();
transpForm.Visible = true;
transpForm.Refresh();
transpForm.Update();
// Grab the control.
Image img = GrabControl(control);
// Put the control back on its original form.
control.Parent = oldParent;
control.Location = oldLocation;
// Get rid of our temporary form.
transpForm.Close();
// Return the image.
return img;
}
示例12: ThreadFunction
private void ThreadFunction()
{
try
{
// show window
Form window = new Form();
window.FormClosing += FormOnClose;
window.Text = "Map";
//window.Size = new System.Drawing.Size(800, 600);
window.AutoSize = true;
while (true)
{
lock (this)
{
if (bitmap != null)
{
if (window.Visible != visible)
{
if (visible)
{
if (first)
{
PictureBox picture = new PictureBox();
picture.Image = bitmap;
picture.SizeMode = PictureBoxSizeMode.AutoSize;
window.Controls.Add(picture);
first = false;
}
window.Show();
}
else
{
window.Hide();
}
}
}
if (updated)
{
if (window.Visible)
{
window.Refresh();
}
updated = false;
}
if (window.Visible)
{
Application.DoEvents();
}
}
Thread.Sleep(100);
}
}
catch (ThreadInterruptedException e)
{
// do nothing
}
}
示例13: CaptureWindowWithDWM
/// <summary>
/// Make a full-size thumbnail of the captured window on a new topmost form, and capture
/// this new form with a black and then white background. Then compute the transparency by
/// difference between the black and white versions.
/// This method has these advantages:
/// - the full form is captured even if it is obscured on the Windows desktop
/// - there is no problem with unpredictable Z-order anymore (the background and
/// the window to capture are drawn on the same window)
/// </summary>
/// <param name="handle">handle of the window to capture</param>
/// <param name="windowRect">the bounds of the window</param>
/// <param name="redBGImage">the window captured with a red background</param>
/// <param name="captureRedBGImage">whether to do the capture of the window with a red background</param>
/// <returns>the captured window image</returns>
private static Image CaptureWindowWithDWM(IntPtr handle, Rectangle windowRect, out Bitmap redBGImage, Color backColor)
{
Image windowImage = null;
redBGImage = null;
if (backColor != Color.White)
{
backColor = Color.FromArgb(255, backColor.R, backColor.G, backColor.B);
}
using (Form form = new Form())
{
form.StartPosition = FormStartPosition.Manual;
form.FormBorderStyle = FormBorderStyle.None;
form.ShowInTaskbar = false;
form.BackColor = backColor;
form.TopMost = true;
form.Bounds = CaptureHelpers.GetWindowRectangle(handle, false);
IntPtr thumb;
NativeMethods.DwmRegisterThumbnail(form.Handle, handle, out thumb);
SIZE size;
NativeMethods.DwmQueryThumbnailSourceSize(thumb, out size);
#if DEBUG
DebugHelper.WriteLine("Rectangle Size: " + windowRect.ToString());
DebugHelper.WriteLine("Window Size: " + size.ToString());
#endif
if (size.Width <= 0 || size.Height <= 0)
{
return null;
}
DWM_THUMBNAIL_PROPERTIES props = new DWM_THUMBNAIL_PROPERTIES();
props.dwFlags = NativeMethods.DWM_TNP_VISIBLE | NativeMethods.DWM_TNP_RECTDESTINATION | NativeMethods.DWM_TNP_OPACITY;
props.fVisible = true;
props.opacity = (byte)255;
props.rcDestination = new RECT(0, 0, size.Width, size.Height);
NativeMethods.DwmUpdateThumbnailProperties(thumb, ref props);
form.Show();
System.Threading.Thread.Sleep(250);
if (form.BackColor != Color.White)
{
// no need for transparency; user has requested custom background color
NativeMethods.ActivateWindowRepeat(form.Handle, 250);
windowImage = Screenshot.CaptureRectangleNative(windowRect) as Bitmap;
}
else if (form.BackColor == Color.White)
{
// transparent capture
NativeMethods.ActivateWindowRepeat(handle, 250);
Bitmap whiteBGImage = Screenshot.CaptureRectangleNative(windowRect) as Bitmap;
form.BackColor = Color.Black;
form.Refresh();
NativeMethods.ActivateWindowRepeat(handle, 250);
Bitmap blackBGImage = Screenshot.CaptureRectangleNative(windowRect) as Bitmap;
// Capture rounded corners with except for Windows 8
if (ZAppHelper.IsWindows8())
{
form.BackColor = Color.Red;
form.Refresh();
NativeMethods.ActivateWindowRepeat(handle, 250);
redBGImage = Screenshot.CaptureRectangleNative(windowRect) as Bitmap;
}
form.BackColor = Color.White;
form.Refresh();
NativeMethods.ActivateWindowRepeat(handle, 250);
Bitmap whiteBGImage2 = Screenshot.CaptureRectangleNative(windowRect) as Bitmap;
// Don't do transparency calculation if an animated picture is detected
if (whiteBGImage.AreBitmapsEqual(whiteBGImage2))
{
windowImage = HelpersLib.GraphicsHelper.Core.ComputeOriginal(whiteBGImage, blackBGImage);
}
else
{
DebugHelper.WriteLine("Detected animated image => cannot compute transparency");
form.Close();
//.........这里部分代码省略.........
示例14: UpdateFonts
public static void UpdateFonts(Form form)
{
foreach (Control c in form.Controls)
{
if (c is TextBox || c is DataGridView || c is ListBox)
{
c.Font = new Font(Properties.Settings.Default.Fonts[0], c.Font.Size);
c.ForeColor = Color.Black;
}
else
{
c.Font = new Font(Main.GetFont(), c.Font.Size);
if (c.Name != "bt_Exit" && c.Name != "bt_Back" && c.Name != "bt_Logout")
c.ForeColor = Main.GetColor();
}
}
form.Update();
form.Refresh();
}
示例15: Border
/// <summary>
/// Tạo một thể hiện mới với các tham số được truyền vào
/// </summary>
/// <param name="frm">Form chứa Border này</param>
/// <param name="backcolor">Màu nền của Border</param>
/// <param name="textcolor">Màu chữ tiêu đề của Border</param>
/// <param name="textsize">Kích thước chữ tiêu đề của Border</param>
/// <param name="backgroundMoveable">Chỉ định khả năng di chuyển form bằng background</param>
/// <param name="resizeable">Chỉ định khả năng thay đổi kích thước của form</param>
public Border(Form frm, Color backcolor, Color textcolor, bool backgroundMoveable, bool resizeable)
{
_frm = frm;
_frm.FormBorderStyle = FormBorderStyle.None;
BackgroundMoveable = backgroundMoveable;
Resizeable = resizeable;
AddFormMoveableControls(this, Title);
InitializeComponent(backcolor, textcolor);
// add event to control
frm.MouseMove += delegate(object sender, MouseEventArgs e)
{
if (e.Y < Height / 2)
{
Timer1.Start();
Timer2.Stop();
}
else
{
Timer2.Start();
Timer1.Stop();
}
};
frm.SizeChanged += delegate(object sender, EventArgs e)
{
this.Width = frm.Width;
CloseBox.Location = new Point(Width - CloseBox.Width, 0);
NormnalBox.Location = new Point(Width - NormnalBox.Width * 2, 0);
MiniBox.Location = new Point(Width - MiniBox.Width * 3, 0);
OpacityTrackbar.Location = new Point(MiniBox.Left - OpacityTrackbar.Width - 5, 2);
Title.Width = OpacityTrackbar.Left;
frm.Refresh();
};
frm.Paint += delegate(object sender, PaintEventArgs e)
{
e.Graphics.DrawRectangle(new Pen(Title.BackColor), new Rectangle(0, 0, frm.Width - 1, frm.Height - 1));
};
Controls.Add(Title);
Controls.Add(OpacityTrackbar);
Controls.Add(MiniBox);
Controls.Add(NormnalBox);
Controls.Add(CloseBox);
frm.Controls.Add(this);
this.BringToFront();
}