本文整理汇总了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);
}
}