Font picker
This commit is contained in:
parent
1ac753e6ff
commit
f038c63718
9 changed files with 289 additions and 51 deletions
30
WPFCatalog/FontFamilyStringConverter.cs
Normal file
30
WPFCatalog/FontFamilyStringConverter.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace WPFCatalog
|
||||
{
|
||||
public class FontFamilyStringConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
FontFamily fontfamily = new FontFamily("Verdana");
|
||||
if (value != null)
|
||||
{
|
||||
fontfamily = new FontFamily(value.ToString());
|
||||
}
|
||||
return fontfamily;
|
||||
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
<Setter Property="Margin" Value="2,2,5,5" />
|
||||
</Style>
|
||||
<Style TargetType="ComboBox" BasedOn="{StaticResource CommonStyle}"></Style>
|
||||
|
||||
<wpfCatalog:FontFamilyStringConverter x:Key="FontFamilyConverter"></wpfCatalog:FontFamilyStringConverter>
|
||||
</Window.Resources>
|
||||
<DockPanel LastChildFill="True">
|
||||
<Menu DockPanel.Dock="Top" Height="auto">
|
||||
|
|
@ -179,7 +179,7 @@
|
|||
<Slider Grid.Column="0" Orientation="Horizontal" Maximum="100" Minimum="0" Value="{Binding CompressioneJpeg}"></Slider>
|
||||
<TextBlock Grid.Column="1" Text="{Binding CompressioneJpeg}"></TextBlock>
|
||||
</Grid>
|
||||
|
||||
|
||||
|
||||
<CheckBox Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,16,0,17.88" IsChecked="{Binding FotoMantieniDimensioni}"/>
|
||||
<TextBlock Grid.Row="3" Grid.Column="2" Text="Mantieni Dimensioni Originali" TextWrapping="WrapWithOverflow" Width="80" Margin="4,0,4,25.88" Grid.RowSpan="2" />
|
||||
|
|
@ -216,13 +216,20 @@
|
|||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Row="0" Grid.Column="0" Content="Font"/>
|
||||
<ComboBox Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" Width="100" HorizontalAlignment="Right" SelectedItem="{Binding CarattereFont}" />
|
||||
<!--todo-->
|
||||
<!--<ComboBox Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" Width="100" HorizontalAlignment="Right" SelectedItem="{Binding CarattereFont}" x:Name="cmbFont" />-->
|
||||
<TextBox Grid.Row="0" Grid.Column="2"
|
||||
Width="100"
|
||||
IsReadOnly="True"
|
||||
FontFamily="{Binding FontName, Converter={StaticResource FontFamilyConverter}, Mode=OneWay}"
|
||||
Text="{Binding FontName}"
|
||||
></TextBox>
|
||||
<!---->
|
||||
|
||||
<CheckBox Grid.Row="0" Grid.Column="3" Content="Grassetto" VerticalAlignment="Center" IsChecked="{Binding CarattereGrassetto}" />
|
||||
<!--<CheckBox Grid.Row="0" Grid.Column="3" Content="Grassetto" VerticalAlignment="Center" IsChecked="{Binding CarattereGrassetto}" />-->
|
||||
<Button Grid.Row="0" Grid.Column="3" Content="Scegli" Command="{Binding PickFontCommand}"></Button>
|
||||
|
||||
<Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Content="Dimensione"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="2" Text="{Binding CarattereDimensione}"/>
|
||||
<TextBox Grid.Row="1" Grid.Column="2" Text="{Binding FontSize}"/>
|
||||
|
||||
<Label Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Content="Dimensione Miniatura"/>
|
||||
<TextBox Grid.Row="2" Grid.Column="2" Text="{Binding CarattereDimensioneMiniatura}"/>
|
||||
|
|
|
|||
|
|
@ -7,12 +7,16 @@ using System.Windows;
|
|||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using CatalogLib;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
using MaddoLibrary.Helpers;
|
||||
using WPFCatalog.Messages;
|
||||
|
||||
namespace WPFCatalog
|
||||
{
|
||||
|
|
@ -29,12 +33,38 @@ namespace WPFCatalog
|
|||
DataContext = new MainWindowViewModel();
|
||||
|
||||
SetDefaults();
|
||||
|
||||
//((MainWindowViewModel) DataContext).
|
||||
Messenger.Default.Register<OpenFontWindowMessage>(this, OpenFonts);
|
||||
}
|
||||
|
||||
private void SetDefaults()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void OpenFonts(OpenFontWindowMessage message)
|
||||
{
|
||||
FontDialog fd = new FontDialog();
|
||||
System.Windows.Forms.DialogResult dr = fd.ShowDialog();
|
||||
if (dr != System.Windows.Forms.DialogResult.Cancel)
|
||||
{
|
||||
//DialogHelper.PopUpMessage(fd.Font.Name);
|
||||
//cmbFont.Text = fd.Font.Name;
|
||||
//tbSomeText.FontFamily = new System.Windows.Media.FontFamily(fd.Font.Name);
|
||||
//tbSomeText.FontSize = fd.Font.Size * 96.0 / 72.0;
|
||||
//tbSomeText.FontWeight = fd.Font.Bold ? FontWeights.Bold : FontWeights.Regular;
|
||||
//tbSomeText.FontStyle = fd.Font.Italic ? FontStyles.Italic : FontStyles.Normal;
|
||||
|
||||
message.Callback(new FontData()
|
||||
{
|
||||
Name = fd.Font.Name,
|
||||
Size = Math.Round(fd.Font.Size) /* 96.0 / 72.0*/,
|
||||
Bold = fd.Font.Bold,
|
||||
Italic = fd.Font.Italic
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using System.Threading.Tasks;
|
|||
using CatalogLib;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using MaddoLibrary.Helpers;
|
||||
using WPFCatalog.Messages;
|
||||
|
||||
namespace WPFCatalog
|
||||
{
|
||||
|
|
@ -39,7 +40,8 @@ namespace WPFCatalog
|
|||
public RelayCommand OpenDestinationFolderCommand { get; private set; }
|
||||
|
||||
public RelayCommand StartCommand { get; private set; }
|
||||
|
||||
|
||||
public RelayCommand PickFontCommand { get; private set; }
|
||||
|
||||
private void RegisterCommands()
|
||||
{
|
||||
|
|
@ -53,16 +55,36 @@ namespace WPFCatalog
|
|||
OpenDestinationFolderCommand = new RelayCommand(OpenDestinationFolder);
|
||||
|
||||
StartCommand = new RelayCommand(Start);
|
||||
|
||||
PickFontCommand = new RelayCommand(PickFont);
|
||||
}
|
||||
|
||||
private void PickFont()
|
||||
{
|
||||
//FontData d = null;
|
||||
MessengerInstance.Send<OpenFontWindowMessage>(new OpenFontWindowMessage((ayy) =>
|
||||
{
|
||||
this.FontName = ayy.Name;
|
||||
this.FontSize = ayy.Size;
|
||||
//d = ayy;
|
||||
}));
|
||||
//if (d != null)
|
||||
//{
|
||||
// FontName = d.Name;
|
||||
//}
|
||||
|
||||
//string s = d.Name;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
//var files = Directory.GetFiles(PicSettings.DirectorySorgente);
|
||||
|
||||
|
||||
// todo folder mode
|
||||
|
||||
foreach (var file in Directory.EnumerateFiles(PicSettings.DirectorySorgente))
|
||||
{
|
||||
IImageProcessor i = new ImgSharpCreator();
|
||||
|
||||
|
||||
//ImageCreator2 i = new ImageCreator2();
|
||||
i.Start(new FileInfo(file));
|
||||
}
|
||||
|
|
@ -649,6 +671,21 @@ namespace WPFCatalog
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Testo
|
||||
|
||||
public bool EnableText
|
||||
{
|
||||
get { return PicSettings.EnableText; }
|
||||
set { PicSettings.EnableText = value; RaisePropertyChanged("EnableText"); }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public string ColoreTestoRGB
|
||||
{
|
||||
get { return PicSettings.GetString("coloreTestoRGB"); }
|
||||
|
|
@ -659,23 +696,39 @@ namespace WPFCatalog
|
|||
}
|
||||
}
|
||||
|
||||
public string FontName
|
||||
{
|
||||
get { return PicSettings.NomeFont; }
|
||||
set
|
||||
{
|
||||
PicSettings.NomeFont = value;
|
||||
RaisePropertyChanged("FontName");
|
||||
}
|
||||
}
|
||||
|
||||
public double FontSize
|
||||
{
|
||||
get
|
||||
{
|
||||
{
|
||||
return PicSettings.DimensioneFont;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
PicSettings.DimensioneFont = value;
|
||||
RaisePropertyChanged("FontSize");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//todo: bold
|
||||
|
||||
//todo: italic
|
||||
#endregion
|
||||
|
||||
#region Testo
|
||||
#region Logo
|
||||
|
||||
public bool EnableText
|
||||
{
|
||||
get { return PicSettings.EnableText; }
|
||||
set { PicSettings.EnableText = value; RaisePropertyChanged("EnableText");}
|
||||
|
||||
}
|
||||
|
||||
public bool EnableThumbnails
|
||||
{
|
||||
get { return PicSettings.EnableThumbnails; }
|
||||
set { PicSettings.EnableThumbnails = value; RaisePropertyChanged("EnableThumbnails"); }
|
||||
|
||||
}
|
||||
|
||||
public bool EnableLogo
|
||||
{
|
||||
|
|
@ -686,6 +739,17 @@ namespace WPFCatalog
|
|||
|
||||
#endregion
|
||||
|
||||
#region Thumbnail
|
||||
|
||||
public bool EnableThumbnails
|
||||
{
|
||||
get { return PicSettings.EnableThumbnails; }
|
||||
set { PicSettings.EnableThumbnails = value; RaisePropertyChanged("EnableThumbnails"); }
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
17
WPFCatalog/Messages/FontData.cs
Normal file
17
WPFCatalog/Messages/FontData.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WPFCatalog.Messages
|
||||
{
|
||||
public class FontData
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public double Size { get; set; }
|
||||
public bool Bold { get; set; }
|
||||
public bool Italic { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
18
WPFCatalog/Messages/OpenFontWindowMessage.cs
Normal file
18
WPFCatalog/Messages/OpenFontWindowMessage.cs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WPFCatalog.Messages
|
||||
{
|
||||
public class OpenFontWindowMessage
|
||||
{
|
||||
public Action<FontData> Callback { get; set; }
|
||||
|
||||
public OpenFontWindowMessage(Action<FontData> calllback)
|
||||
{
|
||||
Callback = calllback;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -99,6 +99,9 @@
|
|||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="FontFamilyStringConverter.cs" />
|
||||
<Compile Include="Messages\FontData.cs" />
|
||||
<Compile Include="Messages\OpenFontWindowMessage.cs" />
|
||||
<Compile Include="ViewModelBase.cs" />
|
||||
<Compile Include="ViewModel\MainViewModel.cs" />
|
||||
<Compile Include="ViewModel\ViewModelLocator.cs" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue