|
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??
|
|
|
|
|
|
|
Hi Miguel Sarafana,
After reading Q? , i belive the best & easy way will be integrating with c# application. Matlab version 7.2(6b) comes with builder for .net , so u can write algorithms in matlab ( m file or mex) can be easily converted .net assemblies(dlls).
Details about matlab builder .net is here
http://www.mathworks.com/access/helpdesk/help/toolbox/dotnetbuilder/index.html?/access/helpdesk/help/toolbox/dotnetbuilder/rn/bq24_kz.html&http://www.mathworks.com/products/new_products/latest_features.html?s_cid=HP_RH_2007a
Happy coding !!!!!
Pls feel free to mail me baijumax@yahoo.com Or reply back to this thread for more info.
By
BAIJUMAX
"believe it or not , i'm always right"
|
|
|
|
|
Dear Sir,
Is there a way to create event in Matlab that will be seen/captured in C#
Thanks
Beni
|
|
|
|
|
yes, checkout this post
Happy coding
cheers
BAIJUMAX
www.baijumax.blogspot.com
|
|
|
|
|
Hi, I have a listview with some items:
ColumnHeader columnHeader1 = new ColumnHeader();
ColumnHeader columnHeader2 = new ColumnHeader();
listView.FullRowSelect = true;
listView.Columns.AddRange(new ColumnHeader[] {
columnHeader1,
columnHeader2,
});
columnHeader1.Text = "Name";
columnHeader1.Width = 150;
columnHeader2.Text = "Note";
columnHeader2.Width = 100;
List<string> items = new List<string>();
items.Add("Some Name");
items.Add("Some Note");
List<string> items2 = new List<string>();
items2.Add("Some Name");
items2.Add("Some Note");
ListViewItem item;
item = new ListViewItem(items.ToArray());
listViewProjects.Items.Add(item);
ListViewItem item2;
item2 = new ListViewItem(items2.ToArray());
listViewProjects.Items.Add(item2);
Now I have a combobox where I want to display the note text from the selected item in the listview. How can I do this? Many thanks for any help.
|
|
|
|
|
SelectedItems returns selected items. SelectedIndices gets selected indexes
|
|
|
|