public ColorPanel() { this.InitializeComponent(); Dispatcher.RunIdleAsync((s) => { if (MainBrush == null) { return; } var c = MainBrush.Color; TXT.Text = string.Format("#{0:X2}{1:X2}{2:X2}", c.R, c.G, c.B); SetValue(RProperty, c.R); SetValue(GProperty, c.G); SetValue(BProperty, c.B); MainBrush.RegisterPropertyChangedCallback(SolidColorBrush.ColorProperty, (obj, prop) => { Color cc = (Color)obj.GetValue(prop); TXT.Text = string.Format("#{0:X2}{1:X2}{2:X2}", cc.R, cc.G, cc.B); //((SolidColorBrush)TXT.Foreground).Color = Color.FromArgb(255,(byte)( 255 - cc.R),(byte)( 255 - cc.G),(byte)( 255 - cc.B)); if (!loc) { SetValue(RProperty, cc.R); SetValue(GProperty, cc.G); SetValue(BProperty, cc.B); } }); }).ToString(); }
public ColorList() { this.InitializeComponent(); Dispatcher.RunIdleAsync((s) => { if (MainBrush == null) { return; } var c = MainBrush.Color; T.Text = string.Format("#{0:X2}{1:X2}{2:X2}", c.R, c.G, c.B); MainBrush.RegisterPropertyChangedCallback(SolidColorBrush.ColorProperty, (obj, prop) => { c = (Color)obj.GetValue(prop); T.Text = string.Format("#{0:X2}{1:X2}{2:X2}", c.R, c.G, c.B); }); }).ToString(); }