Font picker

This commit is contained in:
Maddo 2017-03-17 16:23:29 +01:00
commit f038c63718
9 changed files with 289 additions and 51 deletions

View file

@ -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
});
}
}
}
}