Moi3d Custum Ui Colors

-->

Definition

There are a number of color themes, or skins. The default is blue, but there are also black, purple, green, red, and yellow. You can choose which theme to use with dashboardPage(skin = 'blue'), dashboardPage(skin = 'black'), and so on.

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

  • Window World windows, siding, and entry doors are backed by the prestigious Good Housekeeping Seal. For a full list of products with the Seal, go to goodhousekeeping.com. ENERGY STAR Partner. Window World offers a variety of window and door packages that are ENERGY STAR qualified in each of the nation’s climate zones.
  • Welcome to the MoI discussion forum. This is the place for any kind of discussion (questions, comments, feature requests, WIP screenshots, etc.) about the MoI 3D modeling software. If you need help with a particular model, it can help a lot if you post a.3dm model file as an attachment with your question.

Describes a color in terms of alpha, red, green, and blue channels.

Inheritance
Color
Attributes

Windows requirements

Device family
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Examples

Here's the syntax for defining a Color value as a resource in a XAML ResourceDictionary. You'd typically only need this if you are defining a color that is not already one of the 250+ colors provided as the values in the Colors class, and you want to use the XAML resource system as enforcement that you're using the same color in multiple areas of your app UI. Note the x:Key attribute, required when you define a XAML resource.

This code shows a two-way converter for SolidColorBrush and Color values. This can be useful for databinding scenarios, because it implements the IValueConverter pattern that the Converter property of a data binding can use, and you can then bind a SolidColorBrush source to a Color target and vice versa. To see this code in context, see the source for the SwapChainPanel sample.

Remarks

Color is a Windows Runtime structure that represents a color that has four channels: A (alpha), R (red), G (green), B (blue). Each of the values is stored as a Byte type with value 0-255.

Color values are used in these features and scenarios:

  • Colors for start screens and general UI (for example SecondaryTile.BackgroundColor and UISettings.UIElementColor ). These can be used in JavaScript.
  • Color values for the Windows 8 ink system. Specifically, InkDrawingAttributes.Color. This can be used in JavaScript.
  • Color values for XAML UI and UWP app using C++, C#, or Visual Basic, particularly for brushes. These API can't be used in JavaScript.
  • Defining color values that are used for interfaces representing text, in the Windows.UI.Text namespace. These API can't be used in JavaScript.

Color values and XAML definitions

The most frequent application of Color is to define color-related properties in a UI element as part of a UWP app using C++, C#, or Visual Basic and its XAML UI definition.

Various predefined Color values are available as static properties on the Colors class. These properties are useful for setting Color values in code that match the attribute string form used in XAML to set a named Color. For example, the Colors.AliceBlue property returns a Color that is equal to Color from the XAML usage <SolidColorBrush Color='AliceBlue' />. You can also use the Colors values for equality comparisons against a Color.

In most XAML UI scenarios, a Color isn't used directly as a property value of a UIElement. Instead, a Color is used as a component value of a Brush (either SolidColorBrush or LinearGradientBrush ). However, the Brush type enables a XAML shorthand that lets you set an attribute value of type Brush using a named color string, or a format string that can be parsed into an ARGB form. For example, you can set the Brush -type value TextBlock.Foreground using a syntax such as <TextBlock Foreground='Cyan' />. This syntax implicitly creates a new SolidColorBrush with a Color value equal to Cyan that fills the Brush -type value of TextBlock.Foreground for that element. For more info on using brushes and colors in XAML, see Use brushes.

If you use the same color brush often in your XAML, you should define a SolidColorBrush as a resource rather than using the inline implicit creation of new values, because that's more efficient. For more info, see Optimize your XAML markup or ResourceDictionary and XAML resource references. You might also want to use system colors, which can be accessed as merged-in resources for themes that the system defines. See XAML theme resources.

There are also some XAML properties that take a direct Color value. These mostly support animating a Color value that exists on a Brush. The Windows Runtime supports an interpolation logic so that you can animate from one Color to another in a From/To animation and the animation will use interpolated Color values as the animation runs. For more info, see Storyboarded animations.

Notes on XAML syntax

If you use the '#' token to specify color values in hex form, the hex values are stored in the structure as values between 0 and 255, not as the original hex strings. If you use the 'sc#' token, the values are also stored as values between 0 and 255, not the original value of 0 to 1.

Strings for named colors are interpreted based on the associated Colors constants, and the values for A, R, G and B are set in the structure as values between 0 and 255 that are representative of that color.

The XAML object element usage (with initialization text) is useful for declaring a Color as a resource in a XAML ResourceDictionary. For more info, see ResourceDictionary and XAML resource references.

This table explains the color value placeholders shown in the XAML Syntax section.

ValueNotes
predefinedColorOne of the colors predefined by the Colors class. See members of Colors for a list. These are static properties. Specify just the color name, for example Transparent. Do not include the static class qualifier in the string: for example, 'Colors.Transparent' does not parse in XAML.
<Grid Background='Blue'/>, <Color>Blue</Color>
rgbA three-character hexadecimal value. The first character specifies the color's R value, the second character specifies the G value, and the third character specifies the B value. For example, 00F.
<Grid Background='#00F'/>, <Color>#00F</Color>
argbA four-character hexadecimal value. The first character specifies the color's A value, the second character specifies its R value, the third character specifies the G value, and the fourth character specifies its B value. For example, F00F.
<Grid Background='#F00F'/>, <Color>#F00F</Color>
rrggbbA six-character hexadecimal value. The first two characters specify the color's R value, the next two specify its G value, and the final two specify its B value. For example, 0000FF.
<Grid Background='#0000FF'/>, <Color>#0000FF</Color>
aarrggbbAn eight-character hexadecimal value. The first two characters specify the color's A value, the next two specify its R value, the next two specify its G value, and the final two specify its B value. For example, FF0000FF.
<Grid Background='#FF0000FF'/>, <Color>#FF0000FF</Color>
scAThe color's ScA (alpha) value as a value between 0 and 1.
<Grid Background='sc#1,0,0,1'/>, <Color>sc#1,0,0,1</Color>
scRThe color's ScR (red) value as a value between 0 and 1.
scGThe color's ScG (green) value as a value between 0 and 1.
scBThe color's ScB (blue) value as a value between 0 and 1.

Projection and members of Color

If you are using a Microsoft .NET language (C# or Microsoft Visual Basic) then Color has a static method FromArgb that acts as a Color value generator. Also, the data members of Color are exposed as read-write properties.

If you are programming with C++, either Visual C++ component extensions (C++/CX) or WRL, then only the data member fields exist as members of Color, and you cannot use the utility methods or properties listed in the members table. C++ code can use an equivalent FromArgb method on the ColorHelper class, and the Platform::Object methods.

ToString behavior for Color

For C# and Microsoft Visual Basic, the language support for the Color structure provides a behavior for ToString that serializes the values of the ARGB data properties into a single string. The string representations of Color values are similar to XAML attribute string syntax for specifying Color values in markup. It is the syntax that is most commonly used by designer tools to specify a (non-named) Color. The string is in the form <cmd_line>#AARRGGBB</cmd_line>, where each letter pair represents one of the color channels as a value between <cmd_line>00</cmd_line> and <cmd_line>FF</cmd_line>. Each letter pair is interpreted as if it were a hex value and thus represents a value between 0 and 255. The string always starts with a hash (#). For example, the string form of the color where A=255, R=0, G=128, B=255 is '#FF0080FF'. For named colors you get the serialized string and not the constant name; for example calling ToString on Colors.Blue gives '#FF0000FF'.

Note

Visual C++ component extensions (C++/CX) doesn't use nondata members of Color, and doesn't enable this form of string returned from ToString(). The ToString() value returned from Visual C++ component extensions (C++/CX) for a Color is the unmodified Platform::Object::ToString behavior, which gives a representation of the type (boxed by IReference ) and does not indicate the value.

Fields

A

Gets or sets the sRGB alpha channel value of the color.

B

Gets or sets the sRGB blue channel value of the color.

G

Gets or sets the sRGB green channel value of the color.

R

Gets or sets the sRGB red channel value of the color.

Applies to

See also

Topics

  • Controls
  • Custom Controls, Sections, and Panels

The Customize API is object-oriented. There are four main types of Customizer objects: Panels, Sections, Settings, and Controls. Settings associate UI elements (controls) with settings that are saved in the database. Sections are UI containers for controls, to improve their organization. Panels are containers for sections, allowing multiple sections to be grouped together.

Each Customizer object is represented by a PHP class, and all of the objects are managed by the Customize Manager object, WP_Customize_Manager.

To add, remove, or modify any Customizer object, and to access the Customizer Manager, use the customize_register hook:

The Customizer Manager provides add_, get_, and remove_ methods for each Customizer object type; each works with an id. The get_ methods allow for direct modification of parameters specified when adding a control.

Note: themes generally should not modify core sections and panels with the get methods, since themes should not modify core, theme-agnostic functionality. Plugins are encouraged to use these functions where necessary. Themes should not “reorganize” customizer sections that aren’t added by the theme.

Custum

Settings Settings

Settings handle live-previewing, saving, and sanitization of your customizer objects. Each setting is managed by a control object. There are several parameters available when adding a new setting:

Alert:Important: Do not use a setting ID that looks like widget_*, sidebars_widgets[*], nav_menu[*], or nav_menu_item[*]. These setting ID patterns are reserved for widget instances, sidebars, nav menus, and nav menu items respectively. If you need to use “widget” in your setting ID, use it as a suffix instead of a prefix, for example “homepage_widget”.

There are two primary types of settings: options and theme modifications. Options are stored directly in the wp_options table of the WordPress database and apply to the site regardless of the active theme. Themes should rarely if ever add settings of the option type. Theme mods, on the other hand, are specific to a particular theme. Most theme options should be theme_mods. For example, a custom CSS plugin could register a custom theme css setting as a theme_mod, allowing each theme to have a unique set of CSS rules without losing the CSS when switching themes then switching back.

It is usually most important to set the default value of the setting as well as its sanitization callback, which will ensure that no unsafe data is stored in the database. Typical theme usage:

Typical plugin usage:

Note that the Customizer can handle options stored as keyed arrays for settings using the option type. This allows multiple settings to be stored in a single option that isn’t a theme mod. To retrieve and use the values of your Customizer options, use get_theme_mod() and get_option() with the setting id:

Note that the second argument for get_theme_mod() and get_option() is the default value, which should match the default you set when adding the setting.

Controls Controls

Controls are the primary Customizer object for creating UI. Specifically, every control must be associated with a setting, and that setting will save user-entered data from the control to the database (in addition to displaying it in the live-preview and sanitizing it). Controls can be added by the Customizer Manager and provide a robust set of UI options with minimal effort:

The most important parameter when adding a control is its type — this determines what type of UI the Customizer will display. Core provides several built-in control types:

  • <input> elements with any allowed type (see below)
  • checkbox
  • textarea
  • radio (pass a keyed array of values => labels to the choices argument)
  • select (pass a keyed array of values => labels to the choices argument)
  • dropdown-pages (use the allow_addition argument to allow users to add new pages from the control)

For any input type supported by the html input element, simply pass the type attribute value to the type parameter when adding the control. This allows support for control types such as text, hidden, number, range, url, tel, email, search, time, date, datetime, and week, pending browser support.

Controls must be added to a section before they will be displayed (and sections must contain controls to be displayed). This is done by specifying the section parameter when adding the control. Here is an example for adding a basic textarea control:

And here’s an example of a basic range (slider) control. Note that most browsers will not display the numeric value of this control because the range input type is designed for settings where the exact value is unimportant. If the numeric value is important, consider using the number type. The input_attrs parameter will map a keyed array of attributes => values to attributes on the input element, and can be used for purposes ranging from placeholder text to data- JavaScript-referenced data in custom scripts. For number and range controls, it allows us to set the minimum, maximum, and step values.

Core Custom Controls Core Custom Controls

If none of the basic control types suit your needs, you can easily create and add custom controls. Custom controls are explained more fully later in this post, but they are essentially subclasses of the base WP_Customize_Control object that allow any arbitrary html markup and functionality that you might need. Core features several built-in custom controls that allow developers to implement rich JavaScript-driven features with ease. A color picker control can be added as follows:

WordPress 4.1 and 4.2 also added support for any type of multimedia content, with the Media control. The media control implements the native WordPress media manager, allowing users to select files from their library or upload new ones. By specifying the mime_type parameter when adding the control, you can instruct the media library show to a specific type such as images or audio:

Note that settings associated with WP_Customize_Media_Control save the associated attachment ID, while all other media-related controls (children of WP_Customize_Upload_Control) save the media file URL to the setting. More information is available on Make WordPress Core.

Additionally, WordPress 4.3 introduced the WP_Customize_Cropped_Image_Control, which provides an interface for cropping an image after selecting it. This is useful for instances where a particular aspect ratio is needed.

Sections Sections

Moi3d Custom Ui Colors Code

Sections are UI containers for Customizer controls. While you can add custom controls to the core sections, if you have more than a few options you may want to add one or more custom sections. Use the add_section method of the WP_Customize_Manager object to add a new section:

You only need to include fields that you want to override the default values of. For example, the default priority (order of appearance) is typically acceptable, and most sections shouldn’t require descriptive text if your options are self-explanatory. If you do want to change the location of your custom section, the priorities of the core sections are below:

TitleIDPriority (Order)
Site Title & Taglinetitle_tagline20
Colorscolors40
Header Imageheader_image60
Background Imagebackground_image80
Menus (Panel)nav_menus100
Widgets (Panel)widgets110
Static Front Pagestatic_front_page120
default160
Additional CSScustom_css200

In most cases, sections can be added with only one or two parameters being specified. Here’s an example for adding a section for options that pertain to a theme’s footer:

Panels Panels

The Customizer Panels API was introduced in WordPress 4.0, and allows developers to create an additional layer of hierarchy beyond controls and sections. More than simply grouping sections of controls, panels are designed to provide distinct contexts for the Customizer, such as Customizing Widgets, Menus, or perhaps in the future, editing posts. There is an important technical distinction between the section and panel objects.

Themes should not register their own panels in most cases. Sections do not need to be nested under a panel, and each section should generally contain multiple controls. Controls should also be added to the Sections that core provides, such as adding color options to the colors Section. Also make sure that your options are as streamlined and efficient as possible; see the WordPress philosophy. Panels are designed as contexts for entire features such as Widgets, Menus, or Posts, not as wrappers for generic sections. If you absolutely must use Panels, you’ll find that the API is nearly identical to that for Sections:

Panels must contain at least one Section, which must contain at least one Control, to be displayed. As you can see in the above example, Sections can be added to Panels similarly to how Controls are added to Sections. However, unlike with controls, if the Panel parameter is empty when registering a Section, it will be displayed on the main, top-level Customizer context, as most sections should not be contained with a panel.

Custom Controls, Sections, and Panels Custom Controls, Sections, and Panels

Custom Controls, Sections, and Panels can be easily created by subclassing the PHP objects associated with each Customizer object: WP_Customize_Control, WP_Customize_Section, and WP_Customize_Panel (this can also be done for WP_Customize_Setting, but custom settings are typically better implemented using custom setting types, as outlined in the next section). Here’s an example for a basic custom control:

By subclassing the base control class, you can override any functionality with custom functionality or use the core functionality depending on your needs. The most common function to override is render_content() as it allows you to create custom UI from scratch with HTML. Custom Controls should be used with caution, however, as they may introduce UI that is inconsistent with the surrounding core UI and cause confusion for users. Custom Customizer objects can be added similarly to how default controls, sections, and panels are added:

Parameters passed when adding controls are mapped to class variables within the control class, so you can add and use custom ones where certain parts of your custom object are different across different instances.

When creating custom Controls, Sections, or Panels, it is strongly recommended to reference the core code, in order to fully understand the available functionality that can be overridden. Core also includes examples of custom objects of each type. This can be found in wp-includes/class-wp-customize-control.php, wp-includes/class-wp-customize-section.php, and wp-includes/class-wp-customize-panel.php. There is also a JavaScript API for each Customizer object type, which can be extended with custom objects; see the Customizer JavaScript API section for more details.

Customizer UI Standards Customizer UI Standards

Custom customizer controls, sections, and panels should match core UI practices wherever possible. This includes relying on standards from wp-admin, such as using the .button and .button-primary classes, for example. There are also a few standards specific to the customizer (as of WordPress 4.7):

  • White background colors are used only to indicate navigation and actionable items (such as inputs)
  • The general #eee background color provides visual contrast against the white elements
  • 1px #ddd borders separate navigational elements from background margins and from each other
  • 15px of spacing is provided between elements where visual separation is desired
  • 4px borders are used on one side of a navigation element to show hover or focus, with a color of #0073aa
  • Customizer text uses color: #555d66, with #0073aa for hover and focus states on navigation elements

Custom Setting Types Custom Setting Types

By default, the Customizer supports saving settings as options or theme modifications. But this behavior can be easily overwritten to manually save and preview settings outside of the wp_options table of the WordPress database, or to apply other custom handling. To get started, specify a type other than option or theme_mod when adding your setting (you can use pretty much any string):

The setting will no longer be saved or previewed when its value is changed in the associated control. Now, you can use the customize_update_$setting->type and customize_preview_$setting->type actions to implement custom saving and previewing functionality. Here is an example for saving a menu item’s order property from the Menu Customizer project (the value of the setting is an ordered array of menu ids):

Wow Custom Ui

And here is how the same plugin implements previewing for nav menu items (note that this example requires PHP 5.3 or higher):