private void UpdateFlags(Creature selectedUnit) { for (int i = 0; i < 32; i++) { uint item = 1u << i; UnitFlags1 flag = (UnitFlags1)item; string name = flag.ToString(); bool enabled = (selectedUnit.flags1 & flag) == flag; flag1List[i].Enabled = enabled; } for (int i = 0; i < 32; i++) { uint item = 1u << i; UnitFlags2 flag = (UnitFlags2)item; string name = flag.ToString(); bool enabled = (selectedUnit.flags2 & flag) == flag; flag2List[i].Enabled = enabled; } for (int i = 0; i < 29; i++) { uint item = 1u << i; UnitFlags3 flag = (UnitFlags3)item; string name = flag.ToString(); bool enabled = (selectedUnit.flags3 & flag) == flag; flag3List[i].Enabled = enabled; } }
public MainWindow() { InitializeComponent(); UnitList = new ObservableCollection <Creature>(); RaceList = new ObservableCollection <Creature>(); flag1List = new ObservableCollection <FlagDisplay>(); flag2List = new ObservableCollection <FlagDisplay>(); flag3List = new ObservableCollection <FlagDisplay>(); unitListView.ItemsSource = UnitList; raceListView.ItemsSource = RaceList; flags1ListView.ItemsSource = flag1List; flags2ListView.ItemsSource = flag2List; flags3ListView.ItemsSource = flag3List; for (int i = 0; i < 32; i++) { uint item = 1u << i; UnitFlags1 flag = (UnitFlags1)item; string name = flag.ToString(); name = name.Replace('_', ' '); name = TI.ToTitleCase(name); flag1List.Add(new FlagDisplay() { Name = name, Enabled = false }); } for (int i = 0; i < 32; i++) { uint item = 1u << i; UnitFlags2 flag = (UnitFlags2)item; string name = flag.ToString(); name = name.Replace('_', ' '); name = TI.ToTitleCase(name); flag2List.Add(new FlagDisplay() { Name = name, Enabled = false }); } for (int i = 0; i < 29; i++) { uint item = 1u << i; UnitFlags3 flag = (UnitFlags3)item; string name = flag.ToString(); name = name.Replace('_', ' '); name = TI.ToTitleCase(name); flag3List.Add(new FlagDisplay() { Name = name, Enabled = false }); } }