HeaderPane
Main
Hide
Share Link
Print

DemoSample Sample (VB.NET)

This sample shows standard controls, a slider and a range slider and buttons that open the message box, a task dialog and the color dialog, with options that change dark mode, high contrast and the look of the sliders. The SftStyle component on the form shows every form of the sample, the dialogs included, in the selected mode; the sliders follow it through their own SftSlider.DarkMode and SftSlider.HighContrastMode properties.

The source code is located at C:\Program Files (x86)\Softelvdm\SftStyle NET 3.0\Samples\VB\DemoSample\Form1.vb.

Imports Softelvdm.SftStyleNET
Imports Softelvdm.SftStyleNET.Controls

Public Class Form1

    Public Sub New()
        InitializeComponent()

        ComboCity.Items.AddRange(New Object() {"Orlando", "Ocala", "Oviedo", "Tampa", "Miami"})
        ComboCity.SelectedIndex = 0
        RadioEmail.Checked = True
        ListOrders.Items.Add(New ListViewItem(New String() {"1042", "Avery Johnson", "1,234.50"}))
        ListOrders.Items.Add(New ListViewItem(New String() {"1043", "Blake Rivera", "86.00"}))
        ListOrders.Items.Add(New ListViewItem(New String() {"1044", "Casey Morgan", "412.75"}))
        ListOrders.Items.Add(New ListViewItem(New String() {"1045", "Drew Patel", "2,050.00"}))

        FillCombo(ComboDarkMode, GetType(DarkModeEnum), SftStyle1.DarkMode)
        FillCombo(ComboHighContrast, GetType(HighContrastModeEnum), SftStyle1.HighContrastMode)
        FillCombo(ComboLook, GetType(SliderLookEnum), SliderVolume.Look)
        ShowState()
        ShowSliders()
    End Sub

    Private Sub FillCombo(ByVal combo As ComboBox, ByVal enumType As Type, ByVal current As Object)
        For Each value As Object In [Enum].GetValues(enumType)
            combo.Items.Add(value)
        Next
        combo.SelectedItem = current
    End Sub

    ' The SftStyle component shows every form of the application in the selected mode. The sliders have a DarkMode and
    ' HighContrastMode of their own, which follow the component's here.
    Private Sub ComboDarkMode_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ComboDarkMode.SelectedIndexChanged
        Dim mode As DarkModeEnum = CType(ComboDarkMode.SelectedItem, DarkModeEnum)
        SftStyle1.DarkMode = mode
        SliderVolume.DarkMode = mode
        SliderPrice.DarkMode = mode
    End Sub

    Private Sub ComboHighContrast_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ComboHighContrast.SelectedIndexChanged
        Dim mode As HighContrastModeEnum = CType(ComboHighContrast.SelectedItem, HighContrastModeEnum)
        SftStyle1.HighContrastMode = mode
        SliderVolume.HighContrastMode = mode
        SliderPrice.HighContrastMode = mode
    End Sub

    Private Sub ComboLook_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ComboLook.SelectedIndexChanged
        SliderVolume.Look = CType(ComboLook.SelectedItem, SliderLookEnum)
        SliderPrice.Look = SliderVolume.Look
    End Sub

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

    Private Sub SftStyle1_HighContrastChanged(ByVal sender As Object, ByVal e As EventArgs) Handles SftStyle1.HighContrastChanged
        ShowState()
    End Sub

    ' With Auto, the component follows the Windows settings, also when they change while the form is open.
    Private Sub ShowState()
        LabelState.Text = "Dark mode is " + If(SftStyle1.DarkModeActive, "on", "off") + ", high contrast is " + If(SftStyle1.HighContrastActive, "on", "off") + "."
    End Sub

    Private Sub SliderVolume_ValueChanged(ByVal sender As Object, ByVal e As EventArgs) Handles SliderVolume.ValueChanged
        ShowSliders()
    End Sub

    Private Sub SliderPrice_RangeChanged(ByVal sender As Object, ByVal e As EventArgs) Handles SliderPrice.RangeChanged
        ShowSliders()
    End Sub

    Private Sub ShowSliders()
        LabelSliders.Text = "Volume " + SliderVolume.Value.ToString() + ", price range " + SliderPrice.LowerValue.ToString() + " to " + SliderPrice.UpperValue.ToString()
    End Sub

    ' SftMessageBox takes the arguments of MessageBox.Show and returns the same results.
    Private Sub ButtonMessageBox_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButtonMessageBox.Click
        Dim result As DialogResult = SftMessageBox.Show(Me, "Do you want to save the changes to Order 1042 before closing?", "Orders",
            MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
        LabelResult.Text = "Message box: " + result.ToString()
    End Sub

    Private Sub ButtonTaskDialog_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButtonTaskDialog.Click
        Dim page As New SftTaskDialogPage()
        page.Caption = "Unsaved orders"
        page.Heading = "What do you want to do with the 3 unsaved orders?"
        page.Icon = SftTaskDialogIcon.Warning
        page.Verification = New SftTaskDialogVerificationCheckBox("&Do not ask again")
        page.Expander = New SftTaskDialogExpander("Order 1042, Order 1044 and Order 1045 have changes that are not saved.")
        page.Footnote = New SftTaskDialogFootnote("Drafts are kept for 30 days.")
        page.Buttons.Add(New SftTaskDialogCommandLinkButton("&Save the orders", "They are saved as drafts and can be completed later."))
        page.Buttons.Add(New SftTaskDialogCommandLinkButton("D&iscard the orders", "The changes are lost."))
        page.Buttons.Add(SftTaskDialogButton.Cancel)
        Dim clicked As SftTaskDialogButton = SftTaskDialog.ShowDialog(Me, page)
        Dim text As String = "closed"
        If clicked IsNot Nothing Then
            text = clicked.Text.Replace("&", "")
        End If
        If page.Verification.Checked Then
            text += ", do not ask again"
        End If
        LabelResult.Text = "Task dialog: " + text
    End Sub

    Private Sub ButtonColorDialog_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ButtonColorDialog.Click
        SftColorDialog1.Color = PanelColor.BackColor
        If SftColorDialog1.ShowDialog(Me) = DialogResult.OK Then
            PanelColor.BackColor = SftColorDialog1.Color
            LabelResult.Text = "Color dialog: " + SftColorDialog1.Color.Name
        End If
    End Sub

End Class