/// <summary> /// Builds the selection tree. /// </summary> protected override void BuildSelectionTree(OdinMenuTree tree) { tree.Selection.SupportsMultiSelect = this.supportsMultiSelect; tree.DefaultMenuStyle = OdinMenuStyle.TreeViewStyle; this.getMenuItemName = this.getMenuItemName ?? (x => x == null ? "" : x.ToString()); if (this.FlattenedTree) { if (this.genericSelectorCollection != null) { foreach (var item in this.genericSelectorCollection) { tree.MenuItems.Add(new OdinMenuItem(tree, item.GetNiceName(), item.Value)); } } else { foreach (var item in this.collection) { tree.MenuItems.Add(new OdinMenuItem(tree, this.getMenuItemName(item), item)); } } } else { if (this.genericSelectorCollection != null) { foreach (var item in this.genericSelectorCollection) { tree.AddObjectAtPath(item.GetNiceName(), item.Value); } } else { tree.AddRange(this.collection, this.getMenuItemName); } } if (this.CheckboxToggle) { tree.EnumerateTree().ForEach(DrawCheckboxMenuItems); tree.DefaultMenuStyle.TrianglePadding -= 17; tree.DefaultMenuStyle.Offset += 18; tree.DefaultMenuStyle.SelectedColorDarkSkin = new Color(1, 1, 1, 0.05f); tree.DefaultMenuStyle.SelectedColorLightSkin = new Color(1, 1, 1, 0.05f); tree.DefaultMenuStyle.SelectedLabelStyle = tree.DefaultMenuStyle.DefaultLabelStyle; tree.Config.ConfirmSelectionOnDoubleClick = false; } }
/// <summary> /// Populates the tree with all enum values. /// </summary> protected override void BuildSelectionTree(OdinMenuTree tree) { tree.Selection.SupportsMultiSelect = isFlagEnum; tree.Config.DrawSearchToolbar = true; tree.AddRange(enumValues, x => Enum.GetName(typeof(T), x).SplitPascalCase()); if (isFlagEnum) { tree.DefaultMenuStyle.Offset += 15; if (!enumValues.Select(x => Convert.ToInt64(x)).Contains(0)) { tree.MenuItems.Insert(0, new OdinMenuItem(tree, "None", 0)); } tree.EnumerateTree().ForEach(x => x.OnDrawItem += DrawEnumFlagItem); this.DrawConfirmSelectionButton = false; } else { tree.EnumerateTree().ForEach(x => x.OnDrawItem += DrawEnumItem); } }
protected override void BuildSelectionTree(OdinMenuTree tree) { tree.AddRange(_list, x => Convert.ToString(x)); }
/// <summary> /// Builds the selection tree. /// </summary> protected override void BuildSelectionTree(OdinMenuTree tree) { tree.Selection.SupportsMultiSelect = this.supportsMultiSelect; this.getMenuItemName = this.getMenuItemName ?? (x => x == null ? "" : x.ToString()); tree.AddRange(this.collection, this.getMenuItemName); }