33 double baseOrientation = 0; |
33 double baseOrientation = 0; |
34 double deltaOrientation = 0; |
34 double deltaOrientation = 0; |
35 double lastdeltaOrientation = 0; |
35 double lastdeltaOrientation = 0; |
36 int lastSoundlevel = 0; |
36 int lastSoundlevel = 0; |
37 bool rise = true; //rise is true if the curse of the volume is positive |
37 bool rise = true; //rise is true if the curse of the volume is positive |
|
38 int LastElipseNB = 0; |
|
39 |
38 #endregion |
40 #endregion |
39 |
41 |
40 #region Properties |
42 #region Properties |
41 public Cutting Cutting |
43 public Cutting Cutting |
42 { |
44 { |
71 |
73 |
72 #region Tag Management |
74 #region Tag Management |
73 |
75 |
74 private void InitializeDefinitions() |
76 private void InitializeDefinitions() |
75 { |
77 { |
76 for (byte k = 1; k <= 5; k++) |
78 for (byte k = 1; k <= 25; k++) |
77 { |
79 { |
78 ByteTagVisualizationDefinition tagDef = new ByteTagVisualizationDefinition(); |
80 ByteTagVisualizationDefinition tagDef = new ByteTagVisualizationDefinition(); |
79 // The tag value that this definition will respond to. |
81 // The tag value that this definition will respond to. |
80 tagDef.Value = k; |
82 tagDef.Value = k; |
81 // The .xaml file for the UI. |
83 // The .xaml file for the UI. |
105 be.UpdateSource();*/ |
107 be.UpdateSource();*/ |
106 |
108 |
107 TagVisuSoundControl tagsoundcontrol = (TagVisuSoundControl)e.TagVisualization; |
109 TagVisuSoundControl tagsoundcontrol = (TagVisuSoundControl)e.TagVisualization; |
108 |
110 |
109 deltaOrientation = (tagsoundcontrol.Orientation - baseOrientation) % 360; |
111 deltaOrientation = (tagsoundcontrol.Orientation - baseOrientation) % 360; |
|
112 |
110 if (deltaOrientation < 0) |
113 if (deltaOrientation < 0) |
111 deltaOrientation = 360 + deltaOrientation; |
114 deltaOrientation = 360 + deltaOrientation; |
112 int niveau = (int)(deltaOrientation / 36); |
115 int niveau = (int)(deltaOrientation / 36); |
|
116 |
|
117 |
113 |
118 |
114 //if (((niveau == 9) || (niveau == 8) || (niveau == 7)) && lastSoundlevel == 0) |
119 //if (((niveau == 9) || (niveau == 8) || (niveau == 7)) && lastSoundlevel == 0) |
115 if (((niveau == 9) || (niveau == 8)) && lastSoundlevel == 0) |
120 if (((niveau == 9) || (niveau == 8)) && lastSoundlevel == 0) |
116 rise = false; |
121 rise = false; |
117 //else if (((niveau == 1) || (niveau == 2) || (niveau == 3)) && lastSoundlevel == 0) |
122 //else if (((niveau == 1) || (niveau == 2) || (niveau == 3)) && lastSoundlevel == 0) |
118 else if (((niveau == 1) || (niveau == 2)) && lastSoundlevel == 0) |
123 else if (((niveau == 1) || (niveau == 2)) && lastSoundlevel == 0) |
119 rise = true; |
124 rise = true; |
120 |
125 |
121 if (!rise) |
126 if (!rise) |
122 { |
127 { |
123 niveau = (niveau - 10) % 10; |
128 niveau = (niveau - 10) % 10; |
124 } |
129 } |
125 //--Elipse visibility |
130 //--Elipse visibility |
126 int elipseNB = tagsoundcontrol.TagVisuSoundLevelUpdate(niveau); |
131 int elipseNB = tagsoundcontrol.TagVisuSoundLevelUpdate(niveau); |
127 //Set the Sound of the Player. |
132 //Set the Sound of the Player. |
128 if(elipseNB != -1) |
133 if ((LastElipseNB <1 && deltaOrientation - lastdeltaOrientation < 0) || (LastElipseNB > 9 && deltaOrientation - lastdeltaOrientation > 0)) |
129 { |
134 baseOrientation += deltaOrientation - lastdeltaOrientation; |
130 UserControlSyncSource.setUserPlayerVolume(elipseNB/10.0); |
135 else |
131 } |
136 { |
132 lastSoundlevel = niveau; |
137 if (elipseNB != -1) |
133 tagsoundcontrol.volumeModel.Content = elipseNB;//deltaOrientation.ToString(); |
138 { |
134 |
139 UserControlSyncSource.setUserPlayerVolume(elipseNB / 10.0); |
135 } |
140 lastSoundlevel = niveau; |
|
141 LastElipseNB = elipseNB; |
|
142 tagsoundcontrol.volumeModel.Content = (elipseNB / 10.0).ToString(); |
|
143 lastdeltaOrientation = deltaOrientation; |
|
144 } |
|
145 } |
|
146 } |
|
147 |
136 private void OnVisualizationAdded(object sender, TagVisualizerEventArgs e) |
148 private void OnVisualizationAdded(object sender, TagVisualizerEventArgs e) |
137 { |
149 { |
138 TagVisuSoundControl tagsoundcontrol = (TagVisuSoundControl)e.TagVisualization; |
150 TagVisuSoundControl tagsoundcontrol = (TagVisuSoundControl)e.TagVisualization; |
139 |
151 LastElipseNB = 5; |
|
152 lastdeltaOrientation = 0; |
|
153 |
140 switch (tagsoundcontrol.VisualizedTag.Byte.Value) |
154 switch (tagsoundcontrol.VisualizedTag.Byte.Value) |
141 { |
155 { |
142 case 1: |
156 case 24: |
143 try |
157 try |
144 { |
158 { |
145 /* |
159 /* |
146 Binding mybinding = new Binding("Orientation"); |
160 Binding mybinding = new Binding("Orientation"); |
147 mybinding.Source = tagsoundcontrol; |
161 mybinding.Source = tagsoundcontrol; |