BSA – Dialog Automation

Once we have a functional UML/ERD Tool it is vey easy to move on to HMI and automate creation of HMI as illustrated below. As you create large models it becomes a bit of work to maintain HMI associated with the model and this can easely be created and maintained automatically inside BSA. The result will be simple tables and edit dialogs, but those are still of great use as a starting point or in debugging.

BSA – Task/Error List

Usually then I work on standard languages I use GIT or GitHub etc where you have an issue list associated with GIT. I want the same integrated into BSA so that I can automatically populate the list with errors as well as add manual entries. Such a list is very easy to make using WPF and as it is integrated into the tool it can link directly to places in code and be updated with the project. Once printing is done I will add this because I am in a phase where I start using BSA myself. This will not stop you from using tools like Github and in a future version we might even integrate directly to Github, Gitlab etc – lets see.

BSA – Printing – Part 8

Just the color conversion + a few details left and I have achieved the first part to print diagrams. What you see below is the top of a preview. Color conversion is an issue because as we design on dark theam the colors might not be great for a white paper background. To deal with this I have decided to implement a conversion table of how to change colors rather than attempting some automatic scheme. I use selected colors in design and simply add their converted values in a table. In fact, that table is the light/dark conversion scheme. Some of you will recall that I started BSA on white theme and converted to dark – it is time to complete the process and to have a switchable dark/light theme.

BSA – Printing – Part 7

In this example I loaded an existing diagram and intend to print it using the “Print Page” tool. PrintPage allows me to draw a rectangle on screen of what I want out as a page. I used this on an earlier CASE tool and it proved to be very valuable. The process of printing an entire diagram is the same.

The obvious next step is to cut out the selected area as a printable object. The procss is illustrated using 3D Paint below.

The last step is to position this on an actual page. Below you see what you can expect from a raw page – it is to wide for the A4 page (yellow) and positioned top left with no margins. Not the print we want and we now need to scale the print object, position it within the margins. To do this we compute print size and subtract margins as we scale.

The final page should by default look somethings like this assuming we selected A4 Horizontal (just an example) – Ignore the black background that will not be precent on the actual print.

It is a few more details to it, but the main concept is that (1) we need an automated way to print a page and control the content of that page if we are not happy with the entire diagram. This is what the “PrintPage” tool was created for. I will need to change the name “PrintPage” to soimething else, but you get the picture.

BSA – Printing – Zooming in WPF

I use a Canvas as background for the diagrams and as I print I just provide a different Canvas using the same functions to draw on screen and paper. To zoom per page I just do the following – an example to zoom to 50%. The second part is to just draw the symbols using 100% position and size – the few lines below takes care of zooming.

Page page = new Page();
ScaleTransform scale = new ScaleTransform();
scale.ScaleX = 0.5;
scale.ScaleY = 0.5;
page.RenderTransform = scale;

It is a bit of manual work to use a XpsDocument and provide a print system and this might not be the only way, but all in all it is not a big job. What remains now is to calculate the size of the diagram versus size of paper and compute a zoom factor. After that I need to support margins and vertical/horizontal print pages as well as correct offsets so diagrams always start in the upper, let corner.

Next is to do the same for PDF and Web pages, but I suspect that I can reuse the XpsDocument for that. I also have yet to add the documents as I currently only print diagrams as is.

BSA – Printing – Part 6

This shows 3 diagrams with circles being printed. I have only modified the Ellipse symbol to support printing so far and it works well with a few comments. (1) Colors on the symbol need a white paper version. (2) printing is 1:1 in size, I need to zoom and I have a path, but I want to investigate options. But, all in all – I am almost there. I expect to have a working first version today for paper printing. What you see in backgrund is page 3 displayed at bottom.

I am not so keen on the build-in Preview controls, but changing that is way down on my list – they work.

BSA – Printing – Part 4

WPF have a very simple way of printing what they call a “Visual”, basically it print what you see on the screen, so to use this you need a UserControl. I loadet the diagram below and tested the PrintVisual statement.

I have a Brother DCP-9015 color laser that also has it’s own preview system and the result from “PrintVisual” on a diagram can be seen below. Basically it prints the screen as is and just drops the parts I did not request. I probably can  change that a bit and adjust background as well as scale it – not sure. But, I was happy to find that I hade a preview in the printer system to avoid too much paper usage as I test.

The more interesting function is “PrintDocument” that can print either a FixedDocument or a FlowDocument – actual tutorials and documentation on printing is a bit thin, so I will need to experiment a bit to learn the API. I want to start with paper printing because I like to make class diagrams and put them on the wall in front of me as I work. PrintVisual might just do the work if I can create copies in the background (not visual) and print them – we will see. The result is not exactly there yet, but this was a single line of code.

BSA – Printing – Part 3

Documentation is a vital part of any project since we need to make presentations of our work on regular bases. Managers/Users who pay for your time will like to be kept informed and have a saying in what you do and this takes time, so lets attempt to automate it. Most engineers would love to just press a single button and have reporting/documentation done automatically. To do this we need to consider a few requirements for printing.

  • Some developers will like to maintain documents/presentations manually, so to support those we need a capability to export diagrams and texts using standard copy & paste. They can then add these into their own documents through a clipboard.
  • As I present diagrams I often go through PowerPoint and add some annotated content. We can do that in BSA directly and this will not require extra work due to the next point.
  • Some users (like myself) would like to press a button and be done with doc/presentations by creating a PDF, print a doc or create web pages. And this is possible. Keep in mind that BSA already contain a very powerfully graphical editor that can act as a WYSIWYG page preview. The only thing we lack is (1) a capability to print a single diagram controlled, (2) a capability to include other diagrams within selected frames and the same with text. We can easily allow the user to create a document template that is populated as we generate/print the document – and most of the hard work is done already due to the graphics engine.

Displaying text is the easy one – we just extend our current text tool to display selected text from the repository on a diagram.

Displaying a sub-diagram should be more or less the same – we use a rectangle as base.

Setting page restrictions can be a variant of the existing Print Page tool.

Actually printing a diagram controlled will be some work – not sure as I will need to experiment a bit.

Adding a document template in Dictionary is straight forward.

As this will be a bit of work I like to leave the idea a bit while I consider alternatives and dig more into the details of printing. We also have the issue of including print support in user applications – which earlier was planned as a HMI Form.

Thanks for reading my Sunday ranting 🙂

BSA – Printing – Part 2

It is quite easy to use a tree compont to add content and BSA itself to edit that content as a WYSIWYG document to create tailored reports that is automated according to a document specification. Later I generate an XPS document and print it – skip the Preview and use BSA Canvas directly. This is very similar to work I have done in the past where the user create a template of the doc that later is populated with requested content. I need to give this some thoughts…

A second concern is how we can add tools so we can add print/preview support to user applications as well.