|
Hi everyone,
I am experimenting with ASP.NET charting. I have a bitmap of a given length and width and what I want to do is draw a string in the center of it. Is there a way to calculate the string parameters according to the specified font etc., so that I can know where exactly to draw it so that it will fall in the center.
Thanks,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
You can try the MeasureString function, it gives you the size occupied by the string for the specified Font object.
|
|
|
|
|
Thanks Kannan!
I was using font.Size methods and all and wondering why it was not working.
Sincerely,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
How to get the time when the program executing
Mr Duc Linh Nguyen
|
|
|
|
|
Do you mean DateTime.Now ?
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
I mean. I got a function and i execute it, then i want to know how long does function execute.
Mr Duc Linh Nguyen
|
|
|
|
|
Just record the time when the application/method begins execution and diff the time when it stops.
DateTime start = DateTime.Now;
TimeSpan duration = DateTime.Now - start;
Console.WriteLine("Ran for {0} milliseconds.", duration.Milliseconds); This is basically what Christian's source that someone mentioned is doing. I mean, how else would you do it?
If you want a more thorough solution, I recommend a CLR profile like this free one[^] from Microsoft.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Dear all,
i try to popup a dialog when i change item in a drop down list. i use javascript:
SelectDropDownList1.Attributes.Add("SelectedIndexChanged","Javascript: return confirm('sure?');");
the dialog won't display.
if i use:
SelectDropDownList1.Attributes.Add("onchange","Javascript: return myconfirm();");
confirm dialog will display, but it won't fire my function in code behind of SelectDropDownList1_SelectedIndexChanged.
would anyone give me some advice on this hassle? thank you.
David
|
|
|
|
|
Is AutoPostBack set to true on the control ?
Try not! Do or do not, there is no try. - Master Yoda
|
|
|
|
|
First of all, it's "javascript:return myconfirm();" (notice the colon), but you shouldn't use the "javascript" declaration. This scheme is only necessary when you use it in an attribute that accepts a URL, such as the A.href attribute.
If you change the the handler for the onchange event of your element, auto-post back won't occur since events only work with a single handler. You can, however, call __doPostBack (with the necessary params) in your myconfirm function. The work-around for this problem is just what I mentioned: since you can only have a single handler for an event, have that handler call other functions. Of course, you should call __doPostBack last since it will create a new request (thus resulting in round trip to the server).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath,
i try to work it out follow your way. here is the code i wrote:
in test.aspx.cs
private void Page_Load(object sender, System.EventArgs e)
{
// b1 is a invisible button will save change to database
string sCmd = Page.GetPostBackClientHyperlink(b1,"");
string script1 = "javacript: return myconfirm(" + sCmd + ")";
if (!Page.IsPostBack)
{
DropDownList1.Attributes.Add("onchange",script1);
}
}
in test.aspx
function myconfirm(cmd)
{
var agree = confirm("sure?");
if (agree)
eval(cmd);
}
but the browser always said the javascript code had errors. is there any error in string script1.
thanks.
david
|
|
|
|
|
As I mentioned before, don't include "javascript:" before your script. You only do this in URL attributes, like <a href="javascript:doSomething();">Do something</a> . In event attributes, you don't include this because they only work with script.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Heath,
yes, i got the result i want finally. thank you.
and i have a similar question: how are radiobuttonlist? i can not use the same way to raise a popup dialog.(e.g. radiobuttonlist1.attributes.add( ... ))
david
|
|
|
|
|
Look at the rendered output when the AutoPostBack is set to true. There should be an attribute there that you could "override" in such a way.
Another way in both cases is to let ASP.NET do it's job and post back to the server, then use RegisterStartupSCript to include inline javascript toward the end of the page (before the single server-side form's closing tag) that pops up a window. When you start overriding event attributes, you take a big risk at breaking the ASP.NET pipeline (which is why - as I mentioned before - you must make sure you call __doPostBack with the right params in your javascript function).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi guyz,
Does any of you know how to pop up a save file dialog box for a web application? For example, if we want to save files (image, windows media files,mp3s) from the web to the user-end pc.
Thanks in advance guyz.
Rico
|
|
|
|
|
I believe the dialog you mention is part of your browser functionality. For example, IE or whatever browser you use will prompt you for download, show progress of files that are to be downloaded, or even launch the file with appropriate application.
All you do is create the hyperlink for the downloaded content (i.e. zip, wmv, etc.)
Example:
<a href="/relativepath/somefile.mpg>A cool tune</a>
The browser will handle the file according to the settings. For example, it may launch a hyperlinked .mpg file with Media Player or some other player that is registered with your operating system.
<br>
<hr noshade width="100%" color=#80BFFF>
<p style="background: #C0CBEE;border:2px solid #80BFFF;margin:0px;padding:2px;font-size:8pt;text-align:left;width:457"><a style='color:white' href='/script/profile/whos_who.asp?id=26227'>R.Bischoff</a>
.NET, Kommst du mit?
|
|
|
|
|
That is one way to do it.. thanks for reminding me =)
but the thing is, my web application enables the user to create a file, which I'd rather specify the target location of the file first, before it's created.. so implementing a save file dialog will be just what I'm looking for...
but your idea is quite good as well... =) .. If you know how to implement a save file dialog.. that'll be a bunch of help for me.. =)
Thanks
Rico
|
|
|
|
|
You can't create a file on the user's machine from a web site, so just download the content to the browser, which will create the file after downloading it (or some browsers will create the file in the spot the user specified immediately). I mean, if a web site had the power to just create files on a user's machine, think of how big a security hole that would be!
What the previous post said is the only way to do it unless you want to implement some complex Java applet, ActiveX control, or .NET UserControl (not as easy as you might think because of code access security). But why? It would be a complete waste of time.
If you need to create the file on the fly, so do it. This is common. Do you think a web server just redirects a request for a file? No, it reads the file into a buffer and streams it to the client, which reads the stream as it can.
So, just start writing to the response stream and forget about the client. Their browser will prompt for a location (they may cancel) and start writing what you're buffering on the server to the location the user specified. You (writing the server code) don't have to worry about a thing. This is how web servers (not to mention most daemons) work.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Does anyone know of a control, activex component or otherwise which allows one to edit AVI files and their embeded sound?
I have a time sensitive project of which that will be a part. I need to be able to embed the interface into my own but would rather do as little work as possible on the actual editor (due to the time constraints).
I would also rather buy a fully supported component than a free one-off project (uless its REALLY robust)
--Tony Archer
"I can build it good, fast and cheap. Pick any two."
|
|
|
|
|
Since you didn't specify what kind of editing you need and you didn't even bother to go to google for this:
http://www.softcities.com/VideoEdit-ActiveX-Control/download/6926.htm
which is USD77
|
|
|
|
|
Ok, sorry, let me specify.
I need to be able to cut/paste sections of an avi file (including sound).
Select sections of it and play just those (to preview it) etc.
Imagine most wave editors, but add the video element to it as well.
Small request, isn't it?
--Tony Archer
"I can build it good, fast and cheap. Pick any two."
|
|
|
|
|
well for something small microsoft made a tool that you can cut/paste
AVIEDIT.EXE i think is on one version on vc++ or better yet check the web for free avi editor or on sourceforge.net
anyway you probably need some better to do what you asked!
|
|
|
|
|
visit www.NCTSoft.com . I think there is what u need.
NCTVisualStudio is really good set of activeX libraries.
|
|
|
|
|
Thank you. I'd looked at their audio editing component (which does exactly what I want, by the way) but hadn't taken a hard look at their video studio component. Your post convinced me to look at it closer and it will do what I need.
THANK YOU!
For anyone else this company makes many multimedia components as ActiveX DLLs They also have a few .NET components.
http://www.nctsoft.com/
NCTVideoStudio - video editing
NCTAudioStudio - audio editning
NCTAudioEditor - a drop down audio editing control (very nice)
NCTImageStudio - image editing (haven't checked it out)
NCTPhotoStudio.NET - ?? image processing (haven't checked it out)
NCTSWFProducer.NET - Make macromedia flash files. (haven't checked it out)
NCTFinancialChart.NET -??
NCTDiscWriter - burn dvd's / cds from what I can tell (haven't checked it out)
NCTDialogicVoice - ?? looks like some text to speach thing, but I'm not sure
--Tony Archer
"I can build it good, fast and cheap. Pick any two."
|
|
|
|
|
look at vdub on sourceforge, its not a component, but it does exactly what u want it to, why have a component?
|
|
|
|