本文整理汇总了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));
}
示例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)));
}
示例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);
}));
}
示例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;
}
示例5: Reify
public Cell<bool> Reify(Cell<DateTime> dep, Cell<DateTime> ret) => dep.Lift(ret, this.f);
示例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)));
}
示例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)));
}