Any experience with Xaml's Eto clone, Xeto?

Hello there!

I’ve been messing around with Eto.Forms recently, but only in C# code. I wanted to try and do some testing over the Eto portable version of Xaml, Xeto, and I wanted to know how well did it work within Rhino and if it would be worth my time to consider it for a plugin hat would eventually be compatible with both Windows and Mac’s Rhino versions.

Thanks in advance!

Alonso

Eto.Forms should be compatible as is? I don’t see why you would want to go Xeto specifically? (Granted, I don’t know Xeto).

@curtisw probably will be the best to tell you.

Thanks for your interest @nathanletwory! Indeed, Eto.Forms serves me as is quite nicely. In fact I’ve already developed quite a lot of UI already over it.

This question arises mostly out of curiosity, and because I find the VS tools for the preview of Xaml handy for the development of certain necessary panels. And Xeto would be to ensure compatibility with the Mac, while using this method.

So I wanted some feedback from the community and their experience.

Hi @alonso.rosado,

Xeto should work using Rhino 6.x for Windows, though most (all?) of the UI is still being done via code. Unfortunately, the required Eto.Serialization.Xaml and Portable.Xaml assemblies aren’t included in Mac Rhino v5, but will be in Mac Rhino v6 WIP when it is available.

Another option you might want to try is the “Code Preview” option. It gives you the preview of the panels by using a partial class MyPanel.eto.cs for the view, and MyPanel.cs for the code behind (anything that can’t be used with the view). Code written this way should be compatible with Mac Rhino v5.

I know a lot of people have been using .xeto UI definitions for a number of years outside of Rhino, so in that sense it is fairly mature.

Hope this helps!
Curtis.

2 Likes

This was actually really helpful, @curtisw! I will try both the preview and Xaml in order to discern which option suits me more. The issue over the Mac portability of Xaml shouldn’t be a problem, whilst it is included in the definitive Rhino Mac 6 version. Though, having it available within the Rhino’s WIP version leads to think that it should be so.

I’ve already tried the usage of Xeto Panels through a modeless window, and they worked just fine. So barring any wierdness with integrating the custom Rhino UI components, which I will be testing today, everything should be fine with using it.

Thanks again!

By the way, do you know if it is possible to pass arguments to the constructor through Xaml in Eto?
I tried the <x:Arguments> tag but there was some wierdness going around… I will keep at it an see if I’m able to solve it, but I might as well ask.

Hey @alonso.rosado, this should be possible, but there is also a possibility that there are bugs with the xaml implementation. If you can’t figure it out let me know and I can look into it!

I’ve been trying for a couple extra hours and been unable to solve it, or to find info regarding this particular problem, so I might as well drop the bomb to you, @curtisw :sweat_smile:

Let’s see, I’ve generated a custom class, a dynamic control that depending on its input it assigns the control to one of three options. This is probably the source of the problem, but the compiler is allowing to serialize this without any trouble, so here is the custom class:
(tried using an enum for the constructor but i wanted to keep it simple, so i rolled back to int).

namespace EtoXamlSample
{
    [Serializable]
    public class CustomDynamicControl : DynamicControl
    {
        public enum ControlOutputs
        {
            BUTTON,
            NUMERICSTEPPER,
            TEXTBOX
        }
        public CustomDynamicControl(System.Int32 output)
        {
            switch(output)
            {
                case 0://ControlOutputs.BUTTON:
                    Control = new Button
                    {
                        Text = "DynamicButton"
                    };
                    break;
                case 1://ControlOutputs.NUMERICSTEPPER:
                    Control = new NumericStepper
                    {
                        DecimalPlaces = 3,
                        Increment = 0.1,
                        Value = 1,
                        MinValue = 0,
                        MaxValue = 10
                    };
                    break;
                case 2://ControlOutputs.TEXTBOX:
                    Control = new TextBox
                    {
                        Text = "DynamicTextBox"
                    };
                    break;
                default:
                    Control = new TextBox
                    {
                        Text = "DefaultDynamic"
                    };
                    break;
            }
        }
    }
}

This, i call from the next panel:

<?xml version="1.0" encoding="UTF-8"?>
<Panel
  xmlns="http://schema.picoe.ca/eto.forms" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="clr-namespace:EtoXamlSample;assembly=EtoXamlSample"
  xmlns:rhino="clr-namespace:Rhino;assembly=RhinoCommon"
  >
  <TableLayout x:Name ="SamplePanelLayout">
    <TabControl>
      <TabPage Text = "Tab 3">
          <local:CustomDynamicControl>
            <x:Argument>
              <x:Int32>
                2
              </x:Int32>
            </x:Argument>
          </local:CustomDynamicControl>
        </DynamicLayout>
      </TabPage>
    </TabControl>
  </TableLayout>
</Panel>

I would understand it just got crazy over me trying to serialize something such as Dynamic Control with controls defined in runtime, but instead it yields:

Type ‘Portable.Xaml.XamlObjectWriterException’ in Assembly ‘portable.Xaml, Version = 0.14.0.0, Culture=neutral, PublicKeyToken=blabla…’ is not marked as serializable.

Im assuming the error lies within my code, and it’s causing the XamlObjectWriter to go nuts.
If that is so, how would you go around doing a dynamic control such as this?

Hey @alonso.rosado,

I think you might just have a typo. I think it’s x:Arguments, not x:Argument.

Also, note that the designer preview has limitations when it comes to custom controls, and you may have to create a placeholder and set its content to the custom control in the code behind. I’m still working on this to make it better, but it is not high priority.

Hope this helps!