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); }
public ListViewCombos() { ListView list = new ListView (); var indexField = new DataField<int> (); var indexField2 = new DataField<int> (); var itemsField = new DataField<ItemCollection> (); ListStore store = new ListStore (indexField, indexField2, itemsField); list.DataSource = store; list.GridLinesVisible = GridLines.Horizontal; var comboCellView = new ComboBoxCellView { Editable = true, SelectedIndexField = indexField }; comboCellView.Items.Add (1, "one"); comboCellView.Items.Add (2, "two"); comboCellView.Items.Add (3, "three"); list.Columns.Add (new ListViewColumn ("List 1", comboCellView)); var comboCellView2 = new ComboBoxCellView { Editable = true, SelectedIndexField = indexField2, ItemsField = itemsField }; list.Columns.Add (new ListViewColumn ("List 2", comboCellView2)); int p = 0; for (int n = 0; n < 10; n++) { var r = store.AddRow (); store.SetValue (r, indexField, n % 3); var col = new ItemCollection (); for (int i = 0; i < 3; i++) { col.Add (p, "p" + p); p++; } store.SetValues (r, indexField2, n % 3, itemsField, col); } PackStart (list, true); }
public ListView2() { ListView list = new ListView (); var editableActiveField = new DataField<bool> (); var nonEditableActiveField = new DataField<bool> (); var textField = new DataField<string> (); var textField2 = new DataField<string> (); var editableField = new DataField<bool> (); var somewhatEditableData = new DataField<bool>(); ListStore store = new ListStore(editableActiveField, nonEditableActiveField, textField, textField2, editableField, somewhatEditableData); list.DataSource = store; list.Columns.Add (new ListViewColumn("Editable", new CheckBoxCellView { Editable = true, ActiveField = editableActiveField })); list.Columns.Add (new ListViewColumn("Not Editable", new CheckBoxCellView { Editable = false, ActiveField = nonEditableActiveField })); list.Columns.Add (new ListViewColumn("Editable", new TextCellView { Editable = true, TextField = textField })); list.Columns.Add(new ListViewColumn("Somewhat Editable", new CheckBoxCellView { EditableField = editableField, ActiveField = somewhatEditableData })); list.Columns.Add (new ListViewColumn("Somewhat Editable", new TextCellView { EditableField = editableField, TextField = textField2 })); Random rand = new Random (); for (int n=0; n<100; n++) { var r = store.AddRow (); store.SetValue (r, editableActiveField, rand.Next(0, 2) == 0); store.SetValue (r, nonEditableActiveField, rand.Next(0, 2) == 0); store.SetValue(r, somewhatEditableData, rand.Next(0, 2) == 0); store.SetValue (r, textField, n.ToString ()); var edit = (n % 2) == 0; store.SetValue (r, editableField, edit); store.SetValue (r, textField2, edit ? "editable" : "not editable"); } PackStart (list, true); }
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.IsResizeable = true; var checkBoxCellView = new CheckBoxCellView (completeOnSpace); checkBoxCellView.Editable = true; var completeOnSpaceColumn = list.Columns.Add (GettextCatalog.GetString ("Complete on space"), checkBoxCellView); completeOnSpaceColumn.IsResizeable = true; var textCellView = new TextCellView (completeOnChars); textCellView.Editable = true; var doNotCompleteOnColumn = list.Columns.Add (GettextCatalog.GetString ("Do complete on"), textCellView); doNotCompleteOnColumn.IsResizeable = 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 ListView1() { PackStart (new Label ("The listview should have a red background")); ListView list = new ListView () { BackgroundColor = Colors.Red }; ListStore store = new ListStore (name, icon, text, icon2); list.DataSource = store; list.Columns.Add ("Name", icon, name); list.Columns.Add ("Text", icon2, text); var png = Image.FromResource (typeof(App), "class.png"); 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); } PackStart (list, BoxMode.FillAndExpand); list.RowActivated += delegate(object sender, ListViewRowEventArgs e) { MessageDialog.ShowMessage ("Row " + e.RowIndex + " activated"); }; }
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); }
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 override IScrollableWidget CreateScrollableWidget () { DataField<string> text = new DataField<string> (); ListStore s = new ListStore (text); var list = new ListView (s); list.Columns.Add ("Hi", text); for (int n = 0; n < 100; n++) { var r = s.AddRow (); s.SetValue (r, text, n + new string ('.',100)); } return list; }
/// <summary> /// Constructor. /// </summary> public TextEntryHelper() { // Create text entry InnerTextEntry = new TextEntry(); // Default bind InnerTextEntry.Changed += InnerTextEntry_Changed; // Self changed - show menu Changed += TextEntryHelper_Changed; // Key binding events InnerTextEntry.KeyReleased += InnerTextEntry_KeyPressed; // Helper VBox EntryHelper = new VBox(); EntryHelper.PackStart(InnerTextEntry, true, true); // Create list store Values = new DataField<string>(); HelperStore = new ListStore(Values); // Create helper list view HelperListView = new ListView() { MinHeight = 75, HeightRequest = 75, Visible = false, HeadersVisible = false, DataSource = HelperStore, SelectionMode = SelectionMode.Single }; HelperListView.Columns.Add("Name", Values); // Click selection HelperListView.ButtonReleased += HelperListView_ButtonPressed; // Scroll view to EntryHelper.PackStart(HelperListView, true, true); // Margins MarginTop = 4; MarginBottom = 5; // Set as content Content = EntryHelper; // Show tree items InnerTextEntry.GotFocus += GotFocusHandler; }
public ListView2() { ListView list = new ListView(); var editableActiveField = new DataField<bool>(); var nonEditableActiveField = new DataField<bool>(); var textField = new DataField<string>(); var textField2 = new DataField<string>(); var editableField = new DataField<bool>(); var somewhatEditableData = new DataField<bool>(); ListStore store = new ListStore(editableActiveField, nonEditableActiveField, textField, textField2, editableField, somewhatEditableData); list.DataSource = store; list.GridLinesVisible = GridLines.Horizontal; var checkCellView = new CheckBoxCellView { Editable = true, ActiveField = editableActiveField }; checkCellView.Toggled += (sender, e) => { if (list.CurrentEventRow == 0) { MessageDialog.ShowError("CurrentEventRow is null. This is not supposed to happen"); } else { store.SetValue(list.CurrentEventRow, textField, "Toggled"); } }; list.Columns.Add(new ListViewColumn("Editable", checkCellView)); list.Columns.Add(new ListViewColumn("Not Editable", new CheckBoxCellView { Editable = false, ActiveField = nonEditableActiveField })); list.Columns.Add(new ListViewColumn("Editable", new TextCellView { Editable = true, TextField = textField })); list.Columns.Add(new ListViewColumn("Somewhat Editable", new CheckBoxCellView { EditableField = editableField, ActiveField = somewhatEditableData })); list.Columns.Add(new ListViewColumn("Somewhat Editable", new TextCellView { EditableField = editableField, TextField = textField2 })); Random rand = new Random(); for (int n = 0; n < 100; n++) { var r = store.AddRow(); store.SetValue(r, editableActiveField, rand.Next(0, 2) == 0); store.SetValue(r, nonEditableActiveField, rand.Next(0, 2) == 0); store.SetValue(r, somewhatEditableData, rand.Next(0, 2) == 0); store.SetValue(r, textField, n.ToString()); var edit = (n % 2) == 0; store.SetValue(r, editableField, edit); store.SetValue(r, textField2, edit ? "editable" : "not editable"); } PackStart(list, true); }
public WidgetFocus () { var text = new TextEntry (); var check = new CheckBox ("CheckBox"); var slider = new HSlider (); ListStore store = new ListStore (value); var list = new ListView (store); list.Columns.Add ("Value", value); list.HeadersVisible = false; for (int n=0; n<10; n++) { var r = store.AddRow (); store.SetValue (r, value, "Value " + n); } var btn1 = new Button ("TextEnty"); var btn2 = new Button ("Checkbox"); var btn3 = new Button ("Slider"); var btn4 = new Button ("ListBox"); var btn5 = new Button ("Button"); btn1.Clicked += (sender, e) => text.SetFocus (); btn2.Clicked += (sender, e) => check.SetFocus (); btn3.Clicked += (sender, e) => slider.SetFocus (); btn4.Clicked += (sender, e) => list.SetFocus (); btn5.Clicked += (sender, e) => btn1.SetFocus (); var btnBox = new HBox (); btnBox.PackStart (btn1); btnBox.PackStart (btn2); btnBox.PackStart (btn3); btnBox.PackStart (btn4); btnBox.PackStart (btn5); var focusBox = new HBox (); var vbox = new VBox (); vbox.PackStart (text); vbox.PackStart (check); vbox.PackStart (slider); focusBox.PackStart (vbox); focusBox.PackStart (list, true); PackStart (btnBox); PackStart (focusBox, true); }
public ListView1() { ListView list = new ListView (); ListStore store = new ListStore (name, icon, text, icon2); list.DataSource = store; list.Columns.Add ("Name", icon, name); list.Columns.Add ("Text", icon2, text); var png = Image.FromResource (typeof(App), "class.png"); 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); } PackStart (list, BoxMode.FillAndExpand); }
public ListViewCellBounds () { MinHeight = 120; MinWidth = 100; container = new VBox (); ListView = new ListView(); ListView.GridLinesVisible = GridLines.Both; ListStore = new ListStore (name, icon, text, check, progress); ListView.DataSource = ListStore; ListView.Columns.Add ("Name", icon, name); ListView.Columns.Add ("Check", new TextCellView () { TextField = text }, new CustomCell () { ValueField = progress, Size = new Size(20, 20) }, new CheckBoxCellView() { ActiveField = check }); //list.Columns.Add ("Progress", new TextCellView () { TextField = text }, new CustomCell () { ValueField = progress }, new TextCellView () { TextField = text } ); ListView.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 = ListStore.AddRow (); ListStore.SetValue (r, icon, png); if (rand.Next (50) > 25) { ListStore.SetValue (r, name, "Value \n" + n); ListStore.SetValue (r, check, false); } else { ListStore.SetValue (r, name, "Value " + n); ListStore.SetValue (r, check, true); } ListStore.SetValue (r, text, "Text " + n); ListStore.SetValue (r, progress, new CellData { Value = rand.Next () % 100 }); } ListView.SelectionChanged += (sender, e) => UpdateTracker (ListView.SelectedRow); ListView.MouseMoved += (sender, e) => UpdateTracker (ListView.GetRowAtPosition (e.X, e.Y)); drawer = new ListTrackingCanvas (this); container.PackStart (ListView, true); container.PackStart (drawer); AddChild (container); }
public RunConfigurationsList() { listStore = new Xwt.ListStore(configCol, configNameCol, configIconCol); list = new Xwt.ListView(listStore); list.HeadersVisible = false; var imgCell = new ImageCellView { ImageField = configIconCol }; var textCell = new TextCellView { MarkupField = configNameCol }; list.Columns.Add(GettextCatalog.GetString("Name"), imgCell, textCell); Content = list; list.SelectionChanged += (s, o) => SelectionChanged?.Invoke(this, o); list.RowActivated += (s, o) => RowActivated?.Invoke(this, o); }
public ListViewDialog () { Title = "Xwt List View Box Dialog"; Width = 500; Height = 400; var vbox = new VBox (); Content = vbox; listView = new ListView (); listView.HeadersVisible = false; vbox.PackStart (listView); listStore = new ListStore (dataField); listView.DataSource = listStore; cellView = new CustomCanvasCellView (); var column = new ListViewColumn ("test", cellView); listView.Columns.Add (column); AddItems (); }
public ListView2() { ListView list = new ListView (); editable = new DataField<bool> (); nonEditable = new DataField<bool> (); var textField = new DataField<string> (); ListStore store = new ListStore (editable, nonEditable, textField); list.DataSource = store; list.Columns.Add (new ListViewColumn("Editable", new CheckBoxCellView { Editable = true, ActiveField = editable })); list.Columns.Add (new ListViewColumn("Not Editable", new CheckBoxCellView { Editable = false, ActiveField = nonEditable })); list.Columns.Add (new ListViewColumn("Editable", new TextCellView { Editable = true, TextField = textField })); Random rand = new Random (); for (int n=0; n<100; n++) { var r = store.AddRow (); store.SetValue (r, editable, rand.Next(0, 2) == 0); store.SetValue (r, nonEditable, rand.Next(0, 2) == 0); store.SetValue (r, textField, n.ToString ()); } PackStart (list, true); }
public override Xwt.Widget Makeup(IXwtWrapper Parent) { Xwt.ListView Target = new Xwt.ListView() { BorderVisible = this.BorderVisible, HeadersVisible = this.HeadersVisible, SelectionMode = this.SelectionMode, VerticalScrollPolicy = this.VScrollPolicy, HorizontalScrollPolicy = this.HScrollPolicy }; if (this.Source != "") { IListDataSource Source = (IListDataSource)Parent.GetType().GetField(this.Source).GetValue(Parent); Target.DataSource = Source; Type BackgroundType = (Source).GetType().GetGenericArguments()[0]; if (ColumnDefinition != null && ColumnDefinition.Count() > 0) { foreach (XwtColumnDefinitionNode N in ColumnDefinition) { IDataField X = DataField.GenerateDataField(N.Source, BackgroundType); ListViewColumn C = new ListViewColumn(N.Title, CellViewFactory.Make(X, N.Editable)) { SortDataField = X, SortIndicatorVisible = N.Sortable, CanResize = N.Resizable }; Target.Columns.Add(C); } } } if (Target.DataSource != null && Target.DataSource.RowCount > 0) Target.SelectRow(this.Selection); WindowController.TryAttachEvent(Target, "SelectionChanged", Parent, Changed); WindowController.TryAttachEvent(Target, "RowActivated", Parent, Clicked); InitWidget(Target, Parent); return Target; }
public OptionView(LauncherWindow window) { _texturePacks = new List<TexturePack>(); _lastTexturePack = null; Window = window; this.MinWidth = 250; OptionLabel = new Label("Options") { Font = Font.WithSize(16), TextAlignment = Alignment.Center }; ResolutionLabel = new Label("Select a resolution..."); ResolutionComboBox = new ComboBox(); int resolutionIndex = -1; for (int i = 0; i < WindowResolution.Defaults.Length; i++) { ResolutionComboBox.Items.Add(WindowResolution.Defaults[i].ToString()); if (resolutionIndex == -1) { resolutionIndex = ((WindowResolution.Defaults[i].Width == UserSettings.Local.WindowResolution.Width) && (WindowResolution.Defaults[i].Height == UserSettings.Local.WindowResolution.Height)) ? i : -1; } } if (resolutionIndex == -1) { ResolutionComboBox.Items.Add(UserSettings.Local.WindowResolution.ToString()); resolutionIndex = ResolutionComboBox.Items.Count - 1; } ResolutionComboBox.SelectedIndex = resolutionIndex; FullscreenCheckBox = new CheckBox() { Label = "Fullscreen mode", State = (UserSettings.Local.IsFullscreen) ? CheckBoxState.On : CheckBoxState.Off }; TexturePackLabel = new Label("Select a texture pack..."); TexturePackImageField = new DataField<Image>(); TexturePackTextField = new DataField<string>(); TexturePackStore = new ListStore(TexturePackImageField, TexturePackTextField); TexturePackListView = new ListView { MinHeight = 200, SelectionMode = SelectionMode.Single, DataSource = TexturePackStore, HeadersVisible = false }; OpenFolderButton = new Button("Open texture pack folder"); BackButton = new Button("Back"); TexturePackListView.Columns.Add("Image", TexturePackImageField); TexturePackListView.Columns.Add("Text", TexturePackTextField); ResolutionComboBox.SelectionChanged += (sender, e) => { UserSettings.Local.WindowResolution = WindowResolution.FromString(ResolutionComboBox.SelectedText); UserSettings.Local.Save(); }; FullscreenCheckBox.Clicked += (sender, e) => { UserSettings.Local.IsFullscreen = !UserSettings.Local.IsFullscreen; UserSettings.Local.Save(); }; TexturePackListView.SelectionChanged += (sender, e) => { var texturePack = _texturePacks[TexturePackListView.SelectedRow]; if (_lastTexturePack != texturePack) { UserSettings.Local.SelectedTexturePack = texturePack.Name; UserSettings.Local.Save(); } }; OpenFolderButton.Clicked += (sender, e) => { var dir = new DirectoryInfo(TexturePack.TexturePackPath); Process.Start(dir.FullName); }; BackButton.Clicked += (sender, e) => { Window.MainContainer.Remove(this); Window.MainContainer.PackEnd(Window.MainMenuView); }; OfficialAssetsButton = new Button("Download Minecraft assets") { Visible = false }; OfficialAssetsButton.Clicked += OfficialAssetsButton_Clicked; OfficialAssetsProgress = new ProgressBar() { Visible = false, Indeterminate = true }; LoadTexturePacks(); this.PackStart(OptionLabel); this.PackStart(ResolutionLabel); this.PackStart(ResolutionComboBox); this.PackStart(FullscreenCheckBox); this.PackStart(TexturePackLabel); this.PackStart(TexturePackListView); this.PackStart(OfficialAssetsProgress); this.PackStart(OfficialAssetsButton); this.PackStart(OpenFolderButton); this.PackEnd(BackButton); }
void Build () { Title = Catalog.GetString ("Add Packages"); Width = 820; Height = 520; Padding = new WidgetSpacing (); // Top part of dialog: // Package sources and search. var topHBox = new HBox (); topHBox.Margin = new WidgetSpacing (8, 5, 6, 5); packageSourceComboBox = new ComboBox (); packageSourceComboBox.MinWidth = 200; topHBox.PackStart (packageSourceComboBox); packageSearchEntry = new SearchTextEntry (); packageSearchEntry.WidthRequest = 187; topHBox.PackEnd (packageSearchEntry); this.HeaderContent = topHBox; // Middle of dialog: // Packages and package information. var mainVBox = new VBox (); Content = mainVBox; var middleHBox = new HBox (); middleHBox.Spacing = 0; var middleFrame = new FrameBox (); middleFrame.Content = middleHBox; middleFrame.BorderWidth = new WidgetSpacing (0, 0, 0, 1); middleFrame.BorderColor = lineBorderColor; mainVBox.PackStart (middleFrame, true, true); // Error information. var packagesListVBox = new VBox (); packagesListVBox.Spacing = 0; errorMessageHBox = new HBox (); errorMessageHBox.Margin = new WidgetSpacing (); errorMessageHBox.BackgroundColor = Colors.Orange; errorMessageHBox.Visible = false; var errorImage = new ImageView (); errorImage.Margin = new WidgetSpacing (10, 0, 0, 0); errorImage.Image = ImageService.GetIcon (Stock.Warning, Gtk.IconSize.Menu); errorImage.HorizontalPlacement = WidgetPlacement.End; errorMessageHBox.PackStart (errorImage); errorMessageLabel = new Label (); errorMessageLabel.TextColor = Colors.White; errorMessageLabel.Margin = new WidgetSpacing (5, 5, 5, 5); errorMessageLabel.Wrap = WrapMode.Word; errorMessageHBox.PackStart (errorMessageLabel, true); packagesListVBox.PackStart (errorMessageHBox); // Packages list. middleHBox.PackStart (packagesListVBox, true, true); packagesListView = new ListView (); packagesListView.BorderVisible = false; packagesListView.HeadersVisible = false; packagesListVBox.PackStart (packagesListView, true, true); // Loading spinner. var loadingSpinnerHBox = new HBox (); loadingSpinnerHBox.HorizontalPlacement = WidgetPlacement.Center; var loadingSpinner = new Spinner (); loadingSpinner.Animate = true; loadingSpinner.MinWidth = 20; loadingSpinnerHBox.PackStart (loadingSpinner); loadingSpinnerLabel = new Label (); loadingSpinnerLabel.Text = Catalog.GetString ("Loading package list..."); loadingSpinnerHBox.PackEnd (loadingSpinnerLabel); loadingSpinnerFrame = new FrameBox (); loadingSpinnerFrame.Visible = false; loadingSpinnerFrame.BackgroundColor = Colors.White; loadingSpinnerFrame.Content = loadingSpinnerHBox; loadingSpinnerFrame.BorderWidth = new WidgetSpacing (); packagesListVBox.PackStart (loadingSpinnerFrame, true, true); // No packages found label. var noPackagesFoundHBox = new HBox (); noPackagesFoundHBox.HorizontalPlacement = WidgetPlacement.Center; var noPackagesFoundLabel = new Label (); noPackagesFoundLabel.Text = Catalog.GetString ("No matching packages found."); noPackagesFoundHBox.PackEnd (noPackagesFoundLabel); noPackagesFoundFrame = new FrameBox (); noPackagesFoundFrame.Visible = false; noPackagesFoundFrame.BackgroundColor = Colors.White; noPackagesFoundFrame.Content = noPackagesFoundHBox; noPackagesFoundFrame.BorderWidth = new WidgetSpacing (); packagesListVBox.PackStart (noPackagesFoundFrame, true, true); // Package information packageInfoVBox = new VBox (); var packageInfoFrame = new FrameBox (); packageInfoFrame.BackgroundColor = packageInfoBackgroundColor; packageInfoFrame.BorderWidth = new WidgetSpacing (); packageInfoFrame.Content = packageInfoVBox; packageInfoVBox.Margin = new WidgetSpacing (15, 12, 15, 12); var packageInfoContainerVBox = new VBox (); packageInfoContainerVBox.WidthRequest = 240; packageInfoContainerVBox.PackStart (packageInfoFrame, true, true); var packageInfoScrollView = new ScrollView (); packageInfoScrollView.BorderVisible = false; packageInfoScrollView.HorizontalScrollPolicy = ScrollPolicy.Never; packageInfoScrollView.Content = packageInfoContainerVBox; packageInfoScrollView.BackgroundColor = packageInfoBackgroundColor; var packageInfoScrollViewFrame = new FrameBox (); packageInfoScrollViewFrame.BackgroundColor = packageInfoBackgroundColor; packageInfoScrollViewFrame.BorderWidth = new WidgetSpacing (1, 0, 0, 0); packageInfoScrollViewFrame.BorderColor = lineBorderColor; packageInfoScrollViewFrame.Content = packageInfoScrollView; middleHBox.PackEnd (packageInfoScrollViewFrame); // Package name and version. var packageNameHBox = new HBox (); packageInfoVBox.PackStart (packageNameHBox); packageNameLabel = new Label (); packageNameLabel.Ellipsize = EllipsizeMode.End; Font packageInfoSmallFont = packageNameLabel.Font.WithScaledSize (0.8); packageNameHBox.PackStart (packageNameLabel, true); packageVersionLabel = new Label (); packageVersionLabel.TextAlignment = Alignment.End; packageNameHBox.PackEnd (packageVersionLabel); // Package description. packageDescription = new Label (); packageDescription.Wrap = WrapMode.Word; packageDescription.Font = packageNameLabel.Font.WithScaledSize (0.9); packageDescription.BackgroundColor = packageInfoBackgroundColor; packageInfoVBox.PackStart (packageDescription); // Package id. var packageIdHBox = new HBox (); packageIdHBox.MarginTop = 7; packageInfoVBox.PackStart (packageIdHBox); var packageIdLabel = new Label (); packageIdLabel.Font = packageInfoSmallFont; packageIdLabel.Markup = Catalog.GetString ("<b>Id</b>"); packageIdHBox.PackStart (packageIdLabel); packageId = new Label (); packageId.Ellipsize = EllipsizeMode.End; packageId.TextAlignment = Alignment.End; packageId.Font = packageInfoSmallFont; packageIdLink = new LinkLabel (); packageIdLink.Ellipsize = EllipsizeMode.End; packageIdLink.TextAlignment = Alignment.End; packageIdLink.Font = packageInfoSmallFont; packageIdHBox.PackEnd (packageIdLink, true); packageIdHBox.PackEnd (packageId, true); // Package author var packageAuthorHBox = new HBox (); packageInfoVBox.PackStart (packageAuthorHBox); var packageAuthorLabel = new Label (); packageAuthorLabel.Markup = Catalog.GetString ("<b>Author</b>"); packageAuthorLabel.Font = packageInfoSmallFont; packageAuthorHBox.PackStart (packageAuthorLabel); packageAuthor = new Label (); packageAuthor.TextAlignment = Alignment.End; packageAuthor.Ellipsize = EllipsizeMode.End; packageAuthor.Font = packageInfoSmallFont; packageAuthorHBox.PackEnd (packageAuthor, true); // Package published var packagePublishedHBox = new HBox (); packageInfoVBox.PackStart (packagePublishedHBox); var packagePublishedLabel = new Label (); packagePublishedLabel.Markup = Catalog.GetString ("<b>Published</b>"); packagePublishedLabel.Font = packageInfoSmallFont; packagePublishedHBox.PackStart (packagePublishedLabel); packagePublishedDate = new Label (); packagePublishedDate.Font = packageInfoSmallFont; packagePublishedHBox.PackEnd (packagePublishedDate); // Package downloads var packageDownloadsHBox = new HBox (); packageInfoVBox.PackStart (packageDownloadsHBox); var packageDownloadsLabel = new Label (); packageDownloadsLabel.Markup = Catalog.GetString ("<b>Downloads</b>"); packageDownloadsLabel.Font = packageInfoSmallFont; packageDownloadsHBox.PackStart (packageDownloadsLabel); packageDownloads = new Label (); packageDownloads.Font = packageInfoSmallFont; packageDownloadsHBox.PackEnd (packageDownloads); // Package license. var packageLicenseHBox = new HBox (); packageInfoVBox.PackStart (packageLicenseHBox); var packageLicenseLabel = new Label (); packageLicenseLabel.Markup = Catalog.GetString ("<b>License</b>"); packageLicenseLabel.Font = packageInfoSmallFont; packageLicenseHBox.PackStart (packageLicenseLabel); packageLicenseLink = new LinkLabel (); packageLicenseLink.Text = Catalog.GetString ("View License"); packageLicenseLink.Font = packageInfoSmallFont; packageLicenseHBox.PackEnd (packageLicenseLink); // Package project page. var packageProjectPageHBox = new HBox (); packageInfoVBox.PackStart (packageProjectPageHBox); var packageProjectPageLabel = new Label (); packageProjectPageLabel.Markup = Catalog.GetString ("<b>Project Page</b>"); packageProjectPageLabel.Font = packageInfoSmallFont; packageProjectPageHBox.PackStart (packageProjectPageLabel); packageProjectPageLink = new LinkLabel (); packageProjectPageLink.Text = Catalog.GetString ("Visit Page"); packageProjectPageLink.Font = packageInfoSmallFont; packageProjectPageHBox.PackEnd (packageProjectPageLink); // Package dependencies var packageDependenciesHBox = new HBox (); packageInfoVBox.PackStart (packageDependenciesHBox); var packageDependenciesLabel = new Label (); packageDependenciesLabel.Markup = Catalog.GetString ("<b>Dependencies</b>"); packageDependenciesLabel.Font = packageInfoSmallFont; packageDependenciesHBox.PackStart (packageDependenciesLabel); packageDependenciesNoneLabel = new Label (); packageDependenciesNoneLabel.Text = Catalog.GetString ("None"); packageDependenciesNoneLabel.Font = packageInfoSmallFont; packageDependenciesHBox.PackEnd (packageDependenciesNoneLabel); // Package dependencies list. packageDependenciesListHBox = new HBox (); packageDependenciesListHBox.Visible = false; packageInfoVBox.PackStart (packageDependenciesListHBox); packageDependenciesList = new Label (); packageDependenciesList.Wrap = WrapMode.WordAndCharacter; packageDependenciesList.Margin = new WidgetSpacing (5); packageDependenciesList.Font = packageInfoSmallFont; packageDependenciesListHBox.PackStart (packageDependenciesList, true); // Bottom part of dialog: // Show pre-release packages and Close/Add to Project buttons. var bottomHBox = new HBox (); bottomHBox.Margin = new WidgetSpacing (8, 5, 14, 10); bottomHBox.Spacing = 5; mainVBox.PackStart (bottomHBox); showPrereleaseCheckBox = new CheckBox (); showPrereleaseCheckBox.Label = Catalog.GetString ("Show pre-release packages"); bottomHBox.PackStart (showPrereleaseCheckBox); addPackagesButton = new Button (); addPackagesButton.MinWidth = 120; addPackagesButton.MinHeight = 25; addPackagesButton.Label = Catalog.GetString ("Add Package"); bottomHBox.PackEnd (addPackagesButton); var closeButton = new Button (); closeButton.MinWidth = 120; closeButton.MinHeight = 25; closeButton.Label = Catalog.GetString ("Close"); closeButton.Clicked += (sender, e) => Close (); bottomHBox.PackEnd (closeButton); packageSearchEntry.SetFocus (); packageInfoVBox.Visible = false; }
public MultiplayerView(LauncherWindow window) { Window = window; this.MinWidth = 250; MultiplayerLabel = new Label("Multiplayer") { Font = Font.WithSize(16), TextAlignment = Alignment.Center }; ServerIPEntry = new TextEntry() { PlaceholderText = "Server IP", Text = UserSettings.Local.LastIP }; ConnectButton = new Button("Connect"); BackButton = new Button("Back"); ServerListView = new ListView() { MinHeight = 200, SelectionMode = SelectionMode.Single }; AddServerButton = new Button("Add server"); RemoveServerButton = new Button("Remove") { Sensitive = false }; ServerCreationBox = new VBox() { Visible = false }; NewServerLabel = new Label("Add new server:") { TextAlignment = Alignment.Center }; NewServerName = new TextEntry() { PlaceholderText = "Name" }; NewServerAddress = new TextEntry() { PlaceholderText = "Address" }; CommitAddNewServer = new Button("Add server"); CancelAddNewServer = new Button("Cancel"); var iconField = new DataField<Image>(); var nameField = new DataField<string>(); var playersField = new DataField<string>(); ServerListStore = new ListStore(iconField, nameField, playersField); ServerListView.DataSource = ServerListStore; ServerListView.HeadersVisible = false; ServerListView.Columns.Add(new ListViewColumn("Icon", new ImageCellView { ImageField = iconField })); ServerListView.Columns.Add(new ListViewColumn("Name", new TextCellView { TextField = nameField })); ServerListView.Columns.Add(new ListViewColumn("Players", new TextCellView { TextField = playersField })); ServerIPEntry.KeyReleased += (sender, e) => { if (e.Key == Key.Return || e.Key == Key.NumPadEnter) ConnectButton_Clicked(sender, e); }; BackButton.Clicked += (sender, e) => { Window.InteractionBox.Remove(this); Window.InteractionBox.PackEnd(Window.MainMenuView); }; ConnectButton.Clicked += ConnectButton_Clicked; ServerListView.SelectionChanged += (sender, e) => { RemoveServerButton.Sensitive = ServerListView.SelectedRow != -1; ServerIPEntry.Sensitive = ServerListView.SelectedRow == -1; }; AddServerButton.Clicked += (sender, e) => { AddServerButton.Sensitive = false; RemoveServerButton.Sensitive = false; ConnectButton.Sensitive = false; ServerListView.Sensitive = false; ServerIPEntry.Sensitive = false; ServerCreationBox.Visible = true; }; CancelAddNewServer.Clicked += (sender, e) => { AddServerButton.Sensitive = true; RemoveServerButton.Sensitive = true; ConnectButton.Sensitive = true; ServerListView.Sensitive = true; ServerIPEntry.Sensitive = true; ServerCreationBox.Visible = false; }; RemoveServerButton.Clicked += (sender, e) => { var server = UserSettings.Local.FavoriteServers[ServerListView.SelectedRow]; ServerListStore.RemoveRow(ServerListView.SelectedRow); UserSettings.Local.FavoriteServers = UserSettings.Local.FavoriteServers.Where( s => s.Name != server.Name && s.Address != server.Address).ToArray(); UserSettings.Local.Save(); }; CommitAddNewServer.Clicked += (sender, e) => { var server = new FavoriteServer { Name = NewServerName.Text, Address = NewServerAddress.Text }; var row = ServerListStore.AddRow(); using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("TrueCraft.Launcher.Content.default-server-icon.png")) ServerListStore.SetValue(row, iconField, Image.FromStream(stream)); ServerListStore.SetValue(row, nameField, server.Name); ServerListStore.SetValue(row, playersField, "TODO/50"); UserSettings.Local.FavoriteServers = UserSettings.Local.FavoriteServers.Concat(new[] { server }).ToArray(); UserSettings.Local.Save(); AddServerButton.Sensitive = true; RemoveServerButton.Sensitive = true; ConnectButton.Sensitive = true; ServerListView.Sensitive = true; ServerIPEntry.Sensitive = true; ServerCreationBox.Visible = false; }; foreach (var server in UserSettings.Local.FavoriteServers) { var row = ServerListStore.AddRow(); using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("TrueCraft.Launcher.Content.default-server-icon.png")) ServerListStore.SetValue(row, iconField, Image.FromStream(stream)); ServerListStore.SetValue(row, nameField, server.Name); ServerListStore.SetValue(row, playersField, "TODO/50"); } var addServerHBox = new HBox(); AddServerButton.WidthRequest = RemoveServerButton.WidthRequest = 0.5; addServerHBox.PackStart(AddServerButton, true); addServerHBox.PackStart(RemoveServerButton, true); var commitHBox = new HBox(); CancelAddNewServer.WidthRequest = CommitAddNewServer.WidthRequest = 0.5; commitHBox.PackStart(CommitAddNewServer, true); commitHBox.PackStart(CancelAddNewServer, true); ServerCreationBox.PackStart(NewServerLabel); ServerCreationBox.PackStart(NewServerName); ServerCreationBox.PackStart(NewServerAddress); ServerCreationBox.PackStart(commitHBox); this.PackEnd(BackButton); this.PackEnd(ConnectButton); this.PackStart(MultiplayerLabel); this.PackStart(ServerIPEntry); this.PackStart(ServerListView); this.PackStart(addServerHBox); this.PackStart(ServerCreationBox); }
public SingleplayerView(LauncherWindow window) { Worlds.Local = new Worlds(); Worlds.Local.Load(); Window = window; this.MinWidth = 250; SingleplayerLabel = new Label("Singleplayer") { Font = Font.WithSize(16), TextAlignment = Alignment.Center }; WorldListView = new ListView { MinHeight = 200, SelectionMode = SelectionMode.Single }; CreateWorldButton = new Button("New world"); DeleteWorldButton = new Button("Delete") { Sensitive = false }; PlayButton = new Button("Play") { Sensitive = false }; BackButton = new Button("Back"); CreateWorldBox = new VBox() { Visible = false }; NewWorldName = new TextEntry() { PlaceholderText = "Name" }; NewWorldSeed = new TextEntry() { PlaceholderText = "Seed (optional)" }; NewWorldCommit = new Button("Create") { Sensitive = false }; NewWorldCancel = new Button("Cancel"); NameField = new DataField<string>(); WorldListStore = new ListStore(NameField); WorldListView.DataSource = WorldListStore; WorldListView.HeadersVisible = false; WorldListView.Columns.Add(new ListViewColumn("Name", new TextCellView { TextField = NameField, Editable = false })); ProgressLabel = new Label("Loading world...") { Visible = false }; ProgressBar = new ProgressBar() { Visible = false, Indeterminate = true, Fraction = 0 }; BackButton.Clicked += (sender, e) => { Window.MainContainer.Remove(this); Window.MainContainer.PackEnd(Window.MainMenuView); }; CreateWorldButton.Clicked += (sender, e) => { CreateWorldBox.Visible = true; }; NewWorldCancel.Clicked += (sender, e) => { CreateWorldBox.Visible = false; }; NewWorldName.Changed += (sender, e) => { NewWorldCommit.Sensitive = !string.IsNullOrEmpty(NewWorldName.Text); }; NewWorldCommit.Clicked += NewWorldCommit_Clicked; WorldListView.SelectionChanged += (sender, e) => { PlayButton.Sensitive = DeleteWorldButton.Sensitive = WorldListView.SelectedRow != -1; }; PlayButton.Clicked += PlayButton_Clicked; DeleteWorldButton.Clicked += (sender, e) => { var world = Worlds.Local.Saves[WorldListView.SelectedRow]; WorldListStore.RemoveRow(WorldListView.SelectedRow); Worlds.Local.Saves = Worlds.Local.Saves.Where(s => s != world).ToArray(); Directory.Delete(world.BaseDirectory, true); }; foreach (var world in Worlds.Local.Saves) { var row = WorldListStore.AddRow(); WorldListStore.SetValue(row, NameField, world.Name); } var createDeleteHbox = new HBox(); CreateWorldButton.WidthRequest = DeleteWorldButton.WidthRequest = 0.5; createDeleteHbox.PackStart(CreateWorldButton, true); createDeleteHbox.PackStart(DeleteWorldButton, true); CreateWorldBox.PackStart(NewWorldName); CreateWorldBox.PackStart(NewWorldSeed); var newWorldHbox = new HBox(); NewWorldCommit.WidthRequest = NewWorldCancel.WidthRequest = 0.5; newWorldHbox.PackStart(NewWorldCommit, true); newWorldHbox.PackStart(NewWorldCancel, true); CreateWorldBox.PackStart(newWorldHbox); this.PackStart(SingleplayerLabel); this.PackStart(WorldListView); this.PackStart(createDeleteHbox); this.PackStart(PlayButton); this.PackStart(CreateWorldBox); this.PackStart(ProgressLabel); this.PackStart(ProgressBar); this.PackEnd(BackButton); }
private void Build() { if(Toolkit.CurrentEngine.Type == ToolkitType.Wpf) this.BackgroundColor = (new Button()).BackgroundColor; vbox1 = new VBox(); label1 = new Label("Select Font:"); label1.MarginTop = 4; label1.MarginRight = 4; label1.MarginLeft = 4; vbox1.PackStart(label1); table1 = new Table(); table1.MarginRight = 4; table1.MarginLeft = 4; radioButton1 = new RadioButton("From System: "); table1.Add(radioButton1, 0, 0); combo_font = new ComboBox(); List<string> fonts = new List<string>(); foreach (System.Drawing.FontFamily font in System.Drawing.FontFamily.Families) fonts.Add(font.Name); fonts.Sort(); foreach (string font in fonts) combo_font.Items.Add(font); if(combo_font.Items.Contains("Arial")) combo_font.SelectedText = "Arial"; else if(combo_font.Items.Count > 0) combo_font.SelectedIndex = 0; combo_font.Font = Xwt.Drawing.Font.FromName(combo_font.SelectedText).WithSize(combo_font.Font.Size); table1.Add(combo_font, 1, 0, 1, 1, true); radioButton2 = new RadioButton(); radioButton2.Label = "From File: "; radioButton2.Sensitive = true; radioButton2.Group = radioButton1.Group; table1.Add(radioButton2, 0, 1); hbox1 = new HBox(); entry_font = new TextEntry(); entry_font.Sensitive = false; hbox1.PackStart(entry_font, true); button_font = new Button("Browse"); button_font.Sensitive = false; hbox1.PackStart(button_font); table1.Add(hbox1, 1, 1); vbox1.PackStart(table1); notebook1 = new Notebook(); notebook1.ExpandHorizontal = true; notebook1.ExpandVertical = true; table2 = new Table(); table2.Margin = 4; label4 = new Label("Style:"); table2.Add(label4, 0, 0); hbox2 = new HBox(); check_bold = new CheckBox("Bold "); check_bold.BackgroundColor = Color.FromBytes(0, 0, 0, 0); hbox2.PackStart(check_bold); check_italic = new CheckBox("Italic "); check_italic.BackgroundColor = Color.FromBytes(0, 0, 0, 0); hbox2.PackStart(check_italic); check_kerning = new CheckBox("Kerning "); check_kerning.BackgroundColor = Color.FromBytes(0, 0, 0, 0); hbox2.PackStart(check_kerning); table2.Add(hbox2, 0, 1, 1, 1); label2 = new Label("Size:"); table2.Add(label2, 0, 2); entry_size = new NumericEntry("0", "WARNING: Size needs to be a number"); table2.Add(entry_size, 0, 3, 1, 1, true); label3 = new Label("Spacing:"); table2.Add(label3, 0, 4); entry_spacing = new NumericEntry("0", "WARNING: Spacing needs to be a number"); table2.Add(entry_spacing, 0, 5, 1, 1, true); check_defchar = new CheckBox("Default Character:"); check_defchar.BackgroundColor = Color.FromBytes(0, 0, 0, 0); table2.Add(check_defchar, 0, 6); entry_defchar = new TextEntry(); entry_defchar.Sensitive = false; entry_defchar.TextAlignment = Alignment.Center; table2.Add(entry_defchar, 0, 7, 1, 1, true); notebook1.Add(table2, "Global"); hbox3 = new HBox(); listView1 = new ListView(); hbox3.PackStart(listView1, true); vbox2 = new VBox(); vbox2.MarginRight = 5; vbox2.MarginTop = 5; label8 = new Label(" Main:"); vbox2.PackStart(label8); button_plus = new Button("Add"); vbox2.PackStart(button_plus); button_minus = new Button("Remove"); button_minus.Sensitive = false; vbox2.PackStart(button_minus); button_edit = new Button("Edit"); button_edit.Sensitive = false; vbox2.PackStart(button_edit); vbox2.PackStart(new HSeparator()); label9 = new Label(" Move:"); vbox2.PackStart(label9); button_up = new Button("Up"); button_up.Sensitive = false; vbox2.PackStart(button_up); button_down = new Button("Down"); button_down.Sensitive = false; vbox2.PackStart(button_down); hbox3.PackStart(vbox2); notebook1.Add(hbox3, "Characters"); var pa = new VBox(); textEditor1 = new TextEditor(); textEditor1.Document.MimeType = "application/xml"; pa.PackStart(textEditor1, true); notebook1.Add(pa, "Xml"); vbox3 = new VBox(); hbox4 = new HBox(); hbox4.Margin = 5; label5 = new Label("Font Color: "); hbox4.PackStart(label5); color_font = new ColorPicker(); color_font.Color = Color.FromBytes(0, 0, 0); color_font.SupportsAlpha = false; hbox4.PackStart(color_font); label6 = new Label("Background Color: "); hbox4.PackStart(label6); color_back = new ColorPicker(); color_back.Color = Color.FromBytes(224, 224, 209); color_back.SupportsAlpha = false; hbox4.PackStart(color_back); vbox3.PackStart(hbox4); hbox5 = new HBox(); hbox5.MarginLeft = 5; hbox5.MarginRight = 5; label7 = new Label("Text: "); hbox5.PackStart(label7); entry_text = new TextEntry(); entry_text.Text = "The quick brown fox jumps over the lazy dog"; hbox5.PackStart(entry_text, true); button_preview = new Button("Preview"); hbox5.PackStart(button_preview); vbox3.PackStart(hbox5); web1 = new WebView(); scrollView2 = new ScrollView(); scrollView2.HorizontalScrollPolicy = ScrollPolicy.Automatic; scrollView2.VerticalScrollPolicy = ScrollPolicy.Automatic; if (Toolkit.CurrentEngine.Type != ToolkitType.Gtk) scrollView2.Content = web1; vbox3.PackStart(scrollView2, true); notebook1.Add(vbox3, "Preview"); vbox1.PackStart(notebook1, true); this.Content = vbox1; }