|
However, it's not really going to work. To do this, you need when you create each Panel, pass it into the forms Controls collection, and it's often easier just to create Panels and find them from the Controls collection.
foreach(Control c in Controls)
{
if (c is Panel)
{
}
// OR
Panel p = c as Panel;
if (p != null)
{
}
}
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 )
|
|
|
|
|
Hello,
I want to write a small vocabulary trainer (EN <=> Spanish).
Now I need to know, if two strings are similar. When the trainer ask you, what the meaning of "veinte" is, and the user writes "tewnty" instead of "twenty" the application should only remark that there is a small mistake in the input. When he writes a total different word (e.g. wine) then the trainer should say, that there is a mistake in the input.
Know anyone of you a good class, which compares two strings on similarities? The class should detect if there is a letter missing or a letter too much (or 2 letters are flipped).
Till now I just found classes, which compares complete texts and which say that a line in text A is different to a line in text B.
Bye
|
|
|
|
|
You'd have to write something to do this. A starting point may be to sort both strings alphabetically, and then compare them, to work out if you only have an error of letter order. Then you can walk them character by character, to work out a list of letters that were added, and that were missing, if the wrong letters were also used.
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 )
|
|
|
|
|
There are a number of algorithms that have been developed to determine the similarity between strings (either spelling-wise or pronunciation-wise). A quick Google search brought up this[^], which should give you a good starting point.
-Phil
|
|
|
|
|
I want to move Image through a Path on form
I mean from many points in form until reach destianation
from A , B ,c , d
Like a Flash ,
please Help me.
-- modified at 11:39 Saturday 10th March, 2007
|
|
|
|
|
You need to either use a picturebox ( this is for girls ), or draw the image yourself. You need to set a timer, and handle your paint event. Your timer needs to call Invalidate() to force a paint message, and your paint event needs to draw the image in the right location.
Actually, if you use a picturebox, your timer event can set it's location without having to Invalidate(), but that solution doesn't scale well if you have a lot of images.
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 )
|
|
|
|
|
Thank You very much !
Keep in touch
|
|
|
|
|
Hi,
I'm fighting with performance problems in application which displays data from sound card on the fly.
How can I suppress repaintig a form everytime I move other window over the form or scroll it?
Can I control painting the form only programmaticaly, makes the form holds its state when other window covers it and simply ignore such an events?
|
|
|
|
|
-raada- wrote: How can I suppress repaintig a form everytime I move other window over the form or scroll it?
You can't.
-raada- wrote: Can I control painting the form only programmaticaly, makes the form holds its state when other window covers it and simply ignore such an events?
What you are asking is, you want the form to not refresh itself when it is obscured. If the form is covered, it won't paint itself. It will paint itself when it is uncovered again, or it will be blank.
You can set the AllPaintInWMPaint ( something like that ) control flag, and override the Paint event to control exactly what gets painted. You could set flags within the program which cause this event to do nothing, but, of course, your program will then be ugly.
How do you know that the paint event is your performance problem ? What are you painting ?
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 )
|
|
|
|
|
I know it because when the painting module is not attached the problem doesn't exist. (Module works with already preprocessed data and doesn't do much other thing then just paint them.)
Each sample is represented by array of double values which represents intensity of given frequency in that sample - when it's bigger than a threshold I paint a line at proper place (x axis is time y frequency)
When I repaint the whole signal when new sample was processed - it was unbearable.
Painting is executed in separate thread and I couldn't achieved satisfying results by just set time interval for repainting the signal.
So now I paint just individual samples by calling InvalidateRectangle method and whole signal when Paint event is fired not programmaticaly. But still not satisfyed.
I was asking just to be sure if I have to optimalize painting algorythm or I'm missing something else.
|
|
|
|
|
It does sound like your actual painting code needs optimising. Not drawing parts of it, is not optimisation.
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,
how much data is there to paint ? More samples than pixels in a row ?? If so, reduce the paint work
by either skipping or taking an average value.
It might help to show some code (and some typical values).
|
|
|
|
|
Hi Luc,
well ... I supppose that the most used setting will lead to 160 or 80 Hz frequency when 256 long array of transformed double values has to be processed by painting algorythm.
here is sample code
private void DrawDFTSample(double[] sample, Graphics g)
{
Range yRange = description.YRange;
double colorIndex = 0;
double colorIndexStep = description.Colors.Length / sample.Length;
double fi;
int yGraphBeginning = Height;
double yDisplay;
int xDisplay = currentRectangle.X + currentRectangle.Width / 2;
Pen p = new Pen(Color.Red);
p.Width = (currentRectangle.Width > 1) ? currentRectangle.Width - 1 : 1;
double threshold = 0;
yDisplay = yGraphBeginning;
for(int i=0; i<sample.Length; i++)
{
fi = sample[i];
if(fi >= threshold)
{
p.Color = description.Colors[(int)colorIndex];
yDisplay -= yPixStep;
g.DrawLine(p, xDisplay-1, (int)yDisplay, xDisplay+1, (int)yDisplay);
}
colorIndex += colorIndexStep;
}
counter++;
currentRectangle.X = (int)((double)counter * xPixStep);
}
Now I will try to optimize it by storing already computed values into array of points so I will be able to just draw them without reprocessing signal values when need to repaint whole signal occur.
Hope it will help me
|
|
|
|
|
Hi,
at first glance your code is OK except maybe for p.Color=...
I am not sure but this seems potentially the most expensive line in the for loop.
May I suggest you first retry with only one pen that does not change at all;
if perfo then is all right (or at least much better), make an array of pens
corresponding to description.Colors[] unless that array is really big.
Furthermore I am confused by the line
colorIndexStep = description.Colors.Length / sample.Length;
since it suggests there are more colors than samples (and with 256 samples, that would
be a lot of colors...)
And what is the "160 or 80 Hz frequency" you mentioned ?
is this the rate at which you hope to get the display updated ?? I dont think
Windows can do this at all (see my timers article !).
Best regards.
|
|
|
|
|
There are error to compile this code because panel3.left and panel3.top are not defined in the class. How to overcome this?
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove (e);
if (isDragging3 == true)
{
panel3.Left = e.X + panel3.Left - x3;
panel3.Top = e.Y + panel3.Top - y3;
}
}
|
|
|
|
|
What is panel3, if it's a control of any type, then it would have those properties.
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 )
|
|
|
|
|
Actually it has that control but it need to be declared. But when i made it into class, but in class it can't be done.
|
|
|
|
|
OK, so the control does not exist ? You didn't say that. In the properties window of the designer, make sure the GenerateMember property is true.
And, choose a better name for 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 )
|
|
|
|
|
The problem is that you have abstracted the class from the control, and you have control specific code: you should use
protect override void OnmouseMouseMove(System.Object sender,
System.Windows.Forms.MouseEventArgs e) then you should be able to access the left and top property's through the sender object
|
|
|
|
|
How to access the left and top property's through the sender object? Can you give example. i am new to c# and need guide..
|
|
|
|
|
Sounds to me like you need to learn some C# before you try to write whatever it is you are trying to write.
If you handle an event for a control, within your main class, then you have two incoming variables, like this
protected void OnPaneResize(object sender, EventArgs ea)
{
}
You can then do this:
protected void OnPaneResize(object sender, EventArgs ea)
{
Control c = sender as Control;
if (c != null)
{
c.Left = 5; // or whatever
}
}
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 )
|
|
|
|
|
Hello,
I am using C# and DirectShow making a Windows Application to play DVD. I would like to be able to display the name of the DVD movie which is playing in the application.
I was wondering if you know of any API that I can use to get this information.
Thank you very much and have a great day.
Khoramdin
-- modified at 10:35 Saturday 10th March, 2007
|
|
|
|
|
You should be able to get the name of hte disc, the name that Windows displays. There is no movie name apart from the disc name encoded onto the disc, so no API can get 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 )
|
|
|
|
|
Hello Christian,
Thanx for the reply. Since your last message I have done some research and have come to conclusion that base on your advise I should use "System.Management namespace" to get required information.
Could you be kind enough to let me know if this is the correct way to get this done?
Thank you so much for your help.
Khoramdin
|
|
|
|
|
I have the following code that creates a thumbnail for a given image and saves the new image to disk. It works but the images cannot be displayed by MSIE, and it appears that they are a different format than jpeg. Here's the code:
private void MakeThumbImage(string sSrcFilename, string sDestFilename)
{
Image orgImg = Image.FromFile(sSrcFilename);
int iHeight = orgImg.Height;
int iWidth = orgImg.Width;
int iNewHeight = iHeight;
int iNewWidth = iWidth;
if (orgImg.Width >= 96)
{
iNewWidth = 96;
}
else
{
iNewWidth = orgImg.Width;
}
double ratio = (double)iWidth / iNewWidth;
iNewHeight = (iHeight / (int)ratio);
Image.GetThumbnailImageAbort myCallback = new Image.GetThumbnailImageAbort(ThumbnailCallback);
Image thumb = orgImg.GetThumbnailImage(iNewWidth, iNewHeight, myCallback, IntPtr.Zero);
if (thumb != null)
{
thumb.Save(sDestFilename);
}
orgImg.Dispose();
thumb.Dispose();
}
private bool ThumbnailCallback()
{
return false;
}
I need to create a thumb for whatever file type it is (e.g., gif, png, jpg).
Thanks,
Mark
|
|
|
|