DirectOuput Framework R2
DirectOutput framework R2 for virtual pinball cabinets
Go to:
Overview 
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros Pages
AnalogToyValueEffect.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using DirectOutput.Cab.Toys.Layer;
6 using DirectOutput.General.Analog;
7 
8 namespace DirectOutput.FX.AnalogToyFX
9 {
16  {
17 
18  private AnalogAlpha _ActiveValue = new AnalogAlpha(255, 255);
19 
26  public AnalogAlpha ActiveValue
27  {
28  get { return _ActiveValue; }
29  set { _ActiveValue = value; }
30  }
31 
32  private AnalogAlpha _InactiveValue = new AnalogAlpha(0, 0);
33 
40  public AnalogAlpha InactiveValue
41  {
42  get { return _InactiveValue; }
43  set { _InactiveValue = value; }
44  }
45 
46 
47  private FadeModeEnum _FadeMode = FadeModeEnum.Fade;
48 
55  public FadeModeEnum FadeMode
56  {
57  get { return _FadeMode; }
58  set { _FadeMode = value; }
59  }
60 
61 
66  public override void Trigger(Table.TableElementData TableElementData)
67  {
68  if (Layer != null)
69  {
70  int FadeValue = TableElementData.Value;
71  if (FadeMode == FadeModeEnum.OnOff && FadeValue > 0) { FadeValue = 255; }
72 
73  Layer.Value = InactiveValue.Value + (int)((float)(ActiveValue.Value - InactiveValue.Value) * FadeValue / 255).Limit(0, 255);
74  Layer.Alpha = InactiveValue.Alpha + (int)((float)(ActiveValue.Alpha - InactiveValue.Alpha) * FadeValue / 255).Limit(0, 255);
75 
76  }
77  }
78 
79 
84  public override void Init(Table.Table Table)
85  {
86  base.Init(Table);
87  }
88 
92  public override void Finish()
93  {
94  base.Finish();
95  }
96 
97  }
98 
99 }