当前位置: 首页>>代码示例>>C#>>正文


C# Color.ToString方法代码示例

本文整理汇总了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();
 }
开发者ID:hzsydy,项目名称:Ccao-big-homework,代码行数:7,代码来源:ColorUtils.cs

示例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"));
 }
开发者ID:Esri,项目名称:arcgis-viewer-silverlight,代码行数:8,代码来源:ColorPickerUtils.cs

示例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");
		}
开发者ID:dfr0,项目名称:moon,代码行数:9,代码来源:ColorTest.cs

示例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);
		}
开发者ID:paradoxfm,项目名称:ledx2,代码行数:9,代码来源:ColorCanvas.cs

示例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);
            }
        }
开发者ID:haashkanani,项目名称:code-samples,代码行数:56,代码来源:ThemeManagerHelper.cs

示例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);
 }
开发者ID:ledgarl,项目名称:Samples,代码行数:15,代码来源:AppBarMenuControl.cs

示例7: btnOK_Click

        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            FSelectedColor = colorPicker.SelectedColor;

            // カラー値をあらわす文字列をクリップボードにコピーする
            Clipboard.SetText(FSelectedColor.ToString());

            this.DialogResult = true;
            this.Close();
        }
开发者ID:kienaiProject,项目名称:ArtOfWords,代码行数:10,代码来源:WpfColorDialog.xaml.cs

示例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);
 }
开发者ID:ledgarl,项目名称:Samples,代码行数:15,代码来源:AppBarMenuControl.cs

示例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()];
        }
开发者ID:BrentonWorkman,项目名称:ACT.SpecialSpellTimer,代码行数:17,代码来源:WindowExtension.Visibility.cs

示例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);
            }
        }
开发者ID:kiendev,项目名称:FarjiChat,代码行数:13,代码来源:ColorPicker.xaml.cs

示例11: GetColorName

        public static string GetColorName(Color color)
        {
            Initialize();

            string code = color.ToString();
            if (dictionaryColors.ContainsKey(code))
            {
                return dictionaryColors[code].Name;
            }
            else
            {
                return code;
            }
        }
开发者ID:Jitlee,项目名称:MonitorProject,代码行数:14,代码来源:PredefinedColor.cs

示例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));
			}
		}
开发者ID:paradoxfm,项目名称:ledx2,代码行数:23,代码来源:HexDisplay.xaml.cs

示例13: GetPredefinedColor

        public static PredefinedColor GetPredefinedColor(Color color)
        {
            Initialize();

            string code = color.ToString();
            if (dictionaryColors.ContainsKey(code))
            {
                return dictionaryColors[code];
            }
            else
            {
                return null;
            }
        }
开发者ID:Jitlee,项目名称:MonitorProject,代码行数:14,代码来源:PredefinedColor.cs

示例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);
        }
开发者ID:koen24,项目名称:screentogif,代码行数:19,代码来源:ColorSelector.xaml.cs

示例15: StringFromColor

		public static string StringFromColor(Color c)
		{
			return c.ToString().Substring(1);
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:4,代码来源:ColorHelper.cs


注:本文中的System.Windows.Media.Color.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。