Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save roman-yagodin/1a679d7c99edff600878e2a288f67893 to your computer and use it in GitHub Desktop.
Save roman-yagodin/1a679d7c99edff600878e2a288f67893 to your computer and use it in GitHub Desktop.
Calculator Wiget
using System;
using System.Text;
using NGettext;
using R7.Webmate.Xwt.Icons;
using R7.Webmate.Xwt.Text;
using Xwt;
namespace R7.Webmate.Xwt
{
public class HelloWorldWidget : Widget
{
protected ICatalog T = TextCatalogKeeper.GetDefault ();
protected TextEntry txtWidth;
protected TextEntry txtHeight;
protected TextEntry txtCalculed;
public HelloWorldWidget()
{
var vbox = new VBox ();
var lblWidth = new Label (T.GetString ("Ширина:"));
var lblHeight = new Label(T.GetString("Высота:"));
var btnCalculed = new Button (T.GetString ("Click me!"));
txtWidth = new TextEntry ();
txtHeight = new TextEntry();
txtCalculed = new TextEntry ();
btnCalculed.Clicked += btnCalculed_Clicked;
vbox.PackStart (lblWidth, false, true);
vbox.PackStart (txtWidth, false, true);
vbox.PackStart(lblHeight, false, true);
vbox.PackStart(txtHeight, false, true);
vbox.PackStart (btnCalculed, false, true);
vbox.PackStart (txtCalculed, false, true);
vbox.Margin = Const.VBOX_MARGIN;
Content = vbox;
Content.Show ();
}
void btnCalculed_Clicked(object sender, EventArgs e)
{
var w = int.Parse (txtWidth.Text);
var h = int.Parse (txtHeight.Text);
var r = (float) w / h;
txtCalculed.Text = r.ToString ();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment