BeepFunctionsPanel
Compact function button panel with pre-built common operations and customizable orientation for efficient user interfaces
?? Table of Contents
Overview
BeepFunctionsPanel provides a pre-configured panel containing commonly used function buttons for applications. It includes standard operations like Refresh, Search, Filter, Sort, Print, Export, and more, all in a compact, customizable interface that can be oriented horizontally or vertically to fit various layout needs.
Built on the BeepControl foundation, BeepFunctionsPanel features intelligent auto-sizing, flexible orientation support, comprehensive theming, tooltip integration, and standardized function handling. Perfect for data grids, list views, toolbars, and any interface requiring quick access to common operations.
Key Features
??? Pre-Built Functions
11 standard function buttons including Refresh, Search, Filter, Sort, Print, Export, and more
?? Dual Orientation
Support for both horizontal and vertical layouts with automatic sizing and positioning
?? Intelligent Sizing
Automatic panel sizing based on button count, spacing, and orientation
?? Icon Integration
Professional SVG icons for all functions with theme-aware coloring and sizing
?? Easy Configuration
Simple properties for button sizing, spacing, positioning, and appearance customization
?? Event Handling
Unified event system with function identification for streamlined action handling
Visual Preview
Horizontal Layout
Horizontal layout with 11 standard function buttons
Vertical Layout
Vertical layout with compact stacking for sidebar placement
Application Integration
Data Management
BeepFunctionsPanel integrated in both header (horizontal) and sidebar (vertical) layouts
Basic Usage
Simple Functions Panel
// Create a horizontal functions panel
var functionsPanel = new BeepFunctionsPanel();
functionsPanel.Location = new Point(20, 20);
functionsPanel.PanelOrientation = Orientation.Horizontal;
functionsPanel.ButtonWidth = 32;
functionsPanel.ButtonHeight = 32;
functionsPanel.ButtonSpacing = 8;
// Handle function calls
functionsPanel.FunctionCalled += (sender, e) =>
{
switch (e.EventName)
{
case "Refresh":
RefreshData();
break;
case "Search":
ShowSearchDialog();
break;
case "Filter":
ShowFilterOptions();
break;
case "Print":
PrintCurrentView();
break;
case "Export":
ExportData();
break;
default:
// Console.WriteLine($"Function called: {e.EventName}");
break;
}
};
// Add to form
this.Controls.Add(functionsPanel);
Vertical Sidebar Panel
// Create a vertical functions panel for sidebar
var sidebarFunctions = new BeepFunctionsPanel
{
PanelOrientation = Orientation.Vertical,
ButtonWidth = 40,
ButtonHeight = 40,
ButtonSpacing = 10,
XOffset = 5,
YOffset = 10,
Dock = DockStyle.Left
};
// Configure specific button visibility/accessibility
sidebarFunctions.FunctionButtons["Help"].Visible = true;
sidebarFunctions.FunctionButtons["About"].Visible = true;
sidebarFunctions.FunctionButtons["Settings"].Visible = true;
sidebarFunctions.FunctionButtons["Exit"].Visible = false; // Hide exit in sidebar
// Handle function calls with specific logic
sidebarFunctions.FunctionCalled += HandleSidebarFunctions;
this.Controls.Add(sidebarFunctions);
private void HandleSidebarFunctions(object sender, BeepEventDataArgs e)
{
switch (e.EventName)
{
case "Help":
System.Diagnostics.Process.Start("https://help.example.com");
break;
case "About":
new AboutDialog().ShowDialog();
break;
case "Settings":
new SettingsForm().ShowDialog();
break;
default:
MessageBox.Show($"Function: {e.EventName}", "Sidebar Action");
break;
}
}
Data Grid Integration
public class DataGridWithFunctions : UserControl
{
private BeepFunctionsPanel functionsPanel;
private DataGridView dataGrid;
private BindingSource dataSource;
public DataGridWithFunctions()
{
SetupFunctionsPanel();
SetupDataGrid();
LoadSampleData();
}
private void SetupFunctionsPanel()
{
functionsPanel = new BeepFunctionsPanel
{
Dock = DockStyle.Top,
PanelOrientation = Orientation.Horizontal,
ButtonWidth = 28,
ButtonHeight = 28,
ButtonSpacing = 6,
Height = 40
};
// Hide functions not relevant to data grid
functionsPanel.FunctionButtons["About"].Visible = false;
functionsPanel.FunctionButtons["Exit"].Visible = false;
functionsPanel.FunctionButtons["Close"].Visible = false;
functionsPanel.FunctionCalled += HandleGridFunctions;
this.Controls.Add(functionsPanel);
}
private void SetupDataGrid()
{
dataGrid = new DataGridView
{
Dock = DockStyle.Fill,
AutoGenerateColumns = true,
ReadOnly = false,
AllowUserToAddRows = true,
AllowUserToDeleteRows = true
};
dataSource = new BindingSource();
dataGrid.DataSource = dataSource;
this.Controls.Add(dataGrid);
}
private void HandleGridFunctions(object sender, BeepEventDataArgs e)
{
switch (e.EventName)
{
case "Refresh":
RefreshGridData();
break;
case "Search":
ShowSearchDialog();
break;
case "Filter":
ApplyDataFilter();
break;
case "Sort":
ShowSortDialog();
break;
case "Print":
PrintDataGrid();
break;
case "Export":
ExportGridData();
break;
case "Settings":
ShowGridSettings();
break;
case "Help":
ShowGridHelp();
break;
}
}
private void RefreshGridData()
{
// Reload data from source
dataSource.ResetBindings(false);
MessageBox.Show("Data refreshed", "Info");
}
private void ShowSearchDialog()
{
using var searchForm = new Form
{
Text = "Search Data",
Size = new Size(300, 150),
StartPosition = FormStartPosition.CenterParent
};
var searchBox = new TextBox
{
Location = new Point(20, 20),
Width = 200,
PlaceholderText = "Enter search term..."
};
var searchButton = new Button
{
Text = "Search",
Location = new Point(230, 18),
Width = 60
};
searchButton.Click += (s, e) =>
{
// Implement search logic
string searchTerm = searchBox.Text;
FilterGridData(searchTerm);
searchForm.Close();
};
searchForm.Controls.AddRange(new Control[] { searchBox, searchButton });
searchForm.ShowDialog();
}
private void ApplyDataFilter()
{
// Show filter options dialog
using var filterForm = new Form
{
Text = "Filter Options",
Size = new Size(400, 300),
StartPosition = FormStartPosition.CenterParent
};
// Add filter controls
var statusLabel = new Label { Text = "Status:", Location = new Point(20, 20) };
var statusCombo = new ComboBox
{
Location = new Point(80, 18),
Width = 150,
DropDownStyle = ComboBoxStyle.DropDownList
};
statusCombo.Items.AddRange(new[] { "All", "Active", "Inactive", "Pending" });
statusCombo.SelectedIndex = 0;
var applyButton = new Button
{
Text = "Apply Filter",
Location = new Point(250, 18),
Width = 100
};
applyButton.Click += (s, e) =>
{
string filterValue = statusCombo.SelectedItem.ToString();
ApplyStatusFilter(filterValue);
filterForm.Close();
};
filterForm.Controls.AddRange(new Control[] { statusLabel, statusCombo, applyButton });
filterForm.ShowDialog();
}
private void PrintDataGrid()
{
// Implement printing logic
MessageBox.Show("Print functionality would be implemented here", "Print");
}
private void ExportGridData()
{
using var saveDialog = new SaveFileDialog
{
Filter = "CSV files (*.csv)|*.csv|Excel files (*.xlsx)|*.xlsx",
Title = "Export Data"
};
if (saveDialog.ShowDialog() == DialogResult.OK)
{
// Implement export logic based on file extension
string fileName = saveDialog.FileName;
ExportToFile(fileName);
}
}
// Helper methods
private void LoadSampleData() { /* Load sample data */ }
private void FilterGridData(string searchTerm) { /* Implement search filter */ }
private void ApplyStatusFilter(string status) { /* Implement status filter */ }
private void ShowSortDialog() { /* Show sort options */ }
private void ShowGridSettings() { /* Show grid configuration */ }
private void ShowGridHelp() { /* Show help content */ }
private void ExportToFile(string fileName) { /* Export to file */ }
}
Properties
Layout Properties
| Property | Type | Default | Description |
|---|---|---|---|
PanelOrientation |
Orientation | Horizontal | Orientation of the button layout (Horizontal/Vertical) |
ButtonWidth |
int | 20 | Width of individual function buttons |
ButtonHeight |
int | 20 | Height of individual function buttons |
ButtonSpacing |
int | 5 | Spacing between buttons |
XOffset |
int | 5 | Horizontal offset from panel edge |
YOffset |
int | 5 | Vertical offset from panel edge |
Appearance Properties
| Property | Type | Default | Description |
|---|---|---|---|
ApplyThemeOnImage |
bool | false | Whether to apply theme colors to button icons |
Button References
| Property | Type | Function | Icon |
|---|---|---|---|
btnRefresh |
BeepButton | Refresh data or view | ?? Refresh |
btnSearch |
BeepButton | Search functionality | ?? Search |
btnFilter |
BeepButton | Filter data or options | ?? Filter |
btnSort |
BeepButton | Sort data or items | ?? Sort |
btnPrint |
BeepButton | Print current view | |
btnExport |
BeepButton | Export data | ?? Export |
btnClose |
BeepButton | Close window or dialog | ? Close |
btnHelp |
BeepButton | Show help information | ? Help |
btnSettings |
BeepButton | Open settings or preferences | ?? Settings |
btnAbout |
BeepButton | Show about information | ?? About |
btnExit |
BeepButton | Exit application | ?? Exit |
Collections
| Property | Type | Description |
|---|---|---|
FunctionButtons |
Dictionary<string, BeepButton> | Collection of all function buttons accessible by name |
Events
| Event | Event Args | Description |
|---|---|---|
FunctionCalled |
EventHandler<BeepEventDataArgs> | Fired when any function button is clicked |
BeepEventDataArgs Properties
| Property | Type | Description |
|---|---|---|
EventName |
string | Name of the function that was called (e.g., "Refresh", "Search") |
EventData |
object | Additional data associated with the event (typically null) |
Function Names
- "Refresh" - Refresh button clicked
- "Search" - Search button clicked
- "Filter" - Filter button clicked
- "Sort" - Sort button clicked
- "Print" - Print button clicked
- "Export" - Export button clicked
- "Close" - Close button clicked
- "Help" - Help button clicked
- "Settings" - Settings button clicked
- "About" - About button clicked
- "Exit" - Exit button clicked
Examples
Document Management Interface
public class DocumentManager : Form
{
private BeepFunctionsPanel headerFunctions;
private BeepFunctionsPanel sidebarFunctions;
private ListView documentList;
private List documents;
public DocumentManager()
{
SetupInterface();
LoadDocuments();
}
private void SetupInterface()
{
this.Size = new Size(800, 600);
this.Text = "Document Manager";
// Header functions panel
headerFunctions = new BeepFunctionsPanel
{
Dock = DockStyle.Top,
PanelOrientation = Orientation.Horizontal,
ButtonWidth = 32,
ButtonHeight = 32,
ButtonSpacing = 8,
Height = 50
};
// Configure header functions - hide non-document functions
headerFunctions.FunctionButtons["About"].Visible = false;
headerFunctions.FunctionButtons["Exit"].Visible = false;
headerFunctions.FunctionButtons["Close"].Visible = false;
headerFunctions.FunctionCalled += HandleHeaderFunctions;
// Sidebar functions panel
sidebarFunctions = new BeepFunctionsPanel
{
Dock = DockStyle.Right,
PanelOrientation = Orientation.Vertical,
ButtonWidth = 40,
ButtonHeight = 40,
ButtonSpacing = 12,
Width = 60
};
// Configure sidebar - only show utility functions
var sidebarButtons = new[] { "Print", "Export", "Settings", "Help" };
foreach (var btn in sidebarFunctions.FunctionButtons)
{
btn.Value.Visible = sidebarButtons.Contains(btn.Key);
}
sidebarFunctions.FunctionCalled += HandleSidebarFunctions;
// Document list
documentList = new ListView
{
Dock = DockStyle.Fill,
View = View.Details,
FullRowSelect = true,
GridLines = true
};
documentList.Columns.AddRange(new[]
{
new ColumnHeader { Text = "Name", Width = 200 },
new ColumnHeader { Text = "Type", Width = 100 },
new ColumnHeader { Text = "Size", Width = 100 },
new ColumnHeader { Text = "Modified", Width = 150 },
new ColumnHeader { Text = "Status", Width = 100 }
});
// Add controls to form
this.Controls.AddRange(new Control[]
{
documentList, sidebarFunctions, headerFunctions
});
}
private void HandleHeaderFunctions(object sender, BeepEventDataArgs e)
{
switch (e.EventName)
{
case "Refresh":
RefreshDocumentList();
break;
case "Search":
ShowDocumentSearch();
break;
case "Filter":
ShowDocumentFilter();
break;
case "Sort":
ShowSortOptions();
break;
}
}
private void HandleSidebarFunctions(object sender, BeepEventDataArgs e)
{
switch (e.EventName)
{
case "Print":
PrintDocumentList();
break;
case "Export":
ExportDocumentList();
break;
case "Settings":
ShowDocumentSettings();
break;
case "Help":
ShowDocumentHelp();
break;
}
}
private void RefreshDocumentList()
{
documentList.Items.Clear();
LoadDocuments();
ShowStatusMessage("Document list refreshed");
}
private void ShowDocumentSearch()
{
using var searchDialog = new DocumentSearchDialog();
if (searchDialog.ShowDialog() == DialogResult.OK)
{
var searchResults = SearchDocuments(searchDialog.SearchCriteria);
UpdateDocumentList(searchResults);
}
}
private void ShowDocumentFilter()
{
using var filterDialog = new DocumentFilterDialog();
if (filterDialog.ShowDialog() == DialogResult.OK)
{
var filteredDocuments = FilterDocuments(filterDialog.FilterCriteria);
UpdateDocumentList(filteredDocuments);
}
}
private void PrintDocumentList()
{
// Create print document
var printDoc = new PrintDocument();
printDoc.PrintPage += (s, e) =>
{
// Print document list logic
PrintDocumentListContent(e.Graphics);
};
var printDialog = new PrintDialog { Document = printDoc };
if (printDialog.ShowDialog() == DialogResult.OK)
{
printDoc.Print();
}
}
private void ExportDocumentList()
{
using var saveDialog = new SaveFileDialog
{
Filter = "CSV Files|*.csv|Excel Files|*.xlsx|PDF Files|*.pdf",
Title = "Export Document List"
};
if (saveDialog.ShowDialog() == DialogResult.OK)
{
switch (Path.GetExtension(saveDialog.FileName).ToLower())
{
case ".csv":
ExportToCsv(saveDialog.FileName);
break;
case ".xlsx":
ExportToExcel(saveDialog.FileName);
break;
case ".pdf":
ExportToPdf(saveDialog.FileName);
break;
}
ShowStatusMessage($"Document list exported to {saveDialog.FileName}");
}
}
// Helper methods
private void LoadDocuments() { /* Load documents from storage */ }
private void UpdateDocumentList(IEnumerable docs) { /* Update list view */ }
private IEnumerable SearchDocuments(SearchCriteria criteria) { return documents; }
private IEnumerable FilterDocuments(FilterCriteria criteria) { return documents; }
private void ShowSortOptions() { /* Show sort dialog */ }
private void ShowDocumentSettings() { /* Show settings dialog */ }
private void ShowDocumentHelp() { /* Show help content */ }
private void PrintDocumentListContent(Graphics graphics) { /* Print implementation */ }
private void ExportToCsv(string fileName) { /* CSV export */ }
private void ExportToExcel(string fileName) { /* Excel export */ }
private void ExportToPdf(string fileName) { /* PDF export */ }
private void ShowStatusMessage(string message) { /* Update status bar */ }
}
public class DocumentInfo
{
public string Name { get; set; }
public string Type { get; set; }
public long Size { get; set; }
public DateTime Modified { get; set; }
public string Status { get; set; }
}
Theming
BeepFunctionsPanel provides comprehensive theming for all contained buttons with automatic theme propagation:
Theme Application
var functionsPanel = new BeepFunctionsPanel
{
Theme = "DarkTheme",
ApplyThemeOnImage = true // Apply theme colors to SVG icons
};
// Theme automatically applies to:
// - Panel background color
// - All function button themes
// - Button hover states
// - Icon colors (if ApplyThemeOnImage is true)
// - Tooltip styling
// Manual theme application
functionsPanel.ApplyTheme();
Functions Panel Theming
- ListBackColor - Panel background color
- ListForeColor - Button text/icon colors
- ButtonBackColor - Individual button backgrounds
- ButtonHoverBackColor - Button hover states
- BorderColor - Button borders and panel borders
- ShadowColor - Button shadow effects
Custom Button Styling
// Customize individual buttons after theme application
functionsPanel.ApplyTheme();
// Make important buttons stand out
functionsPanel.FunctionButtons["Refresh"].BackColor = Color.FromArgb(46, 204, 113);
functionsPanel.FunctionButtons["Search"].BackColor = Color.FromArgb(52, 152, 219);
functionsPanel.FunctionButtons["Export"].BackColor = Color.FromArgb(241, 196, 15);
// Style warning/danger buttons
functionsPanel.FunctionButtons["Exit"].BackColor = Color.FromArgb(231, 76, 60);
functionsPanel.FunctionButtons["Close"].BackColor = Color.FromArgb(230, 126, 34);
Best Practices
??? Function Organization
- Context relevance: Show only functions relevant to the current context
- Logical grouping: Group related functions together (data operations, system functions)
- Frequency-based placement: Place most-used functions in easily accessible positions
- Visibility management: Hide irrelevant functions rather than disabling them
?? Layout Considerations
- Orientation choice: Use horizontal for headers/toolbars, vertical for sidebars
- Button sizing: Ensure adequate touch targets (minimum 32x32 pixels)
- Spacing consistency: Use consistent spacing across all instances
- Responsive design: Consider how panels behave on different screen sizes
? Performance
- Function handling: Implement efficient event handling for all functions
- Resource management: Dispose of dialogs and resources properly
- UI responsiveness: Use async operations for time-consuming tasks
- Theme optimization: Apply themes efficiently without excessive redraws
?? Visual Design
- Icon consistency: Use consistent icon styles across all functions
- Tooltips: Provide clear, descriptive tooltips for all functions
- Visual feedback: Ensure buttons provide clear hover and click feedback
- Theme integration: Use theme colors appropriately for different functions
For data-heavy applications, place the functions panel above the data view (horizontal) for easy access to data operations like refresh, search, and filter.
Always implement meaningful functionality for each visible button - users expect all visible functions to work properly and provide value.
Avoid overwhelming users with too many visible functions - consider grouping less-common functions under a "More" or "Tools" submenu.