|
Nothing
Just search in google but no use!modified on Tuesday, March 2, 2010 1:45 AM
|
|
|
|
|
Well, try something and if it doesn't work, then come back and explain what you tried. You really haven't given enough information to help you. CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
depends.
If you're writing in a textbox or richtextbox there's a property that will do that for you.
If you want to open a bunch of text in notepad eg and you want it wrapped you can insert cairrage returns/ line feeds.
You'll have to insert those at a certain amount of characters (80 or 120 would be good)
So in pseudocode it would be like this.
chunckof_X_chars1 + Environment.NewLine + chunckof_Xchars2 + Environment.NewLine + etc...
(You should put that in a loop or something)
To be absolutely correct you should insert your crlf after the last space in the string of X chars in order to keep the words together.
This should get you going.V.
|
|
|
|
|
You can refer to the following code,it can help you.
WebRequest req = null;
WebResponse rsp = null;
try
{
string fileName = "C:\test.xml";
string uri = "http://localhost/PostXml/Default.aspx";
req = WebRequest.Create(uri);
//req.Proxy = WebProxy.GetDefaultProxy(); // Enable if using proxy
req.Method = "POST"; // Post method
req.ContentType = "text/xml"; // content type
// Wrap the request stream with a text-based writer
StreamWriter writer = new StreamWriter(req.GetRequestStream());
// Write the xml text into the stream
writer.WriteLine(this.GetTextFromXMLFile(fileName));
writer.Close();
// Send the data to the webserver
rsp = req.GetResponse();
}
catch(WebException webEx)
{
}
catch(Exception ex)
{
}
finally
{
if(req != null) req.GetRequestStream().Close();
if(rsp != null) rsp.GetResponseStream().Close();
}Function to read xml data from local system
///
/// Read xml data from file
///
/// <param name="file" />
/// <returns>returns file content in xml string format
private string GetTextFromXMLFile(string file)
{
StreamReader reader = new StreamReader(file);
string ret = reader.ReadToEnd();
reader.Close();
return ret;
}
modified 27-May-14 4:54am.
|
|
|
|
|
Was wondering if anyone knows of a workaround for the annoying memory leak in SpeechSynthesizer.
|
|
|
|
|
Don't use it?
Seriously, you're going to have to provide a link to the problem you're talking about, and there's more than one SpeechSynthesizer running around...
|
|
|
|
|
|
FocusedWolf wrote: Sorry i thought everyone knew about this
I do. But since Microsoft isn't the only vendor for speech synthesis software, I like to make sure which library we're talking about.
FocusedWolf wrote: To summarize the effect, the more words that the SpeechSynthesizer .net framework object has to read, the more megabytes of memory it consumes. It's not long before it's soaking up a few hundred mb. First effect, which sets on rather quickly, is the reader gets slower and slower.
I have tried various hacky attempts to dispose and create new objects, but it wasn't 100% successful (besides introduces a noticeable delay). This is from the first link:
I didn't use the code you linked to, but I wrote my own app and couldn't come up with a memory leak. I'm assuming the code you linked to is yours. It's written kind of funny. I'd skip destroying and creating a new synth every time you want to say something and go back to creating a single synth object you can use at any time. I'm not seeing the problem you're talking about in my code and can't find any reference to any kind of memory leak anywhere on the web.
|
|
|
|
|
No i didn't write that code... it's just a random google result from searching for other people experiencing this problem.
Anyway recently i changed the code to just use the class the way people would expect to use it (i.e. no hacky tricks to fight the memory leak) and the memory consumption was about 400 kb/s.
Some things you can try to see the effect is give the reader a few pages of words to read, and set the Rate property to some number like 7 or 10. Subscribing to these events may also be a factor (SpeakCompleted and SpeakProgress).
I've noticed that if i just let the program go then it will get to the point of holding about 40-50 mb of ram where it almost stops allocating, and a few minutes later it will get a few more mb. So i'm wondering if this is a true memory leak or by design (i.e. if it has to read a lot then it allocates all this memory). However one thing i notice is when it finished reading, it doesn't flush the memory because the program is still holding onto 46 mb.
|
|
|
|
|
If you're looking at this "used" in TaskManager, don't. Use Performance Monitor instead.
Task Manager is howing you what the .NET CLR has reserved for your app, not what your app is actually using.
|
|
|
|
|
I am actually the one who wrote the code linked to on StackOverflow. If you read the notes on this post you will see that i originally wrote the code so that it only used one instance of the SpeechSynthesizer object.
This memory leak is very much a problem with the Speak or SpeakAsync method making the System.Speech object unusable in ANY project. If you run the code you will see it will QUICKLY cause Windows 7.0 (couple hours) to crash, and will cause Vista to crash after about 20 hours.
I have both versions of the code linked here in a forum post on the MSDN site.
http://social.msdn.microsoft.com/Forums/en-US/Offtopic/thread/ee7bd34f-20c2-4a75-9d5a-a0c5e7f1a9b2[^]
|
|
|
|
|
In a forms-based application, I would like to synchronize two RichTextBox controls so that one without a vertical scroll bar will scroll in synch with the other one (which has a vertical scroll bar). I.e., I want to be able to scroll both controls with one scroll bar.
Thanks for any suggestions,
Tom
P.S. I saw Karin Huber's article, but this is for WPF and Silverlight.
|
|
|
|
|
You can build a user control (or custom control), and handle the scroll event in another RichTextBox.
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 8:48am.
|
|
|
|
|
|
Hello,
How do I bin and zero fill excel data in both C# and excel? For example below is a list of data. I want to bin the data as integers
120.337
121.041
124.111
So the above should be. I want to say 0 of the date is not between a certain range as shown below
120-121= 120.337
121-122 =121.041
122-123 = 0
123-124 = 0
124-125 =124.111
|
|
|
|
|
Not sure what you mean but maybe something like this?
float RangeCheck(int lower, int upper, float value)
{
return ((value >= lower) && (value <= upper)) ? value : 0;
}
|
|
|
|
|
to make mass data entry easier so i can put my add form over the top of my excel sheet that contains the data i wish to enter. Is there a way to do the following without it minimizing both.
I understand the whole parent/child relationship of the forms but i was wondering if i could somehow do this because I have noticed programs like yahoo and so forth allow one form to be minimized while the other is maximized. Anyway here is what I'm trying...
private void Add_Button_Click(object sender, EventArgs e)
{
AddRecord addRecordForm = new AddRecord();
addRecordForm.Owner = this;
this.WindowState = FormWindowState.Minimized;
addRecordForm.ShowDialog(this);
this.WindowState = FormWindowState.Normal;
LoadData();
}
it minimizes but they both minimize instead of only the parent minimizing. i even tried putting in the constructor of the addrecord this.windowstate = formwindowstate.normal; and that had no effect.
|
|
|
|
|
I have tried compile example into .NET 2.0/3.0/3.5. I am using Windows 7 and didn't encounter your problem.
Did you accedently changed windowstato of your AddRecord Form?
|
|
|
|
|
tonyonlinux wrote: addRecordForm.Owner = this;
this.WindowState = FormWindowState.Minimized;
tonyonlinux wrote: it minimizes but they both minimize instead of only the parent minimizing
Does it really? Have you read the documentation[^]. Which is what you always should do when running into a problem.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
here's a working example:
In the Main form/container, on the add click do something like this:
this.WindowState = FormWindowState.Minimized;
this.ShowInTaskbar = false;
Form2 f = new Form2();
f.Owner = this;
f.Show();
and on the LoadDataForm on the form closing event do something like this:
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
this.Owner.ShowInTaskbar = true;
this.Owner.WindowState = FormWindowState.Normal;
}
|
|
|
|
|
|
i was wondering something since the documentation states if the parent minimizes so does the child. (this was really my original question) because i had read this in the documentation BEFORE asking. is it possible to make the add form an owner of itself? i tried and it said I can't. Basically what I'm trying to achieve all of the parent/child stuff asside is the following. I guess what i want is the form to not be a child but simply another parent (per say).
I'm trying to make it where when i click on the addbutton up pops the addrecord form. and the main form minimizes. as documented and seen and so forth both will minimize. sure i can go down there and click on the thing to open it back up since the mainform is hidden until close(that part i like) but i want the child form return to normal state. is there some kinda method that you can use on the form like you do controls as form1.visible = false or hidden = true or something like that then change that on the form2 closeevent ?
|
|
|
|
|
sure you can trick the owner.
But a better solution is to not own the dataform. Something like:
private btn1Click(object sender, EventArgs e){
this.Hide();
DataForm df = new DataForm();
df.ShowDialog();
this.Show();
}
|
|
|
|
|
can a visual c# project connect to a remote mysql database and execute sql statements but w/out using mysql connector/net?
thanks in advance!
oh,and not just a yes/no answer...doh doh doh... if yes,how can you do it or if not, what is the simplest way of using mysql connector??
|
|
|
|
|
I'm not sure if you can do it without a MySQL connector, but using one is not that tough...
Download the MySQL data connector dll[^]. Register it in your project. Do something like below...
DataTable customerTable = new DataTable();
using (MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection("server=serverName;uid=userID;pwd=password;database=databaseName"))
{
string validationQuery = "SELECT * FROM Table WHERE Contact_ID = '" + actNumber + "';";
MySql.Data.MySqlClient.MySqlDataAdapter odda = new MySql.Data.MySqlClient.MySqlDataAdapter(validationQuery, conn);
odda.Fill(customerTable);
}
Hogan
|
|
|
|