|
You have a 'design' problem not a "class design" problem.
Right now your architecture looks like the following.
xml/objects => business functionality.
The problem with that is that you now want to coerce all possible models into something that is difficult now and possibly impossible in the future.
Your architecture should look like the following.
xml => transform/map => business objects => business functionality.
If it did then all you would need to do would be to add another 'transform/map' for each new form that the xml takes.
|
|
|
|
|
I am working on a project, as the beginning, my program must allow user to draw 2D shapes ( like windows paint or (more professional) 3dsmax ).
I try drawing a grid by calling a function from form' load event. (its not working well , it draw sometimes and sometimes not !! )
I try using mouse_move, mouse_down, mouse_click events of my form to call proper functions for drawing user specified shapes. ( its not working well either. )
because I will have a lot of shapes, I could not use the onPaint event and put all my drawing codes there , cos it will result in screen blanking and I am not satisfied with that.
So, for example one of my main problems with my specified method is this :
I use click-and-move method for drawing shapes, Does anyone knows how I can use this method more effective ?
Or is there any way to do this more fast and reliable ?
|
|
|
|
|
The one correct way is by putting all the painting code in the Paint handler. Here[^] is an article giving theory and an example.
You should describe your drawing elements in some data structures; there are lots of examples around, look for CP articles that have "Paint" in their title, or Google for "Paint.NET".
|
|
|
|
|
You *SHOULD* use WPF. WPF is very conducive to what you want to do. In fact, it will do 90%+ of what you have described out of the box with almost no effort from you. If you do not use WPF, well, you are going to be writing a lot of code yourself thats already been written by the WPF team .
|
|
|
|
|
well , I used WPF for one of my projects before, you are right it has a lot of advantages which are geart !!
But for this project, WPF MAY seem to be useful for GUI part, but for AI part of my project WPF is weak, or better say its so hard to do what I want in WPF.
|
|
|
|
|
That makes absolutely no sense. If WPF makes fully half of your job easier, WPF is probably the way to go. I have a feeling that down deep, you know this to be true, but you're fighting it. That's not going to do anything but hold up the project and pissing off everyone involved.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Huh? When you use WPF for the GUI portion, you still use C#. Heck, you can even break out your "AI" into a seperate assembly and use whatever language you want.
|
|
|
|
|
you'r right, I like to use WPF too, but I have already written a lot of codes in C# and considering that I have just one experience of working with WPF, it will take a long time to migrate.
Now you mean C# itself is useless for drawing ?
I want to do a reasoning from shapes, so the most important part is not drawing the shapes, its working with shapes. such as moving a rectangle on to an other rectangle and saying that which of is greater (pictorially), by the way I am open to hear any ideas for doing reasoning.
|
|
|
|
|
Remember, in GDI/GDI+, you draw on a FLATTENED surface. You lose all context of what you just drew. Lets say you draw 2 squares in GDI/GDI+... as soon as you draw them, as far as the drawing surface is concerned, they are now just a bunch of random pixels. You have to implement all the hit testing, z-order, mouse tracking, position, size, etc. In WPF, the surface is layered for you already and all shapes are objects. So everything I just listed (hit testing, z-order, mouse tracking, position, size, etc.) is free for you out of the box.
Another scenario... lets say you have a bunch of shapes and want to move one. In GDI/GDI+, you'd have to know which part of the screen to redraw, double buffer it and update the position of the new shape. In WPF, you just type "rect.Left += 10;" and you are done. WPF knows what it has to redraw, the double buffering is done for you, etc.
To implement a full featured drawing surface without WPF is a ton of work. To implement the same thing in WPF is a fraction of the work since most of it is done for you already and it will perform better since WPF is hardware accelerated where GDI/GDI+ is not. GDI/GDI+ is all software rendering.
|
|
|
|
|
dear SledgeHammer01 thanks for your support,
I store all essential info of a drawn shape in an ArrayList so that I can move or rotate or do what ever I need to not so hard, but this does not mean that I don't agree the with you with the great benefits of WPF.
I will discuss with my advisor so I may change to WPF.
but I need to know, for reasoning part (which I discussed before) which one is more RELIABLE and Easy-to-Use ? (C#/WPF)
since I have a lot experience of working with AI algorithms in C# and I don't have any such experience in WPF
|
|
|
|
|
Rotation is done for you too .
Me personally, since WPF does so much for you, I'd say its definitely easier. I don't think you have the kind of QA WPF has had, so I'll say WPF will be more reliable then you implementing all that code yourself.
Hey, whatever you want . I still don't see how AI fits into the GUI portion. That seems like implementation details for the back end.
|
|
|
|
|
I trying to say (for example) Rectangle1 is going to fit in Rectangle2 without using the dimensions or Height and Width. I need help in this field too, programmatically how its possible in you ideas ?
|
|
|
|
|
Hi All,
Thank you in advance for reading this, I appreciate your time.
I got a .Net 3.5 application running perfectly on Win7 - 64 and 32 bit.
Also works fine on win XP - 32bit , Didn't try it on XP 64 platform though.
The problem starts on Vista machines.
At first it didnt open at all - DEP error.
I disabled DEP (Post-build event for both obj folder app.exe and bin/Release app.exe)
Checking the .msi deploy (It has to be a deploy eventually - being a commercial product),
on Vista behaved bit better this time but was froze again after a while.
Trying to add the App.exe (after disabled DEP) to the exception list of Vista DEP raised the following:
"This program must run with Data Execution Protection (DEP) enabled.
You cannot turn off DEP for this program."
??
Needless to say I am bit stuck here.
This is for commercial use and I need it to be compatible for all platforms.
A few words of what is included in my project, that I can share:
a. Video runs from start - I use wmp control (ActiveX control).
b. got a keyboard mapped by the InputSimulator.dll[^]
c. got a code using user32.dll to hook some keyboard combinations
I am working on win7-64bit visual studio 2010 C#, FW3.5
My questions:
a. How do I know DEP is really disabled?
- any way to check the .exe for that DEP disabled on my platform?
b. Do you think wmp is causing this or the other .dll's?
Any Suggestions would be appreciated
Thank you again for reading,
Shabi
modified on Tuesday, September 20, 2011 1:25 PM
|
|
|
|
|
If you have to disable DEP to make your app run, you need to re-evaluate the way your app is written. You have much bigger problems.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Turns out it runs perfectly on other Vista machines..
Bad luck on that specific machine I have tested.
Thanks for the reply though,
Shabi
|
|
|
|
|
In Windows Task Manager, open the processes tab. In the view menu, go to select columns. Select "data execution protection".
Have you checked that the remaining problems are not actually caused by UAC?
|
|
|
|
|
Greetings gurus,
I would appreciate your input on whether this idea is even workable before getting to complicated.
The goal:-
Retrieve performance data from remote PC A on Domain A into a SQL database on PC B on Domain B via a running service on PC A.
The method:-
Create a program in C# or C++ which retrieves CPU usage, Available RAM, disk usage and uploads the metrics to a SQL database. This program will run on a target PC as a service/agent.
Note:-
I have already created something similar in vba which runs under MS Access in the LAN but I would like to extend this concept.
I have tried getting Windows Performance Monitor (perfmon) to upload to a remote SQL db but have found that perfmon can't pass on the SQL login (i.e. the connection tests ok but writing to the table fails)
So:-
I have found this Simple Windows Service Sample[^] and used it to create a service. Could someone please point me in the right direction where I can learn (by example) how to read the above metrics?
I have tried to understand some examples of reading hkey_performance_data without getting the code right and I would prefer not to use WMI queries as they seem to slow the host machine down while querying the WMI base.
Any suggestions please.
Many thanks.
|
|
|
|
|
I suggest a WebService running on PC B and the Windows Service on PC A can access it to store its data.
|
|
|
|
|
Hi PIEBALDconsult and thanks for the quick reply.
Why would you want to put middleware between the agent and the SQL backend (if that's what you mean). Surely writing straight to SQL would be more efficient?
|
|
|
|
|
Because every time I write an app that directly connects to a database I have to rewrite it to use a Web Service.
There are all sorts of good reasons to use a Web Service, but I don't feel like trying to think about it right now.
CCodeNewbie wrote: more efficient
There are more important issues at hand.
|
|
|
|
|
Hi ,
I am writing a code to get the assembly version of an exe exists at C:\program files\xyz\xyz.exe.
private void button1_Click(object sender, EventArgs e)
{
try
{
MessageBox.Show(FileVersionInfo.GetVersionInfo(@"C:\Program Files\XYZ Software\XYZ Enterprise 1\Client\XYZ .WinForms.App.exe").ProductVersion.ToString());
}
catch(Exception ex)
{
MessageBox.Show(ex.Message +"--" + ex.StackTrace);
}
}
Its showing correctly when executed in my system like 7.1.0.22 . But the same code executing at Server 2008 its not working fine. its raising exception. May I know how to get version .
Thanks
|
|
|
|
|
Maybe read what the exception says, and adapt your code accordingly.
|
|
|
|
|
My guess is that your application is running into permission issues. You need to read up about the new security model introduced with Windows Vista and above, and see what effect that has on your code.
|
|
|
|
|
That exe is in "Program Files (x86)" on a 64bit server, isn't it?
Yes - No - Cancel - FileNotFound ...
|
|
|
|
|
I've got 2 tables (Components, Servers) with a many-to-many relationship and hence a 3rd table (ComponentServers) connecting the two main tables.
I've created a DataSet and bound WinForm to show and edit this data, but I can't get it to work if there's no data already there. i.e. UPDATE works but INSERT doesn't. I've checked the SQL and that *looks* ok.
The insert is:
INSERT INTO ComponentsServers (ComponentID, ServerID, Environment)
VALUES (@ComponentID,@ServerID,@Environment)
The update is:
UPDATE ComponentsServers
SET ComponentID = @ComponentID, ServerID = @ServerID, Environment = @Environment
WHERE(ComponentID = @Original_ComponentID) AND (ServerID = @Original_ServerID) AND (Environment = @Original_Environment)
On the form I've done the binding via controls not code, and the ComponentServers BindingSource does reference the related ComponentServers table in the DataSet and not the standalone one.
In the save button I've got:
this.Validate();
this.componentsServersBindingSource.EndEdit();
this.componentsBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.eSSDBDataSet);
The form works from a presentation point a few, and as I said, if I update a exisiting entry. But if there's no row in ComponentServers I can't get it to work.
Any clues as to where I've got it wrong? I *think* its the DataSet, but not sure why!
|
|
|
|