This document outlines the strategy for reorganizing the RustPlus Desktop project to improve maintainability, scalability, and code clarity.
1. Current State Assessment
🏗 Architecture
- Paradigm: Hybrid MVVM. While a
MainViewModel exists, significant logic remains in MainWindow.xaml.cs and its partial classes.
- Monolith:
MainWindow.xaml.cs is over 5,000 lines long. Even with partial class splitting, it remains tightly coupled to the UI.
- Componentization: Logical sections (Devices, Map, Camera) are separated into files but still belong to the
MainWindow class, making them hard to test or reuse.
📂 Organization
- Root Directory: Overcrowded with mixed concerns (Models, Services, Windows, Scripts, and Assets).
- Inconsistency: Some converters are in a folder, others are nested in classes. Some models are in
Models/, others in the root.
2. Refactoring Progress
✅ Completed
- MainWindow Partial Splitting: Logic for
Overlay, Devices, Connection, Team, Map, and Camera has been moved to Views/MainWindow/.
- Initial Folder Structure:
Models/, Views/, Services/, and Converters/ folders exist.
- Service Extraction: Core logic for FCM listening (
PairingListenerRealProcess) and Rust+ communication (RustPlusClientReal) is in dedicated classes.
________ edit
⏳ Still Needs Refactoring
- MVVM Implementation: Move logic from
MainWindow.xaml.cs event handlers into MainViewModel commands.
- UserControls: Convert
MainWindow logical sections from partial classes into actual UserControl components (e.g., DevicesTabControl).
- Global Organization: 80% of files are still in the root directory.
- Dependency Injection: Use a service provider to manage service lifetimes instead of manual instantiation in the View.
- Asset Management: Centralize icons, images, and JSON data.
3. Proposed Folder Structure
A clean, industry-standard WPF structure:
RustPlusDesktop/
├── Assets/ # Static resources
│ ├── Icons/ # .ico and .png icons
│ ├── Images/ # Backgrounds, UI images
│ ├── Sounds/ # Alert sounds (.wav)
│ └── Data/ # JSON files (item lists, etc.)
├── Converters/ # XAML Value Converters
├── Models/ # Data entities (DTOs, Database models)
├── Services/ # Logic, API Clients, External integrations
│ ├── Interfaces/ # IService definitions
│ └── Implementations/ # Concrete service classes
├── ViewModels/ # Application state and Command logic
│ ├── Base/ # ViewModelBase, RelayCommand
│ └── Components/ # ViewModels for specific UserControls
├── Views/ # UI Components
│ ├── Windows/ # Actual Window objects
│ ├── Controls/ # Reusable UserControls (Devices, Map, etc.)
│ └── Styles/ # XAML ResourceDictionaries (Themes, Brushes)
├── Utils/ # Static helpers, extensions, global constants
└── Scripts/ # Python scripts and external tools
4. Step-by-Step Action Plan
✅ Completed Phase 1: Physical Reorganization
- Move Models: Relocate
SmartDevice.cs, ServerProfile.cs, TeamChatMessage.cs, etc., to /Models.
- Move Services: Relocate
SteamLoginService.cs, StorageService.cs, TrackingService.cs, etc., to /Services.
- Move Assets: Create
/Assets and move all images, icons, and sounds there. Update XAML URIs accordingly.
- Move ViewModels: Move
ViewModel.cs to /ViewModels/MainViewModel.cs.
Phase 2: Decoupling MainWindow
- Create UserControls: Create
DevicesView.xaml, MapView.xaml, etc., in /Views/Controls.
- Transfer Logic: Move the logic from
MainWindow.Devices.cs into the code-behind or ViewModel of the new DevicesView.
- Simplify MainWindow:
MainWindow.xaml should eventually just be a shell containing these controls.
Phase 3: Pure MVVM & DI
- RelayCommand: Implement a standard
RelayCommand to handle UI clicks in the ViewModel.
- Service Provider: Initialize services in
App.xaml.cs and pass them to ViewModels via constructor injection.
- Event Aggregator: Use a pub/sub pattern for communication between components (e.g., "Server Changed" event) instead of direct method calls.
5. Priorities
- ✅ Completed Cleanup Root: Move all non-View files to their respective folders.
- Extract Map Logic: The Map logic is the most complex; turning it into a standalone
UserControl will significantly clean up MainWindow.
- Update Namespace References: Fix all broken references after moving files.
This document outlines the strategy for reorganizing the RustPlus Desktop project to improve maintainability, scalability, and code clarity.
1. Current State Assessment
🏗 Architecture
MainViewModelexists, significant logic remains inMainWindow.xaml.csand its partial classes.MainWindow.xaml.csis over 5,000 lines long. Even with partial class splitting, it remains tightly coupled to the UI.MainWindowclass, making them hard to test or reuse.📂 Organization
Models/, others in the root.2. Refactoring Progress
✅ Completed
Overlay,Devices,Connection,Team,Map, andCamerahas been moved toViews/MainWindow/.Models/,Views/,Services/, andConverters/folders exist.PairingListenerRealProcess) and Rust+ communication (RustPlusClientReal) is in dedicated classes.________ edit
⏳ Still Needs Refactoring
MainWindow.xaml.csevent handlers intoMainViewModelcommands.MainWindowlogical sections from partial classes into actualUserControlcomponents (e.g.,DevicesTabControl).3. Proposed Folder Structure
A clean, industry-standard WPF structure:
4. Step-by-Step Action Plan
✅ Completed Phase 1: Physical Reorganization
SmartDevice.cs,ServerProfile.cs,TeamChatMessage.cs, etc., to/Models.SteamLoginService.cs,StorageService.cs,TrackingService.cs, etc., to/Services./Assetsand move all images, icons, and sounds there. Update XAML URIs accordingly.ViewModel.csto/ViewModels/MainViewModel.cs.Phase 2: Decoupling MainWindow
DevicesView.xaml,MapView.xaml, etc., in/Views/Controls.MainWindow.Devices.csinto the code-behind or ViewModel of the newDevicesView.MainWindow.xamlshould eventually just be a shell containing these controls.Phase 3: Pure MVVM & DI
RelayCommandto handle UI clicks in the ViewModel.App.xaml.csand pass them to ViewModels via constructor injection.5. Priorities
UserControlwill significantly clean upMainWindow.