Here's the situation:
We have an existing .NET executable that contains an application using WPF components (dialogs and forms). This executable was created using Gupta Team Developer 6.1, but I'm not sure that is relevant to my question. We'd like to re-use some of these forms in a C#-application, but this is proving difficult.
When we include the external components, either in XAML or by instantiating them in code, they look OK (i.e. fields, buttons, layout etc.), but the event wiring seems to be missing. Nothing happens when pressing buttons and tables/grids are empty.
I've read previous articles on this site on using external WPF components, but they all mention external assemblies compiled as control libraries. Are we trying to do something that's not really possible?
P.S As an experiment we've tried to instantiate the App-object from the executable directly and this brings up a fully functional version of the entire application (well, duh), but we'd really like to be able to pick and choose from the individual forms/dialogs.
Related
I would like to be able to do the following and am not sure if it is possible...
I would like to have a WASM Blazor application that can have components added after the application is compiled and running. For example, if I created a simple application that displays photos and give the user the ability to change the style by choosing a different component. Please ignore the fact that there may be better ways to "style", this is a simple example to illustrate my goal. Maybe these "style" components are listed and available for download but are NOT preloaded. I would like the user to be able to choose a different style and then, and only then, download the dll for the component from a remote repository and load that component into the running application so that it is available to render. I have looked into DynamicComponent and that shows some promise. But it seems as though most of the information I can find about this has the need to declare those types up front before compilation.
Does anyone know if what I am attempting is possible? Am I on the right track? Thanks!
You can hold off on loading assemblies until they are required using Lazy Loading, give this a read:
https://learn.microsoft.com/en-us/aspnet/core/blazor/webassembly-lazy-load-assemblies?view=aspnetcore-6.0
I've started using FlaUI for Automating my thick client .net application. The application is Windows Form based. The start was good and Login Form was identified and I could Login, but after that came the dead end and I found that almost everything in the application is developed as Pane control type.
So, there is grid, table etc. but they all just appear as Pane type when I see the object hierarchy using Inspect.exe or FLAUInspect tools. And nothing really appears in thier property, so it seems that nothing could be read. But before giving up I just wanted to check with experienced audience on this forum if there is really any way to get the data from Pane objects.
Please suggest if there is any way, even that means using other libraries like UIAutomation, TestStack.White, etc.
UPDATE: I now understand little more about this. So, the objects that are there in the pane are developed in syncfusion and devexpress. Is it possible to identify objects developed in syncfusion and devexpress using FlaUI or UIAutomation or TestStack.White, etc ?
I don't know if you have already tried the following steps. Have you add automationId's to your objects in xaml code with:
AutomationProperties.AutomationId="AnyID"
In the testcode, first initialize the main window of the application.
MainWindow = fApplication.GetMainWindow(fAutomation, null)?.AsWindow()
After that you can find your objects by the automationId's, like:
MainWindow .FindFirstDescendant(cf => cf.ByAutomationId(AnyID))
I did it this way, and don't have to know the hierarchy of my application. Maybe this will work?
Most UI Frameworks nowadays fully support UI Automation. So first make sure that you have a recent version of your framework (syncfusion, devexpress). In addition, some frameworks provide settings to enable UI Automation. Like for devexpress, you need to set
ClearAutomationEventsHelper.IsEnabled = false;
at the start of your application to test so it exposes way more things (like tabs) to FlaUI.
I am currently working on an enterprise WPF application and I am experiencing some issues with static resources: globally defined styles and converters.
The application works this way:
There is a shared host WPF application that is used as host for components developed by different teams (it's a PRISM application and MEF is used for importing plugins)
Each team can add plugins by creating new dlls, but cannot modify other teams' dlls
No changes can be made to the host application
My team is in charge of few plugins and we need to add more functionalities but we are wondering what is the best way to solve our problem.
In a simple (standard?) WPF application, we would have styles defined in the App.xaml file and all the xaml UserControls or Windows would be able to link to them at design time easily and of course at runtime.
But now, while I managed to get the styles to work during runtime, I cannot have them working at design time and it is causing two major issues:
I cannot see how things would look like in the IDE
When I reference a converter the IDE complains but I have no way to know how wether it will work at runtime or not.
How do I get StaticResources to be imported and, at the same time, work in my IDE?
If not possible, what other strategies can I adopt to overcome these issues?
If I understand you correctly you want to use your "Design" tab in Visual Studio to see style changes and check the look and feel of your WPF application.
If that is the case, I will disappoint you but I haven't met any WPF developer yet using the 'Design' instead of 'XAML' view to make changes etc. in more advanced applications. Unfortunately the "Design" view has many flaws, doesn't display the Views properly, has problem with static resources converter and what is more it is always resource hungry.
The way we are working with WPF applications is building them and inspecting the problems and changes using a Snoop utility to investigate the application, binding errors, style problems, etc. I have never seen a way to use the build in "Design" view without many flaws, hacks and performance issues.
What is more, you should write a fake host application so that you will be able to run your plugins without the need of running the main app (if that is a problem for you)
I have a WPF executable and I wish to make provisions to it, so that later,
someone from outside might modify or add another window or page
using dll totally separate from my solution.
For short, I wish to make my wpf windows or pages pluggable. How do I do this?
Prism's support modular, on-demand-loading of modules and other parts of your application, in it's core.
you can use MEF framework to make pluggable modules (windows and pages), as it's fully integrated with Prism.
You can find examples and more information in the following resources:
http://www.codeproject.com/Articles/188054/An-Introduction-to-Managed-Extensibility-Framework
http://www.codeproject.com/Articles/37579/Managed-Extensibility-Framework-Part-2
http://www.codeproject.com/Articles/432069/Simple-MEF-Application-for-Beginners
http://www.codeproject.com/Articles/232868/MEF-Features-with-Examples
iI there any way to add a GUI component to an application which is already running?
I.E. Add an extra tab into a third party GUI?
I have a third party application where I need to add an extra tab into the tabbed interface (or even a button to link to a new form).
I can see the UI components in UISpy and Spy++ but Can't see a way to alter or add them...
Any ideas? Maybe altering the memory?
Update:
The application I have created to wrap around the third party app is .NET but the third party app is written in VB6
I suppose it's entirely possible with reflection, with the aid of Reflector, assuming it's not been obfuscated. Explore around the reflected source until you find the class of the form, and the instance of the form that you want to modify, then you can invoke the Controls.Add method, or anything else you need to, with reflection. But unless you know exactly what you're doing, you could run into some unexpected behavior from the application.
You can use ResHacker.
http://www.angusj.com/resourcehacker/
Basically, each GUI form is saved as a resource inside of a particular Windows executable. ResHacker has a built-in GUI editor for editing "Dialogs" (as they are referred to in ResHacker).
I assume it's a .NET WinForm app. If you do not have the source files and the app isn't too big, you can try 'decompiling' it and add in your code to become a new app.
I'm a great fan of Lutz Roeder's Reflector which generate code from the CLR codebase.
Here's a link to his tools. http://www.lutzroeder.com/dotnet/
Update:
darkassassin93 is right, hopefully the app is not obfuscated :)
You should have strong reason for doing that.
I think you can start with Add Tab using pure WinAPI and TabCtrl_InsertItem Macro
If you have HWND of TabControl you can try to add your own tab. with TabCtrl_InsertItem. Although i don't think it's possible to do that from another process. But you should try.