|
I don't see which part of Being relates to graphics ?
You should not use get/setpixel in a game - too slow. The paint event is the right place to draw, Invalidate() is what you need to call to force a paint event. Beyond that, I'm not sure what you're hoping for, or what is wrong. What makes you think that 'world' can't manipulate 'being', if it tries to and it compiles, then it is, it's just not doing what you hope.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
what I'm hoping for is that each instance of Being will manipulate variable g (which is of type Graphics) to change where they are currently located on the screen. Unfortunately when I try to do a g.FillRectange( new SolidBrush( Color.Lime), 5, 5, 13, 13 ); for instance it won't add the rectangle to the screen. However if I do it in the OnPaint method with the exact same code it works. I'm also not trying to have the "world" manipulate "being." I'm trying to have "being" manipulate the "world" or in this case, now, the "g" which is the graphics on screen.
Everything compiles perfectly by the way. I hope that makes sense.
|
|
|
|
|
g = Graphics.FromImage( world ); will allow you to draw on the image held in 'world'. It will not display anything you draw there on the screen. The graphics object passed into a paint event cannot be stored for use later, and it's the only way to draw to the screen, except CreateGraphics, and that is a bad idea, as what you draw will be lost if the form is invalidated.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
so if I want to create the graphics for each "being" I'll need to manipulate them in the Paint event and not in the "Being" class? So instead of calling a g.FillRectangle( yada yada ) in the "Being" class i'll have to do that in the Paint event and use variables from a particular instance of "Being" to manipulate the graphics?
|
|
|
|
|
A common solution is to add code in your class which takes a graphics object, so you can iterate over your objects and have them draw themselves, in a paint event.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Sweet it seems to have worked! Thanks buddy. Now to figure out how to read a specific graphic pixel ha.
|
|
|
|
|
If you check out my image processing articles, they show the alternative way to access pixel data.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Bitmap bm = new Bitmap(@"c:\Hamtaro.jpg");
Graphics gr = Graphics.FromImage(bm);
gr.DrawString("Hello Graphics", new Font("Verdana", 10),
new SolidBrush(Color.Tomato), 1, 40);
What seems to be the problem
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
You don't clean up any resources ? You create a new brush instead of using the built in Brushes collection ?
What makes you think there is a problem ? I don't see any code that would display the bitmap with the text on it, and you're not saving it, so the original image will remain the same, only a bitmap in memory is modified.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Then how do you do it?? I even get an error on this line:
Bitmap bm = new Bitmap(@"c:\Hamtaro.jpg");
Error 1 Cannot implicitly convert type 'System.Drawing.Image' to 'System.Drawing.Bitmap'. An explicit conversion exists (are you missing a cast?)
And sorry, how do you save it eventually??
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Display it in a picturebox:
pictureBox1.Image = bm;
Save it to disk:
bm.Save(@"C:\Hamtaro_with_text.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
|
|
|
|
|
I'm a c programmer trying to convert my programs to c#. Many variables are global and require extern to access them. I'm a bit confused on how global variables are used in C#. How do a declare and used then in different dll's
Brian
|
|
|
|
|
There are no global variables in C#. C to C# is a huge jump, because C does not have classes and C# cannot work without them. If you must have globals, create a class with public static properties on it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
How do you suggest I deal with 2-d arrays that must accessed by a number of subroutines (methods in C# - if I read correctly). In some cases the data must be passed to nested methods. global vars seem like the best option. If I read what you are saying correctly. I can create a method that contains a struct which would hold the data,declare it static then refer to it anywhere. Am I right?
Brian
|
|
|
|
|
Yo can create a property which IS the array, and access it anywhere. I'd be more inclined to pass the data through the subroutines, but it's a matter of style. Globals are ugly, but they do no harm, in and of themselves, if they are not misused.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks, I think I now know how to handle my code. Since it's already written for globals I'll use the method approach. Once I have it running I'll rewrite it passing the functions. The irony here is that I was a fortran programmer who had to leardn C to write this code, now I am moving on once again....after this I plan to learn event driven programing. Good grief, I might not survive that!
I'm in the market for good reference books. I thought for sure someone would come up with a good book that explains(ilustrates through examples) how to move from c to c#. If there is, I can't find it.
Brian
|
|
|
|
|
To add to what Christian said. If you are converting your application to C# and are taking advantage of all that OO goodness then you should be aware that in most cases (the vast majority of cases) the feeling that you need a global is an indication of a poor design.
|
|
|
|
|
yeah, I was holding back, but that's what I meant by 'if you must have globals'. Delegates are a good alternative, they let you tell just the other classes you need to, that something has changed.
If only C# had friend classes, things could be a lot tighter than they are.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
I want to show combinations of various factors used in the DOE experiment i.e. in first page I ask the user to choose 6 factors and 2 levels for each factor. So all combinations of these levels come down to 64. I want to show all these combinations in the datagrid in the next page.
For e.g.: Suppose A is the first factor with two levels a1 n a2 and B is the 2nd factor with levels b1 n b2, then all the combinations of the levels will be 4 i.e. a1 b1, a1 b2, a2 b1 and a2 b2. So datagrid will have 2 colums and 4 rows to display these combinations.
I have prepared a new page with a datagrid but I am not able to display all the combinations in the datagrid table.
Thanks.
-- modified at 8:12 Monday 21st May, 2007
|
|
|
|
|
The easiest way to fill a datagrid is to fill a list or an array with the values and make it the data source of the grid.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
is it possible to change the whole style of the user interfaces in an setup and deployment project using VS 2005? I mean to change the font, font-size, background-color and so on... there are no properties available or i don't find them...
Best regards
|
|
|
|
|
I do not believe so. You are probably going to have to go with a different installation product. The Visual Studio version is very scaled back.
Check out http://www.installsite.org
|
|
|
|
|
hi all, i have a solution with a Class Lib. project and ASP.Net 2.0 Web Site. i want to invoke certain method at the web site from the Windows Application, and also need to invoke some method at the windows application from the website.
a search for this problem, i found that i can send from the Web Site to the Class lib. either by web service or by adding whole the class lib. project as ref. to the web site and call methods or by using delegates.
Please send examples to show exactly what should i do, thanks for any help
|
|
|
|
|
I don't see how you can hope to invoke stuff in the windows app from the website, the best you can do is run a webservice, and have it set flags telling the windows app to do something when *it* contacts the web service, the web service cannot contact the windows app.
Darkman_nofear wrote: a search for this problem, i found that i can send from the Web Site to the Class lib. either by web service or by adding whole the class lib. project as ref. to the web site and call methods or by using delegates.
delegates won't work, they only work within a process. Having a reference to the class lib will allow your web app to call methods that are in that lib, but unless they modify a common data store, this will make no difference to your windows app.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks for your reply, but i've tried it using the Web Service, but what i really don't know is how to send something to the web server, my problem exactly is here i got something and i want to call certain method @ my web site application, ok using web service what is to be in this web service to forward the incoming message to the web site.
[WebMethod]
public void SendToWeb(string msg)
{
// What to do here to send to the web site
}
someone in other forum told me to do something without using a web service, by using HTTPRequest Object, as i send to my web server an HTTPRequest object as i faking something like button click or something like that, this HTTPRequest will be handled by the web server and will inkove the method of this HTTPRequest. is this right??
|
|
|
|