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


C# Cell.Map方法代码示例

本文整理汇总了C#中Cell.Map方法的典型用法代码示例。如果您正苦于以下问题:C# Cell.Map方法的具体用法?C# Cell.Map怎么用?C# Cell.Map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cell的用法示例。


在下文中一共展示了Cell.Map方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FrButton

 private FrButton(Cell<string> label, StreamLoop<Unit> sClicked)
     : base((size, sMouse, sKey, focus, idSupply) =>
     {
         Stream<Unit> sPressed = sMouse.Snapshot(size,
             (e, mSize) => mSize.Match(
                 s =>
                 {
                     MouseButtonEventArgs b = e.Args as MouseButtonEventArgs;
                     Point p = e.GetPosition();
                     return b != null && b.ChangedButton == MouseButton.Left && b.ButtonState == MouseButtonState.Pressed
                            && p.X >= 2 && p.X < s.Width - 2 && p.Y >= 2 && p.Y < s.Height - 2
                         ? Maybe.Just(Unit.Value)
                         : Maybe.Nothing<Unit>();
                 },
                 Maybe.Nothing<Unit>)).FilterMaybe();
         Stream<Unit> sReleased = sMouse.Snapshot(size,
             (e, mSize) => mSize.Match(
                 s =>
                 {
                     MouseButtonEventArgs b = e.Args as MouseButtonEventArgs;
                     return b != null && b.ChangedButton == MouseButton.Left && b.ButtonState == MouseButtonState.Released
                         ? Maybe.Just(Unit.Value)
                         : Maybe.Nothing<Unit>();
                 },
                 Maybe.Nothing<Unit>)).FilterMaybe();
         Cell<bool> pressed = sPressed.Map(_ => true).OrElse(sReleased.Map(_ => false)).Hold(false);
         sClicked.Loop(sReleased.Gate(pressed));
         Typeface typeface = new Typeface(new FontFamily("Helvetica"), FontStyles.Normal, FontWeights.Normal, FontStretches.Normal);
         Cell<Size> desiredSize = label.Map(l =>
         {
             Size labelSize = FontUtilities.MeasureString(l, typeface, 13);
             return new Size(labelSize.Width + 14, labelSize.Height + 10);
         });
         return new Output(
             label.Lift(
                 size, pressed,
                 (l, mSize, p) => new DrawableDelegate(d =>
                 {
                     mSize.Match(sz =>
                     {
                         d.DrawRectangle(p ? Brushes.DarkGray : Brushes.LightGray, new Pen(Brushes.Black, 1), new Rect(new Point(2, 2), new Size(sz.Width - 5, sz.Height - 5)));
                         FormattedText t = FontUtilities.GetStandardFormattedText(l, typeface, 13, Brushes.Black);
                         d.DrawText(t, new Point((sz.Width - t.Width) / 2, (sz.Height - t.Height) / 2));
                     }, () => { });
                 })),
             desiredSize,
             Stream.Never<long>());
     })
 {
     this.SClicked = sClicked;
 }
开发者ID:Angeldude,项目名称:sodium,代码行数:51,代码来源:FrButton.cs

示例2: BounceAt

 private static Stream<Signal> BounceAt(TimerSystem<double> sys,
     Cell<Signal> vel, Cell<Signal> pos, double target)
 {
     return sys.At(pos.Map(p => p.When(target))).Snapshot(vel, (t, v) =>
         new Signal(t, v.A, v.B, -v.ValueAt(t) * Restitution));
 }
开发者ID:Angeldude,项目名称:sodium,代码行数:6,代码来源:MainWindow.xaml.cs


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