AttachNative() public method

Attaches the control for direct use in a native application
Use this to use a control directly in a native application. Note that the native application must be running the same framework as the current platform. E.g. a WinForms application can use an Eto.Forms control when using the Eto.WinForms platform. This prepares the control by firing the PreLoad, Load, etc. events.
public AttachNative ( ) : void
return void
Example #1
0
 /// <summary>
 /// Gets the native Wpf framework element that contains the Eto.Forms control.
 /// </summary>
 /// <remarks>
 /// Note for some controls, this will not be the 'main' native control.
 /// For example, a GridView on OS X will return a NSScrollView instead of a NSTableView, since the table view
 /// itself does not scroll.
 ///
 /// When you intend on using the control inside an existing native application, set <paramref name="attach"/> to
 /// true so that it can prepare for attaching to the native application by sending OnPreLoad/Load/LoadComplete events.
 /// </remarks>
 /// <returns>The native control that can be used to add this control to an existing application.</returns>
 /// <param name="control">Control to get the native control for.</param>
 /// <param name="attach">If set to <c>true</c> the control is to be attached to an existing application, or <c>false</c> to get the native control directly.</param>
 public static sw.FrameworkElement ToNative(this Control control, bool attach = false)
 {
     if (attach && !control.Loaded)
     {
         control.AttachNative();
     }
     return(control.GetContainerControl());
 }
Example #2
0
 /// <summary>
 /// Gets the native Gtk widget that contains the Eto.Forms control.
 /// </summary>
 /// <remarks>
 /// Note for some controls, this will not be the 'main' native control.
 /// For example, a GridView on OS X will return a NSScrollView instead of a NSTableView, since the table view
 /// itself does not scroll.
 ///
 /// When you intend on using the control inside an existing native application, set <paramref name="attach"/> to
 /// true so that it can prepare for attaching to the native application by sending OnPreLoad/Load/LoadComplete events.
 /// </remarks>
 /// <returns>The native control that can be used to add this control to an existing application.</returns>
 /// <param name="control">Control to get the native control for.</param>
 /// <param name="attach">If set to <c>true</c> the control is to be attached to an existing application, or <c>false</c> to get the native control directly.</param>
 public static Gtk.Widget ToNative(this Control control, bool attach = false)
 {
     if (attach && !control.Loaded)
     {
         control.AttachNative();
         control.GetContainerWidget().ShowAll();
     }
     return(control.GetContainerWidget());
 }
Example #3
0
 /// <summary>
 /// Gets the native Mac NSView that contains the Eto.Forms control.
 /// </summary>
 /// <remarks>
 /// Note for some controls, this will not be the 'main' native control.
 /// For example, a GridView on OS X will return a NSScrollView instead of a NSTableView, since the table view
 /// itself does not scroll.
 ///
 /// When you intend on using the control inside an existing native application, set <paramref name="attach"/> to
 /// true so that it can prepare for attaching to the native application by sending OnPreLoad/Load/LoadComplete events.
 /// </remarks>
 /// <returns>The native control that can be used to add this control to an existing application.</returns>
 /// <param name="control">Control to get the native control for.</param>
 /// <param name="attach">If set to <c>true</c> the control is to be attached to an existing application, or <c>false</c> to get the native control directly.</param>
 public static NSView ToNative(this Control control, bool attach = false)
 {
     if (control == null)
     {
         return(null);
     }
     if (attach && !control.Loaded)
     {
         control.AttachNative();
     }
     return(control.GetContainerView());
 }
Example #4
0
 /// <summary>
 /// Gets the native Mac NSView that contains the Eto.Forms control.
 /// </summary>
 /// <remarks>
 /// Note for some controls, this will not be the 'main' native control.
 /// For example, a GridView on OS X will return a NSScrollView instead of a NSTableView, since the table view
 /// itself does not scroll.
 ///
 /// When you intend on using the control inside an existing native application, set <paramref name="attach"/> to
 /// true so that it can prepare for attaching to the native application by sending OnPreLoad/Load/LoadComplete events.
 /// </remarks>
 /// <returns>The native control that can be used to add this control to an existing application.</returns>
 /// <param name="control">Control to get the native control for.</param>
 /// <param name="attach">If set to <c>true</c> the control is to be attached to an existing application, or <c>false</c> to get the native control directly.</param>
 public static NSView ToNative(this Control control, bool attach = false)
 {
     if (attach && !control.Loaded)
     {
         control.AttachNative();
         var macControl = control.GetMacControl();
         if (macControl != null && macControl.AutoSize)
         {
             macControl.ContainerControl.SetFrameSize(macControl.GetPreferredSize(SizeF.MaxValue).ToSD());
         }
     }
     return(control.GetContainerView());
 }
Example #5
0
        /// <summary>
        /// Gets the native Mac NSView that contains the Eto.Forms control.
        /// </summary>
        /// <remarks>
        /// Note for some controls, this will not be the 'main' native control.
        /// For example, a GridView on OS X will return a NSScrollView instead of a NSTableView, since the table view
        /// itself does not scroll.
        ///
        /// When you intend on using the control inside an existing native application, set <paramref name="attach"/> to
        /// true so that it can prepare for attaching to the native application by sending OnPreLoad/Load/LoadComplete events.
        /// </remarks>
        /// <returns>The native control that can be used to add this control to an existing application.</returns>
        /// <param name="control">Control to get the native control for.</param>
        /// <param name="attach">If set to <c>true</c> the control is to be attached to an existing application, or <c>false</c> to get the native control directly.</param>
        public static NSView ToNative(this Control control, bool attach = false)
        {
            if (control == null)
            {
                return(null);
            }
            if (attach && !control.Loaded)
            {
                control.AttachNative();
                var macView = control.GetMacViewHandler();

                macView?.SetAlignmentFrameSize(macView.GetPreferredSize(SizeF.PositiveInfinity).ToNS());
            }
            return(control.GetContainerView());
        }
Example #6
0
 /// <summary>
 /// Gets the native Wpf framework element that contains the Eto.Forms control.
 /// </summary>
 /// <remarks>
 /// Note for some controls, this will not be the 'main' native control.
 /// For example, a GridView on OS X will return a NSScrollView instead of a NSTableView, since the table view
 /// itself does not scroll.
 ///
 /// When you intend on using the control inside an existing native application, set <paramref name="attach"/> to
 /// true so that it can prepare for attaching to the native application by sending OnPreLoad/Load/LoadComplete events.
 /// </remarks>
 /// <returns>The native control that can be used to add this control to an existing application.</returns>
 /// <param name="control">Control to get the native control for.</param>
 /// <param name="attach">If set to <c>true</c> the control is to be attached to an existing application, or <c>false</c> to get the native control directly.</param>
 public static sw.FrameworkElement ToNative(this Control control, bool attach = false)
 {
     if (control == null)
     {
         return(null);
     }
     if (attach && !control.Loaded)
     {
         control.AttachNative();
         var handler = control.GetWpfFrameworkElement();
         if (handler != null)
         {
             handler.SetScale(false, false);
         }
     }
     return(control.GetContainerControl());
 }