using System; using System.Collections.Generic; using System.Threading.Tasks; using Avalonia.Controls; using Avalonia.Media; using ControlCatalog.Models; using ControlCatalog.Pages; namespace ControlCatalog.ViewModels; partial class MainWindowViewModel { private readonly HomeSection[] _pageSections = [ Section("Basic Input", Icons.Cursor2, s => { s.Add("Buttons", Icons.CursorClick, "Button, RepeatButton, ToggleButton and friends"); s.Add("ButtonSpinner", Icons.Spinner, "Content with increment and decrement buttons"); s.Add("CheckBox", Icons.Checkbox, "Two- and three-state check boxes"); s.Add("ColorPicker", Icons.Palette, "Pick colors from spectrum and palette views"); s.Add("ComboBox", Icons.Dropdown, "A drop-down list of selectable items"); s.Add("NumericUpDown", Icons.Number, "Numeric input with spinner buttons"); s.Add("RadioButton", Icons.Radio, "Mutually exclusive option groups"); s.Add("Slider", Icons.Tune, "Select a value from a continuous range"); s.Add("ToggleSwitch", Icons.Toggle, "An on/off switch with a sliding knob"); }), Section("Text", Icons.TextBox, s => { s.Add("AutoCompleteBox", Icons.TextInput, "Text input with completion suggestions"); s.Add("Label", Icons.Tag, "Captions with access keys for other controls"); s.Add("TextBox", Icons.TextInput, "Single- and multi-line text editing"); s.Add("TextBlock", Icons.TextInput, "Styled read-only text display"); }), Section("Collections & Data", Icons.Lists, s => { s.Add("Carousel", Icons.Slides, "Cycle through a collection of items"); s.Add("ListBox", Icons.List, "A selectable, virtualized list of items"); s.Add("PipsPager", Icons.HorizontalDots, "Dot-style pager for paginated content"); s.Add("RefreshContainer", Icons.Refresh, "Pull-to-refresh for scrollable content"); s.Add("TableView", Icons.Grid, "Tabular data with resizable, sortable columns"); s.Add("TreeView", Icons.Tree, "Hierarchical data with expandable nodes"); }), Section("Date & Time", Icons.Date, s => { s.Add("Calendar", Icons.Calendar, "A month calendar for selecting dates"); s.Add("CalendarDatePicker", Icons.Calendar, "A date picker with a drop-down calendar"); s.Add("Date/Time Picker", Icons.Clock, "Spinner-style date and time pickers"); }), Section("Menus & Flyouts", Icons.Menus, s => { s.Add("CommandBar", Icons.Terminal, "A toolbar of commands with an overflow menu"); s.Add("ContextFlyout", Icons.Menu, "Attach flyouts shown on right-click"); s.Add("ContextMenu", Icons.Menu, "Traditional right-click context menus"); s.Add("Flyouts", Icons.Flyout, "Lightweight popups anchored to controls"); s.Add("Menu", Icons.Menu, "Menu bars with nested menu items"); }), Section("Navigation & Pages", Icons.HamburgerUnread, s => { s.Add("CarouselPage", Icons.Slides, "Swipeable page-based navigation"); s.Add("ContentPage", Icons.Document, "A page that hosts a single content view"); s.Add("DrawerPage", Icons.Drawer, "A page with a sliding navigation drawer"); s.Add("NavigationPage", Icons.Navigation, "Stack-based page navigation"); s.Add("SplitView", Icons.Split, "A collapsible pane beside content"); s.Add("TabbedPage", Icons.Tab, "Tab-based page navigation"); s.Add("TabControl", Icons.Tab, "Switch between tabbed content views"); s.Add("TabStrip", Icons.Tab, "A standalone strip of selectable tabs"); }), Section("Layout", Icons.Layouts, s => { s.Add("Border", Icons.Border, "Decorate elements with borders and corner radii"); s.Add("Canvas", Icons.Canvas, "Position children at explicit coordinates"); s.Add("Container Queries", Icons.Container, "Styles that respond to container size"); s.Add("Expander", Icons.Expand, "A header that expands to reveal content"); s.Add("Flex Panel", Icons.Grid, "Flexible, CSS-style child layout"); s.Add("HeaderedContentControl", Icons.Header, "Content paired with a header"); s.Add("LayoutTransformControl", Icons.Transform, "Apply transforms that affect layout"); s.Add("RelativePanel", Icons.Layout, "Arrange children relative to each other"); s.Add("ScrollViewer", Icons.Scroll, "Scrollable viewport over large content"); s.Add("Viewbox", Icons.Viewbox, "Scale content to fit available space"); s.Add("WrapPanel", Icons.Layout, "Wrap children onto multiple lines"); }), Section("Media & Graphics", Icons.Media, s => { s.Add("Acrylic", Icons.Blur, "Translucent acrylic window materials"); s.Add("BitmapCache", Icons.Lightning, "Cache visuals as bitmaps for performance"); s.Add("Composition", Icons.Layers, "Composition-layer animations and effects"); s.Add("Custom Drawing", Icons.Brush, "Render custom geometry in code"); s.Add("Image", Icons.Image, "Display bitmaps with different stretch modes"); s.Add("OpenGL", Icons.Cube3D, "Embed custom OpenGL rendering"); s.Add("OpenGL Lease", Icons.Cube3D, "Low-level access to the OpenGL context"); s.Add("TransitioningContentControl", Icons.Transition, "Animate between content changes"); }), Section("Status & Feedback", Icons.Chat, s => { s.Add("AdornerLayer", Icons.Sparkle, "Overlay visuals on top of other controls"); s.Add("Data Validation", Icons.Shield, "Display validation errors from bindings"); s.Add("Dialogs", Icons.Dialog, "File pickers and modal dialog windows"); s.Add("Notifications", Icons.Bell, "Toast-style in-app notifications"); s.Add("ProgressBar", Icons.Progress, "Determinate and indeterminate progress"); s.Add("ToolTip", Icons.Tooltip, "Hover hints for any control"); }), Section("Interaction", Icons.KeyboardFloat, s => { s.Add("Accelerator", Icons.Keyboard, "Keyboard shortcuts that invoke commands"); s.Add("Clipboard", Icons.Clipboard, "Read from and write to the system clipboard"); s.Add("Cursor", Icons.Cursor, "Change the pointer cursor over elements"); s.Add("Drag+Drop", Icons.DragDrop, "Drag data within and between applications"); s.Add("Focus", Icons.Target, "Track and control keyboard focus"); s.Add("Gestures", Icons.Gesture, "Tap, scroll and pinch gesture recognition"); s.Add("Pointers", Icons.Cursor, "Raw pointer input and capture"); }), Section("Window & Platform", Icons.DesktopMobile, s => { s.Add("Native Embed", Icons.Puzzle, "Host native platform controls"); s.Add("Platform Information", Icons.Info, "Runtime platform and capability info"); s.Add("Platform Settings", Icons.Tune, "Platform-specific system settings"); s.Add("Screens", Icons.Monitor, "Enumerate displays and their bounds"); s.Add("Theme Variants", Icons.Theme, "Switch between light and dark variants"); s.Add("Window Customizations", Icons.Window, "Custom chrome, decorations and sizing"); }) ]; private static HomeSection Section(string title, string iconPath, Action builderCallback) { var iconGeometry = StreamGeometry.Parse(iconPath); var section = new HomeSection(title, iconGeometry); var builder = new HomeSectionBuilder(section); builderCallback(builder); section.Items = builder.ToArray(); return section; } private class HomeSectionBuilder(HomeSection section) : List { public void Add(string header, string iconPath, string description) where TPageType : Page, new() { var iconGeometry = StreamGeometry.Parse(iconPath); Add(new PageItem(header, () => new TPageType(), iconGeometry, description, section)); } public async virtual Task Navigate(INavigation navigation) { } } }