Buttons Example for Blazor

Nevron NOV UserInterface for Blazor ships with hundreds of examples with full source code, as part of the Nevron Open Vision Suite. All Blazor UserInterface examples are also available as a stand-alone Visual Studio solution in C#, which you can download from the links below.

Buttons Example for Blazor Description

This example demonstrates the different types of buttons supported by NOV.


Buttons Example

C# Buttons Example Code for Nevron UserInterface for Blazor
Language: C#

using Nevron.Nov;
using Nevron.Nov.Dom;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.UI;
using Nevron.Nov.Windows.Forms;
using System.Windows.Forms;

namespace NovWinFormsProject
{
	public partial class Form1 : Form
	{
		#region Constructors

		public Form1()
		{
			InitializeComponent();

			// Set form title
			Text = "NOV WinForms - NButtonsExample";

			// Create the NOV example and its controls
			NWidget exampleContent = CreateExampleContent();
			NWidget exampleControls = CreateExampleControls();
			if (exampleControls != null)
			{
				exampleControls.PreferredWidth = 300;
			}

			// Place the example and its controls in a pair box
			NPairBox pairBox = new NPairBox(exampleContent, exampleControls);
			pairBox.FillMode = ENStackFillMode.First;
			pairBox.FitMode = ENStackFitMode.First;
			pairBox.Margins = new NMargins(NDesign.HorizontalSpacing, NDesign.VerticalSpacing);

			// Host the example in the form
			NNovWidgetHost host = new NNovWidgetHost(pairBox);
			host.Dock = DockStyle.Fill;
			Controls.Add(host);
		}

		#endregion

        #region Example

        public NWidget CreateExampleContent()
        {
            // create the host
            NStackPanel stack = new NStackPanel();
            stack.HorizontalPlacement = ENHorizontalPlacement.Left;
            stack.VerticalPlacement = ENVerticalPlacement.Top;
            stack.VerticalSpacing = 5;

            // text only push button
            NButton textOnlyButton = new NButton("Text only button");
            textOnlyButton.Click += OnButtonClicked;
            stack.Add(textOnlyButton);

            // image only push button
            NButton imageOnlyButton = new NButton(Nevron.Nov.Graphics.NImage.FromBytes(Nevron.Nov.NConvert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAABnRSTlMAAAAAAABupgeRAAABu0lEQVR42sUPA6yQQfjuz7ZtN2ZzbMpNaYpTtjQvY0pz1lg927ZtHz50/9PY3PpsiH8O8vPvRKeImIiQEB07AIfdQB3Q0dDT8bZ1i8RfgNsZkH0l5Z4jV7yO1oKCgtOnT9+6dcvJsLAwa61fyT4BsUVHIioqoamlxUNEF713754rGDly5PTp0758/V5SWgYolGULPhlg7SR6Tc0tPQHQWFtUVAQAJ06cLCgszC8sMca0aP6RTMW1oq2VWttIado621Na9wTEHj16jh07Lig4KCExKTIsuKG2esqUySR441wGZAsCSGrrZWRL/2kAQBIXzp56dyomr7ho0pA+Y9JCC3KyR02anZVfExaTZSwBEiLNXzCuowGhpb74/q592zdE/rgxb2z/HCqPvbxp3YuiwUOHbt6wBJD9BuK8guKOBgCrualqqFSL580OCgxYOHl4dlZ1i6a0jMKikipjoKNn8rTJfgM66DvK23E/6u3+ct271cqf1UPHHX6kjJg2feL4ieNFFyRmVzkpH7z6sX7VUkCuadStClo1dqSZ2SBJZiBPg2egB0n58tnlnkR0+trdNq2V0sZa54r/DH8AtopTKVMOx+0AAAAASUVORK5CYII=")));
            imageOnlyButton.Click += OnButtonClicked;
            stack.Add(imageOnlyButton);

            // image and text button
            NImage image2 = Nevron.Nov.Graphics.NImage.FromBytes(Nevron.Nov.NConvert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACs0lEQVR4Aa2SA8wtRwBGz+xePtu2bSus7Tao7aBmVEW1bdvus237v76rUad2o/cli8E5Q8G/5IHnl/TMeP4juYyYDbEslaP37rz+HBfVcPPNGyx/yl8E9z21tHne46JmTdJ3jB+RpmfHEMI9rFpdYUNxgFy1cfeVqlR4/OabTw3+Irj5sS9zXZq2nJ7xvLub5LzBh8/Ik04nqFoFL9iPF29Cl3fxwc4j2Liz/KZo0uayy8+asB1APPDEkh7C98/o1FbcOnawT4f2GiKDTkKELCCCA4hwF7gHvZNdyWS+2zPEzF2+7+TmLdt+KR55dunanu1U/9mjKtC07f/C+F1BFtG17XwbXcji3W1eT6VTqf6zhy5F1ZvhBWVE7Kbs1i2S3WACLMoJI2QkMXI1SRjgmYDpmWtZqh87NmWBoJLg9TuG1N921gKJAe0e5R4Ta4xOKJRL1BdfwI4dB0lh4eONg5jaPiSX8dm9v0KzplmEEFgLBovwfIyxlKqSlq1aUIpCPtx83M99UsYY2nbpzxdzdzB7QhdatcjzyQ+7fga0/ukxaGXBCKZN68reAwf45vNN1LvMQe394hfB5GFtmJcWfL1oL77n0Tjnk836GPMTDArBwUKNL77YQakW4HXoRN/BHZk71/wiMMDAfq346oftjBrcmnHDOuE5kbFQk1CWgtZ1yVdfb2bXxiqTZ46mEoGSTuCmSNU9r7y1jsmjOzB8cDsH+kQGImVxnFuzdeUMfUf1JRAp5j8/FztmLFprnEDz4qtrGDagNYOHtKMWCwqRppoIlDFECURSuMeSSOjYq5e71pLK59872LpHaUaM7kzfPi1YX4A9ZaiEPuW6RUkPYwRBoB1sqQcGqSBo1JtaY0Wzov1lCd+9s4TPY0kcJURhTOL+ZSJRTm6t5bfY31/QDMshyY/gFJCcZo3GBQAAAABJRU5ErkJggg=="));
            NButton imageAndTextButton = new NButton(new NPairBox("Image before text", image2, ENPairBoxRelation.Box2BeforeBox1, false));
            imageAndTextButton.Click += OnButtonClicked;
            stack.Add(imageAndTextButton);

            // repeat button
            NRepeatButton repeatButton = new NRepeatButton("Repeat button");
            repeatButton.StartClicking += OnRepeatButtonStartClicking;
            repeatButton.Click += OnButtonClicked;
            repeatButton.EndClicking += OnRepeatButtonEndClicking;
            stack.Add(repeatButton);

            // toggle button
            NToggleButton toggleButton = new NToggleButton("Toggle button");
            toggleButton.Click += OnButtonClicked;
            stack.Add(toggleButton);

            // disabled button
            NButton disabledButton = new NButton("Disabled Button");
            disabledButton.Enabled = false;
            stack.Add(disabledButton);

            return stack;
        }
        public NWidget CreateExampleControls()
        {
            NStackPanel stack = new NStackPanel();
            stack.FillMode = ENStackFillMode.Last;
            stack.FitMode = ENStackFitMode.Last;

            // create the events list box
            m_EventsLog = new NExampleEventsLog();
            stack.Add(m_EventsLog);

            return stack;
        }
        public string GetExampleDescription()
        {
            return @"

This example demonstrates the different types of buttons supported by NOV.

"; } /// /// Gets the relevant documentation links for the example /// /// public (string Name, string Url)[] GetDocumentationUrls() { return new[] { ("Push Buttons", "https://www.nevron.com/docs/openvision/ui-push-buttons.html"), ("Buttons Overview", "https://www.nevron.com/docs/openvision/ui-buttons-overview.html"), }; } #endregion #region Implementation #endregion #region Event Handlers private void OnButtonClicked(NEventArgs arg1) { m_EventsLog.LogEvent("Button clicked"); } private void OnRepeatButtonStartClicking(NEventArgs arg1) { m_EventsLog.LogEvent("Repeat Button Start Clicking"); } private void OnRepeatButtonEndClicking(NEventArgs arg1) { m_EventsLog.LogEvent("Repeat Button End Clicking"); } #endregion #region Fields private NExampleEventsLog m_EventsLog; #endregion #region Static Methods #endregion #region Constants #endregion #region Nested Types #endregion } }

Download a fully functional C# (.cs) Buttons Example for Blazor Solution

Related Documentation Links