本文整理匯總了C#中System.Windows.Forms.UserControl.Invoke方法的典型用法代碼示例。如果您正苦於以下問題:C# UserControl.Invoke方法的具體用法?C# UserControl.Invoke怎麽用?C# UserControl.Invoke使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Forms.UserControl
的用法示例。
在下文中一共展示了UserControl.Invoke方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: LaunchVersionCheck
public static Task LaunchVersionCheck(string currentVersion, string ghUser, string ghRepo, string dlUrl, DateTime lastCheck, UserControl sender)
{
return new Task(() =>
{
var cvc = new XrmToolBox.AppCode.GithubVersionChecker(currentVersion, ghUser, ghRepo);
cvc.Run();
if (cvc.Cpi != null && !string.IsNullOrEmpty(cvc.Cpi.Version))
{
if (lastCheck != DateTime.Now.Date)
{
sender.Invoke(new Action(() =>
{
var nvForm = new NewVersionForm(currentVersion, cvc.Cpi.Version, cvc.Cpi.Description, ghUser, ghRepo, new Uri(string.Format(dlUrl, currentVersion)));
nvForm.ShowDialog(sender);
}));
}
}
});
}
示例2: PageSwitchAnimation
/// <summary>
/// 異步頁切換動畫
/// </summary>
/// <param name="page">進行頁切換動畫的頁</param>
/// <param name="end">頁切換動畫的終點</param>
private static void PageSwitchAnimation(UserControl FromPage, UserControl ToPage, bool TowardsLeft)
{
int direction;
if (TowardsLeft)
direction = -1;
else
direction = 1;
int Start1 = FromPage.Location.X;
int Start2 = ToPage.Location.X;
double S1 = direction * FromPage.Width - FromPage.Location.X;
double S2 = 0 - ToPage.Location.X;
double T = 250;
for(int t = 0; t <= T; t+=10)
{
//注意確保所有運算符皆為double型,以確保精度
double s1 = ((2 * S1 / T) + (- S1 / (T * T)) * t) * t;
double s2 = ((2 * S2 / T) + (- S2 / (T * T)) * t) * t;
Point FromPageNextPoint = new Point(Start1 + (int)s1, FromPage.Location.Y);
Point ToPageNextPoint = new Point(Start2 + (int)s2, ToPage.Location.Y);
CrossThreadOperationControl CrossDelegate = delegate ()
{
FromPage.Location = FromPageNextPoint;
ToPage.Location = ToPageNextPoint;
};
FromPage.Invoke(CrossDelegate);
Thread.Sleep(10);
}
}