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


C# Cell.Lift方法代码示例

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


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

示例1: Preset

        public Preset(Cell<int> presetDollars, Fill fi, Cell<IMaybe<Fuel>> fuelFlowing)
        {
            Cell<Speed> speed = presetDollars.Lift(
                fi.Price, fi.DollarsDelivered, fi.LitersDelivered,
                (presetDollarsLocal, price, dollarsDelivered, litersDelivered) =>
                {
                    if (presetDollarsLocal == 0)
                    {
                        return Speed.Fast;
                    }

                    if (dollarsDelivered >= presetDollarsLocal)
                    {
                        return Speed.Stopped;
                    }

                    double slowLiters = presetDollarsLocal / price - 0.10;
                    return litersDelivered >= slowLiters ? Speed.Slow : Speed.Fast;
                });
            this.Delivery = fuelFlowing.Lift(speed,
                (m, speedLocal) =>
                    speedLocal == Speed.Fast ? (
                        m.Equals(Maybe.Just(Fuel.One)) ? PetrolPump.Delivery.Fast1 :
                            m.Equals(Maybe.Just(Fuel.Two)) ? PetrolPump.Delivery.Fast2 :
                                m.Equals(Maybe.Just(Fuel.Three)) ? PetrolPump.Delivery.Fast3 : PetrolPump.Delivery.Off
                        ) :
                        speedLocal == Speed.Slow ? (
                            m.Equals(Maybe.Just(Fuel.One)) ? PetrolPump.Delivery.Slow1 :
                                m.Equals(Maybe.Just(Fuel.Two)) ? PetrolPump.Delivery.Slow2 :
                                    m.Equals(Maybe.Just(Fuel.Three)) ? PetrolPump.Delivery.Slow3 : PetrolPump.Delivery.Off
                            ) : PetrolPump.Delivery.Off);
            this.KeypadActive = fuelFlowing.Lift(speed, (m, speedLocal) => m.Match(_ => speedLocal == Speed.Fast, () => true));
        }
开发者ID:Angeldude,项目名称:sodium,代码行数:33,代码来源:Preset.cs

示例2: PriceLcd

 public static Cell<string> PriceLcd(
     Cell<IMaybe<Fuel>> fillActive,
     Cell<double> fillPrice,
     Fuel fuel,
     Inputs inputs)
 {
     Cell<double> idlePrice;
     switch (fuel)
     {
         case Fuel.One:
             idlePrice = inputs.Price1;
             break;
         case Fuel.Two:
             idlePrice = inputs.Price2;
             break;
         case Fuel.Three:
             idlePrice = inputs.Price3;
             break;
         default:
             idlePrice = null;
             break;
     }
     return fillActive.Lift(fillPrice, idlePrice,
         (fuelSelectedMaybe, fillPriceLocal, idlePriceLocal) =>
             fuelSelectedMaybe.Match(f => f == fuel ? Formatters.FormatPrice(fillPriceLocal, 4) : string.Empty, () => Formatters.FormatPrice(idlePriceLocal, 4)));
 }
开发者ID:Angeldude,项目名称:sodium,代码行数:26,代码来源:ShowDollarsPump.cs

示例3: Over

 public static Cell<DrawableDelegate> Over(Cell<DrawableDelegate> a, Cell<DrawableDelegate> b)
 {
     return a.Lift(b, (dra, drb) => new DrawableDelegate((d, h, o, s) =>
     {
         drb(d, h, o, s);
         dra(d, h, o, s);
     }));
 }
开发者ID:Angeldude,项目名称:sodium,代码行数:8,代码来源:Shapes.cs

示例4: 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

示例5: Reify

 public Cell<bool> Reify(Cell<DateTime> dep, Cell<DateTime> ret) => dep.Lift(ret, this.f);
开发者ID:Angeldude,项目名称:sodium,代码行数:1,代码来源:MainWindow.xaml.cs

示例6: Translate

 public static Cell<DrawableDelegate> Translate(Cell<DrawableDelegate> drawable, Cell<Point> offset)
 {
     return drawable.Lift(offset, (dr, no) =>
         new DrawableDelegate((d, h, o, s) => dr(d, h, no.Add(o.Multiply(s)), s)));
 }
开发者ID:Angeldude,项目名称:sodium,代码行数:5,代码来源:Shapes.cs

示例7: Scale

 public static Cell<DrawableDelegate> Scale(Cell<DrawableDelegate> drawable, Cell<double> scale)
 {
     return drawable.Lift(scale, (dr, ns) =>
         new DrawableDelegate((d, h, o, s) => dr(d, h, o, s * ns)));
 }
开发者ID:Angeldude,项目名称:sodium,代码行数:5,代码来源:Shapes.cs


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