Browse Source
- implemented ColorPicker - added ColorPicker to XAML option dialog git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4947 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
9 changed files with 174 additions and 69 deletions
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
<UserControl x:Class="ICSharpCode.SharpDevelop.Gui.ColorPicker" x:Name="colorPicker" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:local="clr-namespace:ICSharpCode.SharpDevelop.Gui"> |
||||
<UserControl.Resources> |
||||
<local:ColorToBrushConverter x:Key="converter" /> |
||||
</UserControl.Resources> |
||||
<Button Content="{Binding Value, ElementName=colorPicker}" |
||||
Background="{Binding Value, ElementName=colorPicker, Converter={StaticResource converter}}" |
||||
Foreground="WhiteSmoke" |
||||
Click="ButtonClick"> |
||||
<Button.Template> |
||||
<ControlTemplate TargetType="{x:Type Button}"> |
||||
<Border CornerRadius="3" BorderBrush="Black" BorderThickness="1.5" Background="{TemplateBinding Background}"> |
||||
<ContentPresenter Content="{TemplateBinding Content}" |
||||
HorizontalAlignment="Center" VerticalAlignment="Center" /> |
||||
</Border> |
||||
</ControlTemplate> |
||||
</Button.Template> |
||||
</Button> |
||||
</UserControl> |
||||
@ -0,0 +1,67 @@
@@ -0,0 +1,67 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Siegfried Pammer" email="siegfriedpammer@gmail.com" />
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Data; |
||||
using System.Windows.Documents; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui |
||||
{ |
||||
/// <summary>
|
||||
/// Interaction logic for ColorPicker.xaml
|
||||
/// </summary>
|
||||
public partial class ColorPicker : UserControl |
||||
{ |
||||
SharpDevelopColorDialog dialog; |
||||
|
||||
public static readonly DependencyProperty ValueProperty = |
||||
DependencyProperty.Register("Value", typeof(Color), typeof(ColorPicker)); |
||||
|
||||
public Color Value { |
||||
get { return (Color)GetValue(ValueProperty); } |
||||
set { SetValue(ValueProperty, value); } |
||||
} |
||||
|
||||
public ColorPicker() |
||||
{ |
||||
InitializeComponent(); |
||||
dialog = new SharpDevelopColorDialog(); |
||||
} |
||||
|
||||
void ButtonClick(object sender, RoutedEventArgs e) |
||||
{ |
||||
if (dialog.ShowWpfDialog() ?? false) { |
||||
this.Value = dialog.WpfColor; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public class ColorToBrushConverter : IValueConverter |
||||
{ |
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
||||
{ |
||||
if (value is Color) |
||||
return new SolidColorBrush((Color)value); |
||||
|
||||
throw new NotSupportedException(); |
||||
} |
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
||||
{ |
||||
if (value is SolidColorBrush) |
||||
return (value as SolidColorBrush).Color; |
||||
|
||||
throw new NotSupportedException(); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue