本文整理汇总了C#中System.Windows.Media.Color.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Color.ToString方法的具体用法?C# Color.ToString怎么用?C# Color.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Color
的用法示例。
在下文中一共展示了Color.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetColorName
public static String GetColorName(Color colorToSeek)
{
if (m_colorNames.ContainsKey(colorToSeek))
return m_colorNames[colorToSeek];
else
return colorToSeek.ToString();
}
示例2: GetHexCode
internal static string GetHexCode(Color c)
{
return c.ToString();
//return string.Format("#{0}{1}{2}",
// c.R.ToString("X2"),
// c.G.ToString("X2"),
// c.B.ToString("X2"));
}
示例3: Defaults
public void Defaults ()
{
Color c = new Color ();
Assert.AreEqual (0, c.R, "R");
Assert.AreEqual (0, c.G, "G");
Assert.AreEqual (0, c.B, "B");
Assert.AreEqual (0, c.A, "A");
Assert.AreEqual ("#00000000", c.ToString (), "ToString");
}
示例4: OnSelectedColorChanged
protected virtual void OnSelectedColorChanged(Color oldValue, Color newValue) {
HexadecimalString = newValue.ToString();
UpdateRGBValues(newValue);
UpdateColorShadeSelectorPosition(newValue);
RoutedPropertyChangedEventArgs<Color> args = new RoutedPropertyChangedEventArgs<Color>(oldValue, newValue);
args.RoutedEvent = SelectedColorChangedEvent;
RaiseEvent(args);
}
示例5: CreateAppStyleBy
public static void CreateAppStyleBy(Color color, bool changeImmediately = false)
{
// create a runtime accent resource dictionary
var resourceDictionary = new ResourceDictionary();
resourceDictionary.Add("HighlightColor", color);
resourceDictionary.Add("AccentColor", Color.FromArgb((byte)(204), color.R, color.G, color.B));
resourceDictionary.Add("AccentColor2", Color.FromArgb((byte)(153), color.R, color.G, color.B));
resourceDictionary.Add("AccentColor3", Color.FromArgb((byte)(102), color.R, color.G, color.B));
resourceDictionary.Add("AccentColor4", Color.FromArgb((byte)(51), color.R, color.G, color.B));
resourceDictionary.Add("HighlightBrush", new SolidColorBrush((Color)resourceDictionary["HighlightColor"]));
resourceDictionary.Add("AccentColorBrush", new SolidColorBrush((Color)resourceDictionary["AccentColor"]));
resourceDictionary.Add("AccentColorBrush2", new SolidColorBrush((Color)resourceDictionary["AccentColor2"]));
resourceDictionary.Add("AccentColorBrush3", new SolidColorBrush((Color)resourceDictionary["AccentColor3"]));
resourceDictionary.Add("AccentColorBrush4", new SolidColorBrush((Color)resourceDictionary["AccentColor4"]));
resourceDictionary.Add("WindowTitleColorBrush", new SolidColorBrush((Color)resourceDictionary["AccentColor"]));
resourceDictionary.Add("ProgressBrush", new LinearGradientBrush(
new GradientStopCollection(new[]
{
new GradientStop((Color)resourceDictionary["HighlightColor"], 0),
new GradientStop((Color)resourceDictionary["AccentColor3"], 1)
}),
new Point(0.001, 0.5), new Point(1.002, 0.5)));
resourceDictionary.Add("CheckmarkFill", new SolidColorBrush((Color)resourceDictionary["AccentColor"]));
resourceDictionary.Add("RightArrowFill", new SolidColorBrush((Color)resourceDictionary["AccentColor"]));
resourceDictionary.Add("IdealForegroundColor", Colors.White);
resourceDictionary.Add("IdealForegroundColorBrush", new SolidColorBrush((Color)resourceDictionary["IdealForegroundColor"]));
resourceDictionary.Add("AccentSelectedColorBrush", new SolidColorBrush((Color)resourceDictionary["IdealForegroundColor"]));
// applying theme to MahApps
var resDictName = string.Format("ApplicationAccent_{0}.xaml", color.ToString().Replace("#", string.Empty));
var fileName = Path.Combine(Path.GetTempPath(), resDictName);
using (var writer = System.Xml.XmlWriter.Create(fileName, new System.Xml.XmlWriterSettings { Indent = true }))
{
System.Windows.Markup.XamlWriter.Save(resourceDictionary, writer);
writer.Close();
}
resourceDictionary = new ResourceDictionary() { Source = new Uri(fileName, UriKind.Absolute) };
var newAccent = new Accent { Name = resDictName, Resources = resourceDictionary };
ThemeManager.AddAccent(newAccent.Name, newAccent.Resources.Source);
if (changeImmediately)
{
var application = Application.Current;
var applicationTheme = ThemeManager.AppThemes.First(x => string.Equals(x.Name, "BaseLight"));
ThemeManager.ChangeAppStyle(application, newAccent, applicationTheme);
}
}
示例6: CheckAppBarBackgroundColour
/// <summary>
/// Checks the app bar background colour.
/// </summary>
/// <param name="color">The color.</param>
/// <returns></returns>
private Brush CheckAppBarBackgroundColour(Color color)
{
if (color.ToString().Equals("#00000000")) // Default system theme no colour is given
{
bool isDark = ((Visibility) Application.Current.Resources["PhoneDarkThemeVisibility"] ==
Visibility.Visible);
color = isDark ? Color.FromArgb(255, 33, 32, 33) : Color.FromArgb(255, 223, 223, 223);
}
return new SolidColorBrush(color);
}
示例7: btnOK_Click
private void btnOK_Click(object sender, RoutedEventArgs e)
{
FSelectedColor = colorPicker.SelectedColor;
// カラー値をあらわす文字列をクリップボードにコピーする
Clipboard.SetText(FSelectedColor.ToString());
this.DialogResult = true;
this.Close();
}
示例8: CheckAppBarForegroundColour
/// <summary>
/// Checks the app bar foreground colour.
/// </summary>
/// <param name="color">The color.</param>
/// <returns></returns>
private Brush CheckAppBarForegroundColour(Color color)
{
if (color.ToString().Equals("#00000000")) // Default system theme no colour is given
{
bool isDark = ((Visibility) Application.Current.Resources["PhoneDarkThemeVisibility"] ==
Visibility.Visible);
color = isDark ? Colors.White : Colors.Black;
}
return new SolidColorBrush(color);
}
示例9: GetBrush
/// <summary>
/// Brushを取得する
/// </summary>
/// <param name="color">Brushの色</param>
/// <returns>Brush</returns>
private static SolidColorBrush GetBrush(
Color color)
{
if (!brushDictionary.ContainsKey(color.ToString()))
{
var brush = new SolidColorBrush(color);
brush.Freeze();
brushDictionary[color.ToString()] = brush;
}
return brushDictionary[color.ToString()];
}
示例10: Picker_ColorChanged
private void Picker_ColorChanged(object sender, Color color)
{
try
{
Debug.WriteLine(color.ToString());
_selectedColor = color;
}
catch (Exception exception)
{
Debug.WriteLine(exception.Message);
}
}
示例11: GetColorName
public static string GetColorName(Color color)
{
Initialize();
string code = color.ToString();
if (dictionaryColors.ContainsKey(code))
{
return dictionaryColors[code].Name;
}
else
{
return code;
}
}
示例12: OnColorChanged
private void OnColorChanged(Color c) {
string colorText = "";
if (IsNumberSignIncludedInText) {
colorText = "#";
}
switch (AlphaByteVisibility) {
case EAlphaByteVisibility.visible:
colorText += c.ToString().Substring(1);
break;
case EAlphaByteVisibility.hidden:
colorText += c.ToString().Substring(3);
break;
case EAlphaByteVisibility.auto:
break;
}
txtHex.Text = colorText;
if (ColorChanged != null) {
ColorChanged(this, new EventArgs<Color>(c));
}
}
示例13: GetPredefinedColor
public static PredefinedColor GetPredefinedColor(Color color)
{
Initialize();
string code = color.ToString();
if (dictionaryColors.ContainsKey(code))
{
return dictionaryColors[code];
}
else
{
return null;
}
}
示例14: ArgbText_ValueChanged
private void ArgbText_ValueChanged(object sender, RoutedEventArgs e)
{
if (AlphaText == null) return;
if (_isUpdating) return;
SelectedColor = Color.FromArgb(
(byte)AlphaText.Value,
(byte)RedTextBox.Value,
(byte)GreenText.Value,
(byte)BlueText.Value);
_isUpdating = true;
HexadecimalText.Text = SelectedColor.ToString();
_isUpdating = false;
UpdateMarkerPosition(SelectedColor);
}
示例15: StringFromColor
public static string StringFromColor(Color c)
{
return c.ToString().Substring(1);
}