|
You may track the mouse movement, but this will cause you a refresh and redraw to the line every small pixels.
------------------------------ "The Soapbox has been so ..."
|
|
|
|
|
Well, a friend requested an application, and I've been working on it. And it requires detecting and accessing a USB flash drive.
I looked in the article:
http://www.codeproject.com/dotnet/devicevolumemonitor.asp
I am not using it with a USB Flash Drive right now, just CDs. Well, I'm having an issue. When I insert a CD (drive D: OR E , I get this:
Volume inserted in
No drive letter. But when I eject the CD, it says:
Volume removed from D:/E:
Whichever drive I put the CD in. Could someone else try it out and try to find what's going wrong. I didn't modify the code. I simple downloaded the source code, and built it.
I'm on Windows 2000 Pro Service Pack 4, and VS .NET 2005 Pro. I also tried it on VS .NET 2003 Pro.
Thanks in Advance,
Matt U.
|
|
|
|
|
Ok i have created my first quality application for windows, a Puzzle game and i am planning on giving out a test version to my friends so that any errors found can be fixed. I have added a Rich text box to the app and i want the text that is input into it saved. i know this involves databases and the book i have on C# is very unclear about anything to do with data bases. So i need to know how to create a database and how save the text to it and have it recalled when it loads i know this is alot of work but any help would be much appreciated.
|
|
|
|
|
Why use DB, you may use files, easier, faster, and helpful, you may use System.IO for it, its very easy,
If you are considering files then take a look at TextWriter and TextReader classes of the IO namespace .
------------------------------ "The Soapbox has been so ..."
|
|
|
|
|
i keeping getting an error message stating "Unrecognized escape sequence" when i tell it what file to read any ideas why or how to fix it?
|
|
|
|
|
Use @ infront of the string like
string path = @"mtapp\mypath\";
|
|
|
|
|
Hi,
I desperatelly need an answer on my probably dumb question .
I use data bound DataGridView control and I need (on click of the button) to programmatically add row. When I use command DataGridView1.Rows.Add() I get message: "Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound.". How can I trigger event that causes to create new row?
Thanks,
Aleks
|
|
|
|
|
Add a row to the datatable that is the source, and remove it later.
------------------------------ "The Soapbox has been so ..."
|
|
|
|
|
So simple and so smart. Thanks a lot.
|
|
|
|
|
I am currently trying to build a serial monitoring program.
I am planning on using several ChildMDI forms to hold data grids with decoded serial data. I built an event driven serial driver, and when a packet is received, an event is fired. From that eventhandler, I am trying to call methods within the ChildMDI forms to update their data. When the event fires, everything is executed, except the calls to the ChildMDI forms. Its as if the calls are never made (I have tried one of the methods I wrote, and just using .Close() to no avail). I have verified the methods work by inserting a test button and have gotten the Child forms to respond to that. Is this something that just won't work, or do I need to configure it in a special way?
Thanks!
-- modified at 15:15 Friday 16th February, 2007
|
|
|
|
|
I have an application that frequently modifies the values of certain strings that are attributes of some classes that I use in the application. These strings get modified once every 1-4 minutes during normal software operation. Would the StringBuilder class provide any performance enhancement over a String in this situation?
Thanks.
|
|
|
|
|
Have you tried testing this yourself using the stopwatch class of the System.Diagnostics namespace (should be the correct namespace)?
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Probably not. You incur a hit at three times with a StringBuilder: initialization, ensuring capacity (internal), and calling ToString. I'm guessing you'd be calling ToString too frequently to be a real benefit.
That being said, you definitely need to test it to be sure. Start with the easiest, reasonable implementation and then if the performance is an issue then examine other alternatives.
|
|
|
|
|
I personally have noticed a large difference in performance but then I wasnt building and displaying constantly. I was doing more batch text processing.
Cleako
|
|
|
|
|
Hi,
StringBuilder will show much better performance than string when you need to calculate complex string expressions as in:
string s="the alphabet consists of ";
foreach (char c in "abc...z") s=s+c;
Inside the loop each s=s+c; will create a new string, copy the existing characters and append
one (that is a quadratic operation: when the number of iterations doubles, the cost
will quadruple).
With StringBuilder nothing gets copied as long as the StringBuilder's capacity is
sufficient. So I would say if there are fewer than 3 to 5 operations, string will be faster;
in my example StringBuilder will win hands down; and yes it helps to give it adequate
initial capacity.
Luc Pattyn
|
|
|
|
|
Just to echo the others in the forum, you really need to do testing to be sure. Hook up a performance counter to figure out if it's bottlenecking your application.
That being said, it sounds like your code isn't doing enough work to warrant using StringBuilder objects. Are you modifying only a handful of strings every 1 - 4 minutes? If so, is it worth it to you to optimize away a few milliseconds out of every few minutes?
|
|
|
|
|
I am trying to compress a jpg file in the same manner that you would set the quality factor in an image processing package e.g.
Open image1.jpg
Set quality factor to 50
Save as image2.jpg
This is to reduce the size of the jpg files in my application.
Does anyone know if there are .NET libraries for this or any good commercial toolkits.
|
|
|
|
|
<br />
System.Drawing.Imaging.EncoderParameters encParams = new System.Drawing.Imaging.EncoderParameters();<br />
encParams.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, Quality);<br />
MemoryStream ms = new MemoryStream();<br />
_reformattedImage.Save(ms, System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders()[1], encParams);<br />
_reformattedImage = Image.FromStream(ms);
That's raw code straight out of an app i've got infront of me it's got the quality methods you'll need though. Quality is the parameter from 1 to 100 that sets the quality level
Things like Bitmap should have load and save methods on them (you can load jpegs into bitmap objects).
HTH
Russ
|
|
|
|
|
Thanks Russell. For completeness my final solution was:
private ImageCodecInfo GetEncoderInfo(String mimeType)<br />
{<br />
int j;<br />
ImageCodecInfo[] encoders;<br />
encoders = ImageCodecInfo.GetImageEncoders();<br />
for(j = 0; j < encoders.Length; ++j)<br />
{<br />
if(encoders[j].MimeType == mimeType)<br />
return encoders[j];<br />
} <br />
return null;<br />
}<br />
<br />
Image image = Image.FromFile(sourceFile);<br />
<br />
string mimeType = "image/jpeg";<br />
ImageCodecInfo codecInfo = GetEncoderInfo(mimeType);<br />
if (codecInfo == null)<br />
raise error;<br />
<br />
Encoder qualityEncoder = Encoder.Quality;<br />
EncoderParameter ratio = new EncoderParameter(qualityEncoder, 40L);<br />
EncoderParameters encoderParams = new EncoderParameters(1);<br />
encoderParams.Param[0] = ratio;<br />
<br />
image.Save(destFile, codecInfo, encoderParams);<br />
image.Dispose();<br />
|
|
|
|
|
I am working on a project in c# windows forms. The app requires to read xml file which contains the information about control to draw on the form.
below Sample xml file information:
<control type="Label" id="label1" width="23" height="23" xPos="117" yPos="100" />
<control type="TextBox" id="textBox1" multiline="false" width="143" height="23" xPos="117" yPos="50" />
<control type="Button" id="button1" width="23" height="23" xPos="100" yPos="100" />
The scenario is if I add a new control to the xml file and re-run the windows application it should be able to draw the new control with other controls in the xmlfile on the windows form.
Please help
MSx86
|
|
|
|
|
Use reflection. type tells you what control to instantiate. the remainder of the attributes tell you what properties to set. Then all you do is add the control to the Controls collection on the form.
|
|
|
|
|
Thanks a million.
Can you give me a sample? I am new to it. I didn't understand what you mean.
|
|
|
|
|
Looks like you are reinventing the wheel a bit here. Take a look at what Marc Clifton[^]has done with MyXaml[^] and MicroXaml.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Good point but I cannot use XAML. I just need to populate some basic controls.
|
|
|
|
|
A couple of points. The first part is that Marcs implementation isn't XAML - it's his own version. Point 2 - Marc has solved the problems that you are trying to solve, so learn from him. He's one of the best on CP, and if you think you want to do something then chances are, Marc's already done it.
the last thing I want to see is some pasty-faced geek with skin so pale that it's almost translucent trying to bump parts with a partner - John Simmons / outlaw programmer
Deja View - the feeling that you've seen this post before.
|
|
|
|