当前位置: 首页>>代码示例>>C#>>正文


C# BindingList.WithEvents方法代码示例

本文整理汇总了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);
//.........这里部分代码省略.........
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:101,代码来源:AnimatedToolbarCanvas.cs


注:本文中的BindingList.WithEvents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。