HeaderPane
Main
Hide
Share Link
Print

Using SftStyle/NET with .NET Framework

The components and the slider control are automatically added to your Toolbox in Visual Studio and are automatically registered in the GAC (Global Assembly Cache) during installation of SftStyle/NET, when the .NET Framework SDK tools are installed. Please see Distributing SftStyle/NET for information on how to distribute them with your application.

.NET 10 projects use SftStyle/NET through its NuGet package, see Using SftStyle/NET with .NET 10.

Adding SftStyle/NET To A Form

Add one SftStyle component to the main form of the application by dragging it from the Toolbox to the form. The component appears in the component tray below the form. It styles every form of the application, not only the form it is on (see The SftStyle Component).

If the components are missing from the Toolbox, please see "Manually Adding .NET Components To The Toolbox".

Adding SftStyle to a form

Once the component has been added to the form, its smart tag sets the dark mode and high contrast modes and offers the product information, product updates and product support page on the web. The SftColorDialog component and the SftSlider control are added the same way; the slider's smart tag sets its orientation, range mode and look.

SftStyle Tasks

In this example, the forms follow the Windows light/dark setting and the Windows contrast theme, the form's caption shows the mode and a button asks a question with the SftStyle/NET message box.

VB

Imports Softelvdm.SftStyleNET
Imports Softelvdm.SftStyleNET.Controls

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        SftStyle1.DarkMode = DarkModeEnum.Auto
        SftStyle1.HighContrastMode = HighContrastModeEnum.Auto
        ShowMode()
    End Sub

    Private Sub SftStyle1_DarkModeChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SftStyle1.DarkModeChanged
        ShowMode()
    End Sub

    Private Sub ShowMode()
        Text = If(SftStyle1.DarkModeActive, "Orders (dark mode)", "Orders")
    End Sub

    Private Sub ButtonDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonDelete.Click
        If SftMessageBox.Show(Me, "Delete the selected order?", "Orders", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
            ' delete the order
        End If
    End Sub
End Class

C#

using System;
using System.Windows.Forms;

using Softelvdm.SftStyleNET;
using Softelvdm.SftStyleNET.Controls;

namespace WindowsApplication1 {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e) {
            sftStyle1.DarkMode = DarkModeEnum.Auto;
            sftStyle1.HighContrastMode = HighContrastModeEnum.Auto;
            sftStyle1.DarkModeChanged += (s, a) => ShowMode();
            ShowMode();
        }

        private void ShowMode() {
            Text = sftStyle1.DarkModeActive ? "Orders (dark mode)" : "Orders";
        }

        private void buttonDelete_Click(object sender, EventArgs e) {
            if (SftMessageBox.Show(this, "Delete the selected order?", "Orders", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) {
                // delete the order
            }
        }
    }
}

SftStyle/NET has many more properties, methods and events. Please take a moment to familiarize yourself with the classes and objects offered by SftStyle/NET. Also make sure to run the demo which is included with this product and take a look at the included samples.