ArcGIS Explorer Component Help |
Application..::.ColorSchemeChanged Event |
Application Class Example See Also |
Occurs when the color scheme changes, for example when a user changes the scheme in the application or
when the ColorScheme property is set to a new value.
Namespace:
ESRI.ArcGISExplorer.ApplicationAssembly: ESRI.ArcGISExplorer.Application (in ESRI.ArcGISExplorer.Application.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public static event EventHandler ColorSchemeChanged |
Visual Basic (Declaration) |
---|
Public Shared Event ColorSchemeChanged As EventHandler |
Remarks
Version Information: This event is supported from version 2.0.0.1500.
Examples
The code below demonstrates how you can use the ColorSchemeChanged event to update
the BackColor and ForeColor properties of a DockWindow add-in to match the current color scheme. It is
important to note that the color matching provided in this example is approximate.
CopyC#
using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using ESRI.ArcGISExplorer.Application; namespace ChangeColorScheme { public partial class ColorSchemeChangeDockWindow : ESRI.ArcGISExplorer.Application.DockWindow { /// <summary> /// Initializes a new instance of the ColorSchemeChangeDockWindow class. /// </summary> public ColorSchemeChangeDockWindow() { //Uncomment this if you copy into a DockWindow add-in //InitializeComponent(); //register to listen to the ColorSchemeChangedEvent ESRI.ArcGISExplorer.Application.Application.ColorSchemeChanged += new EventHandler(Application_ColorSchemeChanged); //Call the event method manually when the DockWindow is initialized Application_ColorSchemeChanged(null, null); } /// <summary> /// Handles the ColorSchemeChanged event of the Application control. /// </summary> void Application_ColorSchemeChanged(object sender, EventArgs e) { Color color1 = Color.Red; Color color2 = Color.Orange; //The ArcGIS Explorer ribbon consists of several colors for each scheme. //The code below makes an approximate conversion of two of the colors //on the ribbon to .NET Colors switch (ESRI.ArcGISExplorer.Application.Application.ColorScheme) { case ColorScheme.Aqua: color1 = MakeColor(0xFFC7CDDB); color2 = MakeColor(0xFFE5E6E5); break; case ColorScheme.Black: color1 = MakeColor(0xFFC1C6CD); color2 = MakeColor(0xFF949494); break; case ColorScheme.Blue: color1 = MakeColor(0xFF5688B0); color2 = MakeColor(0xFFDAE2EC); break; case ColorScheme.Silver: color1 = MakeColor(0xFF999B9E); color2 = MakeColor(0xFFEDEFF1); break; } //Set two DockWindow properties based on .NET Colors this.BackColor = color2; //this will be the background color of the DockWindow this.ForeColor = color1; //this will be the color for text in the DockWindow } /// <summary> /// Returns a Color for the specified ARGB value. /// </summary> private Color MakeColor(uint argb) { unchecked { return Color.FromArgb((int)argb); } } } }
CopyVB.NET
Imports System.Collections.Generic Imports System.Drawing Imports System.Windows.Forms Imports ESRI.ArcGISExplorer.Application Public Class ColorSchemeChangedDockWindow Inherits ESRI.ArcGISExplorer.Application.DockWindow ''' <summary> ''' Initializes a new instance of the ColorSchemeChangeDockWindow class. ''' </summary> Public Sub New() 'Uncomment this if you copy into a DockWindow add-in 'InitializeComponent() 'register to listen to the ColorSchemeChangedEvent AddHandler ESRI.ArcGISExplorer.Application.Application.ColorSchemeChanged, AddressOf Application_ColorSchemeChanged 'Call the event method manually when the DockWindow is initialized Application_ColorSchemeChanged(Nothing, Nothing) End Sub ''' <summary> ''' Handles the ColorSchemeChanged event of the Application control. ''' </summary> Private Sub Application_ColorSchemeChanged(ByVal sender As Object, ByVal e As EventArgs) Dim color1 As Color = Color.Red Dim color2 As Color = Color.Orange 'The ArcGIS Explorer ribbon consists of several colors for each scheme. 'The code below makes an approximate conversion of two of the colors 'on the ribbon to .NET Colors Select Case ESRI.ArcGISExplorer.Application.Application.ColorScheme Case ColorScheme.Aqua color1 = MakeColor(&HFFC7CDDBUI) color2 = MakeColor(&HFFE5E6E5UI) Exit Select Case ColorScheme.Black color1 = MakeColor(&HFFC1C6CDUI) color2 = MakeColor(&HFF949494UI) Exit Select Case ColorScheme.Blue color1 = MakeColor(&HFF5688B0UI) color2 = MakeColor(&HFFDAE2ECUI) Exit Select Case ColorScheme.Silver color1 = MakeColor(&HFF999B9EUI) color2 = MakeColor(&HFFEDEFF1UI) Exit Select End Select 'Set two DockWindow properties based on .NET Colors Me.BackColor = color2 'this will be the background color of the DockWindow Me.ForeColor = color1 'this will be the color for text in the DockWindow End Sub ''' <summary> ''' Returns a Color for the specified ARGB value. ''' </summary> Private Function MakeColor(ByVal argb As UInteger) As Color 'Compiler setting set to ignore integer overflow: 'Project properties > Compile Tab > Advanced Compiler Options + check "Remove integer overflow checks" Return Color.FromArgb(System.Convert.ToInt64(argb)) End Function End Class