本文整理汇总了C#中System.Windows.Forms.Button.Invalidate方法的典型用法代码示例。如果您正苦于以下问题:C# Button.Invalidate方法的具体用法?C# Button.Invalidate怎么用?C# Button.Invalidate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Button
的用法示例。
在下文中一共展示了Button.Invalidate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateButtonEnabled
private void UpdateButtonEnabled(Button button, Command command)
{
button.Enabled = command != null && command.Enabled;
//doesn't work becuase the forecolor is ignored when disabled...
button.ForeColor = button.Enabled ? _enabledToolbarColor : _disabledToolbarColor;//.DimGray;
button.Invalidate();
}
示例2: UpdateButtonEnabled
private void UpdateButtonEnabled(Button button, Command command)
{
var enabled = command != null && command.Enabled;
// DuplicatePage and DeletePage are a bit tricky to get right.
// See https://silbloom.myjetbrains.com/youtrack/issue/BL-2183.
if(enabled && command.Implementer != null)
{
var target = command.Implementer.Target as EditingModel;
if(target != null)
{
if(command is DuplicatePageCommand)
enabled = target.CanDuplicatePage;
else if(command is DeletePageCommand)
enabled = target.CanDeletePage;
}
}
//doesn't work because the forecolor is ignored when disabled...
var foreColor = enabled ? _enabledToolbarColor : _disabledToolbarColor; //.DimGray;
// BL-2338: signficant button flashing is apparently caused by setting these and
// invalidating when nothing actually changed. So only do it if something DID change.
if(enabled != button.Enabled || button.ForeColor != foreColor)
{
button.Enabled = enabled;
button.ForeColor = foreColor;
button.Invalidate();
}
}