private void AttachWidgets(TextView textView) { // This is really different from the C version, but the // C versions seems a little pointless. Button button = new Button("Click Me"); button.Clicked += new EventHandler(EasterEggCB); textView.AddChildAtAnchor(button, buttonAnchor); button.ShowAll(); ComboBox combo = ComboBox.NewText(); combo.AppendText("Option 1"); combo.AppendText("Option 2"); combo.AppendText("Option 3"); textView.AddChildAtAnchor(combo, menuAnchor); HScale scale = new HScale(null); scale.SetRange(0, 100); scale.SetSizeRequest(70, -1); textView.AddChildAtAnchor(scale, scaleAnchor); scale.ShowAll(); Gtk.Image image = Gtk.Image.LoadFromResource("floppybuddy.gif"); textView.AddChildAtAnchor(image, animationAnchor); image.ShowAll(); Entry entry = new Entry(); textView.AddChildAtAnchor(entry, entryAnchor); entry.ShowAll(); }
public (string, Widget) CreateHorizontalRange() { var adj = new Adjustment(0.0, 0.0, 101.0, 0.1, 1.0, 1.0); var hScale = new HScale(adj); hScale.SetSizeRequest(200, -1); hScale.ValueChanged += (sender, e) => ApplicationOutput.WriteLine(sender, $"Value Change: {((HScale)sender).Value}"); return("Horizontal", hScale); }
public GameView(Game game) : base("GameOfLife") { this.game = game; AddEvents((int)(EventMask.KeyPressMask | EventMask.ButtonPressMask | EventMask.PointerMotionMask | EventMask.ButtonReleaseMask)); Resize(this.game.column * 10, this.game.rows * 10 + 70); //box with start/stop and clear button VBox vbox = new VBox(); HBox hb1 = new HBox(); //start/stop button Button a = new Button("Start/Stop"); a.SetSizeRequest(350, 35); a.Clicked += Clicked; hb1.PackStart(a, false, false, 0); //clear button Button b = new Button("Clear"); b.SetSizeRequest(350, 35); b.Clicked += Clear; hb1.PackStart(b, false, false, 0); vbox.PackStart(hb1, false, false, 0); HBox hb = new HBox(); //speed button Label speedLr = new Label("Speed"); speedLr.SetSizeRequest(100, 35); HScale speed = new HScale(0, 5, 1); speed.SetSizeRequest(200, 35); speed.ValueChanged += SpeedButton; //scale button Label scaleLr = new Label("Scale"); scaleLr.SetSizeRequest(100, 35); HScale scale = new HScale(0, 2, 1); scale.SetSizeRequest(200, 35); scale.ValueChanged += ScaleButton; hb.PackStart(speedLr, false, false, 0); hb.PackStart(speed, false, false, 0); hb.PackStart(scaleLr, false, false, 0); hb.PackStart(scale, false, false, 0); vbox.PackStart(hb, false, false, 0); area = new DrawingArea(); area.ExposeEvent += exposeHandler; vbox.PackStart(area, true, true, 0); this.Add(vbox); }
public static Gtk.Window Create() { window = new Window("GtkRange"); window.SetDefaultSize(250, 200); VBox box1 = new VBox(false, 0); window.Add(box1); VBox box2 = new VBox(false, 0); box2.BorderWidth = 10; box1.PackStart(box2, true, true, 0); Adjustment adjustment = new Adjustment(0.0, 0.0, 101.0, 0.1, 1.0, 1.0); HScale hscale = new HScale(adjustment); hscale.SetSizeRequest(150, -1); hscale.Digits = 1; hscale.DrawValue = true; box2.PackStart(hscale, true, true, 0); HScrollbar hscrollbar = new HScrollbar(adjustment); box2.PackStart(hscrollbar, true, true, 0); hscale = new HScale(adjustment); hscale.DrawValue = true; hscale.FormatValue += new FormatValueHandler(reformat_value); box2.PackStart(hscale, true, true, 0); HBox hbox = new HBox(false, 0); VScale vscale = new VScale(adjustment); vscale.SetSizeRequest(-1, 200); vscale.Digits = 2; vscale.DrawValue = true; hbox.PackStart(vscale, true, true, 0); vscale = new VScale(adjustment); vscale.SetSizeRequest(-1, 200); vscale.Digits = 2; vscale.DrawValue = true; ((Range)vscale).Inverted = true; hbox.PackStart(vscale, true, true, 0); vscale = new VScale(adjustment); vscale.DrawValue = true; vscale.FormatValue += new FormatValueHandler(reformat_value); hbox.PackStart(vscale, true, true, 0); box2.PackStart(hbox, true, true, 0); box1.PackStart(new HSeparator(), false, true, 0); box2 = new VBox(false, 10); box2.BorderWidth = 10; box1.PackStart(box2, false, true, 0); Button button = new Button(Stock.Close); button.Clicked += new EventHandler(Close_Button); box2.PackStart(button, true, true, 0); button.CanDefault = true; button.GrabDefault(); window.ShowAll(); return(window); }