lkeness
Topic Author
Posts: 1
Joined: 08 Apr 2024, 13:22

Consolidating multiple C++ projects into a single executable

02 May 2024, 19:40

Hello,

I am managing multiple standalone C++ projects, each with its own Application, ApplicationLauncher, and Window class. Currently, each project compiles into a separate executable with a MainWindow.xaml where the main element is <Window ...>.

I aim to consolidate these into a single executable by converting each MainWindow.xaml from a Window to a UserControl. These UserControls will be imported into a single MainWindow.xaml, supported by one Application, ApplicationLauncher, and Window class to manage UserControls visibility and screen changes.

I am seeking advice on two points:

How should I manage and load resource providers (e.g., TextureProvider, XamlProvider, FontProvider) in this new structure, considering each project has its own resources and there are shared
resources?

What are the recommended methods for organizing and loading both project-specific and shared resources efficiently in the unified UserControl framework?

Any guidance or resources you can provide on this process would be greatly appreciated,

Thank you.
 
User avatar
jsantos
Site Admin
Posts: 3939
Joined: 20 Jan 2012, 17:18
Contact:

Re: Consolidating multiple C++ projects into a single executable

03 May 2024, 14:28

The easiest way, if there are non conflicting resource keys, is putting everything in the same global resource dictionary (maybe splitting into several XAMLs that are merged together) and using a single set of providers.

Providers can also be installed per assembly or scheme:
void SetXamlProvider(XamlProvider* provider);
void SetAssemblyXamlProvider(const char* assembly, XamlProvider* provider);
void SetSchemeXamlProvider(const char* scheme, XamlProvider* provider);

You could have one provider for each sub-project, and load resources using full pack uris:
<Image Source="/ProjectA;component/Images/Info.png" />
But probably you don't need this extra complexity.

Or, you could merge the resources into each UserControl. Note that if the UserControl is instantiated several times, merged resources will too. So probably, having everything in the global dictionary is the best idea.

Who is online

Users browsing this forum: AnKor, jsantos and 2 guests