-
Notifications
You must be signed in to change notification settings - Fork 1
/
FontEditor.cs
76 lines (65 loc) · 1.94 KB
/
FontEditor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Creato da SharpDevelop.
* Utente: Family Rose
* Data: 01/02/2009
* Ora: 21.02
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using System.Drawing;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
namespace mkdb
{
public class wxFont : wx.Font
{
public wxFont()
{
}
public wxFont(string name, int size)
{
this.FaceName = name;
this.PointSize = size;
}
public override string ToString()
{
return this.FaceName + "; " + this.PointSize + "pt";
}
}
public class wxFontEditor : UITypeEditor
{
public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
{
// We will use a window for property editing.
return UITypeEditorEditStyle.Modal;
}
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
if (context == null || context.Instance == null || provider == null)
return value;
wxFont wfnt = (wxFont)value;
wx.FontData fntdata = new wx.FontData();
fntdata.InitialFont = wfnt;
wx.FontDialog fntdialog = new wx.FontDialog(null, fntdata);
fntdialog.Font = wfnt;
if (fntdialog.ShowModal() != wx.Dialog.wxCANCEL)
{
wx.FontData rfd = fntdialog.FontData;
wxFont retfont = new wxFont();
retfont.Family = rfd.ChosenFont.Family;
retfont.FaceName = rfd.ChosenFont.FaceName;
retfont.Encoding = rfd.ChosenFont.Encoding;
retfont.PointSize = rfd.ChosenFont.PointSize;
retfont.Style = rfd.ChosenFont.Style;
return retfont;
}
return value;
}
}
}