private void ConstructWidgets() { var headRow = new ListBoxRow(); var gameNameLabel = new Label(); gameNameLabel.Markup = String.Format("<b><u>{0}</u></b>", GameTypeFormatter.ToString(container.type)); gameNameLabel.UseMarkup = true; headRow.Add(gameNameLabel); savegameListBox.Add(headRow); foreach (var section in saveGameData) { var row = new ListBoxRow(); var headingLabel = new Label(); headingLabel.Markup = String.Format("<b>{0}</b>", section.Key); headingLabel.UseMarkup = true; row.Add(headingLabel); savegameListBox.Add(row); foreach (var item in section.Value) { var itemRow = new ListBoxRow(); var itemLayout = new Box(Orientation.Horizontal, 50); itemLayout.CenterWidget = new Separator(Orientation.Vertical); itemRow.Add(itemLayout); var itemLabel = new Label(item.name); itemLayout.PackStart(itemLabel, true, true, 20); var itemWidget = item.CreateEditWidget(); itemLayout.PackEnd(itemWidget, true, true, 50); savegameListBox.Add(itemRow); } } }
/// <summary> /// Cuando el estado del carrito cambia debemos actualizar lo visual y agregar o eleminar widgets de la vista. /// </summary> /// <param name="added">Indica si se ha agregado un elemento a la lista, false si ha sido eliminado.</param> /// <param name="content">Pedido agregado o elimiando, o null si el carrito solo se actualizo.</param> private void OnCarritoChanged(bool added, Pedido content) { CalcularSuma(); if (added) { if (content == null) { var widget = ListaPedidos.SelectedRow?.Child as ProductoWidget; var pedido = Carrito.Contiene(widget?.Producto); if (pedido != null) { ActualizarDetalles(pedido); } return; } ListaPedidos.Add(new ProductoWidget(content.Producto)); } else { var current = from list in ListaPedidos.Children where content == null || (((ListBoxRow)list).Child as ProductoWidget).Producto == content.Producto select list; foreach (ListBoxRow item in current) { using (item) { ListaPedidos.Remove(item); item.Child.Dispose(); } } } }
/// <summary> /// Agrega los productos a <see cref="ListaProductos"/>. /// </summary> private void ConfigurarMenu() { foreach (var item in Vendedor.Menu) { ListaProductos.Add(new ProductoWidget(item)); } }
/// <summary> /// Callback fired each time some work is performed /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void OnMessageReceived(object sender, WorkPerformedEventArgs args) { Application.Current.Dispatcher.Invoke(() => { ListBox.Add(args.Data); }); }
public static void Main() { ListBox lbt = new ListBox("Hello", "World"); lbt.Add("hello"); lbt.Add("rest"); // direct write access lbt[2] = "cheers"; // direct read access for (int i = 0; i < lbt.GetNumEntries(); i++) { Console.WriteLine("lbt[{0}]: {1}", i, lbt[i]); } }
void InitQueue() { queue = new QueueListener(); queue.MessageReceived += (message) => { Task.Run(() => { var question = JObject.Parse(message); if (question["question"] == null) { return; } questions[question["question"].ToString()] = new Question() { ID = question["_id"].ToString(), issueID = question["issueId"].ToString(), Text = question["question"].ToString(), State = question["state"].ToString(), Department = question["department"].ToString(), Date = question["createdAt"].ToString() }; var row = new ListBoxRow(); row.Add(new Label { Text = question["question"].ToString(), Expand = true }); questionsList.Add(row); row.ShowAll(); }); }; queue.Init(); }
public void AddSpellList(string spellName, int cost, Sprite image) { Transform item = SpellListBox.Add(); UnityEngine.UI.Text s = item.GetChild(0).GetComponent <UnityEngine.UI.Text>(); s.text = spellName; UnityEngine.UI.Text c = item.GetChild(1).GetComponent <UnityEngine.UI.Text>(); if (cost > 0) { c.text = cost.ToString(); } else { c.text = ""; } UnityEngine.UI.Image i = item.GetChild(2).GetComponent <UnityEngine.UI.Image>(); i.sprite = image; i.name = spellName; // Add the callback so we know we've been selected EventTrigger trigger = item.GetChild(2).GetComponent <EventTrigger>(); EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerClick; entry.callback.AddListener((eventData) => { SelectSpell((PointerEventData)eventData); }); trigger.triggers.Add(entry); }
public static FrameworkElement Render(AdaptiveImageSet imageSet, AdaptiveRenderContext context) { var uiImageSet = new ListBox(); uiImageSet.BorderThickness = new Thickness(0); uiImageSet.Background = new SolidColorBrush(Colors.Transparent); ScrollViewer.SetHorizontalScrollBarVisibility(uiImageSet, ScrollBarVisibility.Disabled); var itemsPanelTemplate = new ItemsPanelTemplate(); var factory = new FrameworkElementFactory(typeof(WrapPanel)); // factory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal); itemsPanelTemplate.VisualTree = factory; uiImageSet.ItemsPanel = itemsPanelTemplate; uiImageSet.Style = context.GetStyle("Adaptive.ImageSet"); foreach (var image in imageSet.Images) { if (image.Size == AdaptiveImageSize.Auto) { if (imageSet.ImageSize != AdaptiveImageSize.Auto) { image.Size = imageSet.ImageSize; } else { image.Size = context.Config.ImageSet.ImageSize; } } var uiImage = context.Render(image); uiImageSet.Add(uiImage); } return(uiImageSet); }
public void InsertQuestion(JToken question) { try { questions[question["question"].ToString()] = new Question() { Text = question["question"].ToString(), State = question["state"].ToString(), Department = question["department"].ToString(), Date = question["createdAt"].ToString() }; if (question["answer"] != null) { questions[question["question"].ToString()].Answer = question["answer"].ToString(); } var row = new ListBoxRow(); row.Add(new Label { Text = question["question"].ToString(), Expand = true }); questionsList.Add(row); row.ShowAll(); } catch (Exception e) { Console.WriteLine(e.Message); } }
public void AddTryList(string s) { Transform item = TryListBox.Add(); UnityEngine.UI.Text t = item.GetComponent <UnityEngine.UI.Text>(); t.text = s; }
public void SingleSelect_ModifySelectedItems() { var items = new ListBox().SelectedItems; Assert.Throws <InvalidOperationException> (() => items.Add(1), "#1"); Assert.Throws <InvalidOperationException> (() => items.Clear(), "#2"); Assert.Throws <InvalidOperationException> (() => items.Insert(0, 15), "#3"); }
void ActualizarMenu() { var user = DomiciliosApp.ClienteActual as Vendedor; foreach (var item in user.Menu) { ListaPedidos.Add(new ProductoWidget(item)); } }
private void MostrarPedidos() { var user = DomiciliosApp.ClienteActual as Vendedor; foreach (var item in user.Pedidos) { ListaPedidos.Add(new ProductoWidget(item.Producto)); } }
static void Main(string[] args) { Application.Init(); Gtk.Window win = new Gtk.Window("test"); win.Icon = new Pixbuf("images/icon.png"); statusIcon = new StatusIcon(new Pixbuf("images/icon.png")); statusIcon.PopupMenu += OnTrayIcon; win.TypeHint = WindowTypeHint.Dialog; win.SetSizeRequest(800, 500); Box box = new Box(Orientation.Vertical, 5); box.Show(); win.Add(box); Toolbar tb = new Toolbar(); box.Add(tb); tb.Show(); ToolButton tbStop = new ToolButton(Stock.MediaPause); tb.Insert(tbStop, 0); ListBox listbx = new ListBox(); Label lbltest = new Label("test"); lbltest.Show(); listbx.Add(lbltest); listbx.Add(new Label("Test2")); box.Add(listbx); listbx.ShowAll(); win.ShowAll(); win.KeepAbove = true; Application.Run(); }
public void SingleSelect_ModifySelectedItems_ChangedAnyway() { var items = new ListBox().SelectedItems; Assert.Throws <InvalidOperationException> (() => items.Add(1), "#1"); Assert.AreEqual(1, items.Count, "#2"); Assert.Throws <InvalidOperationException> (() => items.Clear(), "#3"); Assert.AreEqual(0, items.Count, "#4"); Assert.Throws <InvalidOperationException> (() => items.Insert(0, 15), "#5"); Assert.AreEqual(1, items.Count, "#6"); }
private void OnNewChatHandler(object sender, Client.NewChatEventArgs args) { Gtk.Application.Invoke((o, e) => { _listBox.Add(new ChatBoxEntry(args.Chat) { //LastMessage = chat.LastMessage.Content.ToString(), //Icon = chat.Photo.Small.Local.Path, //UnreadCount = chat.UnreadCount, //Date = new DateTime(chat.LastMessage.Date) }); }); }
public void MultiSelect_ModifySelectedItems_InvalidItems() { var items = new ListBox { SelectionMode = SelectionMode.Multiple }.SelectedItems; items.Add(1); Assert.AreEqual(1, items.Count, "#1"); items.Clear(); Assert.AreEqual(0, items.Count, "#2"); items.Insert(0, 15); Assert.AreEqual(1, items.Count, "#3"); }
/// <summary> /// Fired when a command is received from the start button /// </summary> private async void OnStartButtonClick() { ShowProgressDialog(); ListBox.Add("Starting demo!"); string result = await mAsyncDemoHelper.DoStuffAsync(); ListBox.Add(result); Application.Current.Dispatcher.Invoke(() => { mProgressDialogService.CloseDialog(); }); }
public void Actualizar() { var user = DomiciliosApp.ClienteActual as Comprador; var diff = user.HistorialPedidos.Count - ListaPedidos.Children.Length; if (diff == 0) { return; } var count = ListaPedidos.Children.Length; foreach (var item in user.HistorialPedidos.Skip(count)) { ListaPedidos.Add(new ProductoWidget(item.Producto)); } ListaPedidos.UnselectAll(); }
/// <summary> /// Creates a new test window instance with the child element type specified by the /// type list selection. /// </summary> private void InstantiateSelectedType(object sender, EventArgs args) { if (typeList.Selection != null) { DemoElements selection = typeList.Selection.AssocMember; var testElement = new TestWindowNode(selection); demoRoot.Add(testElement); instanceList.Add($"[#{instanceList.EntryList.Count}] {selection}", testElement); // If selection is empty set selection to new element if (instanceList.Selection == null) { instanceList.SetSelection(testElement); } } }
private void PluginSelected(PluginListBoxItem pluginListBoxItem) { foreach (var plugin in PluginsListBox.Select(lbi => (PluginListBoxItem)lbi)) { plugin.HideDescription(); } _selectedPlugin = pluginListBoxItem; _selectedPlugin.ShowDescription(); SettingsGenerator.Generate(_selectedPlugin.Plugin.Settings); HistoryListBox.Clear(); foreach (var settings in _selectedPlugin.Plugin.SettingsHistory.Recent) { var item = (RecentSettingsListBoxItem)HistoryListBox.Add(); item.Data = settings; } }
public void AddSpellFoundList(string spellName, int cost, Sprite image) { Transform item = SpellListFoundBox.Add(); UnityEngine.UI.Text s = item.GetChild(0).GetComponent <UnityEngine.UI.Text>(); s.text = spellName; UnityEngine.UI.Text c = item.GetChild(1).GetComponent <UnityEngine.UI.Text>(); if (cost > 0) { c.text = cost.ToString(); } else { c.text = ""; } UnityEngine.UI.Image i = item.GetChild(2).GetComponent <UnityEngine.UI.Image>(); i.sprite = image; }
private void InsertUnassignedIssue(JToken issue) { issues[issue["title"].ToString()] = new Issue() { Title = issue["title"].ToString(), ID = issue["_id"].ToString(), Description = issue["description"].ToString(), State = issue["state"].ToString(), Date = issue["createdAt"].ToString(), Creator = issue["creator"].ToString() }; var listBoxRow = new ListBoxRow(); listBoxRow.Add(new Label { Text = issue["title"].ToString(), Expand = true }); unassignedIssues.Add(listBoxRow); listBoxRow.ShowAll(); }
private void AttachBehavior2Plugins() { var availablePlugins = new List <IElektronikPlugin>(); switch (ModeSelector.Mode) { case Mode.Online: availablePlugins.AddRange(PluginsLoader.Plugins.Value.OfType <IDataSourcePluginOnline>()); break; case Mode.Offline: availablePlugins.AddRange(PluginsLoader.Plugins.Value.OfType <IDataSourcePluginOffline>()); break; } availablePlugins.AddRange(PluginsLoader.Plugins.Value.OfType <IDataRecorderPlugin>()); foreach (var plugin in availablePlugins) { var pluginUIItem = (PluginListBoxItem)PluginsListBox.Add(); pluginUIItem.Plugin = plugin; pluginUIItem.OnToggleChangedAsObservable() .Where(state => state && ModeSelector.Mode == Mode.Offline) .Subscribe(_ => DisableOfflinePlugins(plugin)); pluginUIItem.OnToggleChangedAsObservable() .Where(state => state && _initCompleted && !_selectedPlugins.SelectedPluginsNames.Contains(plugin.DisplayName)) .Do(_ => _selectedPlugins.SelectedPluginsNames.Add(plugin.GetType().FullName)) .Do(_ => PluginSelected(pluginUIItem)) .Subscribe(_ => _pluginsHistory.Save()); pluginUIItem.OnToggleChangedAsObservable() .Where(state => !state && _initCompleted) .Do(_ => _selectedPlugins.SelectedPluginsNames.Remove(plugin.GetType().FullName)) .Subscribe(_ => _pluginsHistory.Save()); } }
public MainWindow() { InitializeComponent(); Widget.Style = MooTUI.Drawing.Style.Light.Value; BoxDrawing.Default = BoxDrawing.Square; TabBox tabs = new TabBox( new LayoutRect( new FlexSize(80), new FlexSize(40))); WPFMooViewer viewer = new WPFFormattedTextViewer(tabs.Width, tabs.Height, 8, 17, 14.725, Theme.Basic.Value); Content = viewer; Background = new SolidColorBrush(Theme.Basic.Value.Palette[MooTUI.Drawing.Color.Base03]); new MooInterface(viewer, tabs); Container = new LayoutContainer( new LayoutRect( new FlexSize(70), new FlexSize(35)), Orientation.Vertical, crossJustification: LayoutContainer.CrossAxisJustification.STRETCH); ScrollBox scroll = new ScrollBox( new LayoutRect(75, 30), Container); tabs.AddTab(scroll, TextSpan.Parse("{base03/altyellow}Tab 01")); Button bigboi = new Button(new LayoutRect(new FlexSize(30), new FlexSize(10)), new TextSpan("This is a beeg boi")); tabs.AddTab(bigboi, TextSpan.Parse("This tab has a button")); ListBox list = new ListBox( new LayoutRect( new FlexSize(20), new Size(10)), new TextSpan("List!"), true); Container.AddChild(list); Button addToList = new Button( new LayoutRect( new FlexSize(35), new Size(1)), TextSpan.Parse("{green/}add an item to the list!")); addToList.Click += (s, e) => { list.Add("This is a {yellow/}listitem!"); }; Button removeList = new Button( new LayoutRect( new FlexSize(35), new Size(1)), TextSpan.Parse("{red/}remove selected listitem!")); removeList.Click += (s, e) => { list.RemoveElementUnderCursor(); }; Container.AddChild(addToList); Container.AddChild(removeList); SimpleTextInput t = new SimpleTextInput( new FlexSize(10), 10, false, "Prompt!!!"); ScrollBox b = new ScrollBox( new LayoutRect( new FlexSize(35), new Size(3)), t, vScrollbarVisibility: ScrollBox.ScrollBarVisibility.DISABLED); Button setText = new Button( new LayoutRect( new FlexSize(35), new Size(1)), new TextSpan("set the text of the textInput")); setText.Click += (s, e) => t.SetText("TEXT :)"); Container.AddChild(b); Container.AddChild(setText); Container.AddChild(new Toggle(TextSpan.Parse("Check?"))); }
public DemoBox(HudParentBase parent = null) : base(parent) { // Spawn controls // // List of available control types typeList = new ListBox <DemoElements>(); createButton = new BorderedButton() { Text = "Create", Padding = Vector2.Zero }; typeColumn = new HudChain(true) { SizingMode = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth, CollectionContainer = { typeList, createButton }, Spacing = 8f }; // Add list of supported test elements to the type list var supportedTypes = Enum.GetValues(typeof(DemoElements)) as DemoElements[]; for (int n = 0; n < supportedTypes.Length; n++) { typeList.Add(supportedTypes[n].ToString(), supportedTypes[n]); } createButton.MouseInput.LeftClicked += InstantiateSelectedType; // Instance list instanceList = new ListBox <TestWindowNode>(); removeButton = new BorderedButton() { Text = "Remove", Padding = Vector2.Zero }; clearAllButton = new BorderedButton() { Text = "Clear All", Padding = Vector2.Zero }; instanceButtonRow = new HudChain(false) { SizingMode = HudChainSizingModes.FitMembersBoth | HudChainSizingModes.FitChainBoth, CollectionContainer = { removeButton, clearAllButton }, Spacing = 8f, }; instanceColumn = new HudChain(true) { SizingMode = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth, CollectionContainer = { instanceList, instanceButtonRow }, Spacing = 8f }; removeButton.MouseInput.LeftClicked += RemoveSelectedInstance; clearAllButton.MouseInput.LeftClicked += ClearInstances; instanceList.SelectionChanged += UpdateSelection; // Transform controls // // Column 1 screenSpaceToggle = new NamedCheckBox() { Name = "Screen Space" }; xAxisBar = new NamedSliderBox() { Name = "AxisX", Padding = new Vector2(40f, 0f), Min = -1f, Max = 1f }; yAxisBar = new NamedSliderBox() { Name = "AxisY", Padding = new Vector2(40f, 0f), Min = -1f, Max = 1f }; zAxisBar = new NamedSliderBox() { Name = "AxisZ", Padding = new Vector2(40f, 0f), Min = -1f, Max = 1f }; angleBar = new NamedSliderBox() { Name = "Angle", Padding = new Vector2(40f, 0f), Min = -(float)(Math.PI), Max = (float)(Math.PI) }; transformCol1 = new HudChain(true) { Spacing = 10f, CollectionContainer = { screenSpaceToggle, xAxisBar, yAxisBar, zAxisBar, angleBar } }; // Column 2 resScaleToggle = new NamedCheckBox() { Name = "Res Scaling" }; scaleBar = new NamedSliderBox() { Name = "Scale", Padding = new Vector2(40f, 0f), Min = 0.001f, Max = 1f }; xPosBar = new NamedSliderBox() { Name = "PosX", Padding = new Vector2(40f, 0f), Min = -.5f, Max = .5f }; yPosBar = new NamedSliderBox() { Name = "PosY", Padding = new Vector2(40f, 0f), Min = -.5f, Max = .5f }; zPosBar = new NamedSliderBox() { Name = "PosZ", Padding = new Vector2(40f, 0f), Min = -2f, Max = 0f }; transformCol2 = new HudChain(true) { Spacing = 10f, CollectionContainer = { resScaleToggle, scaleBar, xPosBar, yPosBar, zPosBar } }; spawnControls = new HudChain(false) { CollectionContainer = { typeColumn, instanceColumn }, Spacing = 16f, }; transformControls = new HudChain(false) { CollectionContainer = { transformCol1, transformCol2 } }; var layout = new HudChain(true, this) { ParentAlignment = ParentAlignments.Left | ParentAlignments.Inner, Spacing = 10f, CollectionContainer = { spawnControls, transformControls } }; Padding = new Vector2(40f, 8f); demoRoot = new HudCollection(HudMain.HighDpiRoot); }
private void Initalize(ThemeMode currentMode) { foreach (var widget in Children) { Remove(widget); } this.CurrentMode = currentMode; BashHandler bashHandler = BashHandler.Instance; #if DEBUG Console.WriteLine(bashHandler.UserThemeExtensionExists); #endif if (currentMode == ThemeMode.ShellTheme && !bashHandler.CheckUserThemeExtExists()) { VBox vBox = new VBox { new Label("Please Install The User Themes Extension" + Environment.NewLine + " to Use This Feature On Gnome") }; Add(vBox); vBox.ShowAll(); Show(); } else { switch (currentMode) { case ThemeMode.GtkTheme: currentArray = bashHandler.ThemeList; currentTheme = bashHandler.GetTheme(); break; case ThemeMode.IconTheme: currentArray = bashHandler.IconList; currentTheme = bashHandler.GetIconTheme(); break; case ThemeMode.ShellTheme: currentArray = bashHandler.ShellList; currentTheme = bashHandler.GetShellTheme(); break; case ThemeMode.CursorTheme: currentArray = bashHandler.CursorList; currentTheme = bashHandler.GetCursorTheme(); break; } ListBox box = new ListBox(); RadioButton radioButton = new RadioButton(""); box.SelectionMode = SelectionMode.None; foreach (var theme in currentArray) { ListBoxRow row = new ListBoxRow(); EventBox eventBox = new EventBox(); BoxItem boxItem = new BoxItem(theme, radioButton); row.Child = boxItem; eventBox.Add(row); if (currentTheme == boxItem.ItemName) { box.UnselectAll(); box.SelectionMode = SelectionMode.Single; boxItem.RadioButton.Active = true; #if DEBUG Console.WriteLine(boxItem.ItemName); #endif } eventBox.ButtonPressEvent += (o, args) => { box.UnselectAll(); #if DEBUG Console.WriteLine(boxItem.ItemName); #endif boxItem.RadioButton.Active = true; switch (currentMode) { case ThemeMode.GtkTheme: bashHandler.ChangeTheme(boxItem.ItemName); break; case ThemeMode.IconTheme: bashHandler.ChangeIcon(boxItem.ItemName); break; case ThemeMode.ShellTheme: bashHandler.ChangeShell(boxItem.ItemName); break; case ThemeMode.CursorTheme: bashHandler.ChangeCursor(boxItem.ItemName); break; } }; box.Add(eventBox); } box.ShowAll(); Add(box); Show(); } }