picoe / Eto

Cross platform GUI framework for desktop and mobile applications in .NET
Other
3.55k stars 323 forks source link

GUI elements with Eto #2545

Open WileyNg opened 11 months ago

WileyNg commented 11 months ago

Hi @cwensley

I have initiated a discussion in the forum here: https://discourse.mcneel.com/t/custom-ui-elements-with-eto-forms/162955/21

Is there any possibility of receiving support for the Eto GUI elements?

Currently, we are employing a workaround to use a transparent Eto.Form by utilizing a WPF hack with styling, as shown below:

            Eto.Style.Add<Eto.Forms.Panel>(
            "transparent-form", control =>
            {
                var wpfwnd = (System.Windows.Window)control.ControlObject;
                wpfwnd.AllowsTransparency = true;

                wpfwnd.Background = swm.Brushes.Transparent;
                wpfwnd.Topmost = true;
                wpfwnd.ShowActivated = false;
                wpfwnd.WindowStyle = sw.WindowStyle.None;
            });

image Since it's currently not possible to create a moduless form that can be attached to the viewport window at the moment, we are employing a convoluted way to hook the form to the viewport window.

        [DllImport("user32.dll", SetLastError = true)]
        public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
//hWndChild is created by the NativeHandle Property from each Control
//hWndNewParent is the active viewport window, found using the NativeHandle of the Rhino Application:
        [DllImport("user32")]
        [return: MarshalAs(UnmanagedType.Bool)]
        private static extern bool EnumChildWindows(IntPtr window, EnumedWindow callback, ArrayList lParam);

Is there a better way to accomplish this? The current method lacks stability since the functionality is not integrated into the Eto library.