protected void OnLinkClicked(BreadCrumb sender) { if (BreadCrumbClicked != null) { BreadCrumbClicked(sender, new BreadCrumbClickedEventArgs(sender)); } }
private TableLayoutPanel CreateContainerBox(BreadCrumb crumb) { var dataFilter = (DataFilter)crumb.Tag; var crumbTable = new TableLayoutPanel { AutoSize = true, Padding = new Padding(5), Size = new Size(0, 0), AutoSizeMode = AutoSizeMode.GrowAndShrink }; var containerBook = CreateContainerBook(dataFilter); PopulateContainerBox(dataFilter, containerBook, 0, crumbTable, crumb); return(crumbTable); }
protected void OnLinkClicked (BreadCrumb sender) { if (BreadCrumbClicked != null) BreadCrumbClicked(sender, new BreadCrumbClickedEventArgs(sender)); }
internal BreadCrumbClickedEventArgs (BreadCrumb breadCrumb) { BreadCrumb = breadCrumb; }
private void PopulateContainerBox(DataFilter dataFilter, List<List<KeyValuePair<string, int>>> containerBook, int pageIndex, TableLayoutPanel crumbTable, BreadCrumb crumb) { var firstColumnSize = 0; var lastColumnSize = 0; var largestDescription = 0; var dataSet = containerBook[pageIndex]; //clear current table and populate with the crumbs present in the current page crumbTable.Controls.Clear(); for (var x = 0; x < dataSet.Count; x++) { var kvp = dataSet[x]; var arrow = new Label { Text = ">", AutoSize = true, Margin = new Padding(0, 5, 0, 5) }; crumbTable.Controls.Add(arrow, 0, x); if (arrow.Width > 0) firstColumnSize = arrow.Width; var description = new Label { Text = kvp.Key, AutoSize = true, Margin = new Padding(5) }; crumbTable.Controls.Add(description, 1, x); if (description.Width > largestDescription) largestDescription = description.Width; var deleteLink = new LinkLabel { Text = "(x)", AutoSize = true, Margin = new Padding(0, 5, 0, 5) }; deleteLink.Click += delegate { var allGone = RemoveItemInContainer(dataFilter, kvp.Value); _subItemPopup.Close(); if (allGone) BreadCrumbClicked(crumb, new BreadCrumbClickedEventArgs(crumb)); else { BreadCrumbClicked(null, new BreadCrumbClickedEventArgs(null)); breadCrumbs_ListChanged(null, null); } }; crumbTable.Controls.Add(deleteLink, 2, x); if (deleteLink.Width > 0) lastColumnSize = deleteLink.Width; } //if there exists more than one page add navigation row if (containerBook.Count > 1) { //forward and back buttons if (pageIndex > 0) { var backButton = new Button { Text = "<-", Size = new Size(30, 20) }; backButton.Click += (x, y) => { PopulateContainerBox(dataFilter, containerBook, pageIndex - 1, crumbTable, crumb); if (_subItemPopup != null) _subItemPopup.Size = _tableSize; }; crumbTable.Controls.Add(backButton, 0, dataSet.Count); if (backButton.Width > firstColumnSize) firstColumnSize = backButton.Width; } if (pageIndex < containerBook.Count - 1) { var forwardButton = new Button { Text = "->", Size = new Size(30, 20) }; forwardButton.Click += (x, y) => { PopulateContainerBox(dataFilter, containerBook, pageIndex + 1, crumbTable, crumb); if (_subItemPopup != null) _subItemPopup.Size = _tableSize; }; crumbTable.Controls.Add(forwardButton, 2, dataSet.Count); if (forwardButton.Width > lastColumnSize) lastColumnSize = forwardButton.Width; } //middle page reporting / goto page control var cellPanel = new Panel {Size = new Size(largestDescription, 23)}; var pageLabel = new Label {Text = "Page ", AutoSize = true}; pageLabel.Font = new Font(pageLabel.Font.ToString(),10.0f); var pageSelectBox = new TextBox {Text = (pageIndex + 1).ToString(), TextAlign = HorizontalAlignment.Center}; pageSelectBox.KeyPress += (x, y) => { //if enter is pressed go to selected page (or reset to current page if no valid page is selected) if (y.KeyChar == (char)13) { y.Handled = true; int tempInt; if (!int.TryParse(pageSelectBox.Text, out tempInt) || tempInt <= 0 || tempInt > containerBook.Count) pageSelectBox.Text = (pageIndex + 1).ToString(); else { PopulateContainerBox(dataFilter, containerBook, tempInt - 1, crumbTable, crumb); if (_subItemPopup != null) _subItemPopup.Size = _tableSize; } } }; pageSelectBox.Leave += (x, y) => { pageSelectBox.Text = (pageIndex + 1).ToString(); }; var totalLabel = new Label { Text = " of " + containerBook.Count, AutoSize = true }; totalLabel.Font = new Font(totalLabel.Font.ToString(), 10.0f); //add all three controls to the cell panel cellPanel.Controls.Add(pageLabel); cellPanel.Controls.Add(pageSelectBox); cellPanel.Controls.Add(totalLabel); //make sure boxes are wide enough pageSelectBox.Width = totalLabel.Width-10; var totalCellWidth = pageLabel.Width + pageSelectBox.Width + totalLabel.Width; if (totalCellWidth > largestDescription) { largestDescription = totalCellWidth; cellPanel.Width = totalCellWidth; } //reposition controls to final locations var startlocation = (largestDescription - totalCellWidth) / 2; pageLabel.Location = new Point(startlocation, 0); pageSelectBox.Location = new Point(startlocation + pageLabel.Width, 0); totalLabel.Location = new Point(startlocation+pageLabel.Width + pageSelectBox.Width,0); crumbTable.Controls.Add(cellPanel, 1, dataSet.Count); } //Hack: sadly the obvious .GetRowHeights() and .getColumnWidths //dont give consistantly valid results, as such proper dimentions have //to be calculated as the table is formed. var rowHeights = (crumbTable.GetRowHeights().Length) * 24; var columnWidths = firstColumnSize + lastColumnSize + 25 +largestDescription; _tableSize = new Size(columnWidths +5, rowHeights +5); }
private TableLayoutPanel CreateContainerBox(BreadCrumb crumb) { var dataFilter = (DataFilter) crumb.Tag; var crumbTable = new TableLayoutPanel { AutoSize = true, Padding = new Padding(5), Size = new Size(0, 0), AutoSizeMode = AutoSizeMode.GrowAndShrink }; var containerBook = CreateContainerBook(dataFilter); PopulateContainerBox(dataFilter, containerBook, 0, crumbTable, crumb); return crumbTable; }
internal BreadCrumbClickedEventArgs(BreadCrumb breadCrumb) { BreadCrumb = breadCrumb; }
private void PopulateContainerBox(DataFilter dataFilter, List <List <KeyValuePair <string, int> > > containerBook, int pageIndex, TableLayoutPanel crumbTable, BreadCrumb crumb) { var firstColumnSize = 0; var lastColumnSize = 0; var largestDescription = 0; var dataSet = containerBook[pageIndex]; //clear current table and populate with the crumbs present in the current page crumbTable.Controls.Clear(); for (var x = 0; x < dataSet.Count; x++) { var kvp = dataSet[x]; var arrow = new Label { Text = ">", AutoSize = true, Margin = new Padding(0, 5, 0, 5) }; crumbTable.Controls.Add(arrow, 0, x); if (arrow.Width > 0) { firstColumnSize = arrow.Width; } var description = new Label { Text = kvp.Key, AutoSize = true, Margin = new Padding(5) }; crumbTable.Controls.Add(description, 1, x); if (description.Width > largestDescription) { largestDescription = description.Width; } var deleteLink = new LinkLabel { Text = "(x)", AutoSize = true, Margin = new Padding(0, 5, 0, 5) }; deleteLink.Click += delegate { var allGone = RemoveItemInContainer(dataFilter, kvp.Value); _subItemPopup.Close(); if (allGone) { BreadCrumbClicked(crumb, new BreadCrumbClickedEventArgs(crumb)); } else { BreadCrumbClicked(null, new BreadCrumbClickedEventArgs(null)); breadCrumbs_ListChanged(null, null); } }; crumbTable.Controls.Add(deleteLink, 2, x); if (deleteLink.Width > 0) { lastColumnSize = deleteLink.Width; } } //if there exists more than one page add navigation row if (containerBook.Count > 1) { //forward and back buttons if (pageIndex > 0) { var backButton = new Button { Text = "<-", Size = new Size(30, 20) }; backButton.Click += (x, y) => { PopulateContainerBox(dataFilter, containerBook, pageIndex - 1, crumbTable, crumb); if (_subItemPopup != null) { _subItemPopup.Size = _tableSize; } }; crumbTable.Controls.Add(backButton, 0, dataSet.Count); if (backButton.Width > firstColumnSize) { firstColumnSize = backButton.Width; } } if (pageIndex < containerBook.Count - 1) { var forwardButton = new Button { Text = "->", Size = new Size(30, 20) }; forwardButton.Click += (x, y) => { PopulateContainerBox(dataFilter, containerBook, pageIndex + 1, crumbTable, crumb); if (_subItemPopup != null) { _subItemPopup.Size = _tableSize; } }; crumbTable.Controls.Add(forwardButton, 2, dataSet.Count); if (forwardButton.Width > lastColumnSize) { lastColumnSize = forwardButton.Width; } } //middle page reporting / goto page control var cellPanel = new Panel { Size = new Size(largestDescription, 23) }; var pageLabel = new Label { Text = "Page ", AutoSize = true }; pageLabel.Font = new Font(pageLabel.Font.ToString(), 10.0f); var pageSelectBox = new TextBox { Text = (pageIndex + 1).ToString(), TextAlign = HorizontalAlignment.Center }; pageSelectBox.KeyPress += (x, y) => { //if enter is pressed go to selected page (or reset to current page if no valid page is selected) if (y.KeyChar == (char)13) { y.Handled = true; int tempInt; if (!int.TryParse(pageSelectBox.Text, out tempInt) || tempInt <= 0 || tempInt > containerBook.Count) { pageSelectBox.Text = (pageIndex + 1).ToString(); } else { PopulateContainerBox(dataFilter, containerBook, tempInt - 1, crumbTable, crumb); if (_subItemPopup != null) { _subItemPopup.Size = _tableSize; } } } }; pageSelectBox.Leave += (x, y) => { pageSelectBox.Text = (pageIndex + 1).ToString(); }; var totalLabel = new Label { Text = " of " + containerBook.Count, AutoSize = true }; totalLabel.Font = new Font(totalLabel.Font.ToString(), 10.0f); //add all three controls to the cell panel cellPanel.Controls.Add(pageLabel); cellPanel.Controls.Add(pageSelectBox); cellPanel.Controls.Add(totalLabel); //make sure boxes are wide enough pageSelectBox.Width = totalLabel.Width - 10; var totalCellWidth = pageLabel.Width + pageSelectBox.Width + totalLabel.Width; if (totalCellWidth > largestDescription) { largestDescription = totalCellWidth; cellPanel.Width = totalCellWidth; } //reposition controls to final locations var startlocation = (largestDescription - totalCellWidth) / 2; pageLabel.Location = new Point(startlocation, 0); pageSelectBox.Location = new Point(startlocation + pageLabel.Width, 0); totalLabel.Location = new Point(startlocation + pageLabel.Width + pageSelectBox.Width, 0); crumbTable.Controls.Add(cellPanel, 1, dataSet.Count); } //Hack: sadly the obvious .GetRowHeights() and .getColumnWidths //dont give consistantly valid results, as such proper dimentions have //to be calculated as the table is formed. var rowHeights = (crumbTable.GetRowHeights().Length) * 24; var columnWidths = firstColumnSize + lastColumnSize + 25 + largestDescription; _tableSize = new Size(columnWidths + 5, rowHeights + 5); }