/// <summary> /// Constructor /// </summary> /// <param name="scrollView">The scroll view host.</param> /// <param name="selectionStrategy">The selection strategy to use.</param> public ButtonGrid(ScrollView scrollView, ButtonGridSelectionStrategy selectionStrategy) : this(scrollView, selectionStrategy, new ButtonGridGridLayout(), null, CreateDefaultCaptionFactory(scrollView)) { }
/// <summary> /// This function only exists to allow the subclasses of ButtonGrid for common strategies to actually be able to set /// their strategy. This should not (and can't) be called from other classes. If you do need to use ButtonGrid raw /// externally to this library just favor object composition to get your grid setup correctly. If you do make a new subclass /// of ButtonGrid, pass null for the strategy in the base call and then call this method as soon as possible. /// </summary> /// <param name="selectionStrategy"></param> protected internal void _workaroundSetSelectionStrategy(ButtonGridSelectionStrategy selectionStrategy) { this.selectionStrategy = selectionStrategy; }
/// <summary> /// Constructor /// </summary> /// <param name="scrollView">The scroll view host.</param> /// <param name="selectionStrategy">The selection strategy to use.</param> /// <param name="layoutEngine">The Layout to use.</param> /// <param name="itemComparer">A comparison instance.</param> /// <param name="captionFactory">The factory to use to make captions.</param> public ButtonGrid(ScrollView scrollView, ButtonGridSelectionStrategy selectionStrategy, ButtonGridLayout layoutEngine, IComparer <ButtonGridItem> itemComparer, ButtonGridCaptionFactory captionFactory) { this.selectionStrategy = selectionStrategy; NonEmptyGroupCount = 0; String read; bool boolValue; int intValue; SuppressLayout = false; this.scrollView = scrollView; scrollView.CanvasPositionChanged += scrollView_CanvasPositionChanged; this.itemComparer = itemComparer; this.layoutEngine = layoutEngine; //Try to get properties from the widget itself. read = scrollView.getUserString("ItemHeight"); if (read != null && NumberParser.TryParse(read, out intValue)) { ItemHeight = ScaleHelper.Scaled(intValue); } else { ItemHeight = ScaleHelper.Scaled(122); } read = scrollView.getUserString("ItemWidth"); if (read != null && NumberParser.TryParse(read, out intValue)) { ItemWidth = ScaleHelper.Scaled(intValue); } else { ItemWidth = ScaleHelper.Scaled(122); } ButtonSkin = scrollView.getUserString("ButtonSkin"); if (ButtonSkin == null || ButtonSkin == String.Empty) { ButtonSkin = "ButtonGridButton"; } read = scrollView.getUserString("ShowGroupCaptions"); if (read != null && bool.TryParse(read, out boolValue)) { ShowGroupCaptions = boolValue; } else { ShowGroupCaptions = true; } read = scrollView.getUserString("ItemPaddingX"); if (read != null && NumberParser.TryParse(read, out intValue)) { layoutEngine.ItemPaddingX = ScaleHelper.Scaled(intValue); } read = scrollView.getUserString("ItemPaddingY"); if (read != null && NumberParser.TryParse(read, out intValue)) { layoutEngine.ItemPaddingY = ScaleHelper.Scaled(intValue); } read = scrollView.getUserString("GroupPaddingY"); if (read != null && NumberParser.TryParse(read, out intValue)) { layoutEngine.GroupPaddingY = ScaleHelper.Scaled(intValue); } read = scrollView.getUserString("Center"); if (read != null && bool.TryParse(read, out boolValue)) { layoutEngine.Center = boolValue; } this.CaptionFactory = captionFactory; }