我必須將Flags Enumeration映射到多個組合框。如何將Flags枚舉映射到多個組合框?
例如,第一個2位需要以對應於組合框爲屏幕的對比度設置:
Bit 0 - 1: Contrast (0=Low/1 = Medium/2=high)
位2 & 3需要爲對應於語音音量
Bit 2 - 3: Speech volume (0=Low/1 = Medium/2 = High)
和位4 & 5對應於蜂鳴器音量。
Bit 4 – 5: Buzzer volume (0=Low/1 = Medium/2 = High)
位6對應於進入或退出(即,如果它是在它的進入,如果是關閉它的退出)
Bit 6: Entry/exit indication
我旗枚舉被定義爲:
[Flags]
public enum RKP
{
Contrast0 = 1, // bit 0
Contrast1 = 2, // bit 1
SpeechVolume2 = 4, // bit 2
SpeechVolume3 = 8, // bit 3
BuzzerVolume4 = 16, // bit 4
BuzzerVolume5 = 32, // bit 5
EntryExitIndication = 64, // bit 6
}
什麼將這些映射到適當的組合框的最佳方法,然後將每個組合框的值轉換爲正確的枚舉值以保存它?
如果您堅持縮小信息大小,您應該製作一個固定大小的結構並提供提取和設置信息的函數。其餘的應該是硬編碼的。 – SimpleVar
也許這可能會給你一個想法:http://www.thejoyofcode.com/Xaml_ObjectDataProvider._They_really_did_think_of_everything.aspx –