Steps for change the UI of desktop app from winforms to wpf - wpf

I built a small desktop app on c# .net
Local desktop without any internet connection or communication with other any computers, I used winforms.
As expected I split up between logic and UI, and now I want to use WPF to my UI (change the way I implement the UI part), and in the future I will want to use mobile UI..
What are my steps should be?
Do I need to write new code, or there is something automatic?

Related

Winform desktop app and touch

I`ve a legacy winform desktop app that works perfectly with mouse and keyboard. It has some selfmade controls that involve the creation of threads and so on, for example the longer a button is pushed the faster a number is incremented.
The application also uses a win32 dll. Now, the client wants that application to be touch enabled and run it in a tablet, which also means resizing and rotation capabilities.
My question is, which is the better way to get that application touch enabled and responsive design?
I can try to modify the existing winform, but I think it will be lot of work with poor results. I can also migrate to WPF and reuse the c# code, but I might have trouble with the keyboard, as I have not found a good way to show the keyboard and maintain the whole app on the screen. Or I can migrate to windows store app, but with the problem of that win32 dll, that I`m not sure it could be migrated.
The winform application is multilingual so creating a keyboard is not a valid option.
If the target is touch screen, then for sure the best option would be a Windows Store App, although there are several limitations.
If you are not going to publish this application in Windows Store, then you should be able to use all WinAPI functions. (I'm not sure what is win32.dll - if it's your own dll then it can be a problem).

User focus in multitouch environment

I am trying to create a multitouch application.
I have the hardware which will allow me to do this. On the software side I want to be able to have WPF textboxes, WPF web browsers, multiple focuses, multiple keyboards and multiple users at the same time.
From what I've seen, I can't be focused on two controls at the same time.
What is the Microsoft MultiTouch approach for this kind of job ?
The OS limitations are what they are (and don't appear to change in Win8): only one hWnd at a time can have focus.
Since you are using WPF though, everything within your application (with the exception of the WebBrowser control ActiveX widgets you may be using) is rendered within one big hWnd.
WPF 4 introduced native support for multitouch, including multi-touch capture. The APIs for this are many but pretty intuitive so I'll just say this... go to http://msdn.microsoft.com/en-us/library/ms590078.aspx and search within the page for all of the members with "Touch" in their name.
The catch however is that the controls shipping with WPF 4 don't work with the touch input events... you'll only be able to interact with one of those controls at a time. To take advantage of the multi-touch capture APIs, you'll have to create controls that are designed with it in mind. Fortunately, the Surface team at Microsoft has you covered on that... the "Surface 2.0 SDK" includes a suite of controls (usable on any Win7 machine, not just for Surface) that were built with this stuff in mind.
To create application with MultiTouch UI, use MultiTouch Framework in .Net
Go to http://multitouchvista.codeplex.com/

Host a Silverlight application in Winforms application

I have a need to host a Silverlight application as a module in an existing WinForms application. My plan is to host the web page that hosts the Silverlight app in a web browser control in the WinForms application.
The part I have not been able to figure out is how to communicate from the Silverlight application back to the Winforms application. For starters, the Silverlight application needs to inform the web page that it is closing and have the browser control inform the WinForms module that the application has terminated. Once that is working I need to be able to send several different events to the WinForms program.
This does not seems like it should be hard to do, but I am hoping that someone can save me a lot of experimenting and keep me from wasting time following the wrong path.
My environment is Silverlight 4. The Winforms application also currently is hosting some WPF controls.
kind of a backwards approach.
Silverlight is a workaround to make WPF available on other platforms.
If you are running winforms, just host it as WPF window. It is really easy.
MyWindow window = new MyWindow(); // WPF widnow
ElementHost.EnableModelessKeyboardInterop(window) // this is part of windforms integration namespace, allows winforms and wpf to communicate
window.Show();

Is there something like a QueryUnload event in WPF page-based apps?

I'm working on my first WPF app, using VS 2008. When I worked in VB6, there was a form event called QueryUnload, which one could use to determine how an application was shutting down. I'd like to do the same thing in a page-based WPF application, if that's possible. (My app is not an XBAP application, but a page-based app.) I know that VB6 didn't have anything like a page-based application, so it might not be possible.
You do it in your handler for Window.Closing, see here

Silverlight 4 Trusted Application - Can I drag widgets outside the window?

I have a feeling this really isn't possible, but (for example) would it be possible to implement a trusted Silverlight 4 filesystem browser that allows me to drag files from within the Silverlight application to another application on my desktop?
For Windows... technically, maybe being able to run your own app when a drag is going outside the area of the app. But super complex and challenging.
You would need a few things:
Elevated SL4 OOB app
A COM component on the system, or a native code app embedded in the app that you can execute with parameters about a drag operation, look into isolated storage, etc.
You monitor when a drag starts, and then would need to execute your native code app somehow to realize the drag. Even then, I don't think the new app could pick up on the true drag operation.

Resources