integrate C# UI (WPF) with flow chart - c#

Recently, I try to develop an UI by WPF.
As a requirement, I have to put some flowcharts on the form.
And I've already tried my best to find some open resource for my project.
for example:
http://www.codeproject.com/Articles/22952/WPF-Diagram-Designer-Part
However, I have no idea how to integrate third party resource into my WPF project in VS2013 from very beginning at all.
(I know this sounds stupid...I'm totally new to this kind of development.)
My expectation is : to include whole third party resource into my project, so that I can drag some utility of them, double click on it and write some code
- just like how we usually do to default utility provided by VS2013 (say:button, textbox,treeview...etc.)
I hope there would be someone who can teach me how to do this, thank you.

Related

Unable to set start page (to windows form) in MFC application

At a broader level, I'm converting a MFC application (MFC 6.0) into Windows Forms application (Visual Studio 2013). I read certain blogs that describes that this conversion is possible. By this conversion I can re-use code written in MFC, only I will need to create UI. However I will need to understand the previous code and may need to re-write it a bit.
I got the motivation from here and here.
I have performed following steps so far.
Opened Visual C++ 6.0 project in Visual Studio 2013.
Build it successfully.
Then added CLR support to it, and fixed errors.
Added a Windows form, and added controls to it. As mentioned here.
Added functionality and build it successfully.
Now when I run this application, then it still point to old MFC window.
I'm missing certain settings which will change the rendering window from MFC to WindowsForm. What am I missing here?
Addition to that, I see problem with this approach as described by #Roger in comments, and I understand that. So, I wanted to know for any tool/utility which may convert legacy code into C#. Does such utility available?
TIA.
The code you are referring to seems suitable for amending a MFC application with a few forms as child windows to make use of .NET features. However, the main window is another story. You wrote the application is huge, so I suppose you don't want a simple form as your main window and rather have some kind of MDI interface in mind. If you replace the CMainFrame in the legacy MFC application, it just doesn't make sense to maintain an old CWinApp class. Anyway, if you are hell-bent on going down that path, you may want to have a look at an old CodeProject articel (.NET1.x, .NET2.x) to get a better grasp at the whole concept.
But as Roger already suggested, it would be a wise choice to find a nice GUI framework, perhaps even WPF instead of WindowsForms, and do a GUI rewrite -- especially if one part of the motivation for the conversion is to move to newer UI concepts. If your C++ program logic is well separated in your MFC project, put it in a COM server and make use of interoperability.

VS2013 CodedUITest on Java client

I'm trying to use Coded UI Test (Visual C#) to test a Java client application and I am quite new to this.
Currently I have built enough to enter the set client which is built in Java. My problem is that it seems that I cannot use the UIMap Coded UI Test Builder to select any buttons within the application. When using the Assertions it selects the entire window instead of single buttons within the GUI.
I would rather code to reach my solution than using the UIMap recorder but unfortunately I cannot seem to find what I'm looking for.
I have searched long and far for a way to do this, and cannot find anything relevant, so please help!
You can use tools like Sikuli...open source image recongition or EggPlant (not free).
We actually integrated sikuli in VS there is a library called SikuliIntegrator (SikuliModule.dll)
Or try anther tool like QTP or other open source to see if they can capture the controls better.
If the Java application you are testing is built by you or your team, you may ask them to change the architecture such that CodedUI could grab the controls...

How to apply Windows Forms Control to WPF Custom Control Library?

I'm trying to encapsulate Windows Forms Control (from previous version of project) to WPF Custom Control Library. Because I want to use it in future Wpf applications (like drag&drop from toolbox in VS). I successfully done this: WinForms in Wpf App. Do you know site/or tutorials where this things are explained?
What I got: .dll with WinForms control, Wpf Custom Control Library project (to place WinForms control) and Wpf Aplication.
Thanks for your help and suggestions.
What SonerGönül is refering to, is that if you read the links he points out.
You can see you should have done this steps better:
Do your homework
There is plenty of examples all over on how to achieve what you want to do.
Search on Google something like "how to host winforms in wpf"
You will get plenty of links like:
http://msdn.microsoft.com/en-us/library/ms751761.aspx
Even questions done in this site in the past.
Be specific, Make it relevant to others
You need to make a more clear question. Read your question as if someone else is the person who wrote it, and think if you would be able to understand it properly.
People in this site wants to see you have worked towards solving your problem, therefore you can mention things you already have done, and make a specific question.
Like "I implemented what this website suggest but I am getting this exception"
To answer your question
I really like this website: Mixing WPF and WinForms
Because it gives you a nice both side explanation of how Mixing WPF and Winforms works, with examples.

Workflow with C# in Visual Studio

I normally code with PHP, I am used to opening up my editor of choice and going away at it, coding classes,methods, etc. It is fairly easy as there is no GUI to worry about.
Last night I spent the whole night following a couple tutorials with C# in Visual Studio, it's turning out to be harder then I thought it would be. Once thing that I am not use to is, all the tutorials have you add a form object like a text box or button, then have you double clikc it to get to the code part, you then enter some code for that method. Then back to the form and re-peat
This seems very hard as you are never really working on "just the code" so 1 question is, is it always like that or just because i'm new and following tutorials?
Another question, when I see source code online to do certain functions, say I see a class I would like to try using, how can I use that class in the existing form class created by VS, do you somehow import other classes or do you add them right to the form code you are working on?
I'm sure that didn't make much sense but hopefully it does to someone, i'll try wording it better if not.
I should add that this was with WPF, also I feel like you have to learn 2 languages, the C# which has very similar syntax to PHP so that doesn't seem too difficult and the for GUI that's like a whole diff language
You can download the classes you are interested into.
Then you go to the Solution Explorer panel and you add existing items.
This will COPY the files to your project.
In order to use those classes you need to declare that you wan to use them.
So, what you have to do is to say something like
using FooNamespace;
Then you are ready to use the classes.
The name space is declared right before any class. You can go edit it.
Now about the forms. Each form is a Class and it consists of three files
ClassForm.cs
ClassForm.designer.cs
ClassForm.resx
You ONLY need the first one. Right click and view code. You can go there and use it.
Many questions, Many answers
Difficulty and Repetition
you can add form objects via the designer or you can hit the source button (CTRL-PgDn). From there you can edit elements in asp and html just like any php IDE. I do most of the work in source. I am a real programmer so I can never do the drag and drop. With intelligence and time you learn the properties and what to do.
to make complex pages you just have to know what you are doing.
What I started with VS I had the same feelings as you, but i have gotten into the flow of it.
As far as the code behind, you are just hooking methods up to the asp elements that get called by the built in code. You can add your own classes, functions, everything in the code behind or in separate files, just like c++, php, whatever.
Hope that helps, VS is really powerful and runs smooth when you learn where things are, been using it for years now and I'm still learning. Bottom line, never use drag and drop and just play with it.
unfortunately the .net world love drag-drop controls. so most tutorials are designed around this concept. drag a textbox on the to form. drag a button onto the form. double click button image to get the click handler.
it's not needed, it's just the approach for most people using visual studio. being that this is a WPF project everything can be done from code, or xaml markup. you don't need the WYSIWYG editor.
as for adding/referencing classes first you need to reference the assembly the class is located in. your core .net types (part of the BCL, base class library) are automatically included as references. then you add a using statement to the appropriate namespace. then you can instantiate the object.
There are ways to have a C# interactive window; see this question. Alternatively, you don't need to use a form, but you could also create a command-line application.
As for the second question, you can add a new class to your project and then use it in your form. There's really no additional step, except that if the namespaces are different, then it is easier if you import that namespace (via using).
Partly, yes, because you're new and using tutorials.
Partly, no, because you're working with forms, and you really don't want to hand-code those by hand.
If you just want to play with C#, and not concern yourself with forms and display, look for information on Console application. Instead of worrying about buttons and textboxes, your worst nightmare will be Console.WriteLine();
Here are some console-based C# tutorials:
C# Station tutorial
C# Yellow Book - it's a PDF. It's good.
Yes, it is exactly because you are following the video tutorials which are almost always tailored for beginners... Most of us making a living working in VS, developing WPF solutions do not even use the visual editor but instead work directly with XAML to build our UI and have very little or no code in the code behind files following the MVVM pattern.
To answer your second question, most of your classes that "do stuff" which is not directly intertwined with the UI should be in a separate class library (dll file) and should not even be referenced directly by your main UI project (in order to facilitate loose coupling) but instead accessed using some form of Dependency Injection, typically utilizing Interfaces.
The code that responds to user interaction should be in your ViewModel classess which are typically a data context for your views and these VM classes are typically using service agents which implement different Interfaces in order to use code stored in the class libraries mentioned in the previous paragraph.
Now, it is possible to just double click on a button and write all your code in that method created for you in the code behind file just like with Winforms, but just like in the Winforms world that leads to code that is hard to maintain, that is tightly coupled to your user interface and very difficult to test so try to resist that instant gratification and invest some time in learning the MVVM pattern, DI and OO design patterns which facilitate code reuse, decoupling and testability...
Hope this helps...
It really depends on what you are trying to learn. I don't think I would start off with WPF if I was using C#. I would start off with a console application to get the basics of the language down, then move down to a simple WinForms application, and finally to WPF where you started.
But yes, your questions about how the editor works is correct. It's how that platform works.

Enable Visual Styles for a Class Library

how do I enable visual styles when my project is a class library and it's being loaded into a program that does not have Application.EnableVisualStyles() set. I have been struggling with this for 2 days now. This is in C# (I've seen some examples for older C++ and some things that may work for VB, but nothing has been clearly laid out for C# and if it's even possible).
I have tried to run Application.EnableVisualStyles() from my Class Library before creating any controls, but it seems that needs to be done before an Application.Run() is done, and I don't have control when an Application.Run() is called since this is going into a 3rd party app as a plugin (VMware's Virtual Infrastructure Client).
I have tried to create a manifest file and after compiling the class library I link in the manifest file to my ProgressBar.dll with:
mt.exe -manifest ProgressBar.dll.manifest -outputresource:ProgressBar.dll;2
Except this doesn't work. If I make a dummy Application that uses my ProgressBar class library and link the manifest to that Application's exe, then the visual styles come up (basically it's doing the long way of specifying the Manifest file in the Project Properties, Application section).
Right now my buttons look ugly, but the biggest thing that is irritating is that the ProgressBar control doesn't work in Marquee style. I'm very soon going to have to resort to making my own Marquee-style ProgressBar or just throwing in an animated GIF in it's place. With regards to the buttons, I guess I can start using Infragistics buttons in order to get a more consistent result.
Please and thanks as always!
How can you be sure that there are no controls created yet when you call Application.EnableVisualStyles? Created does not necessarily mean that the controls are also visible on a form.
Since you are working with a closed 3rd-party component I would invest my time rather in creating my own controls if the look and feel is that important.
You'll have to use the OpenThemeData Win32 api in your control:
MSDN: Using Windows XP Visual Styles

Categories

Resources