コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Text.TextViewModel+FontManagerController"/> class.
 /// </summary>
 /// <param name="window">Window.</param>
 /// <param name="fontFaceName">Font face name.</param>
 /// <param name="fontSize">Font size.</param>
 /// <param name="fontChangedCallback">Font changed callback.</param>
 public FontManagerController(RhinoMac.Window window, string fontFaceName, float fontSize, FontChangedEvent fontChangedCallback)
 {
     // Need the window to get the responder chain working
       _window = window;
       // Call this function when the selected font changes
       _fontChangedCallback = fontChangedCallback;
       // The close flag defaults to ture, set it to false if the
       // shared font manager panel is currently open so it will
       // be left open when this window closes otherwise the
       // font panel will close when this form does.
       if (null != MonoMac.AppKit.NSFontPanel.SharedFontPanel && MonoMac.AppKit.NSFontPanel.SharedFontPanel.IsVisible)
     _closeFontManager = false;
       // Get an instance of the font manager panel
       _fontManager = MonoMac.AppKit.NSFontManager.SharedFontManager;
       // Create an instance of the font we want to change when
       // the font manger selection changes, the font face name
       // will be extracted from this font and passed to the
       // associated view model.
       _font = MonoMac.AppKit.NSFont.FromFontName(fontFaceName, fontSize);
       // Set the font manager panel target to this object so the
       // ChangeFont() method will get called when the current font
       // selection changes
       //_fontManager.Target = this;
       //
       // Save the responder chain
       //
       _resetResponderChain = true;
       _thisNextResponder = NextResponder;
       _windowNextResponder = _window.NextResponder;
       _action = _fontManager.Action;
       //
       // Redirect the responder chain
       this.NextResponder = _window.NextResponder;
       _window.NextResponder = this;
       _fontManager.Action = new MonoMac.ObjCRuntime.Selector("changeFontAction:");
       // Set the currently selected font in the font manger panel
       _fontManager.SetSelectedFont(_font, false);
 }
コード例 #2
0
 public void changeFont(MonoMac.AppKit.NSFontManager sender)
 {
     // Convert the font value and save it
       var newFont = sender.ConvertFont(_font);
       _font = newFont;
       // Update the view model
       _fontChangedCallback(newFont);
 }