Overview

BeepDualPercentageControl provides a sophisticated split-layout control for displaying and comparing two percentage values side by side. It features rich visual elements including icons, labels, progress indicators, and customizable styling perfect for analytics dashboards and performance metrics.

Built on the BeepControl foundation, BeepDualPercentageControl features dual-section layout, visual dividers, icon integration, progress visualization, trend indicators, and comprehensive theming support. Perfect for comparison dashboards, analytics panels, performance metrics, and any application requiring side-by-side percentage comparisons.

Key Features

๐Ÿ“Š Split Layout Design

Dual-section layout with clear visual separation for comparing two metrics

๐ŸŽฏ Rich Visual Elements

Icons, labels, progress bars, and trend indicators for comprehensive data display

๐Ÿ“ˆ Comparison Analytics

Built-in comparison logic with visual indicators for better/worse performance

๐ŸŽจ Custom Styling

Flexible styling options for sections, dividers, and visual elements

๐Ÿ“ฑ Responsive Layout

Adaptive sizing that maintains readability across different container sizes

๐Ÿ”„ Real-time Updates

Support for live data updates with smooth transitions and animations

Visual Preview

Dual Percentage Control Variations

Sales Performance Comparison

๐Ÿ“ˆ
85%
Target Achievement
+12%
๐Ÿ“Š
73%
Target Achievement
Base

System Performance Metrics

๐Ÿ–ฅ๏ธ
45%
๐Ÿ’พ
82%

Project Progress Comparison

๐Ÿš€
92%
Complete
On Track
๐Ÿงช
67%
Complete
In Progress

Financial Performance

๐Ÿ’ฐ
128%
vs. Last Quarter
โ†— +28%
๐Ÿ“‰
89%
vs. Target
โ†˜ -11%

Dual percentage controls showing various metrics, styles, and comparison scenarios

Basic Usage

Simple Dual Percentage Display

// Create and configure a BeepDualPercentageControl
var dualPercentage = new BeepDualPercentageControl();
dualPercentage.Size = new Size(300, 100);

// Configure left section
dualPercentage.LeftIcon = Properties.Resources.SalesIcon;
dualPercentage.LeftLabel = "This Month";
dualPercentage.LeftPercentage = 85;
dualPercentage.LeftSubLabel = "Target Achievement";

// Configure right section
dualPercentage.RightIcon = Properties.Resources.TargetIcon;
dualPercentage.RightLabel = "Last Month";
dualPercentage.RightPercentage = 73;
dualPercentage.RightSubLabel = "Target Achievement";

// Set comparison context
dualPercentage.ShowTrendIndicator = true;
dualPercentage.ShowProgressBars = false;

// Handle value clicks
dualPercentage.LeftSectionClicked += (s, e) =>
{
    ShowDetailedReport("This Month Sales");
};

dualPercentage.RightSectionClicked += (s, e) =>
{
    ShowDetailedReport("Last Month Sales");
};

// Add to dashboard
dashboardPanel.Controls.Add(dualPercentage);

System Performance Monitor

// Create performance monitoring control
var performanceMonitor = new BeepDualPercentageControl
{
    Size = new Size(350, 120),
    ShowProgressBars = true,
    ShowTrendIndicator = false,
    AutoRefresh = true,
    RefreshInterval = 5000 // 5 seconds
};

// Configure CPU monitoring
performanceMonitor.LeftIcon = Properties.Resources.CpuIcon;
performanceMonitor.LeftLabel = "CPU Usage";
performanceMonitor.LeftSubLabel = "Current Load";

// Configure memory monitoring  
performanceMonitor.RightIcon = Properties.Resources.MemoryIcon;
performanceMonitor.RightLabel = "Memory Usage";
performanceMonitor.RightSubLabel = "Available RAM";

// Set up real-time updates
var updateTimer = new Timer { Interval = 1000 };
updateTimer.Tick += (s, e) =>
{
    // Get current system metrics
    var cpuUsage = GetCpuUsage();
    var memoryUsage = GetMemoryUsage();
    
    performanceMonitor.LeftPercentage = cpuUsage;
    performanceMonitor.RightPercentage = memoryUsage;
    
    // Update styling based on thresholds
    performanceMonitor.LeftSectionStyle = cpuUsage > 80 ? SectionStyle.Warning : SectionStyle.Normal;
    performanceMonitor.RightSectionStyle = memoryUsage > 85 ? SectionStyle.Critical : SectionStyle.Normal;
};
updateTimer.Start();

Properties

Left Section Properties

Property Type Default Description
LeftIcon Image null Icon for the left section
LeftLabel string "" Primary label for the left section
LeftPercentage int 0 Percentage value for the left section (0-100)
LeftSubLabel string "" Secondary label for the left section

Right Section Properties

Property Type Default Description
RightIcon Image null Icon for the right section
RightLabel string "" Primary label for the right section
RightPercentage int 0 Percentage value for the right section (0-100)
RightSubLabel string "" Secondary label for the right section

Display Properties

Property Type Default Description
ShowProgressBars bool false Show progress bars for percentage values
ShowTrendIndicator bool true Show trend indicators for comparison
DividerStyle DividerStyle Line Style of divider between sections
ComparisonMode ComparisonMode Relative How to compare left and right values

Events

Event Event Args Description
LeftSectionClicked PercentageEventArgs Fired when left section is clicked
RightSectionClicked PercentageEventArgs Fired when right section is clicked
PercentageChanged PercentageChangedEventArgs Fired when either percentage value changes
ComparisonUpdated ComparisonEventArgs Fired when comparison results change

Examples

Analytics Dashboard with Multiple Metrics

public partial class AnalyticsDashboard : UserControl
{
    private TableLayoutPanel metricsPanel;
    private List<BeepDualPercentageControl> metricControls;
    private IAnalyticsService analyticsService;

    public AnalyticsDashboard(IAnalyticsService analyticsService)
    {
        this.analyticsService = analyticsService;
        InitializeComponents();
        LoadMetrics();
    }

    private void InitializeComponents()
    {
        metricsPanel = new TableLayoutPanel
        {
            Dock = DockStyle.Fill,
            ColumnCount = 2,
            RowCount = 3,
            Padding = new Padding(10)
        };

        // Configure equal column widths
        metricsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
        metricsPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));

        metricControls = new List<BeepDualPercentageControl>();
        this.Controls.Add(metricsPanel);
    }

    private async void LoadMetrics()
    {
        try
        {
            var metrics = await analyticsService.GetDashboardMetricsAsync();
            CreateMetricControls(metrics);
        }
        catch (Exception ex)
        {
            ShowError($"Failed to load metrics: {ex.Message}");
        }
    }

    private void CreateMetricControls(DashboardMetrics metrics)
    {
        // Sales Performance
        var salesMetric = CreateMetricControl(
            "Sales Performance",
            "๐Ÿ“ˆ", "This Quarter", metrics.CurrentQuarterSales, "Sales Target",
            "๐Ÿ“Š", "Last Quarter", metrics.LastQuarterSales, "Sales Target",
            showTrend: true,
            showProgress: false
        );

        // Customer Satisfaction
        var satisfactionMetric = CreateMetricControl(
            "Customer Satisfaction",
            "๐Ÿ˜Š", "Current Score", metrics.CurrentSatisfaction, "Rating",
            "๐Ÿ“ˆ", "Trend", metrics.SatisfactionTrend, "Improvement",
            showTrend: true,
            showProgress: true
        );

        // System Performance
        var performanceMetric = CreateMetricControl(
            "System Performance",
            "๐Ÿ–ฅ๏ธ", "Response Time", metrics.AverageResponseTime, "Target: <2s",
            "โšก", "Uptime", metrics.SystemUptime, "Monthly Target",
            showTrend: false,
            showProgress: true
        );

        // Financial Metrics
        var financialMetric = CreateMetricControl(
            "Financial Health",
            "๐Ÿ’ฐ", "Revenue Growth", metrics.RevenueGrowth, "vs. Target",
            "๐Ÿ’ธ", "Cost Efficiency", metrics.CostEfficiency, "vs. Budget",
            showTrend: true,
            showProgress: false
        );

        // Project Progress
        var projectMetric = CreateMetricControl(
            "Project Status",
            "๐Ÿš€", "Development", metrics.DevelopmentProgress, "Complete",
            "๐Ÿงช", "Testing", metrics.TestingProgress, "Complete",
            showTrend: false,
            showProgress: true
        );

        // Marketing ROI
        var marketingMetric = CreateMetricControl(
            "Marketing ROI",
            "๐Ÿ“ข", "Campaign ROI", metrics.CampaignROI, "vs. Target",
            "๐ŸŽฏ", "Lead Conversion", metrics.LeadConversion, "Rate",
            showTrend: true,
            showProgress: false
        );

        // Add controls to layout
        var controls = new[] 
        { 
            salesMetric, satisfactionMetric, performanceMetric, 
            financialMetric, projectMetric, marketingMetric 
        };

        for (int i = 0; i < controls.Length; i++)
        {
            var row = i / 2;
            var col = i % 2;
            metricsPanel.Controls.Add(controls[i], col, row);
        }
    }

    private BeepDualPercentageControl CreateMetricControl(
        string title,
        string leftIcon, string leftLabel, int leftValue, string leftSubLabel,
        string rightIcon, string rightLabel, int rightValue, string rightSubLabel,
        bool showTrend, bool showProgress)
    {
        var control = new BeepDualPercentageControl
        {
            Size = new Size(280, 120),
            Margin = new Padding(5),
            ShowTrendIndicator = showTrend,
            ShowProgressBars = showProgress,
            Title = title
        };

        // Configure left section
        control.LeftIcon = GetIconImage(leftIcon);
        control.LeftLabel = leftLabel;
        control.LeftPercentage = leftValue;
        control.LeftSubLabel = leftSubLabel;

        // Configure right section
        control.RightIcon = GetIconImage(rightIcon);
        control.RightLabel = rightLabel;
        control.RightPercentage = rightValue;
        control.RightSubLabel = rightSubLabel;

        // Apply conditional styling
        ApplyMetricStyling(control, leftValue, rightValue);

        // Handle interactions
        control.LeftSectionClicked += (s, e) =>
        {
            ShowDetailedAnalytics(title, "left", leftLabel);
        };

        control.RightSectionClicked += (s, e) =>
        {
            ShowDetailedAnalytics(title, "right", rightLabel);
        };

        metricControls.Add(control);
        return control;
    }

    private void ApplyMetricStyling(BeepDualPercentageControl control, int leftValue, int rightValue)
    {
        // Apply styling based on performance thresholds
        if (leftValue >= 90)
            control.LeftSectionStyle = SectionStyle.Excellent;
        else if (leftValue >= 75)
            control.LeftSectionStyle = SectionStyle.Good;
        else if (leftValue >= 50)
            control.LeftSectionStyle = SectionStyle.Warning;
        else
            control.LeftSectionStyle = SectionStyle.Critical;

        // Similar logic for right section
        if (rightValue >= 90)
            control.RightSectionStyle = SectionStyle.Excellent;
        else if (rightValue >= 75)
            control.RightSectionStyle = SectionStyle.Good;
        else if (rightValue >= 50)
            control.RightSectionStyle = SectionStyle.Warning;
        else
            control.RightSectionStyle = SectionStyle.Critical;
    }

    private Image GetIconImage(string iconText)
    {
        // Convert emoji or text to image (implementation specific)
        return CreateIconFromText(iconText);
    }

    private void ShowDetailedAnalytics(string category, string section, string metric)
    {
        var detailForm = new DetailedAnalyticsForm(category, section, metric);
        detailForm.Show();
    }

    private void ShowError(string message)
    {
        MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }

    // Helper methods
    private Image CreateIconFromText(string text) { return null; /* Implementation */ }
}

Theming

BeepDualPercentageControl provides comprehensive theming support with specialized styling for comparison scenarios:

Theme Application

var dualPercentage = new BeepDualPercentageControl
{
    Theme = "AnalyticsDark",
    UseThemeColors = true
};

// Theme automatically applies:
// - SectionBackColors: Background colors for left and right sections
// - DividerColor: Color of the section divider
// - TextColors: Label and percentage text colors
// - ProgressColors: Progress bar styling
// - TrendColors: Trend indicator colors
// - HighlightColors: Hover and selection states

Comparison-Specific Theming

  • Performance-based colors - Automatic color coding based on performance thresholds
  • Trend visualization - Theme-coordinated trend indicators and arrows
  • Section differentiation - Subtle styling differences between comparison sections
  • Progress integration - Consistent progress bar styling with theme colors

Best Practices

๐ŸŽฏ User Experience

  • Clear labeling: Use descriptive labels that make the comparison context obvious
  • Meaningful icons: Choose icons that immediately convey the metric type
  • Consistent scaling: Ensure both sides use the same percentage scale for fair comparison
  • Performance indicators: Use color coding to quickly communicate performance levels

๐Ÿ“Š Data Presentation

  • Appropriate comparisons: Only compare related metrics that make logical sense together
  • Time context: Clearly indicate the time periods being compared
  • Threshold awareness: Consider what constitutes good/bad performance for each metric
  • Trend information: Include trend indicators when historical context is important

๐Ÿ”ง Implementation

  • Real-time updates: Implement smooth value transitions for live data
  • Error handling: Gracefully handle missing or invalid data
  • Performance optimization: Use efficient update patterns for high-frequency data
  • Responsive design: Ensure controls adapt well to different container sizes
๐Ÿ’ก Design Tip

Use progress bars for metrics where the maximum value is meaningful (like resource utilization), and simple percentages for ratio comparisons.

โœ… Best Practice

Implement click handlers for both sections to provide drill-down access to detailed analytics and reports.

โš ๏ธ Data Warning

Always validate that percentage comparisons are meaningful - avoid comparing unrelated metrics just because they're both percentages.