void ShowFontPanel() { NSFontPanel fontPanel = NSFontPanel.SharedFontPanel; fontPanel.SetPanelFont(myFont, false); fontPanel.MakeKeyAndOrderFront(this); fontPanel.Delegate = this; }
void Button_Activated(object sender, EventArgs e) { // NSFontPanelのオブジェクトを取得する NSFontPanel fontPanel = NSFontManager.SharedFontManager.FontPanel(true); // 選択されているフォントを設定する fontPanel.SetPanelFont(Label.Font, false); fontPanel.Delegate = this; // キーウィンドウにして前面に表示する fontPanel.MakeKeyAndOrderFront(this); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Do any additional setup after loading the view. Button.Activated += (sender, e) => { // NSFontPanelのオブジェクトを取得する NSFontPanel fontPanel = NSFontManager.SharedFontManager.FontPanel(true); // 選択されているフォントを設定する fontPanel.SetPanelFont(TextField.Font, false); fontPanel.Delegate = this; // キーウィンドウにして前面に表示する fontPanel.MakeKeyAndOrderFront(this); }; }
public DialogResult RunModal() { panel = NSFontManager.SharedFontManager.FontPanel(true); var prevAccessory = panel.AccessoryView; var prevDelegate = panel.Delegate; var accessoryView = new ModalFontPanelAccessoryView(); accessoryView.Initialize(panel, this); panel.AccessoryView = accessoryView; panel.Delegate = this; // Preset font: panel.SetPanelFont(owner.Font.ToNSFont(), false); //Preset color and other attributes: if (owner.Color != null) { SelectedForeColor = owner.Color.ToNSColor(); SelectedAttributes[AttributeKeys.NSColor] = owner.Color.ToNSColor(); } if (owner.Font != null) { if (owner.Font.Underline) { SelectedAttributes[AttributeKeys.NSUnderline] = new NSNumber(true); } if (owner.Font.Strikeout) { SelectedAttributes[AttributeKeys.NSStrikethrough] = new NSNumber(true); } } NSFontManager.SharedFontManager.SetSelectedAttributes(SelectedAttributes, false); NSApplication.SharedApplication.RunModalForWindow(panel); panel.Delegate = prevDelegate; panel.AccessoryView = prevAccessory; return(Result); }
public void ChangeFont(NSObject sender) { SelectedFont = panel.PanelConvertFont(SelectedFont); panel.SetPanelFont(SelectedFont, false); }