All pastes #1978456 Raw Edit

ZenStudio GUI Alpha

public text v1 · immutable
#1978456 ·published 2010-11-01 05:19 UTC
rendered paste body
using System;
#if AVOID_GENERICS
using System.Collections;
using ConstantValueSource_bool = ZenStudio.Gui.ConstantValueSource;
#else
using System.Collections.Generic;
using System.Linq;
using ConstantValueSource_bool = ZenStudio.Gui.ConstantValueSource<bool>;
#endif
using System.Text;
using ZenStudio.Gui.Widgets;
using ZenStudio.Gui;
using ZenStudio.Sensors;

namespace ZenStudio.Logic
{
    public class MyApplication
    {
        public MyApplication(HostConfig config)
        {
            this.RuntimeHost = config;
        }

        public HostConfig RuntimeHost { get; set; }

        public IWindow RootWindow { get; set; }

        public void Run()
        {
#if AVOID_GENERICS // No generics on Micro Framework :(
            RootWindow = (IWindow)RuntimeHost.UI.CreateWidget(typeof(IWindow));
#else
            RootWindow = RuntimeHost.UI.CreateWidget<IWindow>(); // create window
#endif
            //TODO:simplify typical scenarios, such as constants
            RuntimeHost.UI.LinkManager.Link(new ConstantValueSource_bool(true).GetOutput("Value"), RootWindow.GetInput("Visible"));
            RuntimeHost.UI.RootVisual = RootWindow; // make this window the main window :)
            
            var textBox = (ITextBox)RuntimeHost.UI.CreateWidget(typeof(ITextBox)); // create textbox
            RootWindow.AddChild(textBox); // add textbox to window
            //make textbox visible, too
            RuntimeHost.UI.LinkManager.Link(new ConstantValueSource_bool(true).GetOutput("Value"), textBox.GetInput("Visible"));

            // Source of random text. Works on another thread! Magic!
            var sensor = (IDebugTestSensor)RuntimeHost.UI.CreateLinkable(typeof(IDebugTestSensor));
            // Link Sensor to textbox
            RuntimeHost.UI.LinkManager.Link(sensor.GetOutput("Value"), textBox.GetInput("Text"));

            RuntimeHost.UI.BeginEventLoop(); // GO!
        }

    }
}