|
I want to implement a telephone answering machine. Have searched for the resources but all of them are for MFC. Can anyone who have done it in C# help me in this regard ?
|
|
|
|
|
TAPI and C# don't play well together, you have to do a lot of P/Invoke and Interop work. My prefered solution is to build a COM wrapper in C++ for the telephony functionality and then use it via COM interop in C#.
However Helen Warn has produced this C# wrapper[^] that will get you started.
Michael
CP Blog [^]
|
|
|
|
|
You beat me to it
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
Try here:
http://www.gotdotnet.com/community/usersamples/Default.aspx?query=Tapi[^]
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
thanks for the help
|
|
|
|
|
I have a typical many-to-many relationship between three tables; Apps, AppsToReports, Reports. I am finding it hard to figure how to add DataRelation objects to a DataSet to cover the relationship between Apps and Reports. I saw the DataRelation constructor .add(rel. name, parent table name, child table name, parent columns[], child columns[], bool nested) but can not find any examples of its use or if it would solve my need. As you might assume, I am trying NOT to write large amounts of code. All DataRelation objects I create must have the parent as a unique value which is not true in a many-to-many relationship from the center table to its details. If I must code around this issue then I must but am hoping for a more simplistic solution. Any help would be appreciated.
Bill
|
|
|
|
|
Have you checked out the documentation at MSDN[^]? It shows a quick example on how to do this. For reference, check out this article on CP that talks about Data binding for many-to-many.[^]
~Javier Lozano
(blog)
|
|
|
|
|
Let me first preface this question with a disclaimer. I've never used regular expressions before so I am admittedly clueless!
I'm trying to validate the entry of a TextBox using regular expressions. The entered value should only pass the validation if it contains contiguous alpha characters. The code below breaks if something like "ABC 1" is entered. Any occurance of a space in the string seems be ignored...
Regex re = new Regex(@"[a-z|A-Z]");
return re.IsMatch(TextBox1.Text.ToString(), 0);
What can I add to the pattern to test for the occurence of a " " within the string that will cause the validation to fail?
p.s. Is there a Regular Expressions for Dummies book?
Paul Lyons, CCPL Certified Code Project Lurker
|
|
|
|
|
|
"[a-z|A-Z]" will match on any string that contains any alphabetic characters, including something like "123456a789". If you want to have the whole string pass or fail, bracket the regex with ^ (beginning of string) and $ (end of string).
Also, unless you want to match one - and only one - character, you should specify the length of the intended match. * match zero or more occurances, + matches one or more, and {#, #} matches a given number of matches (for instance {1, 4} will match if there are at least one, but no more than four occurances).
So, if I'm correct in my understanding that you want to match "A", "ABC" and "abcDED", but not "", "ab c" or "abc123", you'd use something like "^[a-zA-Z]+$". (Note that the pipe isn't nessecary in this case).
As an aside, you don't need to call ToString on the Text property, as it is already a string.
Charlie
if(!curlies){ return; }
|
|
|
|
|
Charlie Williams wrote:
So, if I'm correct in my understanding that you want to match "A", "ABC" and "abcDED", but not "", "ab c" or "abc123", you'd use something like "^[a-zA-Z]+$". (Note that the pipe isn't nessecary in this case).
You are absolutely correct and I appreciate your help!
Charlie Williams wrote:
As an aside, you don't need to call ToString on the Text property, as it is already a string.
I'm just anal that way sometimes. I can't control myself...
Thanks again!
Paul Lyons, CCPL Certified Code Project Lurker
|
|
|
|
|
FYI, the | is not necessary. You simply need [a-zA-Z].
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Heath Stewart wrote:
FYI, the | is not necessary. You simply need [a-zA-Z].
You are correct, and I mentioned it wasn't required in my answer. I was quoting the OPs regex in the first line.
Charlie
if(!curlies){ return; }
|
|
|
|
|
Hi guys,
Basically i want to convert the System.Drawing.Image object which is created from BitMap basically from a bit map file to another Image Object of JPEG format. I dont want to use the files for saving intermediately.
can u guys help me in this regard?
thanks,
vinod
|
|
|
|
|
It's as simple as calling the Save method on the Image object.
Image img = Image.FromFile(@"C:\SomeDir\SomeImage.bmp");
if(img != null)
img.Save(@"C:\SomeDir\SomeImage.jpg");
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi Nick,
i dont want to save to another file. I want an image object of jpeg format without saving. Thats what i need.
eligeti
|
|
|
|
|
|
Then just modify Nick's example to save to a MemoryStream instead of a filename.
Keep in mind, however, that whenever you read in an image a bitmap (in the general sense) exists in memory. Some functionality does not work for indexed images, however, because they maintain a separate palette and work a little different.
So, once you've read, say, a .bmp file into a Bitmap object you've it doesn't matter in what format it is, really. To what end is "saving" (or re-encoding) the image if the in-memory data is still the same?
If you're trying to read EXIF headers from a JPEG, then you'll need to re-encode and save it to a MemoryStream so that you can read the headers manually. If that's what you're trying to do, also keep in mind that the .NET Framework has limited support for EXIF already. See the PropertyItem class and the Image.PropertyItems property in the .NET Framework SDK for more information.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Use the overload of the Save method that accepts a Stream and an ImageFormat as parameters. You can then call Image.FromStream to retrieve the new Image .
Charlie
if(!curlies){ return; }
|
|
|
|
|
I would like to have a thread that runs only when the system is idle, and yields when other threads are ready to run. How could I do this?
Thanks
|
|
|
|
|
There is a way to do "idle time processing" but in general, you really want your threads "compartmentalized". That is you want them to stay out of each others way. Each thread of execution should be able to run concurrently without interferring with another or you'll get "very bad behavior".
When you say "yield" do you mean you want to have a thread suspend? This is often unnecessary and causes major threading and debugging issues (threads telling other threads to suspend is a classic way to get into a deadlock). You can preempt the current thread by doing Thread.Sleep(0) .
In any event, look at the Application.Idle event if you want to do something when the application thinks it is idle. I highly recommend you do not count on this though. Instead construct a custom thread safe queue or use the one provided by the .Net Framework where you feed in "work" that gets completed in another thread. Without knowing more of your application there is little reason to suspend any thread. If a thread "resource intensive" that is a completely different problem that won't be solved by idle time processing.
|
|
|
|
|
My application is a realtime system. Frome time to time, I need to save data to disk without slowing down the whole system. That is why I am thinking of "idle time processing". If I use Thread.Sleep(0) in the thread, how do I know when to sleep? Do you mean I insert the sleep(0) in between the saving code?
Another question is that if I don't use Application.Idle how could I know when to start the saving thread?
Thanks
|
|
|
|
|
Hi,
there another way of doing this. There is something called system hooks in windows. ur application needs to hook into windows to get events. and one of this events includes WH_FOREGROUNDIDLE gets fired when the system is idle.
check the link http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/html/msdn_hooks32.asp
it explains clearly how u can write hooks. pretty simple and yet such an effective way to do. remember it is highly recommended that u use the system hooks very cautiously.
hope this helps u
eligeti
|
|
|
|
|
Thank you. I read the link, and it seems that WH_FOREGROUNDIDLE only applies to foreground thread. The realtime system I talked about runs in the background. Maybe what I could do is to lower the saving thread's priority and let it sleep from time to time?
|
|
|
|
|
It should be noted that Windows is not a realtime OS and .Net is not a realtime API framework and will not respond properly if you need true realtime behavior in your threading and processing. If you need true realtime behavior you need to find another system.
Beyond this, without actually knowing percisely what you are trying to do I can only guess as to what to do or are trying to do. If you need to save perodically use a custom built threaded queue or use ThreadPool to spawn new threads to save data. You don't want to suspend saving in the middle or you'll have messed up data in the context before and after the suspend which means that this will break any realtime response.
As for using Application.Idle :
private void idle(object sender,EventArgs e)
{
System.Threading.ThreadPool.QueueUserWorkItem(new WaitCallback(SaveStuff), stuff))
}
private static void SaveStuff(object state)
{
SaveStateStuff stuff = state as SaveStateStuff;
stuff.Save();
}
* this assumes SaveStateStuff is MT safe.
|
|
|
|