Color selector
This commit is contained in:
parent
f038c63718
commit
a3a721af32
6 changed files with 81 additions and 20 deletions
59
WPFCatalog/Converters/MaddoColorConverter.cs
Normal file
59
WPFCatalog/Converters/MaddoColorConverter.cs
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace WPFCatalog
|
||||
{
|
||||
public class MaddoColorConverter : IValueConverter
|
||||
{
|
||||
private DependencyObject _dummy = new DependencyObject();
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
Color color = Colors.Black;
|
||||
|
||||
if (value != null && value != DependencyProperty.UnsetValue && value is string && !String.IsNullOrWhiteSpace((string)value))
|
||||
{
|
||||
string c = (string)value;
|
||||
object convertedColor = null;
|
||||
try
|
||||
{
|
||||
convertedColor = ColorConverter.ConvertFromString(c);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!DesignerProperties.GetIsInDesignMode(_dummy))
|
||||
{
|
||||
throw new FormatException($"String {c} does not represent a valid color", ex);
|
||||
}
|
||||
}
|
||||
if (convertedColor != null)
|
||||
{
|
||||
color = (Color)convertedColor;
|
||||
}
|
||||
}
|
||||
|
||||
return color;
|
||||
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
Color color = (Color)value;
|
||||
Debug.WriteLine(color.ToString());
|
||||
return color.ToString();
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@
|
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:wpfCatalog="clr-namespace:WPFCatalog"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
mc:Ignorable="d"
|
||||
|
||||
Title="Image Catalog" Height="466" Width="772"
|
||||
|
|
@ -19,15 +20,14 @@
|
|||
<Setter Property="Margin" Value="2,2,5,5" />
|
||||
</Style>
|
||||
<Style TargetType="ComboBox" BasedOn="{StaticResource CommonStyle}"></Style>
|
||||
<wpfCatalog:FontFamilyStringConverter x:Key="FontFamilyConverter"></wpfCatalog:FontFamilyStringConverter>
|
||||
<wpfCatalog:FontFamilyStringConverter x:Key="FontFamilyConverter" />
|
||||
<wpfCatalog:MaddoColorConverter x:Key="ColorConverter" />
|
||||
</Window.Resources>
|
||||
<DockPanel LastChildFill="True">
|
||||
<Menu DockPanel.Dock="Top" Height="auto">
|
||||
<MenuItem Header="Files"/>
|
||||
<MenuItem Header="Modifica"></MenuItem>
|
||||
<MenuItem Header="?"></MenuItem>
|
||||
|
||||
|
||||
</Menu>
|
||||
<StatusBar DockPanel.Dock="Bottom" Height="auto">
|
||||
<StatusBarItem>
|
||||
|
|
@ -236,8 +236,9 @@
|
|||
|
||||
<Label Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2" Content="Colore RGB" />
|
||||
|
||||
<TextBox Grid.Row="3" Grid.Column="2" Text="{Binding CarattereColoreRGB}"/>
|
||||
<Button Grid.Row="3" Grid.Column="3" Content="Scegli..." />
|
||||
<xctk:ColorPicker Grid.Row="3" Grid.Column="2" SelectedColor="{Binding ColoreTestoRGB, Converter={StaticResource ColorConverter}}"/>
|
||||
|
||||
<!--<Button Grid.Row="3" Grid.Column="3" Content="Scegli..." />-->
|
||||
|
||||
|
||||
</Grid>
|
||||
|
|
|
|||
|
|
@ -688,7 +688,7 @@ namespace WPFCatalog
|
|||
|
||||
public string ColoreTestoRGB
|
||||
{
|
||||
get { return PicSettings.GetString("coloreTestoRGB"); }
|
||||
get { return PicSettings.GetString("coloreTestoRGB", "#000000"); }
|
||||
set
|
||||
{
|
||||
PicSettings.Set("coloreTestoRGB", value);
|
||||
|
|
|
|||
|
|
@ -75,23 +75,23 @@
|
|||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="Xceed.Wpf.AvalonDock">
|
||||
<HintPath>..\packages\Extended.Wpf.Toolkit.2.1.0\lib\net40\Xceed.Wpf.AvalonDock.dll</HintPath>
|
||||
<Reference Include="Xceed.Wpf.AvalonDock, Version=3.0.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Extended.Wpf.Toolkit.3.0\lib\net40\Xceed.Wpf.AvalonDock.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Aero">
|
||||
<HintPath>..\packages\Extended.Wpf.Toolkit.2.1.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll</HintPath>
|
||||
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Aero, Version=3.0.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Extended.Wpf.Toolkit.3.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Metro">
|
||||
<HintPath>..\packages\Extended.Wpf.Toolkit.2.1.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll</HintPath>
|
||||
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Metro, Version=3.0.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Extended.Wpf.Toolkit.3.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xceed.Wpf.AvalonDock.Themes.VS2010">
|
||||
<HintPath>..\packages\Extended.Wpf.Toolkit.2.1.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll</HintPath>
|
||||
<Reference Include="Xceed.Wpf.AvalonDock.Themes.VS2010, Version=3.0.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Extended.Wpf.Toolkit.3.0\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xceed.Wpf.DataGrid">
|
||||
<HintPath>..\packages\Extended.Wpf.Toolkit.2.1.0\lib\net40\Xceed.Wpf.DataGrid.dll</HintPath>
|
||||
<Reference Include="Xceed.Wpf.DataGrid, Version=3.0.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Extended.Wpf.Toolkit.3.0\lib\net40\Xceed.Wpf.DataGrid.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Xceed.Wpf.Toolkit">
|
||||
<HintPath>..\packages\Extended.Wpf.Toolkit.2.1.0\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath>
|
||||
<Reference Include="Xceed.Wpf.Toolkit, Version=3.0.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Extended.Wpf.Toolkit.3.0\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
@ -99,7 +99,8 @@
|
|||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="FontFamilyStringConverter.cs" />
|
||||
<Compile Include="Converters\MaddoColorConverter.cs" />
|
||||
<Compile Include="Converters\FontFamilyStringConverter.cs" />
|
||||
<Compile Include="Messages\FontData.cs" />
|
||||
<Compile Include="Messages\OpenFontWindowMessage.cs" />
|
||||
<Compile Include="ViewModelBase.cs" />
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="CommonServiceLocator" version="1.0" targetFramework="net45" />
|
||||
<package id="Extended.Wpf.Toolkit" version="2.1.0" targetFramework="net45" />
|
||||
<package id="Extended.Wpf.Toolkit" version="3.0" targetFramework="net46" />
|
||||
<package id="MvvmLight" version="4.1.27.1" targetFramework="net45" />
|
||||
<package id="MvvmLightLibs" version="4.1.27.1" targetFramework="net45" />
|
||||
</packages>
|
||||
Loading…
Add table
Add a link
Reference in a new issue