private void RenderArrestReportListBoxRow(ArrestReport report, ListBoxRow row) { var dateString = report.ArrestTimeDate.ToLocalTimeString(DateOutputPart.DATE); row.Text = String.Format("{0} Charges: {1}", dateString, report.Charges.Count); row.SetToolTipText(String.Format("Arrested {0}, {1} charges with {2} felony", dateString, report.Charges.Count, report.Charges.Count(x => x.IsFelony))); }
private void RenderTrafficCitationListBoxRow(TrafficCitation citation, ListBoxRow row) { var dateString = citation.CitationTimeDate.ToLocalTimeString(DateOutputPart.DATE); row.Text = String.Format("{0}: {1}", dateString, citation.CitationReason); row.SetToolTipText(String.Format("Fine {0}", citation.CitationAmount)); }
private void LaunchQuestionDialog(String questionID, ListBoxRow row) { var questionDialog = new QuestionDialog(questions[questionID], this, row); DepartmentApp.GetApp().AddWindow(questionDialog); questionDialog.ShowAll(); }
private void LaunchAnswerDialog(string questionID, ListBoxRow row) { answerDialog = new AnswerDialog(questions[questionID], this); SolverApp.GetApp().AddWindow(answerDialog); answerDialog.ShowAll(); }
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); } } }
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); } }
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 ListBoxRow AddRow(params object[] rowValues) { ListBoxRow row = new ListBoxRow(rowValues); values.Add(row); return(row); }
void CheckSelectedRow() { rowUnderMouse = -1; if (!IsUnderMouse) { return; } if (!IsMouseInRect(new Rectangle(RealX + TopLeftCorner.Width, RealY + TopLeftCorner.Height + HeaderSize, Width - TopLeftCorner.Width - TopRightCorner.Width, Height - HeaderSize - TopLeftCorner.Height - BottomLeftCorner.Height))) { return; } int rowX = RealX + TopLeftCorner.Width + textMargin; int rowY = RealY + TopLeftCorner.Height + HeaderSize + textMargin; int n = 0; foreach (ListBoxRow row in values) { if (IsMouseInRect(new Rectangle( rowX, rowY, Width - TopLeftCorner.Width - TopRightCorner.Width, Font.CharHeight + textMargin))) { rowUnderMouse = n; if (MouseInput.IsClicked(MouseButtons.Left)) { ListBoxRow oldSelected = SelectedRow; SelectedRow = Values[n]; if (SelectedItemChanged != null) { SelectedItemChanged(this, oldSelected, SelectedRow); } if (ItemClicked != null) { ItemClicked(this, SelectedRow, values.IndexOf(SelectedRow)); } if (!MouseInput.IsDoubleClicked(MouseButtons.Left).IsNegative&& ItemDoubleClicked != null) { ItemDoubleClicked(this, SelectedRow, values.IndexOf(SelectedRow)); } } } rowY += Font.CharHeight + textMargin; n += 1; } }
public GtkHostUiTheme(Window parent) { Entry entry = new Entry(); entry.SetStateFlags(StateFlags.Selected, true); // Get the font and some colors directly from GTK. FontFamily = entry.PangoContext.FontDescription.Family; // Get foreground colors from the style context. var defaultForegroundColor = entry.StyleContext.GetColor(StateFlags.Normal); var selectedForegroundColor = entry.StyleContext.GetColor(StateFlags.Selected); DefaultForegroundColor = new ThemeColor((float)defaultForegroundColor.Alpha, (float)defaultForegroundColor.Red, (float)defaultForegroundColor.Green, (float)defaultForegroundColor.Blue); SelectionForegroundColor = new ThemeColor((float)selectedForegroundColor.Alpha, (float)selectedForegroundColor.Red, (float)selectedForegroundColor.Green, (float)selectedForegroundColor.Blue); ListBoxRow row = new ListBoxRow(); row.SetStateFlags(StateFlags.Selected, true); // Request the main thread to render some UI elements to an image to get an approximation for the color. // NOTE (caian): This will only take the color of the top-left corner of the background, which may be incorrect // if someone provides a custom style with a gradient or image. using (var surface = new Cairo.ImageSurface(Cairo.Format.Argb32, RenderSurfaceWidth, RenderSurfaceHeight)) using (var context = new Cairo.Context(surface)) { context.SetSourceRGBA(1, 1, 1, 1); context.Rectangle(0, 0, RenderSurfaceWidth, RenderSurfaceHeight); context.Fill(); // The background color must be from the main Window because entry uses a different color. parent.StyleContext.RenderBackground(context, 0, 0, RenderSurfaceWidth, RenderSurfaceHeight); DefaultBackgroundColor = ToThemeColor(surface.Data); context.SetSourceRGBA(1, 1, 1, 1); context.Rectangle(0, 0, RenderSurfaceWidth, RenderSurfaceHeight); context.Fill(); // Use the background color of the list box row when selected as the text box frame color because they are the // same in the default theme. row.StyleContext.RenderBackground(context, 0, 0, RenderSurfaceWidth, RenderSurfaceHeight); DefaultBorderColor = ToThemeColor(surface.Data); } // Use the border color as the text selection color. SelectionBackgroundColor = DefaultBorderColor; }
private QuestionDialog(Builder builder, Question _question, MainWindow _mainWindow, ListBoxRow _row) : base(builder.GetObject("QuestionDialog").Handle) { builder.Autoconnect(this); mainWindow = _mainWindow; question = _question; row = _row; DeleteEvent += Window_DeleteEvent; questionBox.Buffer.Text = question.Text; answerBox.Buffer.Text = question.Answer; answerButton.Clicked += AnswerButton_Clicked; closeButton.Clicked += CloseButton_Clicked; }
public void OnItemSelected(ControlBase sender, ItemSelectedEventArgs args) { ListBoxRow row = args.SelectedItem as ListBoxRow; if (row != null) { XmlFile xmlFile = row.UserData as XmlFile; if (xmlFile != null) { if (XmlFileSelected != null) { m_XmlFileSelectedEventArgs.XmlFile = xmlFile; XmlFileSelected(View, m_XmlFileSelectedEventArgs); } } } }
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 IssueWindow(Builder builder, Issue _issue, MainWindow _mainWindow, ListBoxRow _row) : base(builder.GetObject("IssueWindow").Handle) { builder.Autoconnect(this); issue = _issue; mainWindow = _mainWindow; row = _row; questions = new Dictionary <string, Question>(); mainWindow.Sensitive = false; DeleteEvent += Window_DeleteEvent; issueTitle.Text = issue.Title; descriptionBox.Buffer.Text = issue.Description; authorDate.Text = $"Submited by {issue.Creator}, at {issue.Date}"; if (issue.State == "unassigned") { solveButton.Label = "Assign"; solveButton.Clicked += AssignButton_Clicked; } else { solveButton.Clicked += SolveButton_Clicked; } questionsList.RowSelected += (object sender, RowSelectedArgs args) => { if (args.Row == null) { return; } var label = (Label)args.Row.Child; LaunchAnswerDialog(label.Text, args.Row); }; addQuestionButton.Clicked += AddQuestionButton_Clicked; var task = FetchQuestions(); }
private async Task SendQuestion() { try { Console.WriteLine("coiso"); var endpoint = $"http://localhost:3000/api/solver/{issueID}/question"; var requestBody = new JObject(); requestBody["question"] = questionText.Buffer.Text; requestBody["department"] = departmentEntry.Text; var response = await SolverApp.PostRequest(endpoint, requestBody); if (response["question"] == null) { return; } var responseQuestion = response["question"]; issueWindow.questions[responseQuestion["question"].ToString()] = new Question() { Text = responseQuestion["question"].ToString(), Department = responseQuestion["department"].ToString(), State = responseQuestion["state"].ToString(), Date = responseQuestion["createdAt"].ToString() }; var questionRow = new ListBoxRow(); questionRow.Add(new Label { Text = responseQuestion["question"].ToString(), Expand = true }); issueWindow.questionsList.Add(questionRow); questionRow.ShowAll(); issueWindow.Sensitive = true; SolverApp.GetApp().RemoveWindow(this); this.Dispose(); } catch (Exception e) { Console.WriteLine(e.ToString()); } }
internal static ListBoxRow AddPed(this ListBox listBox, Tuple <Ped, Persona> ped) { if (listBox == null) { return(null); } String rowId = String.Format("{0}_{1}", ped.Item2.Forename, ped.Item2.Surname ); ListBoxRow previousRow = listBox.FindChildByName(rowId) as ListBoxRow; if (previousRow == null) { listBox.AddRow( String.Format("({0}) {1} | {2}", ped.Item2.Gender == Gender.Male ? "M" : "F", ped.Item2.FullName, ped.Item2.BirthDay.ToString("MMMM dd yyyy")), String.Format("{0}_{1}", ped.Item2.Forename, ped.Item2.Surname), ped); } return(previousRow); }
private void UpdateItemList() { m_Items.Clear(); IOrderedEnumerable <IFileSystemDirectoryInfo> directories; IOrderedEnumerable <IFileSystemFileInfo> files = null; try { directories = GetDirectories(m_CurrentFolder).OrderBy(di => di.Name); if (!m_FoldersOnly) { files = GetFiles(m_CurrentFolder, m_CurrentFilter).OrderBy(fi => fi.Name); } } catch (Exception ex) { MessageBox.Show(View, ex.Message, Title, MessageBoxButtons.OK); return; } foreach (IFileSystemDirectoryInfo di in directories) { ListBoxRow row = m_Items.AddRow(di.Name, null, di.FullName); row.SetCellText(1, "<dir>"); row.SetCellText(2, di.FormattedLastWriteTime); } if (!m_FoldersOnly) { foreach (IFileSystemFileInfo fi in files) { ListBoxRow row = m_Items.AddRow(fi.Name, null, fi.FullName); row.SetCellText(1, fi.FormattedFileLength); row.SetCellText(2, fi.FormattedFileLength); } } }
public ListBox(ControlBase parent) : base(parent) { { Control.ListBox ctrl = new Control.ListBox(this); ctrl.SetPosition(10, 10); ctrl.AddRow("First"); ctrl.AddRow("Blue"); ctrl.AddRow("Yellow"); ctrl.AddRow("Orange"); ctrl.AddRow("Brown"); ctrl.AddRow("Black"); ctrl.AddRow("Green"); ctrl.AddRow("Dog"); ctrl.AddRow("Cat Blue"); ctrl.AddRow("Shoes"); ctrl.AddRow("Shirts"); ctrl.AddRow("Chair"); ctrl.AddRow("I'm autosized"); ctrl.AddRow("Last"); ctrl.AllowMultiSelect = true; ctrl.SelectRowsByRegex("Bl.e|Dog"); ctrl.RowSelected += RowSelected; ctrl.RowUnselected += RowUnSelected; ctrl.SizeToContents(); } { Table ctrl = new Table(this); ctrl.SetPosition(120, 10); ctrl.AddRow("First"); ctrl.AddRow("Blue"); ctrl.AddRow("Yellow"); ctrl.AddRow("Orange"); ctrl.AddRow("Brown"); ctrl.AddRow("Black"); ctrl.AddRow("Green"); ctrl.AddRow("Dog"); ctrl.AddRow("Cat Blue"); ctrl.AddRow("Shoes"); ctrl.AddRow("Shirts"); ctrl.AddRow("Chair"); ctrl.AddRow("I'm autosized"); ctrl.AddRow("Last"); ctrl.SizeToContents(0); } { Control.ListBox ctrl = new Control.ListBox(this); ctrl.SetBounds(220, 10, 200, 200); ctrl.ColumnCount = 3; //ctrl.AllowMultiSelect = true; ctrl.RowSelected += RowSelected; ctrl.RowUnselected += RowUnSelected; { TableRow row = ctrl.AddRow("Baked Beans"); row.SetCellText(1, "Heinz"); row.SetCellText(2, "£3.50"); } { TableRow row = ctrl.AddRow("Bananas"); row.SetCellText(1, "Trees"); row.SetCellText(2, "£1.27"); } { TableRow row = ctrl.AddRow("Chicken"); row.SetCellText(1, "\u5355\u5143\u6D4B\u8BD5"); row.SetCellText(2, "£8.95"); } } { // fixed-size table Control.Layout.Table table = new Table(this); table.SetColumnCount(3); table.SetBounds(450, 10, 320, 100); table.SetColumnWidth(0, 100); table.SetColumnWidth(1, 100); table.SetColumnWidth(2, 100); var row1 = table.AddRow(); row1.SetCellText(0, "Row 1"); row1.SetCellText(1, "R1 cell 1"); row1.SetCellText(2, "Row 1 cell 2"); table.AddRow().Text = "Row 2, slightly bigger"; table[1].SetCellText(1, "Center cell"); table.AddRow().Text = "Row 3, medium"; table[2].SetCellText(2, "Last cell"); } { //Control.Label outer = new Control.Label(this); //outer.SetBounds(340, 140, 300, 200); // autosized table Control.Layout.Table table = new Table(this); table.SetColumnCount(3); table.SetPosition(450, 150); var row1 = table.AddRow(); row1.SetCellText(0, "Row 1"); row1.SetCellText(1, "R1 cell 1"); row1.SetCellText(2, "Row 1 cell 2"); table.AddRow().Text = "Row 2, slightly bigger"; table[1].SetCellText(1, "Center cell"); table.AddRow().Text = "Row 3, medium"; table[2].SetCellText(2, "Last cell"); table.SizeToContents(0); } /* Selecting Rows in Code */ { Control.ListBox ctrl = new Control.ListBox(this); ctrl.SetPosition(10, 320); ListBoxRow Row = ctrl.AddRow("Row"); ctrl.AddRow("Text"); ctrl.AddRow("InternalName", "Name"); ctrl.AddRow("UserData", "Internal", 12); ctrl.SizeToContents(); Control.CheckBox Multiline = new Control.CheckBox(this); Multiline.SetPosition(10, 405); Multiline.CheckChanged += delegate(ControlBase sender, EventArgs args) { ctrl.AllowMultiSelect = Multiline.IsChecked; }; Control.Label lblml = new Control.Label(this); lblml.Text = "Enable MultiSelect"; lblml.SetPosition(30, 405); //Select by Menu Item { Control.Button TriangleButton = new Control.Button(this); TriangleButton.SetPosition(100, 320); TriangleButton.Text = "Row"; TriangleButton.Width = 100; TriangleButton.Clicked += delegate(ControlBase sender, ClickedEventArgs args) { ctrl.SelectedRow = Row; }; } //Select by Text { Control.Button TestBtn = new Control.Button(this); TestBtn.SetPosition(100, 340); TestBtn.Text = "Text"; TestBtn.Width = 100; TestBtn.Clicked += delegate(ControlBase sender, ClickedEventArgs args) { ctrl.SelectByText("Text"); }; } //Select by Name { Control.Button TestBtn = new Control.Button(this); TestBtn.SetPosition(100, 360); TestBtn.Text = "Name"; TestBtn.Width = 100; TestBtn.Clicked += delegate(ControlBase sender, ClickedEventArgs args) { ctrl.SelectByName("Name"); }; } //Select by UserData { Control.Button TestBtn = new Control.Button(this); TestBtn.SetPosition(100, 380); TestBtn.Text = "UserData"; TestBtn.Width = 100; TestBtn.Clicked += delegate(ControlBase sender, ClickedEventArgs args) { ctrl.SelectByUserData(12); }; } } }
internal static void DefaultRowRender(TrafficCitation citation, ListBoxRow row) { row.Text = String.Format("{0} {1} {2} {3}", citation.ShortId(), citation.CitationDate, citation.CitationTime, citation.FullName); }
public ListBoxTest(ControlBase parent) : base(parent) { HorizontalLayout hlayout = new HorizontalLayout(this); hlayout.Dock = Dock.Top; { ListBox ctrl = new ListBox(hlayout); ctrl.AutoSizeToContent = true; ctrl.AllowMultiSelect = true; ctrl.AddRow("First"); ctrl.AddRow("Blue"); ctrl.AddRow("Yellow"); ctrl.AddRow("Orange"); ctrl.AddRow("Brown"); ctrl.AddRow("Black"); ctrl.AddRow("Green"); ctrl.AddRow("Dog"); ctrl.AddRow("Cat Blue"); ctrl.AddRow("Shoes"); ctrl.AddRow("Shirts"); ctrl.AddRow("Chair"); ctrl.AddRow("I'm autosized"); ctrl.AddRow("Last"); ctrl.SelectRowsByRegex("Bl.e|Dog"); ctrl.RowSelected += RowSelected; ctrl.RowUnselected += RowUnSelected; } { Table ctrl = new Table(hlayout); ctrl.AddRow("First"); ctrl.AddRow("Blue"); ctrl.AddRow("Yellow"); ctrl.AddRow("Orange"); ctrl.AddRow("Brown"); ctrl.AddRow("Black"); ctrl.AddRow("Green"); ctrl.AddRow("Dog"); ctrl.AddRow("Cat Blue"); ctrl.AddRow("Shoes"); ctrl.AddRow("Shirts"); ctrl.AddRow("Chair"); ctrl.AddRow("I'm autosized"); ctrl.AddRow("Last"); ctrl.SizeToContent(); } { ListBox ctrl = new ListBox(hlayout); ctrl.AutoSizeToContent = true; ctrl.ColumnCount = 3; ctrl.RowSelected += RowSelected; ctrl.RowUnselected += RowUnSelected; { TableRow row = ctrl.AddRow("Baked Beans"); row.SetCellText(1, "Heinz"); row.SetCellText(2, "£3.50"); } { TableRow row = ctrl.AddRow("Bananas"); row.SetCellText(1, "Trees"); row.SetCellText(2, "£1.27"); } { TableRow row = ctrl.AddRow("Chicken"); row.SetCellText(1, "\u5355\u5143\u6D4B\u8BD5"); row.SetCellText(2, "£8.95"); } } VerticalLayout vlayout = new VerticalLayout(hlayout); { // fixed-size list box ListBox ctrl = new ListBox(vlayout); ctrl.AutoSizeToContent = true; ctrl.HorizontalAlignment = HorizontalAlignment.Left; ctrl.ColumnCount = 3; ctrl.SetColumnWidth(0, 150); ctrl.SetColumnWidth(1, 150); ctrl.SetColumnWidth(2, 150); var row1 = ctrl.AddRow("Row 1"); row1.SetCellText(1, "R1 cell 1"); row1.SetCellText(2, "Row 1 cell 2"); ctrl.AddRow("Row 2, slightly bigger"); ctrl[1].SetCellText(1, "Center cell"); ctrl.AddRow("Row 3, medium"); ctrl[2].SetCellText(2, "Last cell"); } { // autosized list box ListBox ctrl = new ListBox(vlayout); ctrl.AutoSizeToContent = true; ctrl.HorizontalAlignment = HorizontalAlignment.Left; ctrl.ColumnCount = 3; var row1 = ctrl.AddRow("Row 1"); row1.SetCellText(1, "R1 cell 1"); row1.SetCellText(2, "Row 1 cell 2"); ctrl.AddRow("Row 2, slightly bigger"); ctrl[1].SetCellText(1, "Center cell"); ctrl.AddRow("Row 3, medium"); ctrl[2].SetCellText(2, "Last cell"); } hlayout = new HorizontalLayout(this); hlayout.Dock = Dock.Top; /* Selecting Rows in Code */ { ListBox ctrl = new ListBox(hlayout); ctrl.AutoSizeToContent = true; ListBoxRow Row = ctrl.AddRow("Row"); ctrl.AddRow("Text"); ctrl.AddRow("InternalName", "Name"); ctrl.AddRow("UserData", "Internal", 12); LabeledCheckBox multiline = new LabeledCheckBox(this); multiline.Dock = Dock.Top; multiline.Text = "Enable MultiSelect"; multiline.CheckChanged += delegate(ControlBase sender, EventArgs args) { ctrl.AllowMultiSelect = multiline.IsChecked; }; vlayout = new VerticalLayout(hlayout); //Select by Menu Item { Button TriangleButton = new Button(vlayout); TriangleButton.Text = "Row"; TriangleButton.Width = 100; TriangleButton.Clicked += delegate(ControlBase sender, ClickedEventArgs args) { ctrl.SelectedRow = Row; }; } //Select by Text { Button TestBtn = new Button(vlayout); TestBtn.Text = "Text"; TestBtn.Width = 100; TestBtn.Clicked += delegate(ControlBase sender, ClickedEventArgs args) { ctrl.SelectByText("Text"); }; } //Select by Name { Button TestBtn = new Button(vlayout); TestBtn.Text = "Name"; TestBtn.Width = 100; TestBtn.Clicked += delegate(ControlBase sender, ClickedEventArgs args) { ctrl.SelectByName("Name"); }; } //Select by UserData { Button TestBtn = new Button(vlayout); TestBtn.Text = "UserData"; TestBtn.Width = 100; TestBtn.Clicked += delegate(ControlBase sender, ClickedEventArgs args) { ctrl.SelectByUserData(12); }; } } }
public IssueWindow(Issue issue, MainWindow mainWindow, ListBoxRow row) : this(new Builder("IssueWindow.glade"), issue, mainWindow, row) { }
public QuestionDialog(Question question, MainWindow mainWindow, ListBoxRow row) : this(new Builder("QuestionDialog.glade"), question, mainWindow, row) { }
public ListBox(ControlBase parent) : base(parent) { HorizontalLayout hlayout = new HorizontalLayout(this); hlayout.Margin = Margin.Three; hlayout.Dock = Dock.Top; { Control.ListBox ctrl = new Control.ListBox(hlayout); ctrl.Margin = Margin.Three; ctrl.AllowMultiSelect = true; ctrl.AddRow("First"); ctrl.AddRow("Blue"); ctrl.AddRow("Yellow"); ctrl.AddRow("Orange"); ctrl.AddRow("Brown"); ctrl.AddRow("Black"); ctrl.AddRow("Green"); ctrl.AddRow("Dog"); ctrl.AddRow("Cat Blue"); ctrl.AddRow("Shoes"); ctrl.AddRow("Shirts"); ctrl.AddRow("Chair"); ctrl.AddRow("I'm autosized"); ctrl.AddRow("Last"); ctrl.SelectRowsByRegex("Bl.e|Dog"); ctrl.RowSelected += RowSelected; ctrl.RowUnselected += RowUnSelected; } { Table ctrl = new Table(hlayout); ctrl.Margin = Margin.Three; ctrl.AddRow("First"); ctrl.AddRow("Blue"); ctrl.AddRow("Yellow"); ctrl.AddRow("Orange"); ctrl.AddRow("Brown"); ctrl.AddRow("Black"); ctrl.AddRow("Green"); ctrl.AddRow("Dog"); ctrl.AddRow("Cat Blue"); ctrl.AddRow("Shoes"); ctrl.AddRow("Shirts"); ctrl.AddRow("Chair"); ctrl.AddRow("I'm autosized"); ctrl.AddRow("Last"); ctrl.SizeColumnsToContent(); } { Control.ListBox ctrl = new Control.ListBox(hlayout); ctrl.Margin = Margin.Three; ctrl.ColumnCount = 3; ctrl.RowSelected += RowSelected; ctrl.RowUnselected += RowUnSelected; { TableRow row = ctrl.AddRow("Baked Beans"); row.SetCellText(1, "Heinz"); row.SetCellText(2, "£3.50"); } { TableRow row = ctrl.AddRow("Bananas"); row.SetCellText(1, "Trees"); row.SetCellText(2, "£1.27"); } { TableRow row = ctrl.AddRow("Chicken"); row.SetCellText(1, "\u5355\u5143\u6D4B\u8BD5"); row.SetCellText(2, "£8.95"); } } VerticalLayout vlayout = new VerticalLayout(hlayout); { // fixed-size list box Control.ListBox ctrl = new Control.ListBox(vlayout); ctrl.Margin = Margin.Three; ctrl.Height = 90; ctrl.AutoSizeColumnsToContent = false; ctrl.HorizontalAlignment = HorizontalAlignment.Left; ctrl.ColumnCount = 3; ctrl.SetColumnWidth(0, 120); ctrl.SetColumnWidth(1, 150); ctrl.SetColumnWidth(2, 150); var row1 = ctrl.AddRow("Row 1"); row1.SetCellText(1, "R1 cell 1"); row1.SetCellText(2, "Row 1 cell 2"); ctrl.AddRow("Row 2, slightly bigger"); ctrl[1].SetCellText(1, "Center cell"); ctrl.AddRow("Row 3, medium"); ctrl[2].SetCellText(2, "Last cell"); } { // autosized list box Control.ListBox ctrl = new Control.ListBox(vlayout); ctrl.Margin = Margin.Three; ctrl.HorizontalAlignment = HorizontalAlignment.Left; ctrl.AutoSizeToContent = true; ctrl.ColumnCount = 3; var row1 = ctrl.AddRow("Row 1"); row1.SetCellText(1, "R1 cell 1"); row1.SetCellText(2, "Row 1 cell 2"); ctrl.AddRow("Row 2, slightly bigger"); ctrl[1].SetCellText(1, "Center cell"); ctrl.AddRow("Row 3, medium"); ctrl[2].SetCellText(2, "Last cell"); } { Control.ListBox ctrl = new Control.ListBox(vlayout); ctrl.Margin = Margin.Three; ctrl.HorizontalAlignment = HorizontalAlignment.Left; ctrl.AutoSizeToContent = true; ctrl.Height = 110; ObservableCollection <ListBoxItem> items = new ObservableCollection <ListBoxItem>(); items.Add(new ListBoxItem() { Name = "Baked Beans", Type = "Heinz", Price = 3.50 }); items.Add(new ListBoxItem() { Name = "Bananas", Type = "Trees", Price = 1.27 }); ctrl.DisplayMembers = new string[] { "Name", "Type", "Price" }; ctrl.ItemsSource = items; HorizontalLayout hlayout2 = new HorizontalLayout(vlayout); { Control.Button add = new Control.Button(hlayout2); add.Margin = Margin.Three; add.Text = "Insert"; add.Clicked += (s, e) => { int selectedIndex = ctrl.SelectedRowIndex; if (selectedIndex != -1) { items.Insert(selectedIndex, new ListBoxItem() { Name = "Chicken", Type = "\u5355\u5143\u6D4B\u8BD5", Price = 8.95 }); } else { items.Add(new ListBoxItem() { Name = "Chicken", Type = "\u5355\u5143\u6D4B\u8BD5", Price = 8.95 }); } }; } { Control.Button remove = new Control.Button(hlayout2); remove.Margin = Margin.Three; remove.Text = "Remove"; remove.Clicked += (s, e) => { int selectedIndex = ctrl.SelectedRowIndex; if (selectedIndex != -1) { items.RemoveAt(selectedIndex); } }; } } hlayout = new HorizontalLayout(this); hlayout.Margin = Margin.Six; hlayout.Dock = Dock.Top; /* Selecting Rows in Code */ { Control.ListBox ctrl = new Control.ListBox(hlayout); ctrl.AutoSizeToContent = true; ListBoxRow row = ctrl.AddRow("Row"); ctrl.AddRow("Text"); ctrl.AddRow("InternalName", "Name"); ctrl.AddRow("UserData", "Internal", 12); Control.LabeledCheckBox multiline = new Control.LabeledCheckBox(this); multiline.Margin = Margin.Six; multiline.Dock = Dock.Top; multiline.Text = "Enable MultiSelect"; multiline.CheckChanged += delegate(ControlBase sender, EventArgs args) { ctrl.AllowMultiSelect = multiline.IsChecked; }; vlayout = new VerticalLayout(hlayout); //Select by Row { Control.Button TriangleButton = new Control.Button(vlayout); TriangleButton.Text = "Row"; TriangleButton.Width = 100; TriangleButton.Clicked += delegate(ControlBase sender, ClickedEventArgs args) { ctrl.SelectedRow = row; }; } //Select by Text { Control.Button TestBtn = new Control.Button(vlayout); TestBtn.Text = "Text"; TestBtn.Width = 100; TestBtn.Clicked += delegate(ControlBase sender, ClickedEventArgs args) { ctrl.SelectRows("Text"); }; } //Select by Name { Control.Button TestBtn = new Control.Button(vlayout); TestBtn.Text = "Name"; TestBtn.Width = 100; TestBtn.Clicked += delegate(ControlBase sender, ClickedEventArgs args) { ctrl.SelectByName("Name"); }; } //Select by UserData { Control.Button TestBtn = new Control.Button(vlayout); TestBtn.Text = "UserData"; TestBtn.Width = 100; TestBtn.Clicked += delegate(ControlBase sender, ClickedEventArgs args) { ctrl.SelectByUserData(12); }; } } }
private void LaunchIssueWindow(string issueID, ListBoxRow row) { issueWindow = new IssueWindow(issues[issueID], this, row); SolverApp.GetApp().AddWindow(issueWindow); issueWindow.ShowAll(); }
internal static void DefaultRowRender(ArrestReport report, ListBoxRow row) { row.Text = String.Format("{0} {1} {2} {3}", report.Id().Substring(30), report.ArrestDate, report.ArrestTime, report.FullName); }
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(); } }