本文整理汇总了C#中System.Windows.Forms.Control.Refresh方法的典型用法代码示例。如果您正苦于以下问题:C# Control.Refresh方法的具体用法?C# Control.Refresh怎么用?C# Control.Refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Control
的用法示例。
在下文中一共展示了Control.Refresh方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResumeDrawing
public static void ResumeDrawing(Control c)
{
try
{
//re-enable drawing
if (c is TabPage)
{
SendMessage(c.Parent.Handle, WM_SETREDRAW, 1, IntPtr.Zero);
//c.Refresh(); // <-- actually redraw
c.Parent.Refresh();
}
else
{
SendMessage(c.Handle, WM_SETREDRAW, 1, IntPtr.Zero);
c.Refresh(); // <-- actually redraw
}
suspend = false;
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
return;
}
}
示例2: ResumeDrawing
private static void ResumeDrawing(Control parent)
{
parent.ResumeLayout();
SendMessage(parent.Handle, WM_SETREDRAW, true, 0);
// Force redraw of control now
parent.Refresh();
}
示例3: PositionStickControl
private static void PositionStickControl(Control control, Point location, GamePadThumbSticks.StickValue value)
{
var deltaX = value.X * control.Width * 0.5f;
var deltaY = value.Y * control.Height * -0.5f;
control.Location = new Point(location.X + (int)deltaX, location.Y + (int)deltaY);
control.Refresh();
}
示例4: ResumeDrawing
public static void ResumeDrawing(Control parent)
{
if (_suspended)
{
SendMessage(parent.Handle, WmSetredraw, true, 0);
parent.Refresh();
_suspended = false;
}
}
示例5: DispatchStartAsync
private static async Task DispatchStartAsync(Control control, Bitmap bitmap, byte []buffer)
{
control.Invoke(new Action(() =>
{
ProcessStart(bitmap, buffer);
control.Refresh();
}));
}
示例6: RefreshControl
public static void RefreshControl(Control i_Control)
{
if (i_Control.InvokeRequired)
{
i_Control.Invoke(new Action<Control>(RefreshControl), i_Control);
}
else
{
i_Control.Refresh();
}
}
示例7: ResumeLogic
/// <summary>
/// Starts painting messages and events.
/// </summary>
/// <param name="parent">Parent control handle</param>
public static void ResumeLogic(Control parent)
{
if (parent != null)
{
// Turn-On events:
SendMessage(parent.Handle, EM_SETEVENTMASK, 0, EVENTMASK);
// Turn-On redrawing:
SendMessage(parent.Handle, WM_SETREDRAW, 1, IntPtr.Zero);
parent.Refresh();
}
}
示例8: DispatchDeltaAsync
private static async Task DispatchDeltaAsync(Control control, Bitmap bitmap, IProtocolStream stream)
{
var buffer = await stream.ReceiveAsync();
control.Invoke(new Action(() =>
{
int len = buffer.DecompressQuick(_bufferUncompressed);
ProcessDelta(bitmap, _bufferUncompressed, 0, len);
control.Refresh();
}));
}
示例9: FlashControl
public static void FlashControl(Control control, string message)
{
var oldText = control.Text;
var oldForeColor = control.ForeColor;
var oldFont = control.Font;
try {
control.Text = message;
control.ForeColor = Color.FromArgb(0x00e00000);
var newSize = (float)Math.Pow(oldFont.Size, 1.8) / 5.7; // please don't ask
control.Font = new Font(oldFont.FontFamily, oldFont.Size * 1.25f, FontStyle.Bold);
control.Refresh();
Thread.Sleep(750);
control.Text = oldText;
} finally {
control.Text = oldText;
control.ForeColor = oldForeColor;
control.Font = oldFont;
control.Focus();
}
}
示例10: ResumePainting
public static void ResumePainting(Control control)
{
if (!control.IsDisposed)
{
SendMessage(control.Handle, WM_SETREDRAW, 1, 0);
control.Refresh();
}
}
示例11: ResumeDrawing
public static void ResumeDrawing(Control parent)
{
NativeWinApi.SendMessage(parent.Handle, NativeWinApi.Messages.WM_SETREDRAW, new IntPtr(1), IntPtr.Zero);
parent.Refresh();
}
示例12: ResumeDrawing
public static void ResumeDrawing(Control parent)
{
SendMessage(parent.Handle, (uint)WM_SETREDRAW, (System.UIntPtr)1, (System.IntPtr)0);
parent.Refresh();
}
示例13: Start
/// <summary>
/// Start() combines Print() and Save() to do all of the work
/// </summary>
/// <param name="Ctrl">Control (form or other) that is to be printed or saved</param>
/// <param name="bPrint">Desides whether to print (true) or save (false)</param>
/// <param name="fImage">System.Drawing.Imaging.ImageFormat by which the bitmap
/// has to be saved (printing uses png format as standard)</param>
/// <param name="f8bitPixel">decides how to convert bitmap to 8 bit ColorDepth</param>
/// <param name="sPrinterName">the name of the printer that is to be used</param>
/// <param name="aMargins">the page margins that are to be used</param>
/// <param name="bPortrait">Printing as portrait (true) or landscape (false)</param>
/// <param name="sFileName">String with the complete filename to which the bitmap
/// is to be saved (used only if bPrint == true)</param>
private static void Start(Control Ctrl, bool bPrint,
// formatings
ImageFormat fImage, ColorDepthReduction f8bitPixel,
// additional parameters for printing
string sPrinterName, Margins aMargins, bool bPortrait,
// additional parameter for saving
string sFileName
)
{
// add required standard parameters if necessary
if (fImage == null)
fImage = ImageFormat.Png;
if (bPrint) {
if (sPrinterName == null)
sPrinterName = "";
// orientation and margins are set to the printer standard automatically
} else {
#region NET 2.0 a shorter way to check string.IsNullOrEmpty(sFileName)
// NET 2.0 - you can use next 'if'-query as follows:
// if (String.IsNullOrEmpty(sFileName))
// pay attention: String.IsNullOrEmpty() is new in NET 2.0
// NET 1.1 - you must use next 'if'-query as follows:
// if ((sFileName == null) || (sFileName == ""))
#endregion
// no filename => user's folder, control's name, imageformat as extension
if ((sFileName == null) || (sFileName == "")) {
sFileName = System.IO.Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
Ctrl.Name + "." + fImage.ToString() );
}
}
// check possible errors, otherwise execute
if (Ctrl == null) // reserved for further checks
{
if (Ctrl == null)
MessageBox.Show("Control is not defined", "FormPrint.Start");
else
MessageBox.Show("Any other error", "FormPrint.Start");
} else {
// create the private formprint class cls
cls = new FormPrint(Ctrl, bPrint, fImage, f8bitPixel,
sPrinterName, aMargins, bPortrait, sFileName);
// execute the required printing resp. saving method
try {
if (bPrint) {
cls.StartPrinting();
} else {
cls.StartSaving();
}
} finally {
// free resources
cls.bmp.Dispose();
cls.bmp = null;
// in some situations, the next command is useful
Ctrl.Refresh();
}
}
}
示例14: TestPublicMethods
public void TestPublicMethods ()
{
// Public Methods that force Handle creation:
// - CreateControl ()
// - CreateGraphics ()
// - GetChildAtPoint ()
// - Invoke, BeginInvoke throws InvalidOperationException if Handle has not been created
// - PointToClient ()
// - PointToScreen ()
// - RectangleToClient ()
// - RectangleToScreen ()
Control c = new Control ();
c.BringToFront ();
Assert.IsFalse (c.IsHandleCreated, "A1");
c.Contains (new Control ());
Assert.IsFalse (c.IsHandleCreated, "A2");
c.CreateControl ();
Assert.IsTrue (c.IsHandleCreated, "A3");
c = new Control ();
Graphics g = c.CreateGraphics ();
g.Dispose ();
Assert.IsTrue (c.IsHandleCreated, "A4");
c = new Control ();
c.Dispose ();
Assert.IsFalse (c.IsHandleCreated, "A5");
c = new Control ();
//DragDropEffects d = c.DoDragDrop ("yo", DragDropEffects.None);
//Assert.IsFalse (c.IsHandleCreated, "A6");
//Assert.AreEqual (DragDropEffects.None, d, "A6b");
//Bitmap b = new Bitmap (100, 100);
//c.DrawToBitmap (b, new Rectangle (0, 0, 100, 100));
//Assert.IsFalse (c.IsHandleCreated, "A7");
//b.Dispose ();
c.FindForm ();
Assert.IsFalse (c.IsHandleCreated, "A8");
c.Focus ();
Assert.IsFalse (c.IsHandleCreated, "A9");
c.GetChildAtPoint (new Point (10, 10));
Assert.IsTrue (c.IsHandleCreated, "A10");
c.GetContainerControl ();
c = new Control ();
Assert.IsFalse (c.IsHandleCreated, "A11");
c.GetNextControl (new Control (), true);
Assert.IsFalse (c.IsHandleCreated, "A12");
#if NET_2_0
c.GetPreferredSize (Size.Empty);
Assert.IsFalse (c.IsHandleCreated, "A13");
#endif
c.Hide ();
Assert.IsFalse (c.IsHandleCreated, "A14");
c.Invalidate ();
Assert.IsFalse (c.IsHandleCreated, "A15");
//c.Invoke (new InvokeDelegate (InvokeMethod));
//Assert.IsFalse (c.IsHandleCreated, "A16");
c.PerformLayout ();
Assert.IsFalse (c.IsHandleCreated, "A17");
c.PointToClient (new Point (100, 100));
Assert.IsTrue (c.IsHandleCreated, "A18");
c = new Control ();
c.PointToScreen (new Point (100, 100));
Assert.IsTrue (c.IsHandleCreated, "A19");
c = new Control ();
//c.PreProcessControlMessage ???
//c.PreProcessMessage ???
c.RectangleToClient (new Rectangle (0, 0, 100, 100));
Assert.IsTrue (c.IsHandleCreated, "A20");
c = new Control ();
c.RectangleToScreen (new Rectangle (0, 0, 100, 100));
Assert.IsTrue (c.IsHandleCreated, "A21");
c = new Control ();
c.Refresh ();
Assert.IsFalse (c.IsHandleCreated, "A22");
c.ResetBackColor ();
Assert.IsFalse (c.IsHandleCreated, "A23");
c.ResetBindings ();
Assert.IsFalse (c.IsHandleCreated, "A24");
c.ResetCursor ();
Assert.IsFalse (c.IsHandleCreated, "A25");
c.ResetFont ();
Assert.IsFalse (c.IsHandleCreated, "A26");
c.ResetForeColor ();
Assert.IsFalse (c.IsHandleCreated, "A27");
c.ResetImeMode ();
Assert.IsFalse (c.IsHandleCreated, "A28");
c.ResetRightToLeft ();
Assert.IsFalse (c.IsHandleCreated, "A29");
c.ResetText ();
Assert.IsFalse (c.IsHandleCreated, "A30");
c.SuspendLayout ();
Assert.IsFalse (c.IsHandleCreated, "A31");
c.ResumeLayout ();
Assert.IsFalse (c.IsHandleCreated, "A32");
#if NET_2_0
c.Scale (new SizeF (1.5f, 1.5f));
Assert.IsFalse (c.IsHandleCreated, "A33");
#endif
c.Select ();
Assert.IsFalse (c.IsHandleCreated, "A34");
//.........这里部分代码省略.........
示例15: BlinkControl
private void BlinkControl(Control myControl, int myMsec, int nTimes)
{
System.Drawing.Color oldColor = myControl.BackColor;
for (int x = 1; x <= nTimes; x++)
{
myControl.BackColor = System.Drawing.Color.SeaGreen;
myControl.Refresh();
Thread.Sleep(myMsec);
myControl.BackColor = oldColor;
myControl.Refresh();
Thread.Sleep(myMsec);
}
}