|
Chesnokov Yuriy wrote: the values in RectangleF are fractional
I know. I'm just showing what happens, hence the reason you have to cast it.
|
|
|
|
|
The following two methods are based on the ConvertFrom and ConvertTo methods of the RectangleConverter class, tweaked for RectangleF and other bits removed as we know the types required in advance.
using System;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
public class RectangleFUtilities
{
public static bool TryParse(string s, out RectangleF result)
{
if (string.IsNullOrEmpty(s))
{
result = RectangleF.Empty;
return false;
}
s = s.Trim();
if (s.Length == 0)
{
result = RectangleF.Empty;
return false;
}
CultureInfo culture = CultureInfo.CurrentCulture;
string[] strArray = s.Split(new char[] { culture.TextInfo.ListSeparator[0] });
float[] numArray = new float[strArray.Length];
for (int i = 0; i < numArray.Length; i++)
{
if (!float.TryParse(strArray[i], out numArray[i]))
{
result = RectangleF.Empty;
return false;
}
}
if (numArray.Length != 4)
{
result = RectangleF.Empty;
return false;
}
result = new RectangleF(numArray[0], numArray[1], numArray[2], numArray[3]);
return true;
}
public static string ToString(RectangleF rectangleF)
{
CultureInfo culture = CultureInfo.CurrentCulture;
string separator = culture.TextInfo.ListSeparator + " ";
TypeConverter converter = TypeDescriptor.GetConverter(typeof(float));
string[] strArray = new string[4];
int num = 0;
strArray[num++] = converter.ConvertToString(null, culture, rectangleF.X);
strArray[num++] = converter.ConvertToString(null, culture, rectangleF.Y);
strArray[num++] = converter.ConvertToString(null, culture, rectangleF.Width);
strArray[num++] = converter.ConvertToString(null, culture, rectangleF.Height);
return string.Join(separator, strArray);
}
}
Dave
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.
Astonish us. Be exceptional. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
modified on Wednesday, June 1, 2011 7:12 AM
|
|
|
|
|
Hey all,
Anyone have a very simplified/bare-bone cookbook sample to play a wav file over a serial port that was dialled?
So far I have successfully made a c# app that opens port, dials phone number and the app sleeps for a few seconds till i pick-up phone, i received the phone but then am now at the point where my code should play a wav file.
Anyone have a sample?
Tia
charles
|
|
|
|
|
you want to send some bytes and listen to them? I did those things before PC's became popular, and without a modem.
I suggest you read some articles, maybe google for serialport, waveform, sound, things like that. Here is one CP article that you might learn from: Universal Remote Control with PDA[^].
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
So I have made some EXCELLENT progress. Practically done. What is left is finessing the audio into place. Right now. I take a wav file, and break it into blocks as per some examples. But when I listen to it over the phone it plays for the first couple seconds, then it starts to sound like it's skipping.
PS:I will help anyone who reads this. Email me @ dotnetcoder@hotmail.ca.
But if I can get help here is my audio loop.
BinaryReader rdr = new BinaryReader(strm);
Utils.Write("4");
while (!MSwitch)
{
byte[] bt = new byte[1024];
bt = rdr.ReadBytes(1024);
if (bt.Length == 0)
{
MSwitch = true;
break;
}
comPort.Write(bt, 0, bt.Length);
}
Before this, I read the stream after the 44th byte. Starts fine, but I think the program is writing too fast?
|
|
|
|
|
Did you consider handshaking? maybe your target is using hardware (or software) handshaking, and your code is not?
and plese use PRE tags when showing code snippets.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
Must be something with the audio..... I chopped up the wav into portions. The first portion was skip free, so i repeated that over and over and no skips, then i played a portion that skipped and it skipped so it must be the wav file. though i believe i had re-encoded it properly. will investigate.
But a bigger issue, have you been able to send key tones? I want my system to dial extensions but from some early readings i may have to gimck this.
the other issue is i am targeting a USR5637 56K USB Faxmodem. but it appears that the only at command that gives me an ok is 'at' and 'atd'...... hey, can i give you my email?
dotnetcoder@hotmail.ca
|
|
|
|
|
Sorry, I never had my PC speak to my phone or my modem, and I don't know the specific faxmodem you're talking about.
Dual-tone dialing probably isn't that easy, it is explained here[^]; it needs two sine waves at the same time, and both better be pretty accurate in frequency and pretty close to a sine wave (as to avoid harmonics). So you need to be very careful about the number of bit-times each sample will require on your serial line.
I don't do e-mail, I'm here to help people, but I want to participate in threads for all to read, not off-line individual discussions.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
Hey Luc
If you can clarify one thing, so if I have a modem that is TAPI compatible, it may still not be considered a 'voice' modem. In the sense that it can not play a wav file after dialing a phone number. The modem modem I currently have is the USR 5637 but I am now permitted to get any voice modem avoiable?
|
|
|
|
|
Frankly I don't know these things, I know quite a bit about serial ports, but not about modems.
Setting up a connection is what a modem should be capable of, so I expect it known about dual-tone multi-frequency dialing. I have no idea why you would want more tones once the connection got established, and I don't know whether a modem could generate more tones when connected; I do know my phone can: if I press a button in the middle of a conversation, you can hear the DTMF.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
modified on Friday, June 10, 2011 8:44 PM
|
|
|
|
|
Ohhhhhhhhhhhhh,...
Sorry. I meant to imply that once the application dials a phone number, has a delay (so it can dial extensions) it plays a wav file to the mailbox it dials. So it simply calls an IVR here at the office and leaves someone a voice mail. The wav played is not DTMF but a voice that we choose.
|
|
|
|
|
PS, I gave 'good answer'
|
|
|
|
|
Reply to my own message is what I want.
I want to find the best voice modem out there (but it is ok to have some short comings as it seems there is no clear winner). What are your thoughts as per voice modems? I'm not concerned over flash-hangups (line switch) but mainly want to be able to send wav's to a modem to play after dialing and navigating through an IVR. So I can conquer the initial menu navigation with delays in the ATD command but after that simply need to leave a message (internal alert type system from server).
any recommendations on the optimal voice modem?
modified on Thursday, June 2, 2011 2:54 PM
|
|
|
|
|
in a child thread i'm calling folderbrowsing dialog , i get the exceptiuon and , i got some articles saying i must use STAThreadAttribute attribute for the main method , i did that and the result was the same
"Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process."
i tried
inthrd.SetApartmentState(System.Threading.ApartmentState.STA); too but still the same result. can any one have any idea about this.
thanx in advance.
|
|
|
|
|
I don't know all the details, however here are some facts:
1. you can set the apartment state only once;
2. IIRC you can't set it at all on ThreadPool threads;
3. I don't recall what happens if you try and ignore #1 or #2.
4. the easiest way to solve such problems most often is to do all user interaction on the main (aka GUI) thread.
BTW: when referring to some error message or exception you should paste it verbatim in your question.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
thanks,actually what i'm doing is creating a new window in the child thread, so in that window i want to open this folderbrowsingdialog, so at that point i get the exception.
and following is the exception i got
Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process.
thanks in advance.
|
|
|
|
|
thanks again . i found the issue , i'm using a separate class for creating threads in the application , and i had set the
l_thrd.SetApartmentState(ApartmentState.STA); out side that class , when i moved this line into that thread creating class i got my problem solved. but i really don't know difference the two places i used the code
thankx .
|
|
|
|
|
It is generally a bad idea to create UI on child threads, particularly if those threads are doing any data processing. The modal stack for different threads is separated, so (for example) message boxes and dialogs from a child thread won't interact as you expect with the main thread. A modal dialog is better than normal forms because you don't need to add a message pump to the thread but it's still not recommended in most situations. (For example, what if two threads want to ask the same question at the same time?) Have you thought about why you want to do this?
|
|
|
|
|
It is always a best practise to limit your user interaction to the main GUI thread. Modal windows are modal only to the thread they're created on and not modal to the entire process as one would expect.
|
|
|
|
|
Hi guys,
I've searched google but didn't find anything regarding this issue. I'm updating an MS Access table after reading some fields from the same table. While doing this i have a label to check how many rows have been processed out of total and i see that the reader jumps from an ID to another, process a few rows then comes back to the ID before jump happened. Is this thing normal?
The table is created from an imported text file using Access.Application.DoCmd.TransferText. I thought compacting the database after import will fix this, but didn't. Any ideas?
Thank you!
|
|
|
|
|
IMO a database is not supposed to obey a specific order, unless you specify one. Ultimately if you don't specify an order, the results could be different each time. I always specify an order before the user gets to see the data, so he shouldn't get any surprises here.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
It just didn't cross my mind to order by ID.
Thanks!
|
|
|
|
|
You're welcome.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
Hello Experts,
I have found a very good project for drawing CAD project. But in this article i have very confusion but there is not any reply for my questions. So i m putting my question here.
I have generate the problem while creating the Rectangle Object.
OpenS-CAD, a simple 2D CAD application[^]
So please help me for that..
Thanks
If you can think then I Can.
|
|
|
|
|
The article is four years old.
Your question on the article was 4 hours ago.
Give it time...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|