public ReportViewer() { // Setup layout boxes vboxContents = new Xwt.VBox(); vboxToolMenu = new Xwt.HBox(); // Setup tool button menu Xwt.Button buttonExport = new Xwt.Button("Export"); buttonExport.Clicked += delegate(object sender, EventArgs e) { SaveAs(); }; vboxToolMenu.PackStart(buttonExport); Xwt.Button buttonPrint = new Xwt.Button("Print"); vboxToolMenu.PackStart(buttonPrint); // Add vboxContent widgets vboxPages = new Xwt.VBox(); vboxContents.PackStart(vboxToolMenu); vboxContents.PackStart(vboxPages); // Setup Controls Contents scrollView = new Xwt.ScrollView(); scrollView.Content = vboxContents; scrollView.VerticalScrollPolicy = ScrollPolicy.Automatic; scrollView.BorderVisible = true; this.PackStart(scrollView, true, true); Parameters = new ListDictionary(); ShowErrors = false; }
public ReportViewer() { // Setup layout boxes vboxContents = new Xwt.VBox(); vboxToolMenu = new Xwt.HBox(); // Setup tool button menu Xwt.Button buttonExport = new Xwt.Button("Export"); buttonExport.Clicked += delegate(object sender, EventArgs e) { SaveAs(); }; vboxToolMenu.PackStart(buttonExport); Xwt.Button buttonPrint = new Xwt.Button("Print"); vboxToolMenu.PackStart(buttonPrint); // Add vboxContent widgets vboxPages = new Xwt.VBox(); vboxContents.PackStart(vboxToolMenu); vboxContents.PackStart(vboxPages); // Setup Controls Contents scrollView = new Xwt.ScrollView(); scrollView.Content = vboxContents; scrollView.VerticalScrollPolicy = ScrollPolicy.Automatic; scrollView.BorderVisible = true; this.PackStart(scrollView, BoxMode.FillAndExpand); Parameters = new ListDictionary(); ShowErrors = false; }
void BuildGui() { this.Title = GettextCatalog.GetString("Select Work Item"); VBox content = new VBox(); HBox mainBox = new HBox(); queryView.Columns.Add(new ListViewColumn(string.Empty, new TextCellView(titleField))); queryView.DataSource = queryStore; queryView.WidthRequest = 200; BuildQueryView(); mainBox.PackStart(queryView); workItemList.WidthRequest = 400; workItemList.HeightRequest = 400; workItemList.ShowCheckboxes = true; mainBox.PackStart(workItemList, true, true); content.PackStart(mainBox, true, true); HBox buttonBox = new HBox(); Button okButton = new Button(GettextCatalog.GetString("Ok")); okButton.WidthRequest = Constants.ButtonWidth; okButton.Clicked += (sender, e) => Respond(Command.Ok); buttonBox.PackEnd(okButton); content.PackStart(buttonBox); //this.Resizable = false; this.Content = content; AttachEvents(); }
public ListViewEntries() { ListView list = new ListView (); var editableTextField = new DataField<string> (); var nonEditableTextField = new DataField<string> (); ListStore store = new ListStore (editableTextField, nonEditableTextField); list.DataSource = store; list.GridLinesVisible = GridLines.Horizontal; var textCellView = new TextCellView { Editable = true, TextField = editableTextField }; list.Columns.Add (new ListViewColumn ("Editable", textCellView)); list.Columns.Add (new ListViewColumn ("Not Editable", new TextCellView { Editable = false, TextField = nonEditableTextField })); Random rand = new Random (); for (int n = 0; n < 10; n++) { var r = store.AddRow (); store.SetValue (r, editableTextField, "Editable value " + n); store.SetValue (r, nonEditableTextField, "Non-editable value " + n); } PackStart (list, true); var btn = new Button ("Add Row"); btn.Clicked += delegate { var row = store.AddRow (); store.SetValues (row, editableTextField, "New editable text", nonEditableTextField, "New non-editable text"); list.StartEditingCell (row, textCellView); }; PackStart (btn, false, hpos: WidgetPlacement.Start); }
VBox GenerateFrameContents (bool useMnemonics) { var statusText = useMnemonics ? "with mnemonic" : "without mnemonic"; var vbox = new VBox (); var button = new Button ("_Button"); button.UseMnemonic = useMnemonics; button.Clicked += (sender, e) => MessageDialog.ShowMessage (string.Format ("Button {0} clicked.", statusText)); vbox.PackStart (button); var toggleButton = new ToggleButton ("_Toggle Button"); toggleButton.UseMnemonic = useMnemonics; toggleButton.Clicked += (sender, e) => MessageDialog.ShowMessage (string.Format ("Toggle Button {0} clicked.", statusText)); vbox.PackStart (toggleButton); var menuButton = new MenuButton ("_Menu Button"); menuButton.UseMnemonic = useMnemonics; menuButton.Label = "_Menu Button"; var firstMenuItem = new MenuItem ("_First"); firstMenuItem.UseMnemonic = useMnemonics; firstMenuItem.Clicked += (sender, e) => MessageDialog.ShowMessage (string.Format ("First Menu Item {0} clicked.", statusText)); var secondMenuItem = new MenuItem ("_Second"); secondMenuItem.UseMnemonic = useMnemonics; secondMenuItem.Clicked += (sender, e) => MessageDialog.ShowMessage (string.Format ("Second Menu Item {0} clicked.", statusText)); var menu = new Menu (); menu.Items.Add (firstMenuItem); menu.Items.Add (secondMenuItem); menuButton.Menu = menu; vbox.PackStart (menuButton); return vbox; }
public LoginView(LauncherWindow window) { Window = window; this.MinWidth = 250; ErrorLabel = new Label("Username or password incorrect") { TextColor = Color.FromBytes(255, 0, 0), TextAlignment = Alignment.Center, Visible = false }; UsernameText = new TextEntry(); PasswordText = new PasswordEntry(); LogInButton = new Button("Log In"); RegisterButton = new Button("Register"); RememberCheckBox = new CheckBox("Remember Me"); UsernameText.Text = UserSettings.Local.Username; if (UserSettings.Local.AutoLogin) { PasswordText.Password = UserSettings.Local.Password; RememberCheckBox.Active = true; } using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("TrueCraft.Launcher.Content.truecraft-logo.png")) TrueCraftLogoImage = new ImageView(Image.FromStream(stream)); UsernameText.PlaceholderText = "Username"; PasswordText.PlaceholderText = "Password"; PasswordText.KeyReleased += (sender, e) => { if (e.Key == Key.Return || e.Key == Key.NumPadEnter) LogInButton_Clicked(sender, e); }; UsernameText.KeyReleased += (sender, e) => { if (e.Key == Key.Return || e.Key == Key.NumPadEnter) LogInButton_Clicked(sender, e); }; RegisterButton.Clicked += (sender, e) => { if (RegisterButton.Label == "Register") Window.WebView.Url = "http://truecraft.io/register"; else { Window.User.Username = UsernameText.Text; Window.User.SessionId = "-"; Window.MainContainer.Remove(this); Window.MainContainer.PackEnd(Window.MainMenuView = new MainMenuView(Window)); } }; LogInButton.Clicked += LogInButton_Clicked; this.PackStart(TrueCraftLogoImage); this.PackEnd(RegisterButton); this.PackEnd(LogInButton); this.PackEnd(RememberCheckBox); this.PackEnd(PasswordText); this.PackEnd(UsernameText); this.PackEnd(ErrorLabel); }
void HandleClicked(object sender, EventArgs e) { if (popover == null) { popover = new Popover (); var table = new Table () { DefaultColumnSpacing = 20, DefaultRowSpacing = 10 }; // table.Margin.SetAll (60); table.Attach (new Label ("Font") { TextAlignment = Alignment.End }, 0, 0); table.Attach (new ComboBox (), 1, 0, AttachOptions.Fill, AttachOptions.Fill | AttachOptions.Expand); table.Attach (new Label ("Family") { TextAlignment = Alignment.End }, 0, 1); table.Attach (new ComboBox (), 1, 1, AttachOptions.Fill, AttachOptions.Fill | AttachOptions.Expand); table.Attach (new Label ("Style") { TextAlignment = Alignment.End }, 0, 2); table.Attach (new ComboBox (), 1, 2, AttachOptions.Fill, AttachOptions.Fill | AttachOptions.Expand); table.Attach (new Label ("Size") { TextAlignment = Alignment.End }, 0, 3); table.Attach (new SpinButton (), 1, 3, AttachOptions.Fill, AttachOptions.Fill | AttachOptions.Expand); var b = new Button ("Add more"); table.Attach (b, 0, 4); int next = 5; b.Clicked += delegate { table.Attach (new Label ("Row " + next), 0, next++); }; table.Margin = 20; popover.Content = table; } // popover.Padding.SetAll (20); popover.Show (Popover.Position.Top, (Button)sender); }
public ThemedImages() { Context.RegisterStyles ("dark", "sel"); var img = Image.FromResource ("zoom-in-16.png"); var img_sel = Image.FromResource ("zoom-in-16.png").WithStyles("sel"); var img_dark = Image.FromResource ("zoom-in-16.png").WithStyles("dark"); var img_dark_sel = Image.FromResource ("zoom-in-16.png").WithStyles("dark", "sel"); var img_row = new HBox (); ImageView imgv = new ImageView () { Image = img }; ImageView imgv_sel = new ImageView () { Image = img_sel }; ImageView imgv_dark = new ImageView () { Image = img_dark }; ImageView imgv_dark_sel = new ImageView () { Image = img_dark_sel }; img_row.PackStart (imgv); img_row.PackStart (imgv_sel); img_row.PackStart (imgv_dark); img_row.PackStart (imgv_dark_sel); PackStart (img_row); var btn_row = new HBox (); Button btn = new Button (img); Button btn_sel = new Button (img_sel); Button btn_dark = new Button (img_dark); Button btn_dark_sel = new Button (img_dark_sel); btn_row.PackStart (btn); btn_row.PackStart (btn_sel); btn_row.PackStart (btn_dark); btn_row.PackStart (btn_dark_sel); PackStart (btn_row); }
public ListView1() { PackStart (new Label ("The listview should have a red background")); ListView list = new ListView (); ListStore store = new ListStore (name, icon, text, icon2, progress); list.DataSource = store; list.Columns.Add ("Name", icon, name); list.Columns.Add ("Text", icon2, text); list.Columns.Add ("Progress", new CustomCell () { ValueField = progress }); var png = Image.FromResource (typeof(App), "class.png"); Random rand = new Random (); for (int n=0; n<100; n++) { var r = store.AddRow (); store.SetValue (r, icon, png); store.SetValue (r, name, "Value " + n); store.SetValue (r, icon2, png); store.SetValue (r, text, "Text " + n); store.SetValue (r, progress, rand.Next () % 100); } PackStart (list, true); list.RowActivated += delegate(object sender, ListViewRowEventArgs e) { MessageDialog.ShowMessage ("Row " + e.RowIndex + " activated"); }; var but = new Button ("Scroll one line"); but.Clicked += delegate { list.VerticalScrollControl.Value += list.VerticalScrollControl.StepIncrement; }; PackStart (but); }
void IOptionsPanel.Initialize (OptionsDialog dialog, object dataObject) { this.ExpandHorizontal = true; this.ExpandVertical = true; this.HeightRequest = 400; list = new ListView (); store = new ListStore (language, completeOnSpace, completeOnChars); var languageColumn = list.Columns.Add (GettextCatalog.GetString ("Language"), language); languageColumn.CanResize = true; var checkBoxCellView = new CheckBoxCellView (completeOnSpace); checkBoxCellView.Editable = true; var completeOnSpaceColumn = list.Columns.Add (GettextCatalog.GetString ("Complete on space"), checkBoxCellView); completeOnSpaceColumn.CanResize = true; var textCellView = new TextCellView (completeOnChars); textCellView.Editable = true; var doNotCompleteOnColumn = list.Columns.Add (GettextCatalog.GetString ("Do complete on"), textCellView); doNotCompleteOnColumn.CanResize = true; list.DataSource = store; PackStart (list, true, true); var hbox = new HBox (); var button = new Button ("Reset to default"); button.Clicked += delegate { FillStore (CompletionCharacters.GetDefaultCompletionCharacters ()); }; hbox.PackEnd (button, false, false); PackEnd (hbox, false, true); FillStore (CompletionCharacters.GetCompletionCharacters ()); }
public DragDrop() { HBox box = new HBox (); SimpleBox b1 = new SimpleBox (30); box.PackStart (b1, BoxMode.None); b2 = new Button ("Drop here"); box.PackEnd (b2, BoxMode.None); b1.ButtonPressed += delegate { var d = b1.CreateDragOperation (); d.Data.AddValue ("Hola"); var img = Image.FromResource (GetType(), "class.png"); d.SetDragImage (img, (int)img.Size.Width, (int)img.Size.Height); d.AllowedActions = DragDropAction.All; d.Start (); }; b2.SetDragDropTarget (TransferDataType.Text, TransferDataType.Uri); PackStart (box); b2.DragDrop += HandleB2DragDrop; b2.DragOver += HandleB2DragOver; }
public ListView1 () { PackStart (new Label ("The listview should have a red background")); ListView list = new ListView (); list.GridLinesVisible = GridLines.Both; ListStore store = new ListStore (name, icon, text, icon2, progress); list.DataSource = store; list.Columns.Add ("Name", icon, name); list.Columns.Add ("Text", icon2, text); list.Columns.Add ("Progress", new TextCellView () { TextField = text }, new CustomCell () { ValueField = progress }); var png = Image.FromResource (typeof(App), "class.png"); Random rand = new Random (); for (int n=0; n<100; n++) { var r = store.AddRow (); store.SetValue (r, icon, png); store.SetValue (r, name, "Value " + n); store.SetValue (r, icon2, png); store.SetValue (r, text, "Text " + n); store.SetValue (r, progress, new CellData { Value = rand.Next () % 100 }); } PackStart (list, true); list.RowActivated += delegate(object sender, ListViewRowEventArgs e) { MessageDialog.ShowMessage ("Row " + e.RowIndex + " activated"); }; Menu contextMenu = new Menu (); contextMenu.Items.Add (new MenuItem ("Test menu")); list.ButtonPressed += delegate(object sender, ButtonEventArgs e) { int row = list.GetRowAtPosition(new Point(e.X, e.Y)); if (e.Button == PointerButton.Right && row >= 0) { // Set actual row to selected list.SelectRow(row); contextMenu.Popup(list, e.X, e.Y); } }; var but = new Button ("Scroll one line"); but.Clicked += delegate { list.VerticalScrollControl.Value += list.VerticalScrollControl.StepIncrement; }; PackStart (but); var spnValue = new SpinButton (); spnValue.MinimumValue = 0; spnValue.MaximumValue = 99; spnValue.IncrementValue = 1; spnValue.Digits = 0; var btnScroll = new Button ("Go!"); btnScroll.Clicked += (sender, e) => list.ScrollToRow((int)spnValue.Value); HBox scrollActBox = new HBox (); scrollActBox.PackStart (new Label("Scroll to Value: ")); scrollActBox.PackStart (spnValue); scrollActBox.PackStart (btnScroll); PackStart (scrollActBox); }
public SplashWindow() { Icon = App.Icon; Width = 550; Title = "4Plug First Use"; Resizable = false; VBox V = new VBox(); Content = V; Label lbl; lbl = new Label("A small introduction.") { Font = Font.FromName("Segoe UI Light 24"), TextColor = PluginType.Vpk.GetColor() }; V.PackStart(lbl); lbl = new Label("This tool allows you to quickly enable/disable mods as well as install new ones."); V.PackStart(lbl); lbl = new Label(""); V.PackStart(lbl); lbl = new Label("This is what a mod looks like in 4Plug!") { Font = Font.FromName("Segoe UI Light 24"), TextColor = PluginType.Unknown.GetColor() }; V.PackStart(lbl); lbl = new Label("You can enable/disable mods by clicking on the image."); V.PackStart(lbl); //lbl = new Label("Uninstalled mods are saved in the \"custom_\" instead of the \"custom\" folder of you game."); //V.PackStart(lbl); lbl = new Label(""); DummyPluginWidget dummy = new DummyPluginWidget(lbl); dummy.MarginTop += 16; dummy.MarginBottom += 8; V.PackStart(dummy); V.PackStart(lbl); lbl = new Label(""); V.PackStart(lbl); { HBox box = new HBox(); Button btn; btn = new Button(" Got it! "); box.PackEnd(btn); btn.Clicked += (s, e) => { Close(); }; Label lbl2; lbl2 = new Label(" Feel free to leave feedback (mainmenu -> submit feedback) later "); box.PackStart(lbl2); //btn.Clicked += (s, e) => { new SubmitFeedbackWindow("via Splash Window").Run(); }; V.PackStart(box); } }
public PopoverSample () { var btn = new Button ("Click me"); btn.Clicked += HandleClicked; PackStart (btn); var btn2 = new Button ("Click me"); btn2.Clicked += HandleClicked2; PackEnd (btn2); }
public LogLevelChooser(LogLevel selectedLogLevel) { SelectedLogLevel = selectedLogLevel; // prerender string[] logNames = Enum.GetNames(typeof(LogLevel)); int length = logNames.Length; renderedImage = new Image[length]; using (TextLayout text = new TextLayout()) { for (int i = 0; i < length; i++) { text.Text = logNames[i]; Size size = text.GetSize(); using (ImageBuilder ib = new ImageBuilder(size.Width + size.Height*2 + 3, size.Height)) { Color color = Color.FromName(Log.LevelToColorString((LogLevel) i)); Draw(ib.Context, (LogLevel) i, color); renderedImage[i] = ib.ToBitmap(); Button button = new Button { Image = renderedImage[i], ImagePosition = ContentPosition.Left }; button.HorizontalPlacement = WidgetPlacement.Start; button.Margin = 0; button.ExpandHorizontal = true; button.Style = ButtonStyle.Flat; buttons.PackStart(button, true, true); button.CanGetFocus = false; button.Tag = i; button.Clicked += OnLogChange; windowHeight += size.Height * 2; } } } // hide window on lost fokus buttons.CanGetFocus = true; buttons.LostFocus += delegate { if (menuHide != null) { menuHide(this, EventArgs.Empty); } popupWindow.Hide(); }; buttons.ButtonPressed += delegate { // do nothing // workaround to propagate event to each button }; buttons.Spacing = 0; popupWindow.Padding = 0; popupWindow.ShowInTaskbar = false; popupWindow.Decorated = false; popupWindow.Content = buttons; }
public SubmitFeedbackWindow(string category) { Icon = App.Icon; Title = "Thanks for your feedback!"; Resizable = false; VBox vbox = new VBox(); var text = new TextEntry() { MinWidth = 500, MinHeight = 200, MultiLine = true, Text = "" }; vbox.PackStart(text); { HBox box = new HBox(); Button btn; box.PackEnd(btn = new Button(" Cancel ")); btn.Clicked += (s, e) => { Close(); }; box.PackEnd(btn = new Button(" Submit ")); btn.Clicked += (s, e) => { string feedback = text.Text; new Task(() => { if (feedback.Length > 10) { string URL = "http://yuhrney.square7.ch/4Plug/feedback.php"; WebClient webClient = new WebClient(); webClient.Proxy = null; NameValueCollection formData = new NameValueCollection(); formData["feedback"] = string.Format("{3} - {1} {2}\n{5}\n{4}", App.WindowTitle, Environment.OSVersion.Platform, Xwt.Toolkit.CurrentEngine.Type, DateTime.Now.ToString("dd MMM HH:mm:ss", CultureInfo.InvariantCulture), feedback, category).Trim(); byte[] responseBytes = webClient.UploadValues(URL, "POST", formData); string responsefromserver = Encoding.UTF8.GetString(responseBytes); Console.WriteLine(responsefromserver); webClient.Dispose(); } }).Start(); Close(); }; vbox.PackStart(box); Content = vbox; } }
public InputBox(string label, string button) : base() { TextEntry = new TextEntry (); Label = new Label (label); Button = new Button (button); PackStart (Label); PackStart (TextEntry); PackStart (Button); Button.Sensitive = true; }
public Boxes() { HBox box1 = new HBox (); VBox box2 = new VBox (); box2.PackStart (new SimpleBox (30), BoxMode.None); box2.PackStart (new SimpleBox (30), BoxMode.None); box2.PackStart (new SimpleBox (30), BoxMode.FillAndExpand); box1.PackStart (box2, BoxMode.FillAndExpand); box1.PackStart (new SimpleBox (30), BoxMode.None); box1.PackStart (new SimpleBox (30), BoxMode.Expand); PackStart (box1, BoxMode.None); HBox box3 = new HBox (); box3.PackEnd (new SimpleBox (30)); box3.PackStart (new SimpleBox (20) {Color = new Color (1, 0.5, 0.5)}); box3.PackEnd (new SimpleBox (40)); box3.PackStart (new SimpleBox (10) {Color = new Color (1, 0.5, 0.5)}); box3.PackEnd (new SimpleBox (30)); box3.PackStart (new SimpleBox (10) {Color = new Color (1, 0.5, 0.5)}, BoxMode.FillAndExpand); PackStart (box3); HBox box4 = new HBox (); Button b = new Button ("Click me"); b.Clicked += delegate { b.Label = "Button has grown"; }; box4.PackStart (new SimpleBox (30), BoxMode.FillAndExpand); box4.PackStart (b); box4.PackStart (new SimpleBox (30), BoxMode.FillAndExpand); PackStart (box4); HBox box5 = new HBox (); Button b2 = new Button ("Hide / Show"); box5.PackStart (new SimpleBox (30), BoxMode.FillAndExpand); var hsb = new SimpleBox (20); box5.PackStart (hsb, BoxMode.None); box5.PackStart (b2); box5.PackStart (new SimpleBox (30), BoxMode.FillAndExpand); b2.Clicked += delegate { hsb.Visible = !hsb.Visible; }; PackStart (box5); HBox box6 = new HBox (); for (int n=0; n<15; n++) { var w = new Label ("TestLabel" + n); w.MinWidth = 10; box6.PackStart (w); } PackStart (box6); }
public WidgetRendering () { VBox box = new VBox (); Button b = new Button ("Click here to take a shot if this box"); box.PackStart (b); box.PackStart (new CheckBox ("Test checkbox")); PackStart (box); b.Clicked += delegate { var img = Toolkit.CurrentEngine.RenderWidget (box); PackStart (new ImageView (img)); }; }
public PasswordEntries () { PasswordEntry te1 = new PasswordEntry (); PackStart (te1); Button b = new Button ("Show password"); Label l = new Label (); b.Clicked += (sender, e) => { l.Text = ("Password is: " + te1.Password); }; PackStart (b); PackStart (l); }
public ReferenceImageVerifierDialog() { Width = 500; Height = 300; Table table = new Table (); table.DefaultRowSpacing = table.DefaultColumnSpacing = 6; table.Add (nameLabel = new Label (), 0, 0, hexpand:true); table.Add (new Label ("Reference Image"), 0, 1, hexpand:true); table.Add (new Label ("Test Image"), 1, 1, hexpand:true); nameLabel.Font = nameLabel.Font.WithWeight (Xwt.Drawing.FontWeight.Bold); img1 = new ImageView (); table.Add (img1, 0, 2, hexpand:true, vexpand:true); imgDiff = new ImageView (); table.Add (imgDiff, 1, 2, hexpand:true, vexpand:true); img2 = new ImageView (); table.Add (img2, 2, 2, hexpand:true, vexpand:true); var buttonBox = new HBox (); table.Add (buttonBox, 0, 3, colspan:2, hexpand:true); closeButton = new Button ("Close"); validButton = new Button ("Success"); failButton = new Button ("Failure"); buttonBox.PackEnd (closeButton); buttonBox.PackEnd (failButton); buttonBox.PackEnd (validButton); closeButton.Clicked += delegate { Respond (Command.Ok); }; failButton.Clicked += delegate { var info = ReferenceImageManager.ImageFailures[currentImage]; info.Fail (); ShowNextImage (); }; validButton.Clicked += delegate { var info = ReferenceImageManager.ImageFailures[currentImage]; info.Validate (); ShowNextImage (); }; Content = table; ShowNextImage (); }
void BuildGui() { this.PackStart(new Label(GettextCatalog.GetString("Lock Level:"))); this.PackStart(lockLevelBox); var mergeToolButton = new Button(GettextCatalog.GetString("Config merge tool")); mergeToolButton.Clicked += OnConfigMergeTool; this.PackStart(mergeToolButton); debugModeBox.AllowMixed = false; debugModeBox.Active = TFSVersionControlService.Instance.IsDebugMode; this.PackStart(debugModeBox); }
public SidebarContainer() { _closeButtonBox = new HBox(); _closeButton = new Button("CLOSE") { Style = ButtonStyle.Flat, Image = App.Images["appbar.chevron.left.png"].WithSize(32), Font = Font.SystemFont.WithSize(20).WithStretch(FontStretch.UltraCondensed), ImagePosition = ContentPosition.Left }; _closeButton.Clicked += (sender, args) => Clear(); _closeButtonBox.PackStart(_closeButton); }
Button CreateButton(string title, bool sensitive = true) { var button = new Button(title) { MinWidth = 40, MinHeight = 40 }; this.PackStart(button); _buttons.Add(button); button.Clicked += OnButtonClick; button.Sensitive = sensitive; return button; }
public EnvironmentVariableCollectionEditor () { store = new ListStore (keyField, valueField); list = new ListView (store); PackStart (list, true); TextCellView crt = new TextCellView (); crt.Editable = true; crt.TextField = keyField; var col = list.Columns.Add (GettextCatalog.GetString ("Variable"), crt); col.CanResize = true; crt.TextChanged += (s,a) => NotifyChanged (); valueCell = new TextCellView (); valueCell.Editable = true; valueCell.TextField = valueField; col = list.Columns.Add (GettextCatalog.GetString ("Value"), valueCell); col.CanResize = true; valueCell.TextChanged += (s, a) => NotifyChanged (); var box = new HBox (); var btn = new Button (GettextCatalog.GetString ("Add")); btn.Clicked += delegate { var row = store.AddRow (); list.SelectRow (row); list.StartEditingCell (row, crt); crt.TextChanged += CrtTextChanged; UpdateButtons (); }; box.PackStart (btn); deleteButton = new Button (GettextCatalog.GetString ("Remove")); deleteButton.Clicked += delegate { var row = list.SelectedRow; if (row != -1) { store.RemoveRow (row); if (row < store.RowCount) list.SelectRow (row); else if (store.RowCount > 0) list.SelectRow (store.RowCount - 1); UpdateButtons (); NotifyChanged (); } }; box.PackStart (deleteButton); PackStart (box); UpdateButtons (); }
public AppWindow() { nativeToolkit = Toolkit.Load (ToolkitType.Cocoa); HBox box = new HBox (); var b = new Button ("Gtk Test Window"); b.Clicked += HandleClicked; box.PackStart (b); b = new Button ("Cocoa Test Window"); b.Clicked += HandleClickedCocoa; box.PackStart (b); Content = box; }
public ClipboardSample () { HBox box = new HBox (); var source = new TextEntry (); box.PackStart (source); Button b = new Button ("Copy"); box.PackStart (b); b.Clicked += delegate { Clipboard.SetText (source.Text); }; PackStart (box); box = new HBox (); var dest = new TextEntry (); box.PackStart (dest); b = new Button ("Paste"); box.PackStart (b); b.Clicked += delegate { dest.Text = Clipboard.GetText (); }; PackStart (box); PackStart (new HSeparator ()); box = new HBox (); b = new Button ("Copy complex object"); box.PackStart (b); int n = 0; b.Clicked += delegate { Clipboard.SetData (new ComplexObject () { Data = "Hello world " + (++n) }); }; PackStart (box); box = new HBox (); var destComplex = new TextEntry (); box.PackStart (destComplex); b = new Button ("Paste complex object"); box.PackStart (b); b.Clicked += delegate { ComplexObject ob = Clipboard.GetData<ComplexObject> (); if (ob != null) destComplex.Text = ob.Data; else destComplex.Text = "Data not found"; }; PackStart (box); }
public CalendarSample () { var label = new Label (); var calendar = new Calendar () { ExpandHorizontal = false, }; var entry = new TextEntry () { PlaceholderText = "Enter a date to change calendar", }; var minimumDate = new TextEntry () { PlaceholderText = "Enter the minimum date of calendar", }; var maximumDate = new TextEntry () { PlaceholderText = "Enter the maximum date of calendar", }; calendar.ValueChanged += delegate { label.Text = string.Format ("Selected date: {0}", calendar.Date.ToShortDateString ()); if (entry.Text != string.Empty) entry.Text = calendar.Date.ToShortDateString (); }; label.Text = string.Format ("Selected date: {0}", calendar.Date.ToShortDateString ()); var button = new Button () { Label = "Change values", }; button.Clicked += delegate { DateTime dateMin; if (DateTime.TryParse (minimumDate.Text, out dateMin)) calendar.MinimumDate = dateMin.Date; DateTime dateMax; if (DateTime.TryParse (maximumDate.Text, out dateMax)) calendar.MaximumDate = dateMax.Date; DateTime date; if (DateTime.TryParse (entry.Text, out date)) calendar.Date = date; }; PackStart (calendar); PackStart (entry); PackStart (minimumDate); PackStart (maximumDate); PackStart (button); PackStart (label); }
public Windows() { Button b = new Button ("Show borderless window"); PackStart (b); b.Clicked += delegate { Window w = new Window (); w.Decorated = false; Button c = new Button ("This is a window"); // c.Margin.SetAll (10); w.Content = c; c.Clicked += delegate { w.Dispose (); }; var bpos = b.ScreenBounds; w.Bounds = new Rectangle (bpos.X, bpos.Y + b.Size.Height, w.Bounds.Width, w.Bounds.Height); w.Show (); }; b = new Button ("Show message dialog"); PackStart (b); b.Clicked += delegate { MessageDialog.ShowMessage (ParentWindow, "Hi there!"); }; Button db = new Button ("Show custom dialog"); PackStart (db); db.Clicked += delegate { Dialog d = new Dialog (); d.Title = "This is a dialog"; Table t = new Table (); t.Attach (new Label ("Some field:"), 0, 1, 0, 1); t.Attach (new TextEntry (), 1, 2, 0, 1); t.Attach (new Label ("Another field:"), 0, 1, 1, 2); t.Attach (new TextEntry (), 1, 2, 1, 2); d.Content = t; Command custom = new Command ("Custom"); d.Buttons.Add (new DialogButton (custom)); d.Buttons.Add (new DialogButton ("Custom OK", Command.Ok)); d.Buttons.Add (new DialogButton (Command.Cancel)); d.Buttons.Add (new DialogButton (Command.Ok)); var r = d.Run (this.ParentWindow); db.Label = "Result: " + r.Label; d.Dispose (); }; }
public NoGameWidget() { HasBorder = false; ImageView view = new ImageView(imgError); AddChild(view, 15, 15); AddChild(new Label("No games where found"), 46, 15); var link = new Button(" Select Games "); link.Clicked += (s, e) => { App.MainWindow.ShowGameSelector(); }; AddChild(link, WidthRequest - 115, 12); }
public AppWindow () { nativeToolkit = Toolkit.Load (ToolkitType.Cocoa); HBox box = new HBox (); var b = new Button ("Gtk Test Window"); b.Clicked += HandleClicked; box.PackStart (b, BoxMode.FillAndExpand); b = nativeToolkit.CreateObject<Button> (); b.Label = "Cocoa Test Window"; b.Clicked += HandleClickedCocoa; var wped = Toolkit.CurrentEngine.WrapWidget (b); box.PackStart (wped, BoxMode.FillAndExpand); Content = box; }
public RunConfigurationsPanelWidget(RunConfigurationsPanel panel, OptionsDialog dialog) { this.panel = panel; this.Margin = 6; Spacing = 6; list = new RunConfigurationsList(); this.PackStart(list, true); var box = new Xwt.HBox(); box.Spacing = 6; var btn = new Xwt.Button(GettextCatalog.GetString("New")); btn.Clicked += OnAddConfiguration; box.PackStart(btn, false); copyButton = new Xwt.Button(GettextCatalog.GetString("Duplicate")); copyButton.Clicked += OnCopyConfiguration; box.PackStart(copyButton, false); renameButton = new Xwt.Button(GettextCatalog.GetString("Rename")); renameButton.Clicked += OnRenameConfiguration; box.PackStart(renameButton, false); removeButton = new Xwt.Button(GettextCatalog.GetString("Remove")); removeButton.Clicked += OnRemoveConfiguration; box.PackEnd(removeButton, false); Fill(); this.PackStart(box, false); list.SelectionChanged += (sender, e) => UpdateButtons(); list.RowActivated += (sender, e) => panel.ShowConfiguration((ProjectRunConfiguration)list.SelectedConfiguration); UpdateButtons(); }
/// <summary>Add buttons of mounted medias (*nix)</summary> private void AddLinuxMounts() { if (Directory.Exists(@"/mnt")) { foreach (string dir in Directory.GetDirectories(@"/mnt/")) { Xwt.Button NewBtn = new Xwt.Button(null, dir.Replace("/mnt/", "")); NewBtn.Clicked += (o, ea) => { NavigateTo("file://" + dir); }; NewBtn.CanGetFocus = false; NewBtn.Style = Xwt.ButtonStyle.Flat; NewBtn.Margin = -3; NewBtn.Cursor = Xwt.CursorType.Hand; NewBtn.Image = Xwt.Drawing.Image.FromResource(GetType(), "pluginner.Resources.drive-removable-media.png"); s.Stylize(NewBtn); DiskList.PackStart(NewBtn); } } else { AddSysDrives(); //fallback for Windows } }
public ButtonSample() { Button b1 = new Button("Click me"); b1.Clicked += delegate { b1.Label = "Clicked!"; }; PackStart(b1); Button b2 = new Button("Click me"); b2.Style = ButtonStyle.Flat; b2.Clicked += delegate { b2.Label = "Clicked!"; }; PackStart(b2); PackStart(new Button(StockIcons.ZoomIn.WithSize(22))); PackStart(new Button(new CustomImage().WithSize(22), "with red background") { BackgroundColor = Colors.Red }); MenuButton mb = new MenuButton("This is a Menu Button"); Menu men = new Menu(); men.Items.Add(new MenuItem("First")); men.Items.Add(new MenuItem("Second")); men.Items.Add(new MenuItem("Third")); men.Items.Add(new SeparatorMenuItem()); men.Items.Add(new CheckBoxMenuItem("Check") { Checked = true }); men.Items.Add(new RadioButtonMenuItem("Radio") { Checked = true }); men.Items.Add(new MenuItem("With image") { Image = Image.FromResource(typeof(App), "class.png") }); mb.Menu = men; PackStart(mb); foreach (var mi in men.Items) { var cmi = mi; mi.Clicked += delegate { mb.Label = cmi.Label + " Clicked"; }; } ToggleButton tb = new ToggleButton("Toggle me"); PackStart(tb); var b = new Button("Mini button"); b.Style = ButtonStyle.Borderless; PackStart(b); tb = new ToggleButton("Mini toggle"); tb.Style = ButtonStyle.Borderless; PackStart(tb); b = new Button(" ? "); b.Type = ButtonType.Help; PackStart(b); var child = new VBox(); var container = new MyWidget { Content = child }; var button = new Xwt.Button("Click to add a child"); button.Clicked += delegate { child.PackStart(new Xwt.Label("Child" + child.Children.Count())); }; var content = new Xwt.VBox(); content.PackStart(button); content.PackStart(container); PackStart(content); }
public ButtonSample() { Button b1 = new Button("Click me"); b1.Clicked += delegate { b1.Label = "Clicked!"; }; PackStart(b1, false, false); Button b2 = new Button("Click me"); b2.Style = ButtonStyle.Flat; b2.Clicked += delegate { b2.Label = "Clicked!"; }; PackStart(b2); PackStart(new Button(StockIcons.ZoomIn.WithSize(22))); PackStart(new Button(StockIcons.ZoomIn.WithSize(32), "Custom Size") { WidthRequest = 110, MinHeight = 50 }); var hbox = new HBox(); hbox.PackStart(new Button(StockIcons.ZoomIn.WithSize(22), "Zoom In") { ImagePosition = ContentPosition.Top }); hbox.PackStart(new Button(StockIcons.ZoomOut.WithSize(22), "Zoom Out") { ImagePosition = ContentPosition.Bottom }); hbox.PackStart(new Button(StockIcons.Information.WithSize(48), "Info") { ImagePosition = ContentPosition.Top }, true); hbox.PackEnd(new Button("Custom" + Environment.NewLine + "Width") { MinWidth = 110 }); PackStart(hbox); PackStart(new Button(new CustomImage().WithSize(22), "with red background") { BackgroundColor = Colors.Red }); MenuButton mb = new MenuButton("This is a Menu Button"); Menu men = new Menu(); men.Items.Add(new MenuItem("First")); men.Items.Add(new MenuItem("Second")); men.Items.Add(new MenuItem("Third")); men.Items.Add(new SeparatorMenuItem()); men.Items.Add(new MenuItem() { Markup = "<span color='blue'>Formatted</span> Item" }); men.Items.Add(new SeparatorMenuItem()); men.Items.Add(new CheckBoxMenuItem("Check") { Checked = true }); men.Items.Add(new RadioButtonMenuItem("Radio") { Checked = true }); men.Items.Add(new MenuItem("With image") { Image = Image.FromResource(typeof(App), "class.png") }); mb.Menu = men; PackStart(mb); foreach (var mi in men.Items) { var cmi = mi; mi.Clicked += delegate { mb.Markup = cmi.Markup ?? cmi.Label + " Clicked"; }; } ToggleButton tb1 = new ToggleButton("Toggle me"); ToggleButton tb2 = new ToggleButton("Mini toggle"); tb1.Toggled += delegate(object sender, EventArgs e) { if (tb1.Active) { tb1.Label = "Toggled"; } else { tb1.Label = "Untoggled"; } tb2.Active = tb1.Active; }; PackStart(tb1); var b = new Button("Mini button"); b.Style = ButtonStyle.Borderless; PackStart(b); tb2.Style = ButtonStyle.Borderless; tb2.Toggled += delegate(object sender, EventArgs e) { if (tb2.Active) { tb2.Label = "Toggled"; } else { tb2.Label = "Untoggled"; } tb1.Active = tb2.Active; }; PackStart(tb2); b = new Button(" ? "); b.Type = ButtonType.Help; PackStart(b); var fb = new Button("Formatted Content Button"); fb.Markup = "<b>Formatted</b> <span color='blue'>Content</span> Button"; PackStart(fb); var child = new VBox(); var container = new MyWidget { Content = child }; var button = new Xwt.Button("Click to add a child"); button.Clicked += delegate { child.PackStart(new Xwt.Label("Child" + child.Children.Count())); }; var content = new Xwt.VBox(); content.PackStart(button); content.PackStart(container); PackStart(content); }
/// <summary>Add autobookmark "system disks" onto disk toolbar</summary> private void AddSysDrives() { foreach (System.IO.DriveInfo di in System.IO.DriveInfo.GetDrives()) { string d = di.Name; Xwt.Button NewBtn = new Xwt.Button(null, d); NewBtn.Clicked += (o, ea) => { NavigateTo("file://" + d); }; NewBtn.CanGetFocus = false; NewBtn.Style = Xwt.ButtonStyle.Flat; NewBtn.Margin = -3; NewBtn.Cursor = Xwt.CursorType.Hand; NewBtn.Sensitive = di.IsReady; if (di.IsReady) { NewBtn.TooltipText = di.VolumeLabel + " (" + di.DriveFormat + ")"; } /* todo: rewrite the code; possibly change the XWT to allow * change the internal padding of the button. */ switch (di.DriveType) { case System.IO.DriveType.Fixed: NewBtn.Image = Xwt.Drawing.Image.FromResource(GetType(), "pluginner.Resources.drive-harddisk.png"); break; case System.IO.DriveType.CDRom: NewBtn.Image = Xwt.Drawing.Image.FromResource(GetType(), "pluginner.Resources.drive-optical.png"); break; case System.IO.DriveType.Removable: NewBtn.Image = Xwt.Drawing.Image.FromResource(GetType(), "pluginner.Resources.drive-removable-media.png"); break; case System.IO.DriveType.Network: NewBtn.Image = Xwt.Drawing.Image.FromResource(GetType(), "pluginner.Resources.network-server.png"); break; case System.IO.DriveType.Ram: NewBtn.Image = Xwt.Drawing.Image.FromResource(GetType(), "pluginner.Resources.emblem-system.png"); break; case System.IO.DriveType.Unknown: NewBtn.Image = Xwt.Drawing.Image.FromResource(GetType(), "pluginner.Resources.image-missing.png"); break; } //OS-specific icons if (d.StartsWith("A:")) { NewBtn.Image = Xwt.Drawing.Image.FromResource(GetType(), "pluginner.Resources.media-floppy.png"); } if (d.StartsWith("B:")) { NewBtn.Image = Xwt.Drawing.Image.FromResource(GetType(), "pluginner.Resources.media-floppy.png"); } if (d.StartsWith("/dev")) { NewBtn.Image = Xwt.Drawing.Image.FromResource(GetType(), "pluginner.Resources.preferences-desktop-peripherals.png"); } if (d.StartsWith("/proc")) { NewBtn.Image = Xwt.Drawing.Image.FromResource(GetType(), "pluginner.Resources.emblem-system.png"); } if (d == "/") { NewBtn.Image = Xwt.Drawing.Image.FromResource(GetType(), "pluginner.Resources.root-folder.png"); } s.Stylize(NewBtn); DiskList.PackStart(NewBtn); } }