本文整理汇总了C#中System.Windows.Forms.Label.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# Label.Invoke方法的具体用法?C# Label.Invoke怎么用?C# Label.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Label
的用法示例。
在下文中一共展示了Label.Invoke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: changeLabel
public void changeLabel(Label lbl, string str)
{
if (lbl.InvokeRequired)
{
String name = str;
lbl.Invoke(new MethodInvoker(delegate { lbl.Text = name; }));
}
}
示例2: Check
public static string Check(Label pLabel)
{
// Get Mapler.me assembly
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(Environment.CurrentDirectory + "\\Mapler Client.exe");
string ApplicationName = "Mapler_Client";
string ApplicationVersion = fvi.ProductVersion;
try
{
WebClient wc = new WebClient();
wc.Proxy = null;
string responseText = wc.DownloadString(string.Format("http://direct.craftnet.nl/app_updates/updates.php?appname={0}&appver={1}&v=2", ApplicationName, ApplicationVersion));
string[] lines = responseText.Split(new string[] { "\r\n" }, StringSplitOptions.None);
if (lines[0].StartsWith("ERROR:"))
{
MessageBox.Show(string.Format("Error occurred while checking for new version: {0}", responseText), ApplicationName);
}
else
{
pLabel.Invoke((MethodInvoker)delegate
{
pLabel.Text = "Received info...";
});
string latestVersion = lines[0];
string url = lines[1];
if (latestVersion != ApplicationVersion)
{
// Download version
_tempfile = Path.GetTempPath() + "maplerdownload.exe";
pLabel.Invoke((MethodInvoker)delegate
{
pLabel.Visible = false;
MaplerUpdater.frmMain.Instance.prgrsUpdate.Visible = true;
});
wc.DownloadProgressChanged += wc_DownloadProgressChanged;
wc.DownloadFileCompleted += wc_DownloadFileCompleted;
wc.DownloadFileAsync(new Uri(url), _tempfile);
return "Downloading...";
}
else
{
return "Boot";
}
}
}
catch
{
}
return "Boot";
}
示例3: setLabelTextFromThread
/// <summary>
/// Set label text from within a thread
/// </summary>
/// <param name="label">Label</param>
/// <param name="text">Text to be set</param>
public static void setLabelTextFromThread(Label label, string text)
{
label.Invoke((MethodInvoker)delegate
{
label.Text = text;
});
}
示例4: ReplaceLabelText
public static void ReplaceLabelText(Label label, string text)
{
// Check if the label needs to be invoked.
if (label.InvokeRequired)
// Invoke the label control with an appropiate delegate.
label.Invoke(new Action<Label, string>(ReplaceLabelText), label, text);
else
// Directly change the labels text.
label.Text = text;
}
示例5: ReplaceLabelForeColor
public static void ReplaceLabelForeColor(Label label, Color color)
{
// Check if the label needs to be invoked.
if (label.InvokeRequired)
// Invoke the label control with an appropiate delegate.
label.Invoke(new Action<Label, Color>(ReplaceLabelForeColor), label, color);
else
// Directly change the labels texts color.
label.ForeColor = color;
}
示例6: UpdateLabelText
public static void UpdateLabelText(Label label, string newText)
{
if (label.InvokeRequired)
{
updateLabelTextDelegate del = new updateLabelTextDelegate(UpdateLabelText);
label.Invoke(del, new object[] { label, newText });
}
else
{
label.Text = newText;
}
}
示例7: SetMainThreadHint
public static void SetMainThreadHint(Label label, string msg)
{
if (label.InvokeRequired)
{
SetMainThreadHintLabelDelegate msgCallback = new SetMainThreadHintLabelDelegate(WindowFormDelegate.SetMainThreadHint);
label.Invoke(msgCallback, new object[] { label, msg });
}
else
{
label.Text = msg;
}
}
示例8: SetTextInLabel
public static void SetTextInLabel(string text, Label label)
{
if (label.InvokeRequired)
{
SetLabelCallback d = new SetLabelCallback(SetTextInLabel);
label.Invoke(d, new object[] { text, label });
}
else
{
label.Text = text;
}
}
示例9: UpdateInfo
public static void UpdateInfo(Label lbl, string info)
{
if (lbl.InvokeRequired)
{
lbl.Invoke(new UpdateInfoDelegate(UpdateInfo),
new object[] { lbl, info });
}
else
{
lbl.Text = info;
}
}
示例10: SetLabel
public void SetLabel(Label label, string text)
{
if (label.InvokeRequired)
{
SetLabelCallback d = new SetLabelCallback(SetLabel);
label.Invoke(d, new object[] { label, text });
}
else
{
label.Text = text;
label.Refresh();
Invalidate();
}
}
示例11: Label_Text
//Method for changing the winner name label
public void Label_Text(Label label, string text)
{
if (label.InvokeRequired)
{
try
{
label.Invoke(delLabelText, new object[] { label, text });
}
catch (Exception e) {
Console.WriteLine(e.StackTrace);
}
}
else
{
label.Text = text;
}
}
示例12: UpdateLabelText
private void UpdateLabelText(Label lbl, string txt)
{
if (lbl.InvokeRequired)
{
// This is a worker thread so delegate the task.
lbl.Invoke(new UpdateLabelTextDelegate(this.UpdateLabelText), lbl, txt);
}
else
{
// This is the UI thread so perform the task.
lbl.Text = txt.ToString();
}
}
示例13: setLabel
private void setLabel(Label control, string text)
{
if (control.InvokeRequired)
{
control.Invoke(new MethodInvoker(delegate
{
control.Text = text;
}));
}
else
{
control.Text = text;
}
}
示例14: setLabelText
private void setLabelText(Label label, string text)
{
if (label.InvokeRequired)
{
lDelegate deleg = new lDelegate(setLabelText);
label.Invoke(deleg, new object[] { label, text });
}
else
{
label.Text = text;
}
}
示例15: UpdateLabel
public static void UpdateLabel(Label label, string text)
{
// If the current thread is not the UI thread, InvokeRequired will be true
if (label.InvokeRequired)
{
// If so, call Invoke, passing it a lambda expression which calls
// UpdateText with the same label and text, but on the UI thread instead.
label.Invoke((Action)(() => UpdateLabel(label, text)));
return;
}
// If we're running on the UI thread, we'll get here, and can safely update
// the label's text.
label.Text = text;
}