Pin Functionality

This feature enables tabs to be pinned, anchoring them at the start of the tab list for quick access and improved organization.

Overview

The Pin Functionality feature of the SiticoneTabControl allows developers to mark certain tabs as "pinned." Pinned tabs are automatically reordered to remain at the beginning of the tab collection, ensuring that important or frequently used tabs remain easily accessible. This feature includes properties to enable or disable pinning, customize the visual appearance of the pin icon (including color, size, padding, and outline thickness), and manage pin hover effects.


Properties Overview

Property Name
Description
Default Value
Data Type

AllowPinning

Enables or disables the ability to pin tabs. When disabled, no tabs can be pinned.

false

bool

PinnedIconColor

Sets the color of the pin icon when a tab is in the pinned state.

Material Blue (e.g., #1e88e5)

Color

UnpinnedIconColor

Defines the color of the pin icon when the tab is not pinned.

Gray

Color

PinThickness

Adjusts the line thickness of the pin icon’s outline, affecting its visual weight.

2f

float

PinIconSize

Sets the pixel dimensions of the pin icon, balancing visibility with tab space.

22

int

PinIconPadding

Specifies the spacing around the pin icon to ensure proper separation from other tab elements.

6

int

PinIconHoverColor

Determines the color of the pin icon when the mouse hovers over it, providing immediate visual feedback.

DarkGray

Color

Pinned Collection

A public collection accessed via the Pinned property that enables getting or setting the pinned state of individual tabs.

N/A

PinnedCollection


Key Points

Aspect
Details

Enhanced Organization

Pinned tabs are automatically repositioned at the start of the tab list, ensuring that important tabs remain accessible.

Visual Differentiation

Customizable icon colors and hover effects clearly distinguish between pinned and unpinned tabs.

Toggle Capability

Developers can enable or disable pinning via the AllowPinning property, making the feature adaptable to different UI needs.


Best Practices

Practice
Explanation
Code Example

Enable Pinning When Needed

Set AllowPinning to true only if your application's tab organization benefits from a pinned feature.

tabControl.AllowPinning = true;

Use Consistent Visual Cues

Choose pin icon colors that match your overall theme; ensure that the pinned icon color contrasts with the unpinned state.

tabControl.PinnedIconColor = Color.FromArgb(30, 144, 255);tabControl.UnpinnedIconColor = Color.Gray;

Maintain Appropriate Sizing and Padding

Adjust PinIconSize and PinIconPadding to ensure that the icon is visible without overcrowding the tab header.

tabControl.PinIconSize = 24;tabControl.PinIconPadding = 8;


Common Pitfalls

Pitfall
Explanation
How to Avoid

Enabling Pinning Unnecessarily

Enabling pinning when not required may lead to confusion in the user interface if no tabs need to be anchored.

Only set AllowPinning to true when the application design calls for it.

Overcrowding the Tab Header

A too-large pin icon or insufficient padding can make the tab header look cluttered.

Adjust PinIconSize and PinIconPadding to maintain a clean layout.

Poor Color Contrast

Choosing pin icon colors that do not contrast well with the background may reduce the effectiveness of visual cues.

Select colors for PinnedIconColor and PinIconHoverColor that stand out against the tab background.


Usage Scenarios

Scenario
Description
Sample Code Snippet

Prioritizing Frequently Used Tabs

In applications where certain tabs (e.g., settings, dashboard) need to remain accessible, developers can mark these as pinned.

csharp<br>// Enable pinning<br>tabControl.AllowPinning = true;<br><br>// Mark the first tab as pinned<br>TabPage settingsTab = new TabPage("Settings");<br>tabControl.TabPages.Add(settingsTab);<br>tabControl.Pinned[settingsTab] = true;<br>

Visual Differentiation Between Pinned and Unpinned Tabs

Customize the pin icon's appearance so users can easily identify which tabs are pinned versus unpinned.

csharp<br>tabControl.PinnedIconColor = Color.Blue;<br>tabControl.UnpinnedIconColor = Color.Gray;<br>tabControl.PinIconHoverColor = Color.DarkGray;<br>


Detailed Code Examples

Example 1: Basic Pinning Setup

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

public class PinningDemoForm : Form
{
    private SiticoneTabControl tabControl;

    public PinningDemoForm()
    {
        InitializeComponents();
    }

    private void InitializeComponents()
    {
        // Initialize the SiticoneTabControl
        tabControl = new SiticoneTabControl
        {
            Location = new Point(20, 20),
            Size = new Size(600, 300),
            AllowPinning = true, // Enable pinning functionality
            PinIconSize = 22,
            PinIconPadding = 6,
            PinThickness = 2f,
            PinnedIconColor = Color.FromArgb(30, 144, 255), // Dodger Blue for pinned tabs
            UnpinnedIconColor = Color.Gray,
            PinIconHoverColor = Color.DarkGray
        };

        // Add several tabs
        for (int i = 0; i < 5; i++)
        {
            TabPage page = new TabPage($"Tab {i + 1}");
            tabControl.TabPages.Add(page);
        }

        // Mark the first tab as pinned using the Pinned collection
        tabControl.Pinned[tabControl.TabPages[0]] = true;

        // Add the control to the form
        this.Controls.Add(tabControl);
        this.Text = "Pin Functionality Demo";
        this.StartPosition = FormStartPosition.CenterScreen;
    }
    
    [STAThread]
    public static void Main()
    {
        Application.EnableVisualStyles();
        Application.Run(new PinningDemoForm());
    }
}

Example 2: Dynamic Pin Toggle with Interactive Feedback

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

public class DynamicPinToggleForm : Form
{
    private SiticoneTabControl tabControl;
    private Button togglePinButton;
    private bool isPinned = false;

    public DynamicPinToggleForm()
    {
        InitializeComponents();
    }

    private void InitializeComponents()
    {
        // Initialize the SiticoneTabControl
        tabControl = new SiticoneTabControl
        {
            Dock = DockStyle.Top,
            Height = 250,
            AllowPinning = true,
            PinIconSize = 22,
            PinIconPadding = 6,
            PinThickness = 2f,
            PinnedIconColor = Color.Blue,
            UnpinnedIconColor = Color.Gray,
            PinIconHoverColor = Color.DarkGray
        };

        // Add a few tabs
        for (int i = 0; i < 3; i++)
        {
            TabPage page = new TabPage($"Page {i + 1}");
            tabControl.TabPages.Add(page);
        }

        // Create a button to toggle the pin state of the second tab
        togglePinButton = new Button
        {
            Text = "Toggle Pin on Page 2",
            Dock = DockStyle.Bottom,
            Height = 40
        };
        togglePinButton.Click += TogglePinButton_Click;

        this.Controls.Add(tabControl);
        this.Controls.Add(togglePinButton);
        this.Text = "Dynamic Pin Toggle Demo";
        this.StartPosition = FormStartPosition.CenterScreen;
    }

    private void TogglePinButton_Click(object sender, EventArgs e)
    {
        // Toggle the pinned state of the second tab
        TabPage page = tabControl.TabPages[1];
        isPinned = !isPinned;
        tabControl.Pinned[page] = isPinned;
        tabControl.Invalidate(); // Refresh the control to display the updated state
    }

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

Review

Aspect
Review Comments

Enhanced Accessibility

Pinned tabs provide a clear mechanism for prioritizing frequently accessed tabs, improving overall user navigation.

Visual Customization

Customizable pin icon properties (colors, size, padding, thickness) ensure that pinned tabs are visually distinct and consistent with the UI.

Flexibility and Adaptability

The ability to enable/disable pinning dynamically allows developers to tailor the behavior to the specific needs of the application.


Summary

The Pin Functionality feature in the SiticoneTabControl allows developers to pin important tabs so that they remain at the beginning of the tab list. By setting AllowPinning to true and utilizing properties such as PinnedIconColor, UnpinnedIconColor, PinThickness, PinIconSize, PinIconPadding, and PinIconHoverColor, the appearance and behavior of the pin icon can be finely tuned. This feature improves navigation by ensuring that key tabs remain easily accessible, and it supports dynamic changes at runtime for interactive applications.


Additional Sections

Integration Checklist

Step
Action Required

Instantiate the Control

Create an instance of SiticoneTabControl and add it to your form.

Enable Pinning

Set AllowPinning to true if your design requires pinned tabs.

Configure Pin Properties

Adjust properties such as PinnedIconColor, UnpinnedIconColor, PinThickness, PinIconSize, and PinIconPadding.

Mark Tabs as Pinned

Use the Pinned collection to set the pinned state for individual TabPages.

Test and Validate

Verify that pinned tabs are repositioned correctly and that the visual feedback (hover effects) is as desired.

Frequently Asked Questions

Question
Answer

How do I enable pinning for tabs?

Set the AllowPinning property to true and then mark individual tabs as pinned using the Pinned collection.

Can I change the pin icon properties at runtime?

Yes, you can modify properties such as PinnedIconColor and PinIconSize at runtime and call Invalidate() to refresh the control.

What happens to the order of tabs when one is pinned?

Pinned tabs are automatically reordered to appear at the beginning of the tab list.


This comprehensive documentation for the Pin Functionality feature, based solely on the provided code, offers a detailed guide to help developers integrate and customize the pinning behavior in their WinForms applications using the SiticoneTabControl.

Last updated