KotBehamot.RadialSegmentControl 1.0.0

Suggested Alternatives

RadialSegmentControl

dotnet add package KotBehamot.RadialSegmentControl --version 1.0.0
                    
NuGet\Install-Package KotBehamot.RadialSegmentControl -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="KotBehamot.RadialSegmentControl" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="KotBehamot.RadialSegmentControl" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="KotBehamot.RadialSegmentControl" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add KotBehamot.RadialSegmentControl --version 1.0.0
                    
#r "nuget: KotBehamot.RadialSegmentControl, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package KotBehamot.RadialSegmentControl@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=KotBehamot.RadialSegmentControl&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=KotBehamot.RadialSegmentControl&version=1.0.0
                    
Install as a Cake Tool

RadialSegmentControl

<div align="center">

NuGet NuGet Downloads Build Status License .NET MAUI

</div>

<div align="center"> <img src="assets/icon.png" alt="RadialSegmentControl Icon" width="128" height="128" /> </div>


A high-quality, customizable radial/circular segment button control library for .NET MAUI applications. This library provides an interactive circular button interface with customizable segments, following SOLID principles and best practices for library development.

โœจ Features

  • ๐ŸŽฏ Radial Segment Layout: Display buttons in a circular/radial pattern
  • ๐ŸŽจ Customizable Appearance: Configure colors, text, and styling for each segment
  • ๐Ÿ“ฑ Touch Interaction: Full support for tap/click interactions
  • ๐Ÿ”Œ Extensible Design: Implement custom drawables through the IRadialSegmentDrawable interface
  • ๐Ÿ“ฆ MVVM Support: Bindable properties and command support
  • ๐ŸŽญ Event-Driven: Events and commands for segment selection

๐Ÿ“ฆ Installation

Install via NuGet Package Manager:

dotnet add package KotBehamot.RadialSegmentControl

Or via Package Manager Console:

Install-Package KotBehamot.RadialSegmentControl

๐Ÿš€ Quick Start

Basic Usage

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:controls="clr-namespace:RadialSegmentControl.Controls;assembly=RadialSegmentControl"
             x:Class="YourApp.MainPage">
    
    <controls:RadialSegmentControl x:Name="radialControl"
                                   WidthRequest="300"
                                   HeightRequest="300"
                                   CenterRadius="30"
                                   SegmentSelected="OnSegmentSelected" />
</ContentPage>

Code-Behind

using RadialSegmentControl.Models;

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
        
        // Add segments programmatically
        radialControl.Segments.Add(new RadialSegment
        {
            Text = "Option 1",
            BackgroundColor = Colors.Blue,
            TextColor = Colors.White,
            Value = "value1"
        });
        
        radialControl.Segments.Add(new RadialSegment
        {
            Text = "Option 2",
            BackgroundColor = Colors.Green,
            TextColor = Colors.White,
            Value = "value2"
        });
        
        radialControl.Segments.Add(new RadialSegment
        {
            Text = "Option 3",
            BackgroundColor = Colors.Red,
            TextColor = Colors.White,
            Value = "value3"
        });
    }
    
    private void OnSegmentSelected(object sender, SegmentSelectedEventArgs e)
    {
        DisplayAlert("Selected", $"You selected: {e.Segment.Text}", "OK");
    }
}

MVVM Usage

using System.Collections.ObjectModel;
using System.Windows.Input;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using RadialSegmentControl.Models;

public partial class MainViewModel : ObservableObject
{
    [ObservableProperty]
    private ObservableCollection<RadialSegment> segments;
    
    [ObservableProperty]
    private RadialSegment? selectedSegment;
    
    public ICommand SegmentSelectedCommand { get; }
    
    public MainViewModel()
    {
        Segments = new ObservableCollection<RadialSegment>
        {
            new RadialSegment { Text = "A", BackgroundColor = Colors.Blue, TextColor = Colors.White },
            new RadialSegment { Text = "B", BackgroundColor = Colors.Green, TextColor = Colors.White },
            new RadialSegment { Text = "C", BackgroundColor = Colors.Red, TextColor = Colors.White }
        };
        
        SegmentSelectedCommand = new RelayCommand<RadialSegment>(OnSegmentSelected);
    }
    
    private void OnSegmentSelected(RadialSegment? segment)
    {
        if (segment != null)
        {
            // Handle selection
        }
    }
}
<controls:RadialSegmentControl Segments="{Binding Segments}"
                               SelectedSegment="{Binding SelectedSegment}"
                               SegmentSelectedCommand="{Binding SegmentSelectedCommand}"
                               WidthRequest="300"
                               HeightRequest="300" />

๐Ÿ”ง Advanced Usage

Custom Drawable

Create a custom rendering implementation by implementing IRadialSegmentDrawable:

using RadialSegmentControl.Interfaces;
using RadialSegmentControl.Models;

public class CustomRadialDrawable : IRadialSegmentDrawable
{
    public void DrawSegment(ICanvas canvas, RadialSegment segment, 
                           float centerX, float centerY, float radius, bool isSelected)
    {
        // Custom drawing logic
    }
    
    public void DrawCenter(ICanvas canvas, float centerX, float centerY, float radius)
    {
        // Custom center circle drawing
    }
}

// Use custom drawable
var control = new RadialSegmentControl(new CustomRadialDrawable());

๐Ÿ“œ API Reference

RadialSegmentControl

Properties:

  • Segments (ObservableCollection<RadialSegment>): Collection of segments to display
  • SelectedSegment (RadialSegment?): Currently selected segment (bindable, two-way)
  • CenterRadius (float): Radius of the center circle (default: 30)
  • SegmentSelectedCommand (ICommand?): Command executed when a segment is selected

Events:

  • SegmentSelected: Raised when a segment is selected

RadialSegment

Properties:

  • Id (string): Unique identifier
  • Text (string): Display text
  • BackgroundColor (Color): Segment background color
  • TextColor (Color): Text color
  • Value (object?): Associated value/data
  • IsEnabled (bool): Whether segment is enabled
  • StartAngle (float): Start angle in degrees (auto-calculated)
  • SweepAngle (float): Segment size in degrees (auto-calculated)
  • Metadata (IDictionary<string, object>): Additional custom data

๐Ÿ›๏ธ Architecture & SOLID Principles

This library is built with clean architecture and SOLID principles:

Single Responsibility Principle (SRP)

  • RadialSegment: Pure data model - only stores segment information
  • RadialSegmentControl: Manages control lifecycle, events, and bindings
  • IRadialSegmentDrawable: Defines rendering contract
  • BasicRadialSegmentDrawable: Implements default rendering logic
  • RadialSegmentBuilder: Handles fluent object construction
  • RadialSegmentExtensions: Provides utility operations

Open/Closed Principle (OCP)

  • Extensible: Create custom rendering by implementing IRadialSegmentDrawable
  • Closed for modification: Core control logic doesn't change when adding new visual styles
  • Example: Swap rendering implementations without touching control code

Liskov Substitution Principle (LSP)

  • Properly inherits from GraphicsView
  • All IRadialSegmentDrawable implementations are interchangeable
  • Maintains expected behavior across substitutions

Interface Segregation Principle (ISP)

  • IRadialSegmentDrawable: Contains only drawing methods
  • No forced implementation of unused functionality
  • Clean, focused contracts

Dependency Inversion Principle (DIP)

  • RadialSegmentControl depends on IRadialSegmentDrawable abstraction
  • Concrete implementations injected via constructor
  • Easily testable through mocking

๐ŸŽจ Use Cases

Radial Menus

Perfect for creating circular context menus and radial selection interfaces.

Music Applications

Ideal for key signature selection, chord progression wheels, or music theory tools.

Create unique circular navigation interfaces for mobile apps.

Data Visualization

Interactive pie charts with selectable segments.

Game Interfaces

Circular skill trees, radial weapon selectors, or ability wheels.

๐Ÿ“Š Platform Support

Platform Supported Notes
๐Ÿค– Android โœ… Yes Tested on Android 7.0+
๐ŸŽ iOS โœ… Yes Tested on iOS 14.0+
๐ŸชŸ Windows โœ… Yes Windows 10 1809+
๐ŸŽ macOS โœ… Yes macOS 10.15+
๐Ÿ Mac Catalyst โœ… Yes macOS 10.15+

โšก Performance

  • Optimized rendering using ICanvas for hardware acceleration
  • Efficient hit-testing with mathematical calculations (no pixel iteration)
  • Minimal allocations - reuses objects where possible
  • Smooth animations - 60 FPS on modern devices

๐Ÿ”’ Requirements

  • .NET: 8.0 or later
  • MAUI: 8.0 or later
  • C#: 12.0 or later

๐Ÿ› Known Limitations

  • Segment count: Recommended 2-12 segments for optimal usability
  • Text length: Best with short labels (1-10 characters)
  • Center radius: Should be proportional to control size (10-30% of radius)

๐Ÿ“š Documentation

๐Ÿท๏ธ Versioning

This project adheres to Semantic Versioning:

  • MAJOR: Incompatible API changes
  • MINOR: Backwards-compatible functionality additions
  • PATCH: Backwards-compatible bug fixes

Current version: 1.0.0

๐Ÿ›ก๏ธ Security

For security concerns, please see our Security Policy.

๐Ÿ’ฌ Support

๐ŸŒŸ Star History

If you find this library useful, please consider giving it a โญ on GitHub!

๐Ÿค Contributing

Contributions are welcome! Please read our Contributing Guidelines before submitting PRs.

Ways to Contribute

  • ๐Ÿ› Report bugs
  • ๐Ÿ’ก Suggest features
  • ๐Ÿ“ Improve documentation
  • ๐Ÿ”ง Submit pull requests
  • โญ Star the repository
  • ๐Ÿ“ข Spread the word

๐Ÿ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Copyright 2025 KotBehamot

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

๐Ÿ™ Acknowledgments

๐Ÿ‘จโ€๐Ÿ’ป Authors

๐Ÿ“‚ Project Structure

RadialSegmentControl/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ RadialSegmentControl/        # Main library
โ”‚   โ”œโ”€โ”€ Controls/         # UI Controls
โ”‚       โ”œโ”€โ”€ Models/        # Data models
โ”‚       โ”œโ”€โ”€ Interfaces/            # Abstractions
โ”‚       โ”œโ”€โ”€ Drawing/           # Rendering implementations
โ”‚       โ”œโ”€โ”€ Builders/     # Builder patterns
โ”‚ โ”œโ”€โ”€ Adapters/         # Adapter patterns
โ”‚  โ”œโ”€โ”€ Extensions/  # Extension methods
โ”‚       โ””โ”€โ”€ Events/           # Event arguments
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ RadialSegmentControl.Tests/ # Unit tests
โ”œโ”€โ”€ samples/
โ”‚   โ””โ”€โ”€ RadialSegmentControl.Sample/ # Sample application
โ”œโ”€โ”€ docs/# Documentation
โ””โ”€โ”€ assets/# Package assets (icon, etc.)

<div align="center">

Made with โค๏ธ by KotBehamot

Report Bug ยท Request Feature ยท Documentation

</div>

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 266 10/28/2025 1.0.0 is deprecated because it is no longer maintained.