19 KiB
Main Window and Navigation
**Referenced Files in This Document** - [MainWindow.axaml](file://ClassicAssist.Avalonia/Views/MainWindow.axaml) - [MainWindow.axaml.cs](file://ClassicAssist.Avalonia/Views/MainWindow.axaml.cs) - [MainWindowViewModel.cs](file://ClassicAssist.Shared/UI/ViewModels/MainWindowViewModel.cs) - [AgentsTabControl.axaml](file://ClassicAssist.Avalonia/Views/AgentsTabControl.axaml) - [OptionsTabControl.axaml](file://ClassicAssist.Avalonia/Views/OptionsTabControl.axaml) - [MacrosTabControl.axaml](file://ClassicAssist.Avalonia/Views/MacrosTabControl.axaml) - [SkillsTabControl.axaml](file://ClassicAssist.Avalonia/Views/SkillsTabControl.axaml) - [DebugWindow.axaml](file://ClassicAssist.Avalonia/Views/DebugWindow.axaml) - [App.axaml](file://ClassicAssist.Avalonia/App.axaml) - [Program.cs](file://ClassicAssist.Avalonia/Program.cs)Table of Contents
- Introduction
- Project Structure
- Core Components
- Architecture Overview
- Detailed Component Analysis
- Navigation System
- Tab Management
- Responsive Design
- Toolbar and Status Indicators
- Keyboard Shortcuts and Accessibility
- Performance Considerations
- Troubleshooting Guide
- Conclusion
Introduction
The ClassicAssist.Avalonia main window serves as the primary interface for users to interact with the Ultima Online assistant functionality. Built using Avalonia UI framework, it provides a modern, cross-platform desktop application experience with a tabbed interface organization that allows seamless navigation between different functional areas including Agents, Options, Macros, Skills, and Debug features.
The main window implements a sophisticated navigation system that maintains application state across different views while providing responsive behavior across various screen sizes and resolutions. The interface is designed with accessibility in mind, supporting screen readers and alternative input methods to ensure inclusive user experience.
Project Structure
The ClassicAssist.Avalonia application follows a clean MVVM (Model-View-ViewModel) architecture pattern typical of modern Avalonia applications. The main window implementation is organized into several key components:
graph TB
subgraph "Main Application"
App[App.axaml]
Program[Program.cs]
end
subgraph "Main Window Layer"
MainWindow[MainWindow.axaml]
MainWindowVM[MainWindowViewModel.cs]
end
subgraph "Tab Controls"
AgentsTab[AgentsTabControl.axaml]
OptionsTab[OptionsTabControl.axaml]
MacrosTab[MacrosTabControl.axaml]
SkillsTab[SkillsTabControl.axaml]
DebugWindow[DebugWindow.axaml]
end
subgraph "Shared ViewModels"
SharedVM[Shared UI/ViewModels/]
end
App --> Program
Program --> MainWindow
MainWindow --> MainWindowVM
MainWindow --> AgentsTab
MainWindow --> OptionsTab
MainWindow --> MacrosTab
MainWindow --> SkillsTab
MainWindow --> DebugWindow
MainWindowVM --> SharedVM
Diagram sources
Section sources
Core Components
The main window interface consists of several core components that work together to provide a cohesive user experience:
Main Window Container
The MainWindow serves as the root container for all UI elements, implementing proper window management, lifecycle handling, and integration with the Avalonia application framework.
Tab Control System
A sophisticated tab control system manages the different functional areas, providing smooth transitions and maintaining state for each tab independently.
ViewModel Integration
Each tab has its corresponding ViewModel that handles business logic, data binding, and user interactions, following the MVVM pattern for clean separation of concerns.
Resource Management
Centralized resource management handles themes, icons, strings, and other shared resources across the application.
Section sources
Architecture Overview
The ClassicAssist.Avalonia main window architecture follows a layered approach with clear separation between presentation, business logic, and data access layers:
classDiagram
class MainWindow {
+TabControl MainTabControl
+StatusBar StatusBar
+ToolBar ToolBar
+InitializeComponent()
+OnLoaded()
+OnClosing()
}
class MainWindowViewModel {
+ObservableCollection~TabItem~ Tabs
+TabItem SelectedTab
+string Title
+bool IsLoading
+NavigateToTab(tabIndex)
+UpdateStatus(message)
+SaveWindowState()
+LoadWindowState()
}
class BaseTabViewModel {
+string TabTitle
+bool IsActive
+void OnActivate()
+void OnDeactivate()
+void Dispose()
}
class AgentsTabViewModel {
+ObservableCollection~AgentEntry~ Agents
+void AddAgent()
+void RemoveAgent()
+void EditAgent()
}
class OptionsTabViewModel {
+ObservableCollection~OptionEntry~ Options
+void SaveOptions()
+void ResetOptions()
+void ImportSettings()
}
class MacrosTabViewModel {
+ObservableCollection~MacroEntry~ Macros
+void ExecuteMacro()
+void StopMacro()
+void EditMacro()
}
class SkillsTabViewModel {
+ObservableCollection~SkillEntry~ Skills
+void UpdateSkillLock()
+void RefreshSkills()
}
MainWindow --> MainWindowViewModel : "binds to"
MainWindowViewModel --> BaseTabViewModel : "manages"
BaseTabViewModel <|-- AgentsTabViewModel
BaseTabViewModel <|-- OptionsTabViewModel
BaseTabViewModel <|-- MacrosTabViewModel
BaseTabViewModel <|-- SkillsTabViewModel
Diagram sources
- MainWindow.axaml
- MainWindowViewModel.cs
- AgentsTabControl.axaml
- OptionsTabControl.axaml
- MacrosTabControl.axaml
- SkillsTabControl.axaml
Detailed Component Analysis
Main Window Layout Structure
The main window layout is structured to provide optimal usability across different screen sizes and orientations. The layout includes:
Header Section
- Application title and version information
- Quick access toolbar with frequently used actions
- Status indicators showing connection status and current mode
Navigation Area
- Tab control with icons and labels for each functional area
- Context menu support for right-click navigation
- Keyboard shortcut indicators displayed in tab headers
Content Area
- Dynamic content panel that displays the active tab's content
- Loading indicators during content initialization
- Error handling and retry mechanisms for failed operations
Footer Section
- Status bar with detailed information
- Progress indicators for long-running operations
- Help and feedback quick access buttons
Section sources
Tabbed Interface Organization
The tabbed interface provides intuitive navigation between different functional areas:
Agents Tab
Manages various agent types including autoloot, dress, friends, organizer, scavenger, and vendor agents. Each agent type has specific configuration options and monitoring capabilities.
Options Tab
Provides comprehensive application settings management including general options, hotkey configuration, network settings, and appearance customization.
Macros Tab
Offers macro creation, editing, and execution capabilities with syntax highlighting, command help, and debugging tools.
Skills Tab
Displays skill information, lock status management, and skill-based automation controls.
Debug Tab
Provides debugging tools, log viewers, packet inspection, and diagnostic information for troubleshooting.
Section sources
- AgentsTabControl.axaml
- OptionsTabControl.axaml
- MacrosTabControl.axaml
- SkillsTabControl.axaml
- DebugWindow.axaml
Navigation Patterns
The application implements multiple navigation patterns to accommodate different user preferences and workflows:
Tab-Based Navigation
Primary navigation method using the tab control with visual feedback for the active tab. Supports mouse clicks, keyboard navigation, and programmatic switching.
Command-Based Navigation
Quick access commands through toolbar buttons, context menus, and keyboard shortcuts for power users who prefer efficient workflows.
State-Based Navigation
Automatic navigation based on application events, such as opening debug window when errors occur or switching to macros tab when macro execution is requested.
Section sources
Navigation System
The navigation system in ClassicAssist.Avalonia is built around a robust tab management architecture that ensures smooth user experience and proper state maintenance.
Tab Switching Mechanism
The tab switching mechanism implements several key features:
sequenceDiagram
participant User as "User"
participant TabControl as "TabControl"
participant VM as "MainWindowViewModel"
participant ActiveTab as "Active Tab ViewModel"
participant PreviousTab as "Previous Tab ViewModel"
User->>TabControl : Click Tab
TabControl->>VM : TabChanged Event
VM->>PreviousTab : OnDeactivate()
VM->>ActiveTab : OnActivate()
VM->>VM : UpdateUIState()
VM-->>TabControl : SetSelectedTab()
TabControl-->>User : Display New Tab
Diagram sources
Window State Management
The application maintains comprehensive window state information:
Position and Size Persistence
- Window position, size, and maximized state are saved and restored automatically
- Per-monitor DPI awareness ensures correct positioning across different displays
- Responsive layout adapts to different screen sizes and orientations
Tab State Preservation
- Active tab selection is maintained across application restarts
- Individual tab scroll positions and filter states are preserved
- Temporary data and search queries are retained within session
Theme and Appearance Settings
- Dark/light theme switching with immediate effect
- Custom color schemes and font scaling support
- High-DPI display optimization
Section sources
Responsive Behavior
The interface adapts seamlessly to different screen sizes and device characteristics:
Adaptive Layout
- Grid-based layout system adjusts column counts based on available width
- Font sizes scale proportionally with DPI changes
- Touch-friendly target sizes for tablet devices
Performance Optimization
- Lazy loading of tab content to improve startup performance
- Virtualization for large lists and collections
- Memory-efficient image and resource management
Section sources
Toolbar Functionality
The toolbar provides quick access to frequently used functions and important controls:
Primary Toolbar Actions
- Connect/Disconnect: Toggle game client connection status
- Start/Stop All: Control macro execution globally
- Refresh: Reload current tab content and update data
- Help: Access contextual help and documentation
- Settings: Open options dialog for application configuration
Contextual Actions
- Right-click Menu: Additional options specific to current tab context
- Drag and Drop: Reorder tabs and drag items between lists
- Hover Tooltips: Descriptive tooltips for all toolbar buttons
Status Indicators
- Connection Status: Visual indicator showing game client connectivity
- Macro Status: Shows current macro execution state
- Error Notifications: Warning and error message display
- Progress Indicators: Animated progress bars for long operations
Section sources
Status Bar and Context Menus
Status Bar Features
The status bar provides real-time application status and quick access information:
- Connection Status: Shows UO client connection state with color coding
- Memory Usage: Displays current memory consumption metrics
- FPS Counter: Real-time frame rate monitoring for performance tuning
- Last Action: Shows the most recent user action or system event
- Help Button: Quick access to contextual help documentation
Context Menu Implementation
Context menus provide additional functionality without cluttering the main interface:
- Tab Context Menu: Close, close others, pin/unpin tabs
- List Context Menu: Add, edit, delete, copy, paste operations
- Grid Context Menu: Column customization, sorting, filtering options
- Property Context Menu: Value editing, validation, and formatting tools
Section sources
Keyboard Shortcuts and Accessibility
Keyboard Navigation
The application supports comprehensive keyboard navigation for power users and accessibility requirements:
Global Shortcuts
- Ctrl+1-5: Navigate to specific tabs (Agents, Options, Macros, Skills, Debug)
- Ctrl+T: Open new tab or focus tab control
- Ctrl+W: Close current tab
- Ctrl+F: Focus search/filter functionality
- F1: Open help documentation
- Alt+F4: Close application
Tab-Specific Shortcuts
- Agents Tab: Ctrl+A (select all), Ctrl+C (copy), Ctrl+V (paste)
- Macros Tab: F5 (execute), Shift+F5 (stop), Ctrl+E (edit)
- Options Tab: Ctrl+S (save), Ctrl+R (reset), Ctrl+I (import)
- Skills Tab: Space (toggle lock), Enter (edit details)
Screen Reader Support
- ARIA Labels: Comprehensive accessibility labels for all interactive elements
- Focus Management: Logical tab order and focus trapping in dialogs
- Announcements: Live region updates for dynamic content changes
- High Contrast: Full high contrast theme support for visual impairments
Alternative Input Methods
- Voice Control: Compatible with Windows Speech Recognition
- Switch Control: Full switch device compatibility
- Eye Tracking: Point-and-click functionality for eye tracking devices
- Customizable Gestures: Mouse gesture support for advanced users
Section sources
Performance Considerations
Memory Management
- Lazy Loading: Tab content loads only when first accessed
- Resource Disposal: Proper cleanup of images, fonts, and unmanaged resources
- Garbage Collection: Optimized object pooling for frequently created objects
UI Responsiveness
- Background Processing: Long-running operations execute on background threads
- Progressive Rendering: UI updates incrementally for better perceived performance
- Virtual Scrolling: Efficient rendering of large datasets
Startup Optimization
- Assembly Loading: Deferred loading of optional assemblies
- Theme Initialization: Lightweight default theme with deferred heavy processing
- Configuration Caching: Cached configuration files to reduce disk I/O
Troubleshooting Guide
Common Issues and Solutions
Tab Not Responding
- Symptom: Tab appears frozen or unresponsive
- Solution: Check background thread exceptions, verify data source availability
- Prevention: Implement proper error handling and timeout mechanisms
Memory Leaks
- Symptom: Increasing memory usage over time
- Solution: Review event handler subscriptions, check for circular references
- Prevention: Use weak references for event handlers, implement proper disposal
Performance Degradation
- Symptom: Slow UI response or laggy scrolling
- Solution: Enable virtualization, optimize data binding expressions
- Prevention: Profile regularly, use appropriate collection types
Accessibility Issues
- Symptom: Screen reader not announcing content changes
- Solution: Verify live regions are properly configured, check ARIA labels
- Prevention: Test with multiple screen readers, follow WCAG guidelines
Debugging Tools
- Built-in Profiler: Memory and CPU usage monitoring
- Log Viewer: Centralized logging with filtering and export capabilities
- Network Inspector: Packet flow analysis and debugging
- Hot Reload: Development-time UI changes without restart
Section sources
Conclusion
The ClassicAssist.Avalonia main window and navigation system provides a comprehensive, accessible, and performant interface for managing Ultima Online gameplay assistance. The implementation demonstrates best practices in modern desktop application development, including proper MVVM architecture, responsive design principles, and comprehensive accessibility support.
Key strengths of the implementation include:
- Modular Architecture: Clean separation of concerns with well-defined interfaces
- Responsive Design: Seamless adaptation to different screen sizes and DPI settings
- Accessibility Compliance: Full support for assistive technologies and alternative input methods
- Performance Optimization: Efficient resource management and lazy loading strategies
- User Experience: Intuitive navigation patterns with multiple interaction methods
The navigation system successfully balances simplicity for casual users with advanced features for power users, making it suitable for the diverse user base of the Ultima Online community. The implementation serves as an excellent example of modern Avalonia UI development practices and can serve as a reference for similar desktop application projects.