Forked from Viklor/gist:8981f48902d0f1854857fb69605becf8
Last active
October 2, 2020 19:19
-
-
Save roman-yagodin/1a679d7c99edff600878e2a288f67893 to your computer and use it in GitHub Desktop.
Calculator Wiget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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