Mecha view

So I’m currently doing a few minor .NET apps from scratch, so I started looking for a few UI frameworks to speed up development, and I found this little gem MechaView.

On a side note, this blog has (as feared or expected) been dormant for quite some time, so I’m secretly glad it still works and I still remember how everything works. Humble shout-out to to myself for making the scripts and committing everything last time.

So of course I need to make a little tracker UI in that. Sadly it is not .NET core and I’m not quite sure I like the build process. At least I need to investigate how to get it in to the build process.

The gist of the framework is to make it SUPER fast to make a simple ui for an ap, and get one single exe as a result, and all from c# code without messing with xaml.

Will the app be BEAUTIFUL - not, but it will be functional and fast to make. In my day job I often need to make quick small apps to help out our customers. Sometimes we help by making software robots, sometimes powerapps, sometimes webapps and sometimes small native apps. Quick turnaround is the key, so lets take out Macha out for a spin.

Installation

This iss extremely simple, and it is well described on the github site so go there for more info.

  • Make a .NET Libraray (not Standard nor Core)
  • Install-Package MechaView.MahApps

Usage

Using this is just as simple:

  • Create a public class App in the global namespace (no namespace).
  • Create a view class
  • run Start-App from the PM Console
using System;
using Mecha.Wpf.Settings;

public class App : IApp {
    public void Init(AppSettings s) {
        s.Title = "Basic App";
        s.Window.Width = 450;
        s.Content = typeof(BasicsVM);
    }
}

public class BasicsVM {

    public virtual string Label { get; set; }
    public void SetLabel() { Label = DateTime.Now.ToString(); }
}

THATS IT!!

Here is a screenshot of all the code, the project structure, the installation, the building and the running app - all in one.

When something looks too good to be true…

When you simplify so much, what can you actually create. Lets see…. First lets get a list of tracks

public class BasicsVM {

    private TrackerClient _client;

    public BasicsVM() {
        _client = new TrackerClient();
    }
    public virtual Track[] Tracks { get; set; }
    public async Task GetTracks() {
        Tracks = await _client.GetTracks();
    }
}

So far so good - We get a list of tracks:

Lets add two input fields and allow the user to add steps:

public class BasicsVM {

    private TrackerClient _client;

    public BasicsVM() {
        _client = new TrackerClient();
    }
    public virtual Track[] Tracks { get; set; }
    public async Task GetTracks() {
        Tracks = await _client.GetTracks();
    }
    
    public virtual string Track { get; set; }
    public virtual string Step { get; set; }
    
    public async Task Add() {
        _client.AddStepSync(Track, Step);
        await GetTracks();
    }
}

Next step is to set the two fields as mandatory, and add a bit of description:

...
using Mecha.ViewModel.Attributes;
...
public class BasicsVM {
    ...
    [TextInput(Mandatory = true, Description = "Track name")]
    public virtual string Track { get; set; }
    
    [TextInput(Mandatory = true, Description = "Step name")]
    public virtual string Step { get; set; }
    ...
}

So now the next step would be to see all the steps of the selected track, and the is where we hit the wall. I have not yet found a way to do that.

Debugging

To debug the process you need to attach to the process. I did this in hope of getting some clues about how to get a bit further, without any success.

Conclusion

This makes sens for very simple apps, where you fill out a few fields and get a response. If you want to do anything more than that … you need to look somewhere else. Even in this very simple example I got stuck. Hats of for a project thet does one thing well, and as it is open source, you cant complain, you can only make pull requests ;)