-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
SemanticValue.xml
1356 lines (1234 loc) · 89.3 KB
/
SemanticValue.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<Type Name="SemanticValue" FullName="System.Speech.Recognition.SemanticValue">
<TypeSignature Language="C#" Value="public sealed class SemanticValue : System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string,System.Speech.Recognition.SemanticValue>>, System.Collections.Generic.IDictionary<string,System.Speech.Recognition.SemanticValue>, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string,System.Speech.Recognition.SemanticValue>>" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi serializable sealed beforefieldinit SemanticValue extends System.Object implements class System.Collections.Generic.ICollection`1<valuetype System.Collections.Generic.KeyValuePair`2<string, class System.Speech.Recognition.SemanticValue>>, class System.Collections.Generic.IDictionary`2<string, class System.Speech.Recognition.SemanticValue>, class System.Collections.Generic.IEnumerable`1<valuetype System.Collections.Generic.KeyValuePair`2<string, class System.Speech.Recognition.SemanticValue>>, class System.Collections.IEnumerable" FrameworkAlternate="net-6.0;net-7.0;net-8.0;net-9.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1" />
<TypeSignature Language="DocId" Value="T:System.Speech.Recognition.SemanticValue" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class SemanticValue
Implements ICollection(Of KeyValuePair(Of String, SemanticValue)), IDictionary(Of String, SemanticValue), IEnumerable(Of KeyValuePair(Of String, SemanticValue))" />
<TypeSignature Language="F#" Value="type SemanticValue = class
 interface IDictionary<string, SemanticValue>
 interface ICollection<KeyValuePair<string, SemanticValue>>
 interface seq<KeyValuePair<string, SemanticValue>>
 interface IEnumerable" FrameworkAlternate="net-6.0;net-7.0;net-8.0;net-9.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1" />
<TypeSignature Language="C++ CLI" Value="public ref class SemanticValue sealed : System::Collections::Generic::ICollection<System::Collections::Generic::KeyValuePair<System::String ^, System::Speech::Recognition::SemanticValue ^>>, System::Collections::Generic::IDictionary<System::String ^, System::Speech::Recognition::SemanticValue ^>, System::Collections::Generic::IEnumerable<System::Collections::Generic::KeyValuePair<System::String ^, System::Speech::Recognition::SemanticValue ^>>" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit SemanticValue extends System.Object implements class System.Collections.Generic.ICollection`1<valuetype System.Collections.Generic.KeyValuePair`2<string, class System.Speech.Recognition.SemanticValue>>, class System.Collections.Generic.IDictionary`2<string, class System.Speech.Recognition.SemanticValue>, class System.Collections.Generic.IEnumerable`1<valuetype System.Collections.Generic.KeyValuePair`2<string, class System.Speech.Recognition.SemanticValue>>, class System.Collections.IEnumerable" FrameworkAlternate="netstandard-2.0" />
<TypeSignature Language="F#" Value="type SemanticValue = class
 interface ICollection<KeyValuePair<string, SemanticValue>>
 interface seq<KeyValuePair<string, SemanticValue>>
 interface IEnumerable
 interface IDictionary<string, SemanticValue>" FrameworkAlternate="netstandard-2.0" />
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces>
<Interface>
<InterfaceName>System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>></InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>></InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.Collections.Generic.IDictionary<System.String,System.Speech.Recognition.SemanticValue></InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>></InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey,TValue>></InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.Collections.Generic.IEnumerable<T></InterfaceName>
</Interface>
<Interface>
<InterfaceName>System.Collections.IEnumerable</InterfaceName>
</Interface>
</Interfaces>
<Attributes>
<Attribute FrameworkAlternate="net-6.0;net-7.0;net-8.0;net-9.0">
<AttributeName Language="C#">[System.Diagnostics.DebuggerDisplay("{_keyName} = {Value}, Children = {_dictionary.Count}")]</AttributeName>
<AttributeName Language="F#">[<System.Diagnostics.DebuggerDisplay("{_keyName} = {Value}, Children = {_dictionary.Count}")>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="net-6.0;net-7.0;net-8.0;net-9.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.Diagnostics.DebuggerTypeProxy(typeof(System.Speech.Recognition.SemanticValue+SemanticValueDebugDisplay))]</AttributeName>
<AttributeName Language="F#">[<System.Diagnostics.DebuggerTypeProxy(typeof(System.Speech.Recognition.SemanticValue+SemanticValueDebugDisplay))>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="net-6.0;net-7.0;net-8.0;net-9.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.Serializable]</AttributeName>
<AttributeName Language="F#">[<System.Serializable>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1">
<AttributeName Language="C#">[System.Diagnostics.DebuggerDisplay("'{_keyName}'= {Value} - Children = {_dictionary.Count}")]</AttributeName>
<AttributeName Language="F#">[<System.Diagnostics.DebuggerDisplay("'{_keyName}'= {Value} - Children = {_dictionary.Count}")>]</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Represents the semantic organization of a recognized phrase.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
<xref:System.Speech.Recognition.SemanticValue> is the primary object that implements the semantic technology in System.Speech. Semantic interpretation allows grammars to define rules for use by a recognition engine to correctly interpret audio input. Semantic interpretation also enables recognition engines to organize their results so that they can be more easily processed, rather than returning only recognized words and sequences of words.
For example, the recognition engine output "Change background to red" would have to be parsed and interpreted by an application before it could be acted upon. A <xref:System.Speech.Recognition.Grammar> object can specify a semantic interpretation to make processing clearer by specifying that the phrase has two semantic substructures, one for selecting background or foreground (represented by the text "background"), and the other for selecting color (represented by the text "red").
System.Speech represents the semantics of a recognition operation in a tree of <xref:System.Speech.Recognition.SemanticValue> objects.
Each <xref:System.Speech.Recognition.SemanticValue> instance includes the following:
- An <xref:System.Object>, accessed by means of the <xref:System.Speech.Recognition.SemanticValue.Value%2A> property, used to key the instance of the <xref:System.Speech.Recognition.SemanticValue>.
- A measure of the accuracy of semantic parsing, returned by the <xref:System.Speech.Recognition.SemanticValue.Confidence%2A> property.
- A collection of name/value pairs (<xref:System.Collections.Generic.KeyValuePair%602>) of child objects, which are also <xref:System.Speech.Recognition.SemanticValue> instances. Child nodes are accessible through the <xref:System.Speech.Recognition.SemanticValue> implementation of <xref:System.Collections.Generic.IDictionary%602> using a string lookup key and a <xref:System.Speech.Recognition.SemanticValue> instance, as in the following example.
```csharp
foreach (KeyValuePair<String, SemanticValue> child in semantics)
{
Utils.CreateSemanticsTreeNodes(semanticsNode.Nodes, child.Value, child.Key);
}
```
Recognition engines based on System.Speech provide valid instances of <xref:System.Speech.Recognition.SemanticValue> for all output from recognition, even for phrases with no explicit semantic structure.
The <xref:System.Speech.Recognition.SemanticValue> instance for a phrase is obtained using the <xref:System.Speech.Recognition.RecognizedPhrase.Semantics%2A> property on the <xref:System.Speech.Recognition.RecognizedPhrase> object (or objects that inherit from it, such as <xref:System.Speech.Recognition.RecognitionResult>).
<xref:System.Speech.Recognition.SemanticValue> objects obtained for recognized phrases without semantic structure are characterized by:
- The lack of children (<xref:System.Speech.Recognition.SemanticValue.Count%2A> is 0).
- The <xref:System.Speech.Recognition.SemanticValue.Value%2A> property is `null`.
- An artificial semantic confidence level of 1.0 (returned by <xref:System.Speech.Recognition.SemanticValue.Confidence%2A>).
Typically, applications create <xref:System.Speech.Recognition.SemanticValue> instances indirectly, adding them to <xref:System.Speech.Recognition.Grammar> objects by using <xref:System.Speech.Recognition.SemanticResultValue> and <xref:System.Speech.Recognition.SemanticResultKey> instances, in conjunction with <xref:System.Speech.Recognition.Choices> and <xref:System.Speech.Recognition.GrammarBuilder> objects.
Direct construction of a <xref:System.Speech.Recognition.SemanticValue> instance is useful during the creation of strongly-typed grammars.
<xref:System.Speech.Recognition.SemanticValue> implements the <xref:System.Collections.Generic.IDictionary%602>, <xref:System.Collections.Generic.ICollection%601>, and <xref:System.Collections.Generic.IEnumerable%601> interfaces.
## Examples
The following example shows a handler for a <xref:System.Speech.Recognition.Grammar.SpeechRecognized> event designed to handle commands to change foreground and background color.
The handler identifies recognized phrases that have no underlying semantic structure by detecting a <xref:System.Speech.Recognition.SemanticValue.Count%2A> of zero and a <xref:System.Speech.Recognition.SemanticValue.Value%2A> of `null`. This recognition output is then processed directly by parsing the raw text.
In other cases, the handler uses keys to obtain the RGB components of a color name, to determine whether the command will change the foreground or background, or to indicate that no valid key was found.
```csharp
newGrammar.SpeechRecognized +=
delegate(object sender, SpeechRecognizedEventArgs eventArgs)
{
// Retrieve the value of the semantic property.
bool changeBackGround = true;
string errorString = "";
SemanticValue semantics = eventArgs.Result.Semantics;
Color newColor = Color.Empty;
try
{
if (semantics.Count == 0 && semantics.Value==null)
{
// Signifies recognition by a grammar with no semantics.
// Parse the string, assuming that the last word is color,
// and search for "background" or "foreground" in the input.
if (eventArgs.Result.Text.Contains("foreground"))
{
changeBackGround = false;
}
string cName = eventArgs.Result.Words[eventArgs.Result.Words.Count - 1].Text;
newColor = Color.FromName(cName);
}
else if (semantics.ContainsKey("colorStringList") ^ semantics.ContainsKey("colorRGBValueList"))
{
// Determine whether to change background or foreground.
if (semantics.ContainsKey("applyChgToBackground"))
{
changeBackGround = semantics["applyChgToBackground"].Value is bool;
}
// Get the RGB color value.
if (semantics.ContainsKey("colorStringList"))
{
newColor = Color.FromName((string)semantics["colorStringList"].Value);
}
if (semantics.ContainsKey("colorRGBValueList"))
{
newColor = System.Drawing.Color.FromArgb((int)semantics["colorRGBValueList"].Value);
}
}
else
{
// Throw an exception if the semantics do not contain the keys we
// support.
throw(new Exception("Unsupported semantics keys found."));
}
}
catch (Exception exp)
{
MessageBox.Show(String.Format("Unable to process color semantics.:\n{0}\n", exp.Message));
return;
}
// Change colors, either foreground or background.
if (changeBackGround)
{
BackColor = newColor;
float Bright = BackColor.GetBrightness();
float Hue = BackColor.GetHue();
float Sat = BackColor.GetSaturation();
// Make sure that text is readable regardless of the background.
if (BackColor.GetBrightness() <= .50)
{
ForeColor = Color.White;
}
else
{
ForeColor = Color.Black;
}
}
else
{
ForeColor = newColor;
float Bright = ForeColor.GetBrightness();
float Hue = ForeColor.GetHue();
float Sat = ForeColor.GetSaturation();
// Make sure that text is readable regardless of Foreground.
if (ForeColor.GetBrightness() <= .50)
{
BackColor = Color.White;
}
else
{
BackColor = Color.Black;
}
}
return;
};
```
]]></format>
</remarks>
<altmember cref="T:System.Speech.Recognition.SemanticResultValue" />
<altmember cref="T:System.Speech.Recognition.SemanticResultKey" />
</Docs>
<Members>
<MemberGroup MemberName=".ctor">
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Speech.Recognition.SemanticValue" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Typically, you will not create <xref:System.Speech.Recognition.SemanticValue> objects explicitly, except to support the building of strongly-typed grammars.
]]></format>
</remarks>
</Docs>
</MemberGroup>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public SemanticValue (object value);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(object value) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Speech.Recognition.SemanticValue.#ctor(System.Object)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (value As Object)" />
<MemberSignature Language="F#" Value="new System.Speech.Recognition.SemanticValue : obj -> System.Speech.Recognition.SemanticValue" Usage="new System.Speech.Recognition.SemanticValue value" />
<MemberSignature Language="C++ CLI" Value="public:
 SemanticValue(System::Object ^ value);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="value" Type="System.Object" />
</Parameters>
<Docs>
<param name="value">The information to be stored in the <see cref="T:System.Speech.Recognition.SemanticValue" /> object.</param>
<summary>Initializes a new instance of the <see cref="T:System.Speech.Recognition.SemanticValue" /> class and specifies a semantic value.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
There are no restrictions on the type of `value` to be stored.
An application can retrieve `value` by using the <xref:System.Speech.Recognition.SemanticValue.Value%2A> property on a <xref:System.Speech.Recognition.SemanticValue> instance.
The value of the <xref:System.Speech.Recognition.SemanticValue.Confidence%2A> property for the <xref:System.Speech.Recognition.SemanticValue> instance will be set to -1.
A <xref:System.Speech.Recognition.SemanticValue> constructed with this method cannot be referenced by key name.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public SemanticValue (string keyName, object value, float confidence);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string keyName, object value, float32 confidence) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Speech.Recognition.SemanticValue.#ctor(System.String,System.Object,System.Single)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (keyName As String, value As Object, confidence As Single)" />
<MemberSignature Language="F#" Value="new System.Speech.Recognition.SemanticValue : string * obj * single -> System.Speech.Recognition.SemanticValue" Usage="new System.Speech.Recognition.SemanticValue (keyName, value, confidence)" />
<MemberSignature Language="C++ CLI" Value="public:
 SemanticValue(System::String ^ keyName, System::Object ^ value, float confidence);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="keyName" Type="System.String" />
<Parameter Name="value" Type="System.Object" />
<Parameter Name="confidence" Type="System.Single" />
</Parameters>
<Docs>
<param name="keyName">A key that can be used to reference this <see cref="T:System.Speech.Recognition.SemanticValue" /> instance.</param>
<param name="value">An object containing information to be stored in the <see cref="T:System.Speech.Recognition.SemanticValue" /> object.</param>
<param name="confidence">A <see langword="float" /> containing an estimate of the certainty of semantic analysis.</param>
<summary>Initializes a new instance of the <see cref="T:System.Speech.Recognition.SemanticValue" /> class and specifies a semantic value, a key name, and a confidence level.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
There are no restrictions on the type of `value` to be stored.
An application can retrieve `value` by using the <xref:System.Speech.Recognition.SemanticValue.Value%2A> property on a <xref:System.Speech.Recognition.SemanticValue> instance.
The `confidence` parameter (returned by the <xref:System.Speech.Recognition.SemanticValue.Confidence%2A> property on a <xref:System.Speech.Recognition.SemanticValue> instance), should be between 0.0 and 1.0.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Confidence">
<MemberSignature Language="C#" Value="public float Confidence { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance float32 Confidence" />
<MemberSignature Language="DocId" Value="P:System.Speech.Recognition.SemanticValue.Confidence" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property Confidence As Single" />
<MemberSignature Language="F#" Value="member this.Confidence : single" Usage="System.Speech.Recognition.SemanticValue.Confidence" />
<MemberSignature Language="C++ CLI" Value="public:
 property float Confidence { float get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Single</ReturnType>
</ReturnValue>
<Docs>
<summary>Returns a relative measure of the certainty as to the correctness of the semantic parsing that returned the current instance of <see cref="T:System.Speech.Recognition.SemanticValue" />.</summary>
<value>Returns a <see langword="float" /> that is a relative measure of the certainty of semantic parsing that returned the current instance of <see cref="T:System.Speech.Recognition.SemanticValue" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Speech.Recognition.SemanticValue.Confidence%2A?displayProperty=nameWithType> property, which returns a measure of the correctness of semantic parsing, should not be confused with the <xref:System.Speech.Recognition.RecognizedPhrase.Confidence%2A?displayProperty=nameWithType> property, which returns a measure of the accuracy of speech recognition.
## Examples
The following example is used to recursively traverse and then display information (including confidence) as a <xref:System.Windows.Forms.TreeNodeCollection>, or as the nodes making up the tree structure of the semantics used to recognize a phrase.
```csharp
internal static void CreateSemanticsTreeNodes(
TreeNodeCollection nodes,
SemanticValue semantics,
String name)
{
string semanticsText =
String.Format(" {0} (Confidence {1})", name,semantics.Confidence);
// Format integers as hexadecimal.
if (semantics.Value == null )
{
semanticsText = semanticsText + " = null";
}
else if (semantics.Value.GetType() == typeof(int))
{
semanticsText = String.Format("{0} = {1:X} ", semanticsText, semantics.Value);
}
else
{
semanticsText = semanticsText + " = " + semantics.Value.ToString();
}
TreeNode semanticsNode = new TreeNode(semanticsText);
foreach (KeyValuePair<String, SemanticValue> child in semantics)
{
CreateSemanticsTreeNodes(semanticsNode.Nodes, child.Value, child.Key);
}
nodes.Add(semanticsNode);
}
```
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Contains">
<MemberSignature Language="C#" Value="public bool Contains (System.Collections.Generic.KeyValuePair<string,System.Speech.Recognition.SemanticValue> item);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance bool Contains(valuetype System.Collections.Generic.KeyValuePair`2<string, class System.Speech.Recognition.SemanticValue> item) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Speech.Recognition.SemanticValue.Contains(System.Collections.Generic.KeyValuePair{System.String,System.Speech.Recognition.SemanticValue})" />
<MemberSignature Language="VB.NET" Value="Public Function Contains (item As KeyValuePair(Of String, SemanticValue)) As Boolean" />
<MemberSignature Language="F#" Value="abstract member Contains : System.Collections.Generic.KeyValuePair<string, System.Speech.Recognition.SemanticValue> -> bool
override this.Contains : System.Collections.Generic.KeyValuePair<string, System.Speech.Recognition.SemanticValue> -> bool" Usage="semanticValue.Contains item" />
<MemberSignature Language="C++ CLI" Value="public:
 virtual bool Contains(System::Collections::Generic::KeyValuePair<System::String ^, System::Speech::Recognition::SemanticValue ^> item);" />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.Collections.Generic.ICollection`1.Contains(`0)</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="item" Type="System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>" />
</Parameters>
<Docs>
<param name="item">An instance of <see cref="T:System.Collections.Generic.KeyValuePair`2" /> instantiated for a given value of a key string and a <see cref="T:System.Speech.Recognition.SemanticValue" /> instance.</param>
<summary>Indicates whether the current <see cref="T:System.Speech.Recognition.SemanticValue" /> instance collection contains a specific key and a specific instance of <see cref="T:System.Speech.Recognition.SemanticValue" /> expressed as a key/value pair.</summary>
<returns>Returns a <see langword="bool" /> which is <see langword="true" /> if the current <see cref="T:System.Speech.Recognition.SemanticValue" /> contains an instance of <c>KeyValuePair<String, SemanticValue></c> for a specified value of the key string and the <see cref="T:System.Speech.Recognition.SemanticValue" />. Otherwise, <see langword="false" /> is returned.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="ContainsKey">
<MemberSignature Language="C#" Value="public bool ContainsKey (string key);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance bool ContainsKey(string key) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Speech.Recognition.SemanticValue.ContainsKey(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Function ContainsKey (key As String) As Boolean" />
<MemberSignature Language="F#" Value="abstract member ContainsKey : string -> bool
override this.ContainsKey : string -> bool" Usage="semanticValue.ContainsKey key" />
<MemberSignature Language="C++ CLI" Value="public:
 virtual bool ContainsKey(System::String ^ key);" />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.Collections.Generic.IDictionary`2.ContainsKey(`0)</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="key" Type="System.String" />
</Parameters>
<Docs>
<param name="key">
<see cref="T:System.String" /> containing the key string used to identify a child instance of <see cref="T:System.Speech.Recognition.SemanticValue" /> under the current <see cref="T:System.Speech.Recognition.SemanticValue" />.</param>
<summary>Indicates whether the current <see cref="T:System.Speech.Recognition.SemanticValue" /> instance collection contains a child <see cref="T:System.Speech.Recognition.SemanticValue" /> instance with a given key string.</summary>
<returns>Returns a <see langword="bool" />, <see langword="true" /> if a child instance <see cref="T:System.Speech.Recognition.SemanticValue" /> tagged with the string <paramref name="key" /> is found, <see langword="false" /> if not.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You can only access data by key value at runtime, for example to check *semantic["myKey"].Value*, and this generates an exception. We recommend that you query the object with <xref:System.Speech.Recognition.SemanticValue.ContainsKey%2A> before using <xref:System.Speech.Recognition.SemanticValue.Item%2A> with a given instance of <xref:System.Speech.Recognition.SemanticValue>.
## Examples
The following example shows a handler for a <xref:System.Speech.Recognition.Grammar.SpeechRecognized> event designed to handle commands to change foreground and background color.
After handling phrases that are recognized but have no semantic structure, the handler checks for the presence of appropriate keys using <xref:System.Speech.Recognition.SemanticValue.ContainsKey%2A> (`applyChgToBackground`, `colorRGBValueList`, or `colorStringList)`, and then processes the semantically organized data.
```csharp
newGrammar.SpeechRecognized +=
delegate(object sender, SpeechRecognizedEventArgs eventArgs)
{
// Retrieve the value of the semantic property.
bool changeBackGround = true;
string errorString = "";
SemanticValue semantics = eventArgs.Result.Semantics;
Color newColor = Color.Empty;
try
{
if (semantics.Count == 0 && semantics.Value==null)
{
// Signifies recognition by a grammar with no semantics.
// Parse the string, assuming that the last word is color,
// searching for background or foreground in input.
if (eventArgs.Result.Text.Contains("foreground"))
{
changeBackGround = false;
}
string cName = eventArgs.Result.Words[eventArgs.Result.Words.Count - 1].Text;
newColor = Color.FromName(cName);
}
else if (semantics.ContainsKey("colorStringList") ^ semantics.ContainsKey("colorRGBValueList"))
{
// Determine whether to change background or foreground.
if (semantics.ContainsKey("applyChgToBackground"))
{
changeBackGround = semantics["applyChgToBackground"].Value is bool;
}
// Get the RGB color value.
if (semantics.ContainsKey("colorStringList"))
{
newColor = Color.FromName((string)semantics["colorStringList"].Value);
}
if (semantics.ContainsKey("colorRGBValueList"))
{
newColor = System.Drawing.Color.FromArgb((int)semantics["colorRGBValueList"].Value);
}
}
else
{
// Throw an exception if the semantics do not contain the keys we
// support.
throw(new Exception("Unsupported semantics keys found."));
}
}
catch (Exception exp)
{
MessageBox.Show(String.Format("Unable to process color semantics.:\n{0}\n", exp.Message));
return;
}
// Change colors, either foreground or background.
if (changeBackGround)
{
BackColor = newColor;
float Bright = BackColor.GetBrightness();
float Hue = BackColor.GetHue();
float Sat = BackColor.GetSaturation();
// Make sure that text is readable regardless of background.
if (BackColor.GetBrightness() <= .50)
{
ForeColor = Color.White;
}
else
{
ForeColor = Color.Black;
}
}
else
{
ForeColor = newColor;
float Bright = ForeColor.GetBrightness();
float Hue = ForeColor.GetHue();
float Sat = ForeColor.GetSaturation();
// Make sure that text is readable regardless of Foreground.
if (ForeColor.GetBrightness() <= .50)
{
BackColor = Color.White;
}
else
{
BackColor = Color.Black;
}
}
return;
};
```
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Count">
<MemberSignature Language="C#" Value="public int Count { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 Count" />
<MemberSignature Language="DocId" Value="P:System.Speech.Recognition.SemanticValue.Count" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property Count As Integer" />
<MemberSignature Language="F#" Value="member this.Count : int" Usage="System.Speech.Recognition.SemanticValue.Count" />
<MemberSignature Language="C++ CLI" Value="public:
 property int Count { int get(); };" />
<MemberType>Property</MemberType>
<Implements>
<InterfaceMember>P:System.Collections.Generic.ICollection`1.Count</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Docs>
<summary>Returns the number of child <see cref="T:System.Speech.Recognition.SemanticValue" /> objects under the current <see cref="T:System.Speech.Recognition.SemanticValue" /> instance.</summary>
<value>The number of child <see cref="T:System.Speech.Recognition.SemanticValue" /> objects under the current <see cref="T:System.Speech.Recognition.SemanticValue" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Recognition results that do not make use of semantic parsing always have a <xref:System.Speech.Recognition.SemanticValue.Count%2A> value of zero, as well as a <xref:System.Speech.Recognition.SemanticValue.Value%2A> of `null`.
## Examples
The following example shows a handler for a <xref:System.Speech.Recognition.Grammar.SpeechRecognized> event designed to handle commands to change foreground and background color.
The handler identifies recognized phrases that have no underlying semantic structure by detecting a <xref:System.Speech.Recognition.SemanticValue.Count%2A> of zero and a <xref:System.Speech.Recognition.SemanticValue.Value%2A> of `null`. This recognition output is then processed directly by parsing the raw text.
In other cases, the handler uses keys to obtain the RGB components of a color name, to determine whether the command will change the foreground or background, or to indicate that no valid key was found.
```csharp
newGrammar.SpeechRecognized +=
delegate(object sender, SpeechRecognizedEventArgs eventArgs)
{
// Retrieve the value of the semantic property.
bool changeBackGround = true;
string errorString = "";
SemanticValue semantics = eventArgs.Result.Semantics;
Color newColor = Color.Empty;
try
{
if (semantics.Count == 0 && semantics.Value==null)
{
// Signifies recognition by a grammar with no semantics.
// Parse the string, assuming that the last word is color,
// searching for background or foreground in input.
if (eventArgs.Result.Text.Contains("foreground"))
{
changeBackGround = false;
}
string cName = eventArgs.Result.Words[eventArgs.Result.Words.Count - 1].Text;
newColor = Color.FromName(cName);
}
else if (semantics.ContainsKey("colorStringList") ^ semantics.ContainsKey("colorRGBValueList"))
{
// Determine whether to change background or foreground.
if (semantics.ContainsKey("applyChgToBackground"))
{
changeBackGround = semantics["applyChgToBackground"].Value is bool;
}
// Get the RGB color value.
if (semantics.ContainsKey("colorStringList"))
{
newColor = Color.FromName((string)semantics["colorStringList"].Value);
}
if (semantics.ContainsKey("colorRGBValueList"))
{
newColor = System.Drawing.Color.FromArgb((int)semantics["colorRGBValueList"].Value);
}
}
else
{
// Throw an exception if the semantics do not contain the keys we
// support.
throw(new Exception("Unsupported semantics keys found."));
}
}
catch (Exception exp)
{
MessageBox.Show(String.Format("Unable to process color semantics.:\n{0}\n", exp.Message));
return;
}
// Change colors, either foreground or background.
if (changeBackGround)
{
BackColor = newColor;
float Bright = BackColor.GetBrightness();
float Hue = BackColor.GetHue();
float Sat = BackColor.GetSaturation();
// Make sure that text is readable regardless of background.
if (BackColor.GetBrightness() <= .50)
{
ForeColor = Color.White;
}
else
{
ForeColor = Color.Black;
}
}
else
{
ForeColor = newColor;
float Bright = ForeColor.GetBrightness();
float Hue = ForeColor.GetHue();
float Sat = ForeColor.GetSaturation();
// Make sure that text is readable regardless of Foreground.
if (ForeColor.GetBrightness() <= .50)
{
BackColor = Color.White;
}
else
{
BackColor = Color.Black;
}
}
return;
};
```
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="Equals">
<MemberSignature Language="C#" Value="public override bool Equals (object obj);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance bool Equals(object obj) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Speech.Recognition.SemanticValue.Equals(System.Object)" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function Equals (obj As Object) As Boolean" />
<MemberSignature Language="F#" Value="override this.Equals : obj -> bool" Usage="semanticValue.Equals obj" />
<MemberSignature Language="C++ CLI" Value="public:
 override bool Equals(System::Object ^ obj);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="obj" Type="System.Object" />
</Parameters>
<Docs>
<param name="obj">The object to evaluate.</param>
<summary>Determines whether a specified object is an instance of <c>SemanticValue</c> and equal to the current instance of <c>SemanticValue</c>.</summary>
<returns>
<see langword="true" /> if the specified Object is equal to the current Object; otherwise, <see langword="false" />.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="GetHashCode">
<MemberSignature Language="C#" Value="public override int GetHashCode ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance int32 GetHashCode() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Speech.Recognition.SemanticValue.GetHashCode" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function GetHashCode () As Integer" />
<MemberSignature Language="F#" Value="override this.GetHashCode : unit -> int" Usage="semanticValue.GetHashCode " />
<MemberSignature Language="C++ CLI" Value="public:
 override int GetHashCode();" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Provides a hash code for a <c>SemanticValue</c> object.</summary>
<returns>A hash code for the current <see cref="T:System.Speech.Recognition.SemanticValue" /> object.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Item">
<MemberSignature Language="C#" Value="public System.Speech.Recognition.SemanticValue this[string key] { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Speech.Recognition.SemanticValue Item(string)" />
<MemberSignature Language="DocId" Value="P:System.Speech.Recognition.SemanticValue.Item(System.String)" />
<MemberSignature Language="VB.NET" Value="Default Public Property Item(key As String) As SemanticValue" />
<MemberSignature Language="F#" Value="member this.Item(string) : System.Speech.Recognition.SemanticValue with get, set" Usage="System.Speech.Recognition.SemanticValue.Item" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::Speech::Recognition::SemanticValue ^ default[System::String ^] { System::Speech::Recognition::SemanticValue ^ get(System::String ^ key); void set(System::String ^ key, System::Speech::Recognition::SemanticValue ^ value); };" />
<MemberType>Property</MemberType>
<Implements>
<InterfaceMember>P:System.Collections.Generic.IDictionary`2.Item(`0)</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Speech.Recognition.SemanticValue</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="key" Type="System.String" />
</Parameters>
<Docs>
<param name="key">A key for a <see langword="KeyValuePair<String, SemanticValue>" /> contained in the current instance of <see cref="T:System.Speech.Recognition.SemanticValue" />.</param>
<summary>Returns child <see cref="T:System.Speech.Recognition.SemanticValue" /> instances that belong to the current <see cref="T:System.Speech.Recognition.SemanticValue" />.</summary>
<value>Returns a child of the current <see cref="T:System.Speech.Recognition.SemanticValue" /> that can be indexed as part of a key value pair: <c>KeyValuePair<String,</c><c>SemanticValue></c>.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Speech.Recognition.SemanticValue.Item%2A> is read-only and generates exceptions if members are modified.
You can only access data by key value at run-time, not at compile-time, for example to check `semantic["myKey"].Value`. Specifying a key that is not present generates an exception.
To detect the presence of a given key, use the <xref:System.Speech.Recognition.SemanticValue.ContainsKey%2A> property on an <xref:System.Speech.Recognition.SemanticValue> instance.
## Examples
The following example shows a handler for a <xref:System.Speech.Recognition.Grammar.SpeechRecognized> event designed to handle commands to change foreground and background color.
After handling recognized phrases that have no semantic structure, the handler checks for the presence of appropriate keys using <xref:System.Speech.Recognition.SemanticValue.ContainsKey%2A> (`applyChgToBackground`, `colorRGBValueList`, or `colorStringList)`, and then uses the <xref:System.Speech.Recognition.SemanticValue.Item%2A> property to obtain the nodes with needed information.
The use of <xref:System.Speech.Recognition.SemanticValue.Item%2A> is highlighted below.
```csharp
newGrammar.SpeechRecognized +=
delegate(object sender, SpeechRecognizedEventArgs eventArgs)
{
// Retrieve the value of the semantic property.
bool changeBackGround = true;
string errorString = "";
SemanticValue semantics = eventArgs.Result.Semantics;
Color newColor = Color.Empty;
try
{
if (semantics.Count == 0 && semantics.Value==null)
{
// Signifies recognition by a grammar with no semantics.
// Parse the string, assuming that the last word is color,
// searching for background or foreground in input.
if (eventArgs.Result.Text.Contains("foreground"))
{
changeBackGround = false;
}
string cName = eventArgs.Result.Words[eventArgs.Result.Words.Count - 1].Text;
newColor = Color.FromName(cName);
}
else if (semantics.ContainsKey("colorStringList") ^ semantics.ContainsKey("colorRGBValueList"))
{
// Determine whether to change background or foreground.
if (semantics.ContainsKey("applyChgToBackground"))
{
changeBackGround = semantics["applyChgToBackground"].Value is bool;
}
// Get the RGB color value.
if (semantics.ContainsKey("colorStringList"))
{
newColor = Color.FromName((string)semantics["colorStringList"].Value);
}
if (semantics.ContainsKey("colorRGBValueList"))
{
newColor = System.Drawing.Color.FromArgb((int)semantics["colorRGBValueList"].Value);
}
}
else
{
// Throw an exception if the semantics do not contain the keys we
// support.
throw(new Exception("Unsupported semantic keys found."));
}
}
catch (Exception exp)
{
MessageBox.Show(String.Format("Unable to process color semantics.:\n{0}\n", exp.Message));
return;
}
// Change colors, either foreground or background.
if (changeBackGround)
{
BackColor = newColor;
float Bright = BackColor.GetBrightness();
float Hue = BackColor.GetHue();
float Sat = BackColor.GetSaturation();
// Make sure that text is readable regardless of background.
if (BackColor.GetBrightness() <= .50)
{
ForeColor = Color.White;
}
else
{
ForeColor = Color.Black;
}
}
else
{
ForeColor = newColor;
float Bright = ForeColor.GetBrightness();
float Hue = ForeColor.GetHue();
float Sat = ForeColor.GetSaturation();
// Make sure that text is readable regardless of the foreground.
if (ForeColor.GetBrightness() <= .50)
{
BackColor = Color.White;
}
else
{
BackColor = Color.Black;
}
}
return;
};
```
]]></format>
</remarks>
<exception cref="T:System.Collections.Generic.KeyNotFoundException">No child member of the current instance of <see cref="T:System.Speech.Recognition.SemanticValue" /> has a key matching the <paramref name="key" /> parameter.</exception>
<exception cref="T:System.InvalidOperationException">Code attempted to change the <see cref="T:System.Speech.Recognition.SemanticValue" /> at the specified index.</exception>
</Docs>
</Member>
<Member MemberName="System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>>.Add">
<MemberSignature Language="C#" Value="void ICollection<KeyValuePair<string,SemanticValue>>.Add (System.Collections.Generic.KeyValuePair<string,System.Speech.Recognition.SemanticValue> key);" />
<MemberSignature Language="ILAsm" Value=".method hidebysig newslot virtual instance void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>>.Add(valuetype System.Collections.Generic.KeyValuePair`2<string, class System.Speech.Recognition.SemanticValue> key) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Speech.Recognition.SemanticValue.System#Collections#Generic#ICollection<System#Collections#Generic#KeyValuePair<System#String,System#Speech#Recognition#SemanticValue>>#Add(System.Collections.Generic.KeyValuePair{System.String,System.Speech.Recognition.SemanticValue})" />
<MemberSignature Language="VB.NET" Value="Sub Add (key As KeyValuePair(Of String, SemanticValue)) Implements ICollection(Of KeyValuePair(Of String, SemanticValue)).Add" />
<MemberSignature Language="F#" Value="abstract member System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>>.Add : System.Collections.Generic.KeyValuePair<string, System.Speech.Recognition.SemanticValue> -> unit
override this.System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>>.Add : System.Collections.Generic.KeyValuePair<string, System.Speech.Recognition.SemanticValue> -> unit" Usage="semanticValue.System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>>.Add key" />
<MemberSignature Language="C++ CLI" Value=" virtual void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>>.Add(System::Collections::Generic::KeyValuePair<System::String ^, System::Speech::Recognition::SemanticValue ^> key) = System::Collections::Generic::ICollection<System::Collections::Generic::KeyValuePair<System::String ^, System::Speech::Recognition::SemanticValue ^>>::Add;" />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.Collections.Generic.ICollection`1.Add(`0)</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="key" Type="System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>" />
</Parameters>
<Docs>
<param name="key">A key for a <see cref="T:System.Speech.Recognition.SemanticValue" />.</param>
<summary>Adds the specified key and <see cref="T:System.Speech.Recognition.SemanticValue" /> to the collection.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>>.Clear">
<MemberSignature Language="C#" Value="void ICollection<KeyValuePair<string,SemanticValue>>.Clear ();" />
<MemberSignature Language="ILAsm" Value=".method hidebysig newslot virtual instance void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>>.Clear() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Speech.Recognition.SemanticValue.System#Collections#Generic#ICollection<System#Collections#Generic#KeyValuePair<System#String,System#Speech#Recognition#SemanticValue>>#Clear" />
<MemberSignature Language="VB.NET" Value="Sub Clear () Implements ICollection(Of KeyValuePair(Of String, SemanticValue)).Clear" />
<MemberSignature Language="F#" Value="abstract member System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>>.Clear : unit -> unit
override this.System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>>.Clear : unit -> unit" Usage="semanticValue.System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>>.Clear " />
<MemberSignature Language="C++ CLI" Value=" virtual void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>>.Clear() = System::Collections::Generic::ICollection<System::Collections::Generic::KeyValuePair<System::String ^, System::Speech::Recognition::SemanticValue ^>>::Clear;" />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.Collections.Generic.ICollection`1.Clear</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Removes all key/value pairs from the collection.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>>.CopyTo">
<MemberSignature Language="C#" Value="void ICollection<KeyValuePair<string,SemanticValue>>.CopyTo (System.Collections.Generic.KeyValuePair<string,System.Speech.Recognition.SemanticValue>[] array, int index);" />
<MemberSignature Language="ILAsm" Value=".method hidebysig newslot virtual instance void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>>.CopyTo(valuetype System.Collections.Generic.KeyValuePair`2<string, class System.Speech.Recognition.SemanticValue>[] array, int32 index) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Speech.Recognition.SemanticValue.System#Collections#Generic#ICollection<System#Collections#Generic#KeyValuePair<System#String,System#Speech#Recognition#SemanticValue>>#CopyTo(System.Collections.Generic.KeyValuePair{System.String,System.Speech.Recognition.SemanticValue}[],System.Int32)" />
<MemberSignature Language="VB.NET" Value="Sub CopyTo (array As KeyValuePair(Of String, SemanticValue)(), index As Integer) Implements ICollection(Of KeyValuePair(Of String, SemanticValue)).CopyTo" />
<MemberSignature Language="F#" Value="abstract member System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>>.CopyTo : System.Collections.Generic.KeyValuePair<string, System.Speech.Recognition.SemanticValue>[] * int -> unit
override this.System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>>.CopyTo : System.Collections.Generic.KeyValuePair<string, System.Speech.Recognition.SemanticValue>[] * int -> unit" Usage="semanticValue.System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>>.CopyTo (array, index)" />
<MemberSignature Language="C++ CLI" Value=" virtual void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>>.CopyTo(cli::array <System::Collections::Generic::KeyValuePair<System::String ^, System::Speech::Recognition::SemanticValue ^>> ^ array, int index) = System::Collections::Generic::ICollection<System::Collections::Generic::KeyValuePair<System::String ^, System::Speech::Recognition::SemanticValue ^>>::CopyTo;" />
<MemberType>Method</MemberType>
<Implements>
<InterfaceMember>M:System.Collections.Generic.ICollection`1.CopyTo(`0[],System.Int32)</InterfaceMember>
</Implements>
<AssemblyInfo>
<AssemblyName>System.Speech</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="array" Type="System.Collections.Generic.KeyValuePair<System.String,System.Speech.Recognition.SemanticValue>[]" />
<Parameter Name="index" Type="System.Int32" />