private void UpdateArmorGrid(ArmorGrid armorGrid, CharacterSheet.ArmorClassItem item, int itemIndex) { var sheet = CharacterSheetStorage.Instance.selectedCharacter; if (sheet == null) { return; } MainPage.SetTapHandler(armorGrid.container, (s, e) => Armor_DoubleTap(item), 2); #if EXPAND_SELECTED #if EXPAND_CHECKBOX if (armorGrid.selectedHandler != null) { armorGrid.selected.CheckedChanged -= armorGrid.selectedHandler; } armorGrid.selectedHandler = (s, e) => ArmorSelected_CheckedChanged(item, e.Value); UpdateValue(armorGrid.selected, item.selected); armorGrid.selected.CheckedChanged += armorGrid.selectedHandler; #if EXPAND_WITH_TAP MainPage.AddTapHandler(armorGrid.container, (s, e) => Armor_Tap(armorGrid.selected), 1); #endif #else #if EXPAND_WITH_TAP MainPage.AddTapHandler(armorGrid.container, (s, e) => Armor_Tap(item), 1); #endif #endif #endif UpdateValue(armorGrid.name, item.AsString(sheet)); armorGrid.name.FontAttributes = item.active ? FontAttributes.Bold : FontAttributes.None; }
private void RemoveArmorGrid(ArmorGrid armorGrid) { if (armorGrid == null) { return; } Armor.Children.Remove(armorGrid.container); armorGrids.Remove(armorGrid); armorGridsPool.Add(armorGrid); }
private void CreateArmorGrid(CharacterSheet.ArmorClassItem item, int itemIndex) { if (item == null) { return; } var sheet = CharacterSheetStorage.Instance.selectedCharacter; if (sheet == null) { return; } if (armorGridsPool.Count > 0) { var armorGrid = armorGridsPool[0]; armorGridsPool.RemoveAt(0); UpdateArmorGrid(armorGrid, item, itemIndex); var pos = #if EXPAND_SELECTED selectedArmorGrids.Count + #endif armorGrids.Count; armorGrids.Add(armorGrid); Armor.Children.Insert(pos, armorGrid.container); return; } #if USE_GRID var container = new Grid() { ColumnSpacing = 5, RowSpacing = 5, BackgroundColor = Color.LightGray, }; container.ColumnDefinitions = new ColumnDefinitionCollection() { new ColumnDefinition() { Width = GridLength.Auto }, new ColumnDefinition() { Width = GridLength.Star }, }; container.RowDefinitions = new RowDefinitionCollection() { new RowDefinition() { Height = GridLength.Auto }, }; #else var container = new StackLayout() { Orientation = StackOrientation.Horizontal, BackgroundColor = Color.LightGray, }; #endif var armorNameFrame = CreateFrame(item.AsString(sheet)); armorNameFrame.HorizontalOptions = LayoutOptions.FillAndExpand; var armorName = armorNameFrame.Content as Label; armorName.FontAttributes = item.active ? FontAttributes.Bold : FontAttributes.None; MainPage.AddTapHandler(container, (s, e) => Armor_DoubleTap(item), 2); #if EXPAND_SELECTED #if EXPAND_CHECKBOX var selectedcb = new CheckBox() { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, IsChecked = item.selected, }; EventHandler <CheckedChangedEventArgs> selectedHandler = (s, e) => ArmorSelected_CheckedChanged(item, e.Value); selectedcb.CheckedChanged += selectedHandler; #if EXPAND_WITH_TAP MainPage.AddTapHandler(container, (s, e) => Armor_Tap(selectedcb), 1); #endif #if USE_GRID container.Children.Add(selectedcb, 0, 0); #else container.Children.Add(selectedcb); #endif #else #if EXPAND_WITH_TAP MainPage.AddTapHandler(container, (s, e) => Armor_Tap(item), 1); #endif #endif #endif #if USE_GRID container.Children.Add(armorNameFrame, 1, 0); #else container.Children.Add(armorNameFrame); #endif var newArmorGrid = new ArmorGrid() { container = container, #if EXPAND_SELECTED && EXPAND_CHECKBOX selectedHandler = selectedHandler, selected = selectedcb, #endif name = armorName, nameFrame = armorNameFrame, }; var newpos = #if EXPAND_SELECTED selectedArmorGrids.Count + #endif armorGrids.Count; armorGrids.Add(newArmorGrid); Armor.Children.Insert(newpos, newArmorGrid.container); }
private void UpdateArmorGrid(ArmorGrid armorGrid, KeyValuePair <CharacterSheet.ArmorClassItem, int> kvp) { UpdateArmorGrid(armorGrid, kvp.Key, kvp.Value); }