> For the complete documentation index, see [llms.txt](https://docs-siticoneframework.gitbook.io/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-siticoneframework.gitbook.io/home/net-framework-or-net-core-ui/progress-and-loading/siticone-smoothlprogress/dual-bar-behavior.md).

# Dual-Bar Behavior

Dual-Bar Behavior enables toggling between a single animated progress indicator and a dual-bar animation mode, creating a dynamic interweaving visual effect.

## Overview

The Dual-Bar Behavior feature provides developers with the flexibility to switch between a traditional single progress bar and a dual-bar animation mode. When enabled, the control displays two progress segments that can either share the same path or run on parallel tracks. This feature is primarily controlled by the properties `AllowAlternateMode` and `AllowSharedPath`, which allow for creative visual effects and enhanced user engagement in .NET WinForms applications.

***

### Key Points

<table><thead><tr><th width="220">Aspect</th><th>Details</th></tr></thead><tbody><tr><td>Feature Name</td><td>Dual-Bar Behavior</td></tr><tr><td>Primary Properties</td><td><code>AllowAlternateMode</code> (toggles dual-bar mode), <code>AllowSharedPath</code> (determines whether the two bars share the same path)</td></tr><tr><td>Animation Behavior</td><td>When <code>AllowAlternateMode</code> is true, the control animates two progress segments in coordinated motion with adjustable offsets.</td></tr><tr><td>Visual Customization</td><td>Developers can further customize the visual appearance (colors, stroke thickness, etc.) using other properties.</td></tr></tbody></table>

***

### Best Practices

<table><thead><tr><th width="257">Practice Aspect</th><th>Recommendation</th></tr></thead><tbody><tr><td>Initialization</td><td>Set the desired dual-bar mode properties (e.g., <code>AllowAlternateMode</code> and <code>AllowSharedPath</code>) in the control's constructor or form load event.</td></tr><tr><td>Consistent UI Styling</td><td>Ensure that the chosen colors and stroke thickness are consistent with your application’s design guidelines.</td></tr><tr><td>Dynamic Behavior Control</td><td>Use the provided methods <code>StartAnimation()</code>, <code>StopAnimation()</code>, and <code>ResetAnimation()</code> to manage the animation state as needed.</td></tr><tr><td>Testing Animation Modes</td><td>Test both single and dual-bar modes on various form sizes to ensure the visual effect remains consistent.</td></tr></tbody></table>

***

### Common Pitfalls

<table><thead><tr><th width="325">Pitfall</th><th>Explanation and Mitigation</th></tr></thead><tbody><tr><td>Overlapping UI Elements</td><td>Not accounting for the fixed control height (20 pixels) might result in clipping; always consider the fixed dimensions.</td></tr><tr><td>Inconsistent Animation States</td><td>Changing properties at runtime without properly resetting the animation may lead to unexpected behavior; use <code>ResetAnimation()</code>.</td></tr><tr><td>Ignoring Shared Path Considerations</td><td>Failing to set <code>AllowSharedPath</code> appropriately can lead to visual disarray; verify this setting to match the desired layout.</td></tr></tbody></table>

***

### Usage Scenarios

| Scenario                      | Description                                                                                                                     | Example Use Case                                                                                  |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| Enhanced Loading Screens      | Use dual-bar animations to indicate progress with a more dynamic and engaging visual cue compared to static progress bars.      | Applications requiring a modern loading indicator during data processing or startup.              |
| Data Processing Visualization | Visualize parallel progress in data-driven applications by using two synchronized progress bars that reflect different metrics. | A dashboard showing simultaneous progress of data import and processing tasks.                    |
| Creative UI Animations        | Implement a visually appealing progress indicator that deviates from the conventional single bar by enabling the dual-bar mode. | Multimedia or game applications where user engagement is enhanced through dynamic visual effects. |

***

### Code Examples and Integration

Below are sample code snippets to demonstrate how to integrate and configure the Dual-Bar Behavior feature in your .NET WinForms application.

#### Example 1: Enabling Dual-Bar Behavior with Shared Path

```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
using SiticoneNetFrameworkUI;

public class MainForm : Form
{
    private SiticoneSmoothLinearProgress progressControl;

    public MainForm()
    {
        InitializeComponent();
        SetupProgressControl();
    }

    private void InitializeComponent()
    {
        this.Text = "Dual-Bar Behavior Demo";
        this.Size = new Size(400, 150);
    }

    private void SetupProgressControl()
    {
        progressControl = new SiticoneSmoothLinearProgress
        {
            Location = new Point(20, 40),
            Size = new Size(350, 20),
            AllowAlternateMode = true,   // Enable dual-bar mode
            AllowSharedPath = true,        // Both bars share the same path
            PrimaryColor = Color.Blue,
            SecondaryColor = Color.Red,
            StrokeThickness = 8
        };

        this.Controls.Add(progressControl);
    }

    [STAThread]
    public static void Main()
    {
        Application.EnableVisualStyles();
        Application.Run(new MainForm());
    }
}
```

#### Example 2: Switching Between Single and Dual-Bar Modes at Runtime

```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
using SiticoneNetFrameworkUI;

public class RuntimeSwitchForm : Form
{
    private SiticoneSmoothLinearProgress progressControl;
    private Button toggleModeButton;

    public RuntimeSwitchForm()
    {
        InitializeComponent();
        SetupProgressControl();
    }

    private void InitializeComponent()
    {
        this.Text = "Runtime Dual-Bar Switch Demo";
        this.Size = new Size(450, 200);

        toggleModeButton = new Button
        {
            Text = "Toggle Dual-Bar Mode",
            Location = new Point(20, 80),
            Size = new Size(150, 30)
        };
        toggleModeButton.Click += ToggleModeButton_Click;

        this.Controls.Add(toggleModeButton);
    }

    private void SetupProgressControl()
    {
        progressControl = new SiticoneSmoothLinearProgress
        {
            Location = new Point(20, 30),
            Size = new Size(400, 20),
            AllowAlternateMode = false,  // Start with single bar mode
            PrimaryColor = Color.Green,
            SecondaryColor = Color.Orange,
            StrokeThickness = 8
        };

        this.Controls.Add(progressControl);
    }

    private void ToggleModeButton_Click(object sender, EventArgs e)
    {
        // Toggle the dual-bar mode and reset the animation
        progressControl.AllowAlternateMode = !progressControl.AllowAlternateMode;
        progressControl.ResetAnimation();
    }

    [STAThread]
    public static void Main()
    {
        Application.EnableVisualStyles();
        Application.Run(new RuntimeSwitchForm());
    }
}
```

***

### Review

<table><thead><tr><th width="234">Aspect</th><th>Review Comments</th></tr></thead><tbody><tr><td>Flexibility</td><td>The Dual-Bar Behavior feature is highly flexible, allowing dynamic switching between single and dual-bar animations.</td></tr><tr><td>Customization</td><td>Developers can easily adjust colors, stroke thickness, and shared path settings to achieve the desired visual effect.</td></tr><tr><td>Integration Ease</td><td>With intuitive properties and methods, integrating the feature into existing WinForms applications is straightforward.</td></tr><tr><td>Runtime Responsiveness</td><td>The ability to toggle the animation mode at runtime ensures that applications can adapt the visual presentation dynamically.</td></tr></tbody></table>

***

### Summary

<table><thead><tr><th width="205">Summary Aspect</th><th>Summary</th></tr></thead><tbody><tr><td>Feature Impact</td><td>Dual-Bar Behavior enhances the visual appeal of progress indicators by offering an alternative to traditional single-bar animations.</td></tr><tr><td>Implementation</td><td>Through properties like <code>AllowAlternateMode</code> and <code>AllowSharedPath</code>, developers can easily control and customize the animation mode.</td></tr><tr><td>Developer Benefits</td><td>The feature provides a modern, dynamic animation style that is easy to integrate, adjust, and manage within .NET WinForms applications.</td></tr></tbody></table>

***

### Additional Sections

#### Troubleshooting

<table><thead><tr><th width="305">Issue</th><th>Potential Cause and Resolution</th></tr></thead><tbody><tr><td>Animation Not Displaying</td><td>Ensure that the control’s size is sufficient (minimum width and fixed height of 20 pixels) and that <code>IsAnimating</code> is true.</td></tr><tr><td>Incorrect Bar Alignment</td><td>Verify that <code>AllowSharedPath</code> is set correctly; if false, the bars are drawn in offset positions which might not be desired.</td></tr><tr><td>Unexpected Animation Behavior</td><td>Use <code>ResetAnimation()</code> after changing properties at runtime to ensure all animation parameters are reinitialized properly.</td></tr></tbody></table>

#### Integration Checklist

<table><thead><tr><th width="248">Checklist Item</th><th>Status/Action Required</th></tr></thead><tbody><tr><td>Control Initialization</td><td>Ensure the control is instantiated and added to the form.</td></tr><tr><td>Property Configuration</td><td>Configure <code>AllowAlternateMode</code> and <code>AllowSharedPath</code> along with visual properties such as <code>PrimaryColor</code>, <code>SecondaryColor</code>, and <code>StrokeThickness</code>.</td></tr><tr><td>Animation Management</td><td>Confirm that animation is started using <code>StartAnimation()</code> and can be controlled via <code>IsAnimating</code>.</td></tr><tr><td>Runtime Testing</td><td>Test both single and dual-bar modes across different form sizes and scenarios.</td></tr></tbody></table>

***

This extensive documentation for the Dual-Bar Behavior feature should empower developers to seamlessly integrate, customize, and troubleshoot the animation control within their .NET WinForms applications. By following the best practices and usage scenarios outlined above, you can create engaging and visually dynamic progress indicators that enhance the user experience.
