/// <summary> /// Creates a color picker control with data binding. /// </summary> /// <param name="d">The cell definition.</param> /// <returns> /// A color picker. /// </returns> protected virtual FrameworkElement CreateColorPickerControl(CellDefinition d) { var c = new ColorPicker { VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Stretch, Focusable = false }; c.SetBinding(ColorPicker.SelectedColorProperty, this.CreateBinding(d)); this.SetIsEnabledBinding(d, c); this.SetBackgroundBinding(d, c); return c; }
/// <summary> /// Stores the palette. /// </summary> /// <param name="picker">The picker.</param> /// <param name="path">The path.</param> public void StorePalette( ColorPicker picker, string path ) { // Write the colors as text StringBuilder sb = new StringBuilder(); foreach( ColorWrapper cw in picker.PersistentPalette ) { sb.AppendFormat( "{0}\n", cw.Color.ToString( CultureInfo.InvariantCulture ) ); } File.WriteAllText( path, sb.ToString(), Encoding.UTF8 ); StoreLastUsedPalette( path ); }
/// <summary> /// Loads the palette. /// </summary> /// <param name="picker">The picker.</param> /// <param name="path">The path.</param> public void LoadPalette( ColorPicker picker, string path ) { string s = File.ReadAllText( path, Encoding.UTF8 ); string[] colors = s.Split( new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries ); StoreLastUsedPalette( path ); ObservableCollection<ColorWrapper> palette = new ObservableCollection<ColorWrapper>(); foreach( string c in colors ) { try { Color color = (Color)ColorConverter.ConvertFromString( c ); palette.Add( new ColorWrapper( color ) ); } catch { // Silently ignore } } picker.PersistentPalette = palette.Count > 0 ? palette : CreateEmptyPalette(); }
/// <summary> /// Creates the color control. /// </summary> /// <param name="property">The property.</param> /// <returns> /// The control. /// </returns> protected virtual FrameworkElement CreateColorControl(PropertyItem property) { var c = new ColorPicker(); c.SetBinding(ColorPicker.SelectedColorProperty, property.CreateBinding()); return c; }
/// <summary> /// Creates a color picker control with data binding. /// </summary> /// <param name="propertyDefinition">The property definition.</param> /// <param name="bindingPath">The binding path.</param> /// <returns> /// A color picker. /// </returns> protected virtual FrameworkElement CreateColorPickerControl(PropertyDefinition propertyDefinition, string bindingPath) { var c = new ColorPicker { VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Stretch, Focusable = false }; c.SetBinding(ColorPicker.SelectedColorProperty, propertyDefinition.CreateBinding(bindingPath)); return c; }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.buttonQuery = ((System.Windows.Controls.Button)(target)); #line 36 "..\..\BaiduIndex.xaml" this.buttonQuery.Click += new System.Windows.RoutedEventHandler(this.btQuery); #line default #line hidden return; case 2: this.buttonExport = ((System.Windows.Controls.Button)(target)); #line 37 "..\..\BaiduIndex.xaml" this.buttonExport.Click += new System.Windows.RoutedEventHandler(this.btExport); #line default #line hidden return; case 3: this.wheel = ((Hammer.SpinningWheel.SpinningWheel)(target)); return; case 4: this.wtKey = ((Xceed.Wpf.Toolkit.WatermarkTextBox)(target)); return; case 5: #line 66 "..\..\BaiduIndex.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.BlueSkinClick); #line default #line hidden return; case 6: #line 67 "..\..\BaiduIndex.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.SilverSkinClick); #line default #line hidden return; case 7: #line 68 "..\..\BaiduIndex.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.BlackSkinClick); #line default #line hidden return; case 8: #line 75 "..\..\BaiduIndex.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btDefaultThemes); #line default #line hidden return; case 9: #line 80 "..\..\BaiduIndex.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btSystemThemes); #line default #line hidden return; case 10: #line 83 "..\..\BaiduIndex.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btMediaThemes); #line default #line hidden return; case 11: this.cp = ((PropertyTools.Wpf.ColorPicker)(target)); return; case 12: #line 92 "..\..\BaiduIndex.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.btForeground); #line default #line hidden return; case 13: this.gauge = ((WpfGauge.Gauge)(target)); return; case 14: this.edgResult = ((ExtendedGrid.ExtendedGridControl.ExtendedDataGrid)(target)); return; } this._contentLoaded = true; }