How yoshi-782/swab2 works
Main Components
• User Interface (UI) Layer:
• MainWindow.xaml and its code-behind (MainWindow.xaml.cs) represent the primary WPF window.
• App.xaml & App.xaml.cs: Application entry point and global resources.
• Configuration & Resources:
• App.config: Holds application configuration settings.
• Resources directory: Contains HTML templates (Template.html, index.html, setting.html) for generating and loading pages.
• Business Logic & Functionality:
• File operations: Logic to create new templates, open existing HTML files and reload them.
• WebServer.cs: Likely acts as an internal server or a controller for managing HTML file serving and integrations.
• Callee.cs & Setting.cs & Swab2.csproj: Contain the core business logic, including the interoperability aspects (JavaScript invoking C# functions).
• External Tools & Integration:
• Integration with Chrome’s CefSharp (as indicated by the README): for rendering the HTML content within the application.
• Developer tools: Functionality to show the browser development tools.
Relationships and Interactions
• The UI layer (MainWindow) drives user interactions such as file operations (new, open, reload, exit).
• When a user opens or creates a file:
• The application loads the respective HTML template from the Resources directory.
• These HTML files are displayed using the embedded browser (CefSharp).
• JavaScript within these HTML files can invoke C# functions (handled in Callee.cs), establishing a bidirectional communication between the front-end content and the back-end application logic.
• WebServer.cs might manage the communication or local hosting aspects for dynamically loaded content.
Architectural Patterns & Design Principles
• Separation of Concerns: The UI, the business logic (file and event handling), and resource management are clearly separated.
• Inter-component communication is achieved via explicit function calls (e.g., from JavaScript to C# via the Callee class), demonstrating an integration pattern typical for hybrid applications.
• The design relies on both WPF and embedded browser technologies (CefSharp) to deliver rich, dynamic content while leveraging the robustness of a desktop .NET application.
Relevant Technologies & Frameworks
• C#, WPF for the UI layer.
• .NET Framework 4.7.2 for the overall application runtime.
• CefSharp to embed a Chrome-like browser into the application.
• Visual Studio 2019 as the development environment, with files like .sln and .csproj managing the project structure.
• Each main component should be clearly labeled (UI layer, Configuration/Resources, Business Logic, External Services like CefSharp).
• From the user’s input in the MainWindow, to invoking actions in the business logic.
• From the business logic to loading resources (HTML templates) and dispatching them to the embedded web view.
• From JavaScript running in the web view back to the C# functions in Callee.cs.
• Backend processing components (another style),
• Annotations that mention configuration files (App.config) and explain the role of each core file/directory (like the Resources folder for templates).