本文整理汇总了C#中System.Windows.Forms.Form.Update方法的典型用法代码示例。如果您正苦于以下问题:C# Form.Update方法的具体用法?C# Form.Update怎么用?C# Form.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Form
的用法示例。
在下文中一共展示了Form.Update方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: InstallComShellExt
public static void InstallComShellExt(bool install, Form form, bool silent)
{
//Debug.Assert(false);
if (!CSScriptInstaller.IsInstalled())
{
MessageBox.Show("Advanced Shell Extensions can be installed only after CS-Script configuration completed.\nPlease execute config.bat to configure the CS-Script.");
}
else
{
if (install)
{
EnsureComShellExtensionPlacement();
DialogResult response = DialogResult.Yes;
if (!silent)
{
response = MessageBox.Show(form,
"You are about to install/activate additional Advanced Shell Extensions.\n" +
"\nPlease note that the structure of the shell extensions will follow the file structure of the\n" +
"'" + Path.GetDirectoryName(comShellEtxDLL32) + "' folder\n" +
"(See CS-Script documentation for details)\n" +
"\n" +
"Do you want to proceed with the installation?", "CS-Script", MessageBoxButtons.YesNo);
if (form != null)
form.Update();
}
if (DialogResult.Yes == response)
{
if (Directory.Exists(Environment.ExpandEnvironmentVariables(@"%windir%\SysWOW64")))
{
RunApp(Environment.ExpandEnvironmentVariables(@"%windir%\SysWOW64\regsvr32.exe"), (silent ? "/s \"" : "\"") + comShellEtxDLL32 + "\"");
RunApp(Environment.ExpandEnvironmentVariables(@"%windir%\System32\regsvr32.exe"), (silent ? "/s \"" : "\"") + comShellEtxDLL64 + "\"");
}
else
{
RunApp(Environment.ExpandEnvironmentVariables(@"%windir%\System32\regsvr32.exe"), (silent ? "/s \"" : "\"") + comShellEtxDLL32 + "\"");
}
}
}
else
{
DialogResult response = DialogResult.Yes;
if (!silent)
{
response = MessageBox.Show("You are about to uninstall/deactivate additional Advanced Shell Extentions.\n" +
"\nPlease note that some files of '" + Path.GetDirectoryName(comShellEtxDLL32) + "'\n" +
"will be locked until Windows Explorer is restarted.\n" +
"\n" +
"Do you want to proceed with uninstallating?", "CS-Script", MessageBoxButtons.YesNo);
if (form != null)
form.Update();
}
if (DialogResult.Yes == response)
{
string dll = GetComShellExtRegisteredDll();
if (dll != null)
{
if (Directory.Exists(Environment.ExpandEnvironmentVariables(@"%windir%\SysWOW64")))
{
//dll will be the path to either ShellExt or ShellExt64 (depending which one registry search returns); both are in the same directory
string dll32 = dll.Replace("ShellExt64.", "ShellExt.");
string dll64 = dll.Replace("ShellExt.", "ShellExt64.");
RunApp(Environment.ExpandEnvironmentVariables(@"%windir%\SysWOW64\regsvr32.exe"), (silent ? "/s /u \"" : "/u \"") + dll32 + "\"");
RunApp(Environment.ExpandEnvironmentVariables(@"%windir%\System32\regsvr32.exe"), (silent ? "/s /u \"" : "/u \"") + dll64 + "\"");
}
else
{
RunApp(Environment.ExpandEnvironmentVariables(@"%windir%\System32\regsvr32.exe"), (silent ? "/s /u \"" : "/u \"") + dll + "\"");
}
}
}
}
}
}
示例3: TrackHandle
protected bool TrackHandle(int nHandle,Control frm,Point point,Form frmClipTo)
{
Debug.Assert(nHandle >= 0);
Debug.Assert(nHandle <= 8); // handle 8 is inside the rect
// don't handle if capture already set
//if(frm.Capture) return false;
Debug.Assert(!m_bFinalErase);
// save original width & height in pixels
int nWidth = m_rect.Width;
int nHeight = m_rect.Height;
// set capture to the window which received this message
frm.Capture=true;
Debug.Assert(frm.Capture);
frm.Update();
if (frmClipTo!=null)
frmClipTo.Update();
Rectangle rectSave = m_rect;
// find out what x/y coords we are supposed to modify
int px=0, py=0;
int xDiff=0, yDiff=0;
GetModifyPointers(nHandle,ref px,ref py,ref xDiff,ref yDiff,true);
xDiff = point.X - xDiff;
yDiff = point.Y - yDiff;
// get DC for drawing
Graphics gs;
if (frmClipTo!=null)
{
// clip to arbitrary window by using adjusted Window DC
gs=frmClipTo.CreateGraphics();
}
else
{
// otherwise, just use normal DC
gs=frm.CreateGraphics();
}
Rectangle rectOld;
bool bMoved = false;
// get messages until capture lost or cancelled/accepted
for (;;)
{
MSG msg=new MSG();
if(GetMessage(ref msg, 0, 0, 0)!=1) break;
if(!frm.Capture) break;
switch (msg.message)
{
// handle movement/accept messages
case WM_LBUTTONUP:
case WM_MOUSEMOVE:
rectOld = m_rect;
// handle resize cases (and part of move)
SetRectInt(px,LoWord(msg.lParam) - xDiff);
SetRectInt(py,HiWord(msg.lParam) - yDiff);
// handle move case
if (nHandle == (int)TrackerHit.hitMiddle)
{
m_rect.Width=nWidth;
m_rect.Height=nHeight;
}
// allow caller to adjust the rectangle if necessary
AdjustRect(nHandle,ref m_rect);
// only redraw and callback if the rect actually changed!
m_bFinalErase = (msg.message == WM_LBUTTONUP);
if (m_bFinalErase)
goto ExitLoop;
if (!rectOld.Equals(m_rect) || m_bFinalErase)
{
if (bMoved)
{
m_bErase = true;
DrawTrackerRect(rectOld, frmClipTo, gs, frm);
}
OnChangedRect(rectOld);
if (msg.message != WM_LBUTTONUP)
bMoved = true;
}
if (m_bFinalErase)
goto ExitLoop;
if (!rectOld.Equals(m_rect))
{
m_bErase = false;
DrawTrackerRect(m_rect, frmClipTo, gs, frm);
}
break;
// handle cancel messages
case WM_KEYDOWN:
if (msg.wParam != 0x1B)//VK_ESCAPE
break;
//.........这里部分代码省略.........
示例4: Updater
public Updater(Form uForm, string uLocator, string uProgramName, string uVersionInfo, string uReplaceFile)
{
//uReplaceFile is empty => check for new version and download if necessary
if (uReplaceFile == "")
{
//create update form
uLabel.Size = new Size(400,20);
uLabel.Text = "Checking for Updates...";
uLabel.Location = new Point(10, 10);
uPBar.Size = new Size(480, 30);
uPBar.Location = new Point(10, 40);
uPBar.Minimum = 0;
uPBar.Maximum = 100;
uPBar.Value = 1;
uProgress.FormBorderStyle = FormBorderStyle.None;
uProgress.Text = "Updater";
uProgress.SetBounds(0, 0, 500, 80);
uProgress.StartPosition = FormStartPosition.CenterScreen;
//uProgress.ShowInTaskbar = false;
uProgress.Controls.Add(uLabel);
uProgress.Controls.Add(uPBar);
uProgress.Show();
uProgress.Update();
// generate license key
//string hw_key = generateKey();
string hw_key = "null";
// test the key
if (testKey(hw_key) == false)
{
MessageBox.Show("Could not fetch end user licence.", "Licence Error");
Environment.Exit(-1);
}
//check the version
string uVersionOnline = uCheckVersion(uLocator, uVersionInfo);
if (uVersionOnline != "")
{
uPBar.Value = 30;
uProgress.Update();
//new update exists, ask for install
if (MessageBox.Show("New update available. Download & Install?", "Update", MessageBoxButtons.YesNo) == DialogResult.No)
{
//close form and exit
uProgress.Close();
return;
}
//uForm.ShowInTaskbar = false;
uForm.WindowState = FormWindowState.Minimized;
uForm.Update();
//yes, user wants to install it. Begin download
uLabel.Text = "Downloading ";
uProgress.Update();
Uri uUri = new Uri(uLocator + uProgramName + uVersionOnline + ".exe");
WebClient uDownloadClient = new WebClient();
uDownloadClient.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
//add download progress event handlers
uDownloadClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(progressChanged);
uDownloadClient.DownloadFileCompleted += new AsyncCompletedEventHandler((EventHandler)delegate(object sender, EventArgs args)
{
progressCompleted(sender, uProgramName, uVersionOnline);
});
//does file exist?
WebRequest request = WebRequest.Create(uUri);
request.Method = "GET";
try
{
WebResponse response = request.GetResponse();
}
catch (WebException uWebEx)
{
//connection failed
uLabel.Text = "Cannot reach server: " + uWebEx.Status;
uPBar.Value = 100;
uProgress.Update();
System.Threading.Thread.Sleep(1000);
uProgress.Close();
uForm.WindowState = FormWindowState.Normal;
return;
}
/* using ()
{
MessageBox.Show("here:" +response.ContentLength + "-" + response.ContentType);
}*/
//test if the file already exists in the folder and delete it...
System.IO.FileInfo uFile = new System.IO.FileInfo(uProgramName + uVersionOnline + ".exe");
try
//.........这里部分代码省略.........
示例5: TestPublicMethods
//.........这里部分代码省略.........
c = new Form ();
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");
c.Scale (new SizeF (1.5f, 1.5f));
Assert.IsFalse (c.IsHandleCreated, "A33");
c.Select ();
Assert.IsTrue (c.IsHandleCreated, "A34");
c.Dispose ();
c = new Form ();
c.SelectNextControl (new Control (), true, true, true, true);
Assert.IsFalse (c.IsHandleCreated, "A35");
c.SetBounds (0, 0, 100, 100);
Assert.IsFalse (c.IsHandleCreated, "A36");
c.Update ();
Assert.IsFalse (c.IsHandleCreated, "A37");
// Form
c.Activate ();
Assert.IsFalse (c.IsHandleCreated, "F1");
c.AddOwnedForm (new Form ());
Assert.IsFalse (c.IsHandleCreated, "F2");
c.Close ();
Assert.IsFalse (c.IsHandleCreated, "F3");
c.Hide ();
Assert.IsFalse (c.IsHandleCreated, "F4");
c.LayoutMdi (MdiLayout.Cascade);
Assert.IsFalse (c.IsHandleCreated, "F5");
#if !MONO
c.PerformAutoScale ();
Assert.IsFalse (c.IsHandleCreated, "F6");
#endif
c.PerformLayout ();
Assert.IsFalse (c.IsHandleCreated, "F7");
c.AddOwnedForm (new Form ());
c.RemoveOwnedForm (c.OwnedForms [c.OwnedForms.Length - 1]);
Assert.IsFalse (c.IsHandleCreated, "F8");
c.ScrollControlIntoView (null);
Assert.IsFalse (c.IsHandleCreated, "F9");
c.SetAutoScrollMargin (7, 13);
Assert.IsFalse (c.IsHandleCreated, "F10");
c.SetDesktopBounds (-1, -1, 144, 169);
Assert.IsFalse (c.IsHandleCreated, "F11");
c.SetDesktopLocation (7, 13);
Assert.IsFalse (c.IsHandleCreated, "F12");
c = new Form ();
c.Show (null);
Assert.IsTrue (c.IsHandleCreated, "F13");
c.Close ();
c = new Form ();
//c.ShowDialog ()
c.ToString ();
Assert.IsFalse (c.IsHandleCreated, "F14");
c.Validate ();
Assert.IsFalse (c.IsHandleCreated, "F15");
#if !MONO
c.ValidateChildren ();
Assert.IsFalse (c.IsHandleCreated, "F16");
#endif
c.Close ();
}
示例6: StartProgress
private void StartProgress()
{
FDownload = new frmValidateRecordings();
FDownload.Tag = DI;
FDownload.Update();
this.AddOwnedForm(FDownload);
FDownload.Show();
}
示例7: 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();
}
示例8: DeleteLastLine
// Delete the last line drawn on the Scratch Pad from collection.
// Does NOT delete the line from the form itself, but calls Invalidate() & Update()
// to force a repaint.
public void DeleteLastLine(Form frmDraw)
{
// Retrieve count of LineGraphic objects in collection.
int nLineGraphicCount = f_collLineGraphics.Count;
// If not empty, delete last line added (drawn).
if (nLineGraphicCount > 0)
{
// Delete last line from LineGraphic collection.
f_collLineGraphics.RemoveAt(nLineGraphicCount - 1);
// Invalidate entire screen area for repaint.
frmDraw.Invalidate();
// Force repaint.
frmDraw.Update();
}
}
示例9: InitMainWindow
/// <summary>
/// Initialize the Windows... window. Attach Windows elements as well
/// </summary>
/// <returns>True if success, false otherwise</returns>
protected bool InitMainWindow()
{
try
{
Window = new D3DForm
{
Text = MainWindowCaption,
Name = "OutsideWndClassName",
FormBorderStyle = FormBorderStyle.Sizable,
ClientSize = new System.Drawing.Size(ClientWidth, ClientHeight),
StartPosition = FormStartPosition.CenterScreen,
MyWndProc = WndProc,
MinimumSize = new System.Drawing.Size(200, 200)
};
Window.MouseDown += OnMouseDown;
Window.MouseUp += OnMouseUp;
Window.MouseMove += OnMouseMove;
Window.MouseWheel += OnMouseWheel;
Window.ResizeBegin += (sender, args) =>
{
AppPaused = true;
Resizing = true;
Timer.Stop();
};
Window.ResizeEnd += (sender, args) =>
{
AppPaused = false;
Resizing = false;
Timer.Start();
OnResize();
};
Window.Show();
Window.Update();
return true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\n" + ex.StackTrace, "Outside Engine - Error");
return false;
}
}
示例10: CreateWindow
protected void CreateWindow(int width, int height)
{
Debug.Print("Application initiated");
MainWindow = new Form {
Width = width,
Height = height,
Text = GetName(),
FormBorderStyle = FormBorderStyle.None
};
MainWindow.Show();
MainWindow.Update();
Input.Init(MainWindow);
}