Palette Color Picker 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.

Palette Color Picker Example for Blazor Description

This example demonstrates how to create a palette color picker. The palette color picker is table picker that lets the user pick a color from a palette of colors. The palette to use may be passed as a parameter to the palette color picker constructor or may be assigned to its Palette property. You can use the controls on the right to change the currently used color palette.


Palette Color Picker Example

C# Palette Color Picker Example Code for Nevron UserInterface for Blazor
Language: C#

using Nevron.Nov;
using Nevron.Nov.DataStructures;
using Nevron.Nov.Dom;
using Nevron.Nov.Editors;
using Nevron.Nov.Graphics;
using Nevron.Nov.Layout;
using Nevron.Nov.Presentation;
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 - NPaletteColorPickerExample";

			// 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

		private NWidget CreateExampleContent()
		{
			return null;
		}
		private NWidget CreateExampleControls()
		{
			return null;
		}

		#endregion

		#region Implementation
		#endregion

		#region Event Handlers

		private void OnPaletteComboBoxSelectedIndexChanged(NValueChangeEventArgs args)
		{
			NComboBox cbPalette = (NComboBox)args.TargetNode;
			switch (cbPalette.SelectedIndex)
			{
				case 0: // "MS Paint"
					m_PaletteColorPicker.Palette = new NColorPalette(ENColorPaletteType.MicrosoftPaint);
					break;

				case 1: // "Office 2003":
					m_PaletteColorPicker.Palette = new NColorPalette(ENColorPaletteType.MicrosoftOffice2003);
					break;

				case 2: // "Office 2007":
					m_PaletteColorPicker.Palette = new NColorPalette(ENColorPaletteType.MicrosoftOffice2007);
					break;

				case 3: // "Web Safe":
					m_PaletteColorPicker.Palette = new NColorPalette(ENColorPaletteType.WebSafe);
					break;
			}
		}
		private void OnSelectedIndexChanged(NValueChangeEventArgs args)
		{
			NPaletteColorPicker colorPicker = (NPaletteColorPicker)args.TargetNode;
			NColor selectedColor = colorPicker.SelectedColor;
			m_EventsLog.LogEvent(selectedColor.GetHEX().ToUpper());
		}

		#endregion

		#region Fields

		private NPaletteColorPicker m_PaletteColorPicker;
		private NExampleEventsLog m_EventsLog;

		#endregion

		#region Static Methods
		#endregion

		#region Constants
		#endregion

		#region Nested Types
		#endregion
	}
}

Download a fully functional C# (.cs) Palette Color Picker Example for Blazor Solution