|
Hi, I'm really new to C# so I hope everyone forgives if my question is a silly one. I'm basically a PHP programmer turned C# Programmer for a new project being developed at my office.
Here is what I want to do, I have an application that has some menu items on the top. Now when user clicks on one of the menu item, I want to show the form that contains the interface to be shown in the main form instead of launching a separate form.
I hope I made myself clear. Maybe an example would be helpful. Well here goes.
Example: There is a menu item named "User Management". When someone clicks that menu item the interface would show a list of users, their login details, position etc. Now what I want is that this information will be shown in the form containing the menu, not in a separate form launched when that menu is clicked. Since there are different menu items doing different things, the main form will probably act like a container of some sort that has a designated area where other forms ( or other controls ) can simply show up.
Thanks in advance for any help.
|
|
|
|
|
Instead of making forms, create UserControls, add them to the main form, and show/hide them as needed. For an example of what I mean, check out my wiard form article[^]. In that article, the various wizard pages are nothing more than user controls. For your needs, the forms would change based on the menu item that was clicked.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thank you very much. I guess I can use that very well written article of yours as a guide.
|
|
|
|
|
If you want an SDI (single document interface) I would use some of the dynamic controls .NET provides and make the data "fit" into the main form somehow. If your main form had generic space for properties (i.e. a property table), fill the user data into there. All of the controls and layout panels in .NET offer some sort of on the fly data filling or layout changing. Add/Remove controls from parents, or make them invisible to build the UI as needed.
If you want an MDI (multiple document interface), which is little windows contained inside a big one, I would use a 3rd party MDI creator like this one: http://www.arstdesign.com/articles/sdimdiwizards.html[^]
Word is an MDI using many windows for your many documents or views of documents. IE is an SDI, using a tabs user control to show many layouts / documents.
|
|
|
|
|
Thank you for your reply. I guess I will use that app you linked to. Will have to go through a bit of testing to know which will serve me best. Thanks once again.
|
|
|
|
|
I have a simple PDF organizer I wrote for personal use and it loads pdf files using the ActiveX control. My problem is that when I load a password protected file and choose cancel when the password is requested the control goes blank and it will no longer load other files until it is disposed and replaced. Problem is there is no error or event that I can associate with this phenomenon to tell when I need to do this. The only other way around this is to create a new instance of the ActiveX control before loading every file. Anyone know what I'm getting at here and how to fix it?
Thanks.
|
|
|
|
|
Hi All.
I have a suggestion to write an application that installed on client pc and communicate with a VPN server.
User can connect via username and password and can send some request to server via the application.
For example they can ask from the server to unblock some special site for them,that usually is forbidden for other or another service.
In server Admin should to manage user request,user service,user info and so ...
I want to see if it possible and what type of programming i should to do?(socket programming,...?).
Thanks for any idea or help.
sepel
|
|
|
|
|
Hello everyone,
I have some python source code and I want to convert to .Net C# code. Any tools to recommend?
thanks in advance,
George
|
|
|
|
|
The only conversion tool is your eyeballs and hands. There is no automated conversion tool possible.
Your only other option is IronPython[^], which is a .NET CLR version of Python. Of course, there may be a fair amount of rewriting of your code to get it to work.
|
|
|
|
|
Thanks Dave,
I am confused about your solution of using IronPython. I am also new to IronPython, but I think the function of IronPython is to invole .Net code from Python code. Does it have function to compile Python code into .Net IL? Any more reference links?
regards,
George
|
|
|
|
|
George_George wrote: I am confused about your solution of using IronPython
What's to be confused about?? IronPython is a .NET CLR, managed-code verison, of Python. It's not to involved .NET in Python. It is a version of the language that cannot run without .NET. No, there is no possible way to convert the code you have to work under the .NET CLR, without rewriting it, by hand.
|
|
|
|
|
Thanks Dave,
I am confused about what do you mean "IronPython is a .NET CLR, managed-code verison, of Python. It's not to involved .NET in Python". I am interested in how IronPython works, does it compiles Python code into .Net IL code and then run them under .Net Runtime?
regards,
George
|
|
|
|
|
Just like C#, VB.NET, C++/CLI, ..., yes.
|
|
|
|
|
But what do you mean "It's not to involved .NET in Python"?
regards,
George
|
|
|
|
|
He means 'Yes'.
probably.Dave Cross
|
|
|
|
|
Wow your request is on every forum possible isn't it.
Such a tool doesn't exist, you're gonna need some help on this one from someone who knows both python and c#.
|
|
|
|
|
You mean convert the code manually?
regards,
George
|
|
|
|
|
what is the .xsd file in a C# project ?
Thanks...
|
|
|
|
|
Which one? It might be a dataset schema, it might be virtually anything
Be more specific.
Regards,
Lev
|
|
|
|
|
xsd files are XML schemas for datasets
|
|
|
|
|
What if I have a xsd file in my project for some xml-html transformations? Will it make it a dataset schema?
Of course not. It is not clear which file hung1984 means, that's why I asked him to be more specific.
Regards,
Lev
|
|
|
|
|
I've been kicking around the idea now of writing a guitar tuner in C#; but I've no idea on where to begin. Specifically I've seen excellent articles such as: http://www.codeproject.com/KB/audio-video/SoundCatcher.aspx[^] which will let me plot a wav file in real time; but I need to be able to calculate (I suppose, anyway) the pitch of a sample, correct?
In other words:
1. Suppose I have a WAV file looping that is playing a guitar string, say E, that is in tune.
2. I want to take the project mentioned above, and put a mic on my guitar and play my E string over and over...
3. I'd like to be able to tell if my E string that I am playing is in tune with the recorded WAV file...
For that, I'd need to be able to calculate pitch, correct? Is there a library to be able to do this? If not, could anyone kindly give me pointers on where to begin?
Many thanks,
Brandon.
|
|
|
|
|
Hi,
I've recently wrote project that could help you (in c#).
What I did was:
1. Write library wrapper to MM, which enables me to catch sound from microphone as pure data.
2. Write functions that will do FFT on that data
3. Check what sound (frequency) is "the loudest".
4. That's all folks! .
I've tested it on my piano and some youtube piano songs and my program is able to tell what tone I am playing (not as correctly as I would like though).
Anyway:
My approach was a bit different than yours, I wasn't comparing my sound to wav file with recorded, instead I was transforming small chunks of data, fe. 8192 samples (with 44.1kHz sampling rate, you will get enough samples after 1/5 sec, so that's the shortest sound you can catch), transform it to frequency domain using DFT / FFT, get "loudest" frequency from that sample and check what sound (tune) it is. If you decide to try write your soft that way, write if you will have any questions on that.
Good luck,
Ravadre
modified on Sunday, December 28, 2008 11:57 PM
|
|
|
|
|
Thanks for the reply.
Using the above project I mentioned, I have an example to follow for capturing live mic input; however I'm lost on the FFT. In the above mentioned project, he has a FFT class (which I would happily copy and paste, except that it would make this post hard to read) that takes an array of doubles and that will spit back out an array of doubles, but I'm not sure exactly what to do with them? Plot them?
I guess where I'm currently stuck is that I don't understand at all the FFT - other than it is a method for computing a wave?? I think I may go to the local community college library and check out a few books to bring myself up to speed.
Do you have a writeup, kind sir, of your project? If not, may I ask which library you used for your FFT? Or - if you know of any excellent articles that you could refer me to in getting started (because I don't fully understand either the sampling rate, etc) would be of most help.
Thank you for your time,
Brandon.
|
|
|
|
|
Hello,
In my library I use few FFT algorithms, just for fun, the best and easiest to use and understand was FFT algorithm in AForge library (100% c#) (by Andrew Kirillov, who writes greats articles on CP.com btw ).
The mystery of DFT (Discrete Fourier Transform)is, that it simply converts data from time-domain to frequency-domain (now mathematicans will scratch simply and write few books on how hard, complicated and beatiful it is, but for now - we don't need that knowledge).
FFT is nothing more then algorithm of computing DFT efficiently, so I will use FFT term from now on.
And now quick tutorial on FFT and sound data:
What you have when capturing sound from microphone is buffer of data, this data represents how sound has changed over time, so it's in time-domain. Now, what you have to do is compute F = FFT(T), where T is your time domain data, and what you will have in result is the same data, but in frequency domain. You should get array of complex numbers (or 2 double arrays, 1st representing Re part, 2nd representing Im part), if algorithm from this program returns doubles, I assume it computes magnitude of complex numbers, which is OK for your purpose (you would have to compute it anyway from normal FFT algorithm). So, what we've got now is:
T - array of input data (sound we've catched).<br />
F - array of output data (magnitudes of complex numbers computed by FFT)<br />
length(T) == length(F)
Now we have to find which frequency has the highest magnitude. We iterate over our array and find index with the highest value - that's the easy part.
So now we also have
fi - Index in array of F with greatest value
Now the question is how to get frequency of that sound. The answer is:
double freqStep = sampling_rate / length(F)
Now, if fe. your fi = 50, sample_rate = 44100 (which is standard value), and you will catch 4096 samples (which means, your T tables has length od 4096, and that means, your F table has length of 4096), the most significant frequency in your sound probe is:
Freq = 50 * (44100 / 4096)
If you analyse this, you can see, that the longer probes you will have, the smaller freqStep will be, and that means you will analyze sound frequency better (more accurate), but you will have to catch sound longer.
Now the last part is how to convert Freq to pitch (C, C#, D ...). I don't know how does it look for guitar, but in piano 1st key has frequency of 27.5Hz, which is A sound, and piano has 88 keys, so We have to compute help table:
pitches = new double[88];
pitches[0] = 27.5;
double step = Math.Pow(2, 1.0 / 12.0);
for (int i = 1; i < 88; ++i)
{
pitches[i] = pitches[i - 1] * step;
}
Now, to get pitch, we find index that value is closest to Freq, fe. If we have Freq=445.0, the closest index will be 48 (which has value of 440). Now, because 1st value in our array is A pitch, and we have 12 pitches, we can get pitch like that:
string GetPitch(int pitchindex)
{
int rest = pitchindex % 12;
switch (rest)
{
case 0: return "A";
case 1: return "A#";
case 2: return "H";
case 3: return "C";
case 4: return "C#";
case 5: return "D";
case 6: return "D#";
case 7: return "E";
case 8: return "F";
case 9: return "F#";
case 10: return "G";
case 11: return "G#";
}
throw new Exception("?");
}
|
|
|
|
|