本文整理汇总了C#中BindingList.WithEvents方法的典型用法代码示例。如果您正苦于以下问题:C# BindingList.WithEvents方法的具体用法?C# BindingList.WithEvents怎么用?C# BindingList.WithEvents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BindingList
的用法示例。
在下文中一共展示了BindingList.WithEvents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnimatedToolbarCanvas
public AnimatedToolbarCanvas()
{
var ButtonOuterWidth = 16 + 4;
Items = new BindingList<AnimatedToolbarItem>();
Items.WithEvents(
(AddedSource, AddedIndex) =>
{
AddedSource.x = AddedIndex * ButtonOuterWidth;
AddedSource.cx = 8;
AddedSource.Button = new Canvas
{
Cursor = Cursors.Hand
}.AttachTo(this);
AddedSource.MoveTo =
delegate
{
AddedSource.Button.MoveTo(AddedSource.x + AddedSource.cx, 0);
};
#region ItemClicked
AddedSource.Button.MouseLeftButtonUp +=
delegate
{
if (ItemClicked != null)
ItemClicked(AddedSource);
};
#endregion
#region ItemMouseEnter
AddedSource.Button.MouseEnter +=
(e, s) =>
{
if (ItemMouseEnter != null)
ItemMouseEnter(AddedSource, s);
};
#endregion
#region ItemMouseLeave
AddedSource.Button.MouseLeave +=
(e, s) =>
{
if (ItemMouseLeave != null)
ItemMouseLeave(AddedSource, s);
};
#endregion
AddedSource.Button.MouseEnter +=
delegate
{
SelectedItem = AddedSource;
};
AddedSource.a = AddedSource.Button.ToAnimatedOpacity();
AddedSource.a.Opacity = 0;
#region fade in and slide left
AddedSource.Image.AttachTo(AddedSource.Button);
AddedSource.a.Opacity = 1;
if (AddedSource.cx > 0)
(1000 / 60).AtIntervalWithTimerAndCounter(
(t, c) =>
{
AddedSource.cx--;
AddedSource.MoveTo();
if (AddedSource.cx > 0)
return;
t.Stop();
}
);
#endregion
#region StartAnimatingRemove
Action StartAnimatingRemove =
delegate
{
if (Items.Count > MaxItems)
{
Items.First().With(
RemovedSource =>
{
RemovedSource.a.SetOpacity(0,
delegate
{
RemovedSource.Button.Orphanize();
RemovedSource.Button = null;
}
);
Items.Remove(RemovedSource);
//.........这里部分代码省略.........