News combit Dev Blog

Two Ways to Reuse Existing Objects In New Projects

Posted: Wednesday, March 4, 2015 | 0 comment(s)
 
The idea for this post was triggered by a comment by MikeH on the last blog post. He requested the feature to have a kind of meta object containing different other objects in a pre-specified manner in order to speed things up for endusers. There are already a couple of features that cover at least similar use cases and I thought I'd highlight them.

1. Project Includes

Project Includes offer a way to include one project into another. A typical use case would be a corporate letterhead where everything is pre-configured from the logo and the addressee to the footer containing your bank account etc. Whenever you change the template, all projects referencing this template are also changed automatically on-the-fly. Great if your corporate design is quite volatile and a great time saver if you have to design an offer template, an invoice template, a letter template and so on and all should look the same.
Usage is straight forward. Just head to Project > Includes, click the "Insert include" button and choose your template. You'll end up with this:



In the Designer, the objects from the included project are displayed as "locked" in the "Objects" tool window (BTW: the context menu offers a handy shortcut to editing the template). Apart from that, the objects behave like "normal" objects and can now be used across multiple projects:




2. User Defined Actions and Object Model Manipulations

An even more sophisticated method is the addition of a custom action combined with a manipulation of the report's object model. NB: you need at least the professional edition to be able to change the object model in this way.
The List & Label component has a property "DesignerActions" which can be used to extend the Designer's functionality. This way, you can add a new action to insert the letterhead into arbitrary objects:



This gives you this new button on the "Project" tab:



The code to execute is written as event handler for the "ExecuteAction" event of the DesignerAction. Writing complex object model code can be a tough task at times – the automatic DOM code generation helps a lot here. You find this little gem hidden as "C# Dynamic Generated List & Label DOM Code" sample. What it does is to take an arbitrary List & Label project, analyze its object model and return the code required to generate exactly this project. So if your plan is to add the ACME logo, you open the corporate letterhead in this sample, select the logo and click the "Generate Code" button. The result is this:
 



From the right hand side you can now easily copy the code that generated your ACME Corp. logo into the event handler. Note – this is automatically generated code which is seldomly very beautiful to look at but very effective as it spares you the time to write it manually ;-).



The "real" handler also has the code to draw the logo circle – once you followed up to here it's easy to imagine how to extend this further. The result of course is now an easy way to add the letterhead or even just the logo to any project:






Author: Jochen Bartlau
Head of Development List & Label

Jochen Bartlau leads the development at combit as Managing Director. He's a Microsoft .NET enthusiast driving innovation & agile project management. The mobile devices geek who used to be a physicist in his first life loves to spend his spare time with his family.


  

RSS
combit Development BlogRSS
What’s this blog for?
A place to share updates about the ongoing development of our products. General musings on the software industry included.
Archive
April 2021 (1)
March 2021 (1)
February 2021 (2)
January 2021 (1)
December 2020 (2)
November 2020 (1)
October 2020 (2)
September 2020 (1)
August 2020 (2)
July 2020 (1)
June 2020 (1)
May 2020 (2)
April 2020 (2)
March 2020 (2)
February 2020 (1)
January 2020 (1)
December 2019 (1)
November 2019 (2)
October 2019 (2)
September 2019 (2)
August 2019 (2)
July 2019 (2)
June 2019 (2)
May 2019 (1)
April 2019 (0)
April 2019 (1)
March 2019 (1)
February 2019 (1)
January 2019 (1)
December 2018 (1)
November 2018 (2)
October 2018 (4)
September 2018 (4)
August 2018 (2)
July 2018 (2)
June 2018 (2)
May 2018 (1)
April 2018 (1)
March 2018 (1)
February 2018 (2)
January 2018 (1)
December 2017 (1)
November 2017 (2)
October 2017 (3)
September 2017 (3)
August 2017 (2)
July 2017 (2)
June 2017 (1)
May 2017 (2)
April 2017 (1)
March 2017 (1)
February 2017 (1)
January 2017 (2)
December 2016 (1)
November 2016 (1)
October 2016 (4)
September 2016 (5)
August 2016 (2)
July 2016 (2)
June 2016 (3)
May 2016 (2)
April 2016 (3)
March 2016 (3)
February 2016 (1)
January 2016 (2)
December 2015 (2)
November 2015 (1)
October 2015 (4)
September 2015 (5)
August 2015 (2)
July 2015 (2)
June 2015 (2)
May 2015 (1)
April 2015 (2)
March 2015 (1)
February 2015 (1)
January 2015 (1)
December 2014 (2)
November 2014 (1)
October 2014 (1)
September 2014 (2)
August 2014 (1)
July 2014 (2)
June 2014 (1)
May 2014 (2)
April 2014 (1)
March 2014 (2)
+1 800 256 3608 (toll-free North America only)