Hello there reader,
now that I want to work on SimpleSteer again I’d like to plan a bit more ahead instead of just doing it live. As I try to do this I encountered an issue I had before: I could really use some tool to write documents that are clearly structured in a hierarchical order. I think an application for editing and viewing hierarchical documents could come in handy in a number of situations where you want to compose some sort of feature list. Add to that the ability to elaborate on each feature and detail it with charts, diagrams, tables etc.
I think such an app would be great and since I’m trying to get better with WPF it would be nice practice. So that is what I will try to make. So here is the plan:
- edit and view hierarchical composit documents (HCD)
- HCD is a list of items that are arranged in a hierarchical order
- each item can contain multiple item components such as texts, diagrams/charts, tables, images…
- the application supports adding, removing, and arranging items
- adding and removing item components
- editing the components inside the application
- switching to a viewer mode for presentation of the document
- searching the document and the components
The planned layout of the application:
- sidebar with a tree-view of the hierarchical document
- a larger area containing pages (tabs) with the editors for the various components
- menu bar on top with buttons for saving, loading, starting new document, and searching
- status bar on bottom for status text output and slider for zooming in/out
WPF supports a separation of UI appearance and control code. The layout of each window or user control is written in the declarative XAML while the code for the behaviour of the interface like buttons and sliders is written in the imperative C#(or any other language that can be compiled into CIL code). They are kept in 2 separate files but are actually parts of the same class since C#(or rather .Net) allows such partial classes.
But to make things even easier I will try to use a Model-View-Presenter pattern. Here the View is made up by the user interface classes. I will certainly have a main window, which is made up by the MainWindow.xaml and MainWindow.xaml.cs code that together form the MainWindow class. So MainWindow will be one of the views, but instead of implementing the code for things like saving the document here, the views will get their presenters. The presenter is a class that will be instanced at some point when the view is created and will be connected to the view by dependency injections which basically means that when created they will get a reference to each other. The presenter will take care of all the application logic, it will initiate saving, loading and searches. Finally there is the document manager, the model part that handles the data, this is where the serialization is implemented for example.
So here is an example:
- user clicks the close application button
- the view (main window) tells its presenter that the close button was clicked, in other word requests application shutdown
- the presenter checks if shutdown is ok, that is if there are any unsaved changes in the document
- let’s say there are so it signals back to the user through a dialogue window and asks if it should quit or save
- the user choses to save as a new document
- the request for save as new goes to the presenter which handles the savefile dialogue and in the end tells document manager to serialize the data
The point is to build a system where all parts of the program are only connected to the parts they actually need to communicate with, the responsibilities are clearly separated, and the individual parts don’t have to know about how their requests are handled. This way implementation of a specific procedure can be changed without changing or messing up the whole program as long as each part keeps the “interface” through which the other parts communicate with it. Even if that should not be the case and bigger changes are needed, it will be easier to handlethem without breaking the system.
I’m still just planning how I want to do it and due to my lack of experience it won’t be easy but I have already written down some class ideas in kind of a Class Responsibility Collaboration style, so I’ll post some updates soon.