private void Color_Changed(object sender, RoutedPropertyChangedEventArgs <double> e) { try { int num1 = (int)(byte)this.sliderA.Value; byte num2 = (byte)this.sliderR.Value; byte num3 = (byte)this.sliderG.Value; byte num4 = (byte)this.sliderB.Value; int num5 = (int)num2; int num6 = (int)num3; int num7 = (int)num4; System.Windows.Media.Color color = System.Windows.Media.Color.FromArgb((byte)num1, (byte)num5, (byte)num6, (byte)num7); this.gridColor.Background = (Brush) new SolidColorBrush(color); if (this.ignore) { return; } this.textBox.Text = color.ToString((IFormatProvider)CultureInfo.InvariantCulture); BlueStacksUIColorManager.AppliedTheme.DictBrush[this.dataGrid.CurrentRow.Cells["Name"].Value.ToString()] = (Brush) new SolidColorBrush(new ColorUtils(color).WPFColor); if (this.dataGrid.CurrentRow.Cells["Category"].Value.ToString().Equals("*MainColors*", StringComparison.OrdinalIgnoreCase)) { BlueStacksUIColorManager.AppliedTheme.CalculateAndNotify(true); } else { BlueStacksUIColorManager.AppliedTheme.NotifyUIElements(); } } catch (Exception ex) { } }
public static String GetColorName(Color colorToSeek) { if (m_colorNames.ContainsKey(colorToSeek)) return m_colorNames[colorToSeek]; else return colorToSeek.ToString(); }
public static System.Windows.Media.Color ObtenerTonalidadOscuraDeColor(System.Windows.Media.Color color) { String stCol = color.ToString().Replace("#", ""); String r = stCol.Substring(0, 2); String v = stCol.Substring(2, 2); String a = stCol.Substring(4, 2); double ir = color.R; //Convert.ToInt32(r, 16); double iv = color.G; //Convert.ToInt32(v, 16); double ia = color.B; //Convert.ToInt32(a, 16); double factor = 40; if (ir - factor >= 0) { ir -= factor; } if (iv - factor >= 0) { iv -= factor; } if (ia - factor >= 0) { ia -= factor; } System.Windows.Media.Color colorNuevo = System.Windows.Media.Color.FromRgb((byte)ir, (byte)iv, (byte)ia); return(colorNuevo); }
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")); }
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"); }
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); }
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); } }
private void btnOK_Click(object sender, RoutedEventArgs e) { FSelectedColor = colorPicker.SelectedColor; // カラー値をあらわす文字列をクリップボードにコピーする Clipboard.SetText(FSelectedColor.ToString()); this.DialogResult = true; this.Close(); }
/// <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); }
/// <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); }
private Button BuildColorButton(System.Windows.Media.Color color) { return(new Button { Width = 20, Height = 20, Background = new SolidColorBrush(color), Tag = color.ToString() }); }
public static string GetColorName(this Color color) { string colorName = KnownColors.Where(kvp => kvp.Value.Equals(color)).Select(kvp => kvp.Key).FirstOrDefault(); if (String.IsNullOrEmpty(colorName)) { colorName = color.ToString(); } return(colorName); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return(value); } System.Drawing.Color color = (System.Drawing.Color)value; System.Windows.Media.Color result = System.Windows.Media.Color.FromArgb(color.A, color.R, color.G, color.B); return(result.ToString()); }
private void ChangeColor(object sender, RoutedEventArgs e) { var senderElement = (System.Windows.Controls.Button)sender; System.Windows.Forms.ColorDialog colorDialog = new System.Windows.Forms.ColorDialog(); if (colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { System.Windows.Media.Color selectedColor = System.Windows.Media.Color.FromArgb(colorDialog.Color.A, colorDialog.Color.R, colorDialog.Color.G, colorDialog.Color.B); BrushConverter brushConverter = new BrushConverter(); senderElement.Background = (Brush)brushConverter.ConvertFromString(selectedColor.ToString()); } }
/// <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()]; }
private void Picker_ColorChanged(object sender, Color color) { try { Debug.WriteLine(color.ToString()); _selectedColor = color; } catch (Exception exception) { Debug.WriteLine(exception.Message); } }
public static PredefinedColor GetPredefinedColor(Color color) { Initialize(); string code = color.ToString(); if (dictionaryColors.ContainsKey(code)) { return dictionaryColors[code]; } else { return null; } }
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)); } }
public static string GetColorName(Color color) { Initialize(); string code = color.ToString(); if (dictionaryColors.ContainsKey(code)) { return dictionaryColors[code].Name; } else { return code; } }
/// <summary> /// Modify the opacity of a colour. /// </summary> /// <param name="colour">The colour to modify.</param> /// <param name="opacity">The opacity (0 to 255).</param> /// <returns>The modified colour.</returns> public static Primitive SetOpacity(Primitive colour, Primitive opacity) { try { opacity = opacity < 0 ? 0 : opacity > 255 ? 255 : (int)opacity; Media.Color col = (Media.Color)Media.ColorConverter.ConvertFromString(colour); col.A = Utilities.getByte((int)opacity); return(col.ToString()); } catch (Exception ex) { Utilities.OnError(Utilities.GetCurrentMethod(), ex); return(colour); } }
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); }
private void SelectAddComboBoxItem(ComboBox comboBox, Color color) { if (!_colors.ContainsValue(color)) { _colors.Add(color.ToString(), color); } int count = comboBox.Items.Count; for (int i = 0; i < count; i++) { KeyValuePair <string, Color> item = (KeyValuePair <string, Color>)comboBox.Items[i]; if (item.Value == color) { comboBox.SelectedIndex = i; return; } } }
public static string StringFromColor(Color c) { return c.ToString().Substring(1); }
private void SetBgColor(Color color) { RegUtil.CreateRegKey("BgColor", color.ToString()); MainGrid.Background = new SolidColorBrush(color); }
public static string ConvertToName(Color originalColor) { if (ColourTable.ContainsKey(originalColor.ToString().Substring(3))) return ColourTable[originalColor.ToString().Substring(3)].ToLower(); var outputString = ""; int A = Convert.ToInt32(originalColor.A); int R = Convert.ToInt32(originalColor.R); int G = Convert.ToInt32(originalColor.G); int B = Convert.ToInt32(originalColor.B); string primaryColour; if (R == 0 && G == 0 && B == 0) return "black"; if (R == 255 && G == 255 && B == 255) return "white"; if (R + G + B > 511) outputString += "light "; else if (R + G + B < 255) outputString += "dark "; if (R > G && R > B) primaryColour = "Red"; else if (G > B && G > R) primaryColour = "Green"; else if (B > G && B > R) primaryColour = "Blue"; else if (R == B && R > G) primaryColour = "Purple"; else if (G == R && G > B) primaryColour = "Yellow"; else if (B == G && B > R) primaryColour = "Cyan"; else primaryColour = "Grey"; switch (primaryColour) { case "Red": if (isRoughlyGreater(G, B)) outputString += "greenish "; else if (isRoughlyGreater(B, G)) outputString += "blueish "; outputString += "red"; break; case "Green": if (isRoughlyGreater(R, B)) outputString += "reddish "; else if (isRoughlyGreater(B, R)) outputString += "blueish "; outputString += "green"; break; case "Blue": if (isRoughlyGreater(G, R)) outputString += "greenish "; else if (isRoughlyGreater(R, G)) outputString += "reddish "; outputString += "blue"; break; case "Purple": if (R - G < 100) outputString += "greenish "; outputString += "purple"; break; case "Yellow": if (B - R < 100) outputString += "orangish "; outputString += "yellow"; break; case "Cyan": if (G - R < 100) outputString += "reddish "; outputString += "cyan"; break; case "Grey": outputString += "grey"; break; } return outputString; }
public void ToStringIFormatProvider () { Color c = new Color (); c.A = 1; c.R = 2; c.G = 3; c.B = 4; ColorFormatter.CallCount = 0; Assert.AreEqual ("#01020304", c.ToString (null), "null"); Assert.AreEqual (0, ColorFormatter.CallCount, "CallCount-a"); Assert.AreEqual ("#[1][2][3][4]", c.ToString (new ColorFormatter ()), "ColorFormatter"); // 4 times for each byte Assert.AreEqual (4, ColorFormatter.CallCount, "CallCount"); }
// todo move into a different file public static String GetSystemColorValue(System.Windows.Media.Color color) { return(color.ToString()); }
public MainPageViewModel(INavigationService n) { // XNA stuff for media control GameTimer gameTimer = new GameTimer(); gameTimer.UpdateInterval = TimeSpan.FromMilliseconds(33); gameTimer.Update += delegate { try { FrameworkDispatcher.Update(); } catch { } }; gameTimer.Start(); // navigation service this.navigationService = n; // event handlers MediaPlayer.ActiveSongChanged += new EventHandler<EventArgs>(SongChanged); MediaPlayer.MediaStateChanged += new EventHandler<EventArgs>(StateChanged); FrameworkDispatcher.Update(); currentAccentColorHex = (System.Windows.Media.Color)Application.Current.Resources["PhoneAccentColor"]; if (MediaPlayer.GameHasControl) { MessageBox.Show(AppResources.TurnMusicOnLongWP7); IsEnabled = false; } else { IsEnabled = true; NextSongBackground = currentAccentColorHex.ToString(); UpdateView(); } }
public void Highlight(Card card, Color? color) { //Log.Info("[ProtOut] Highlight"); if(Program.Client == null)return; MemoryStream stream = new MemoryStream(512); stream.Seek(4, SeekOrigin.Begin); BinaryWriter writer = new BinaryWriter(stream); if (Program.Client.Muted != 0) writer.Write(Program.Client.Muted); else writer.Write(0); writer.Write((byte)43); writer.Write(card.Id); writer.Write(color == null ? "" : color.ToString()); writer.Flush(); writer.Seek(0, SeekOrigin.Begin); writer.Write((int)stream.Length); writer.Close(); Send(stream.ToArray()); }
public static void CreateAppStyleBy(System.Windows.Media.Color color, bool changeImmediately = false) { // create a runtime accent resource dictionary var resourceDictionary = new ResourceDictionary(); resourceDictionary.Add("HighlightColor", color); resourceDictionary.Add("AccentBaseColor", 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", GetSolidColorBrush((Color)resourceDictionary["HighlightColor"])); resourceDictionary.Add("AccentBaseColorBrush", GetSolidColorBrush((Color)resourceDictionary["AccentBaseColor"])); resourceDictionary.Add("AccentColorBrush", GetSolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("AccentColorBrush2", GetSolidColorBrush((Color)resourceDictionary["AccentColor2"])); resourceDictionary.Add("AccentColorBrush3", GetSolidColorBrush((Color)resourceDictionary["AccentColor3"])); resourceDictionary.Add("AccentColorBrush4", GetSolidColorBrush((Color)resourceDictionary["AccentColor4"])); resourceDictionary.Add("WindowTitleColorBrush", GetSolidColorBrush((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", GetSolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("RightArrowFill", GetSolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("IdealForegroundColor", IdealTextColor(color)); resourceDictionary.Add("IdealForegroundColorBrush", GetSolidColorBrush((Color)resourceDictionary["IdealForegroundColor"])); resourceDictionary.Add("IdealForegroundDisabledBrush", GetSolidColorBrush((Color)resourceDictionary["IdealForegroundColor"], 0.4)); resourceDictionary.Add("AccentSelectedColorBrush", GetSolidColorBrush((Color)resourceDictionary["IdealForegroundColor"])); resourceDictionary.Add("MetroDataGrid.HighlightBrush", GetSolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("MetroDataGrid.HighlightTextBrush", GetSolidColorBrush((Color)resourceDictionary["IdealForegroundColor"])); resourceDictionary.Add("MetroDataGrid.MouseOverHighlightBrush", GetSolidColorBrush((Color)resourceDictionary["AccentColor3"])); resourceDictionary.Add("MetroDataGrid.FocusBorderBrush", GetSolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("MetroDataGrid.InactiveSelectionHighlightBrush", GetSolidColorBrush((Color)resourceDictionary["AccentColor2"])); resourceDictionary.Add("MetroDataGrid.InactiveSelectionHighlightTextBrush", GetSolidColorBrush((Color)resourceDictionary["IdealForegroundColor"])); resourceDictionary.Add("MahApps.Metro.Brushes.ToggleSwitchButton.OnSwitchBrush.Win10", GetSolidColorBrush((Color)resourceDictionary["AccentColor"])); resourceDictionary.Add("MahApps.Metro.Brushes.ToggleSwitchButton.OnSwitchMouseOverBrush.Win10", GetSolidColorBrush((Color)resourceDictionary["AccentColor2"])); resourceDictionary.Add("MahApps.Metro.Brushes.ToggleSwitchButton.ThumbIndicatorCheckedBrush.Win10", GetSolidColorBrush((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")); // detect current application theme Tuple <AppTheme, Accent> applicationTheme = ThemeManager.DetectAppStyle(application); ThemeManager.ChangeAppStyle(application, newAccent, applicationTheme.Item1); } }
/// <summary> /// The update controls. /// </summary> /// <param name="color"> /// The color. /// </param> /// <param name="hsv"> /// The hsv. /// </param> /// <param name="rgb"> /// The rgb. /// </param> /// <param name="predifined"> /// The predifined. /// </param> private void UpdateControls(Color color, bool hsv, bool rgb, bool predifined) { if (this.Updating) { return; } try { this.BeginUpdate(); // HSV if (hsv) { double h = ColorHelper.GetHSV_H(color); double s = ColorHelper.GetHSV_S(color); double v = ColorHelper.GetHSV_V(color); this.sliderHSV.Value = h; this.gradientStopHSVColor.Color = ColorHelper.HSV2RGB(h, 1d, 1d); double x = s * (this.rectangleHSV.ActualWidth - 1); double y = (1 - v) * (this.rectangleHSV.ActualHeight - 1); this.ellipseHSV.SetValue(Canvas.LeftProperty, x - this.ellipseHSV.ActualWidth / 2); this.ellipseHSV.SetValue(Canvas.TopProperty, y - this.ellipseHSV.ActualHeight / 2); } if (rgb) { byte a = color.A; byte r = color.R; byte g = color.G; byte b = color.B; this.sliderA.Value = a; this.gradientStopA0.Color = Color.FromArgb(0, r, g, b); this.gradientStopA1.Color = Color.FromArgb(255, r, g, b); this.textBoxA.Text = a.ToString("X2"); this.sliderR.Value = r; this.gradientStopR0.Color = Color.FromArgb(255, 0, g, b); this.gradientStopR1.Color = Color.FromArgb(255, 255, g, b); this.textBoxR.Text = r.ToString("X2"); this.sliderG.Value = g; this.gradientStopG0.Color = Color.FromArgb(255, r, 0, b); this.gradientStopG1.Color = Color.FromArgb(255, r, 255, b); this.textBoxG.Text = g.ToString("X2"); this.sliderB.Value = b; this.gradientStopB0.Color = Color.FromArgb(255, r, g, 0); this.gradientStopB1.Color = Color.FromArgb(255, r, g, 255); this.textBoxB.Text = b.ToString("X2"); } if (predifined) { this.brushColor.Color = color; if (this.dictionaryColor.ContainsKey(color)) { this.comboBoxColor.SelectedItem = this.dictionaryColor[color]; this.textBoxColor.Text = string.Empty; } else { this.comboBoxColor.SelectedItem = null; this.textBoxColor.Text = color.ToString(); } } this.Color = color; } finally { this.EndUpdate(); } }
internal void RaiseValueChangedAutomationEvent(Color oldColor, Color newColor) { base.RaisePropertyChangedEvent(ValuePatternIdentifiers.ValueProperty, oldColor.ToString(), newColor.ToString()); }
public static string GetColorName(Color colorToSeek) { return MColorNames.ContainsKey(colorToSeek) ? MColorNames[colorToSeek] : colorToSeek.ToString(); }
public static SolidColorBrush ToBrush(this System.Windows.Media.Color input) { return((SolidColorBrush) new BrushConverter().ConvertFromString(input.ToString())); }
private void CalculateColor(Point p) { HsvColor hsv = new HsvColor(360 - _spectrumSlider.Value, 1, 1) { S = p.X, V = 1 - p.Y }; var currentColor = ColorUtilities.ConvertHsvToRgb(hsv.H, hsv.S, hsv.V); currentColor.A = A; SelectedColor = currentColor; HexadecimalString = SelectedColor.ToString(); }
public void Highlight(Card card, Color? color) { StringBuilder sb = new StringBuilder(); XmlWriter writer = XmlWriter.Create(sb, xmlSettings); writer.WriteStartElement("Highlight"); if (Script.ScriptEngine.CurrentScript != null && Script.ScriptEngine.CurrentScript.muted) writer.WriteAttributeString("muted", Script.ScriptEngine.CurrentScript.GetUniqueId().ToString(CultureInfo.InvariantCulture)); else if (Program.Client.Muted != 0) writer.WriteAttributeString("muted", Program.Client.Muted.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("card", card.Id.ToString(CultureInfo.InvariantCulture)); writer.WriteElementString("color", color == null ? "" : color.ToString()); writer.WriteEndElement(); writer.Close(); Send(sb.ToString()); }
public void Update(Color newColor) { _textBox.Text = newColor.ToString(); }
/// <summary> /// Choose board setting /// </summary> private void ChooseBoardSetting() { frmBoardSetting frm; Properties.Settings settings; frm = new frmBoardSetting(m_chessCtl.LiteCellColor, m_chessCtl.DarkCellColor, m_chessCtl.WhitePieceColor, m_chessCtl.BlackPieceColor, m_colorBackground, m_listPieceSet, PieceSet); frm.Owner = this; if (frm.ShowDialog() == true) { m_colorBackground = frm.BackgroundColor; Background = new SolidColorBrush(m_colorBackground); m_chessCtl.LiteCellColor = frm.LiteCellColor; m_chessCtl.DarkCellColor = frm.DarkCellColor; m_chessCtl.WhitePieceColor = frm.WhitePieceColor; m_chessCtl.BlackPieceColor = frm.BlackPieceColor; PieceSet = frm.PieceSet; settings = Properties.Settings.Default; settings.PieceSet = PieceSet.Name; settings.WhitePieceColor = m_chessCtl.WhitePieceColor.ToString(); settings.BlackPieceColor = m_chessCtl.BlackPieceColor.ToString(); settings.LiteCellColor = m_chessCtl.LiteCellColor.ToString(); settings.DarkCellColor = m_chessCtl.DarkCellColor.ToString(); settings.BackgroundColor = m_colorBackground.ToString(); settings.Save(); } }
/// <summary> /// Calculates the value this animation believes should be the current value for the property. /// </summary> /// <param name="defaultOriginValue"> /// This value is the suggested origin value provided to the animation /// to be used if the animation does not have its own concept of a /// start value. If this animation is the first in a composition chain /// this value will be the snapshot value if one is available or the /// base property value if it is not; otherise this value will be the /// value returned by the previous animation in the chain with an /// animationClock that is not Stopped. /// </param> /// <param name="defaultDestinationValue"> /// This value is the suggested destination value provided to the animation /// to be used if the animation does not have its own concept of an /// end value. This value will be the base value if the animation is /// in the first composition layer of animations on a property; /// otherwise this value will be the output value from the previous /// composition layer of animations for the property. /// </param> /// <param name="animationClock"> /// This is the animationClock which can generate the CurrentTime or /// CurrentProgress value to be used by the animation to generate its /// output value. /// </param> /// <returns> /// The value this animation believes should be the current value for the property. /// </returns> protected override Color GetCurrentValueCore(Color defaultOriginValue, Color defaultDestinationValue, AnimationClock animationClock) { Debug.Assert(animationClock.CurrentState != ClockState.Stopped); if (!_isAnimationFunctionValid) { ValidateAnimationFunction(); } double progress = animationClock.CurrentProgress.Value; IEasingFunction easingFunction = EasingFunction; if (easingFunction != null) { progress = easingFunction.Ease(progress); } Color from = new Color(); Color to = new Color(); Color accumulated = new Color(); Color foundation = new Color(); // need to validate the default origin and destination values if // the animation uses them as the from, to, or foundation values bool validateOrigin = false; bool validateDestination = false; switch(_animationType) { case AnimationType.Automatic: from = defaultOriginValue; to = defaultDestinationValue; validateOrigin = true; validateDestination = true; break; case AnimationType.From: from = _keyValues[0]; to = defaultDestinationValue; validateDestination = true; break; case AnimationType.To: from = defaultOriginValue; to = _keyValues[0]; validateOrigin = true; break; case AnimationType.By: // According to the SMIL specification, a By animation is // always additive. But we don't force this so that a // user can re-use a By animation and have it replace the // animations that precede it in the list without having // to manually set the From value to the base value. to = _keyValues[0]; foundation = defaultOriginValue; validateOrigin = true; break; case AnimationType.FromTo: from = _keyValues[0]; to = _keyValues[1]; if (IsAdditive) { foundation = defaultOriginValue; validateOrigin = true; } break; case AnimationType.FromBy: from = _keyValues[0]; to = AnimatedTypeHelpers.AddColor(_keyValues[0], _keyValues[1]); if (IsAdditive) { foundation = defaultOriginValue; validateOrigin = true; } break; default: Debug.Fail("Unknown animation type."); break; } if (validateOrigin && !AnimatedTypeHelpers.IsValidAnimationValueColor(defaultOriginValue)) { throw new InvalidOperationException( SR.Get( SRID.Animation_Invalid_DefaultValue, this.GetType(), "origin", defaultOriginValue.ToString(CultureInfo.InvariantCulture))); } if (validateDestination && !AnimatedTypeHelpers.IsValidAnimationValueColor(defaultDestinationValue)) { throw new InvalidOperationException( SR.Get( SRID.Animation_Invalid_DefaultValue, this.GetType(), "destination", defaultDestinationValue.ToString(CultureInfo.InvariantCulture))); } if (IsCumulative) { double currentRepeat = (double)(animationClock.CurrentIteration - 1); if (currentRepeat > 0.0) { Color accumulator = AnimatedTypeHelpers.SubtractColor(to, from); accumulated = AnimatedTypeHelpers.ScaleColor(accumulator, currentRepeat); } } // return foundation + accumulated + from + ((to - from) * progress) return AnimatedTypeHelpers.AddColor( foundation, AnimatedTypeHelpers.AddColor( accumulated, AnimatedTypeHelpers.InterpolateColor(from, to, progress))); }
private string GetFormatedColorString( Color colorToFormat ) { return ColorUtilities.FormatColorString( colorToFormat.ToString(), UsingAlphaChannel ); }
private void determineColor(Point p) { HsvColor hsv = new HsvColor(360 - m_ColorSlider.Value, 1, 1); hsv.S = p.X; hsv.V = 1 - p.Y; m_color = ColorUtilities.ConvertHsvToRgb(hsv.H, hsv.S, hsv.V); shouldFindPoint = false; m_color.ScA = (float)GetValue(ScAProperty); SetValue(HexadecimalStringProperty, m_color.ToString()); shouldFindPoint = true; }
public static bool IsPredefined(Color color) { Initialize(); string code = color.ToString(); return dictionaryColors.ContainsKey(code); }