|
Use the return statement
--------------------------------------------------------
My portfolio & development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
if(Condition is true)
{
e.handle=true;
return ;
}
sameer
|
|
|
|
|
Please help me,
I have a final year project on Audio Video Logging System.
I basically want to do some motion detection, for which i have got some articles from CodeProject.com... this is the only small part of my Project
A big issue is that i want to do indexing on Video ie i want to do "Content Base Retrivel of Audio & Vedio Data"..
I have a server which always capturing Video in a office room, say, and store it in a database.... now if i want to do query on thoes store video, How can i do it.... Please help me.....
Any suggesstion will be appreciated.....
aLi
|
|
|
|
|
first we need to know how they are stored
It is Good to be Important but!
it is more Important to be Good
|
|
|
|
|
Hi,
How can i randomly add text in 50 labels at once instead of one at the time?
The labels are called:
label1
label2
label3
......
......
label50
Thanks in advance!
|
|
|
|
|
Wow, 50 labels, that must be one big form
Anyway, this should work:
<br />
foreach(Control label in this.Controls)<br />
{<br />
if(label.GetType().ToString() == "System.Windows.Forms.Label")<br />
{<br />
label.Text = "Hello";<br />
}<br />
}<br />
|
|
|
|
|
Hi The Undefeated,
Thank you very much for your reply!
Its going to be a calculation application for the kids
Instead of "Hello" how can i randomly give it sums like this:
2+6=
5+4=
....
....
Thanks in advance!
|
|
|
|
|
Hmm, you could do this then:
<br />
Random rnd = new Random();<br />
<br />
foreach(Control label in this.Controls)<br />
{<br />
if(label.GetType().ToString() == "System.Windows.Forms.Label")<br />
{<br />
label.Text = rnd.Next(0, 20) + " + " + rnd.Next(0, 20) + " =";<br />
}<br />
}<br />
on the rnd.Next part, you have to set the minimum and maximum values (in this case 0 and 20)
If you wanted to include minus questions to could do this:
Random rnd = new Random();<br />
Random sign = new Random();<br />
<br />
foreach(Control label in this.Controls)<br />
{<br />
switch(sign.Next(0, 2).ToString())<br />
{<br />
case "0": <br />
if(label.GetType().ToString() == "System.Windows.Forms.Label")<br />
{<br />
label.Text = rnd.Next(0, 20) + " + " + rnd.Next(0, 20) + " =";<br />
}<br />
break;<br />
<br />
case "1":<br />
if(label.GetType().ToString() == "System.Windows.Forms.Label")<br />
{<br />
int large = rnd.Next(1, 20); <br />
int small = rnd.Next(0, 20);<br />
while(large < small)
{<br />
small = rnd.Next(0, 20);<br />
}<br />
<br />
label.Text = large + " - " + small + " =";<br />
}<br />
break;<br />
}<br />
}
And use a switch to change between + or -
-- modified at 9:30 Sunday 15th October, 2006
|
|
|
|
|
Hi,
Thank you for your reply!
The 0, 20 has to be random aswel. This is what i had in mind to do it:
int number1;
int number2;
int answer;
answer = number1 + number2;
The answer is a number which the application will get from a textbox. The user will give up a maximum number in the textbox.
Suppose the user types 100, than number1 + number2 = can never cross the 100.
Thanks in advance!
|
|
|
|
|
The (0, 20) cannot be random, and if it was it would be pointless.
int n1 = rnd.Next(0, 51);
int n2 = rnd.Next(0, 51);
n1+n2 would never be greater than 100, and the lowest would be 0, but the answer could be anything inbetween.
As for storing the answerm you can put it in the tag, and check it later
Random rnd = new Random();<br />
<br />
foreach(Control label in this.Controls)<br />
{<br />
if(label.GetType().ToString() == "System.Windows.Forms.Label")<br />
{<br />
int n1 = rnd.Next(0, 20);<br />
int n2 = rnd.Next(0, 20);<br />
int answer = n1+n2;<br />
<br />
label.Tag = answer;<br />
label.Text = n1 + " + " + n2 + " =";<br />
}<br />
}<br />
You'd have to make sure that each text box was referencing the right label though, if you keep all the default names the textBox1 should reference label1
To get the answer back to check it simply:
int answer = (int)label1.Tag;
|
|
|
|
|
Hi The Undefeated,
Thanks for your reply!
I'll just make a few extra variables than
Thanks for your time and help The Undefeated!!!!!
|
|
|
|
|
The Undefeated,
How do i reference the textbox to the right labels?
|
|
|
|
|
The Undefeated wrote:
foreach(Control label in this.Controls)
{
if(label.GetType().ToString() == "System.Windows.Forms.Label")
{
label.Text = "Hello";
}
}
I recommend not to use a string comparison to determine the type of an object. Use typeof() instead.
foreach(Control label in this.Controls)
{
if( label.GetType() == typeof( System.Windows.Forms.Label ) )
{
label.Text = "Hello";
}
}
Regards,
Tim
|
|
|
|
|
Hi Tim,
Thanks for your reply!
I've changed that in to:
if(label is Label)
Regards,
Yustme
|
|
|
|
|
I'm just trying to send a string to another PC, i got my IP, set up the stuff, and it didn't work. Then i realised that im on a router so the IP address is actually wrong
So, i can only think of two things, sending it to the MAC address, or getting some other IP for the computer.
I know quite a bit about computers, but my knowledge of networking is err, lacking... so im not exactly sure what to do.
Thanks in advance, i'll keep searching.
EDIT: My IP is '192.168.1.3' - but of course, that will only work for computers connected to my router won't it? (Its also subject to change)
-- modified at 8:30 Sunday 15th October, 2006
|
|
|
|
|
I doesn't matter what Your IP is, nor that it is on a private network. You need to send to the IP of the OTHER computer. The router's IP should be your computers gateway address, then the router will route the message correctly.
We need to graduate from the ridiculous notion that greed is some kind of elixir for capitalism - it's the downfall of capitalism. Self-interest, maybe, but self-interest run amok does not serve anyone. The core value of conscious capitalism is enlightened self-interest.
Patricia Aburdene
|
|
|
|
|
Aww, im still confused, or at least somebody is.
My computer, and the computer downstairs, both have the same IP (when checked at whatsmyip.org or whatever) except for the IP on the network, downstairs has 192.168.1.2 because it connected before i did.
So if i wanted to send something to that, what would i put? (Well I could put in the IP on our network, but what if i was somewhere else completely?)
|
|
|
|
|
Hello
Just as a guidline, use System.Net.NetworkInformation namespace, and use IPGlobalProperties.GetActiveTcpConnections() to get the activve Tcp/Ip connections. Now foreach connection use Dns.Resolve() to get the Hostname, and compare it with the computer's name of the other computer.
Regards
|
|
|
|
|
Greetings,
I just need to have a progressbar that updates from a seperate thread that acts as a timer to show a countdown to refresh, and then refresh a datagrid with data, how would i make thread safe calls to the progressbar? because at debug i receive the exception
Message="Cross-thread operation not valid: Control 'pbarAutoRefresh' accessed from a thread other than the thread it was created on."
i have searched all over, some of the examples i've seen have delegates, if i need to create a delegate for the progressbar class what would the delegate class be?
Thanks in advance.
|
|
|
|
|
For void methods without any parameters you can use System.Windows.Forms.MethodInvoker :
pbarAutoRefresh.Invoke(new MethodInvoker(pbarAutoRefresh.PerformStep));
____________________________________
There is no proof for this sentence.
|
|
|
|
|
Thank you, working now
|
|
|
|
|
Hi,
I am trying to use XML file as an config file. The structure of the xml file is quite simple. It needs to have only
5 fields. This file stores information about 3 websites - so ideally structure should be like
<root>
<config>
<website 1="">
<url>test
<delay>23
<username>23
<password>32423
<website 2="">
<url>test
<delay>23
<username>23
<password>32423
I am using following code to create this Xml schema and xml file - but having some trouble (which i don't know WHY -
and I seek your guidence...)
public void create_Config_Table(string service_name, string url, string delay,
string freq, string username, string password)
{
string filename = "config.xml";
FileStream fs;
XmlTextWriter xtw;
XmlTextReader xtr;
string msg = "";
//create the table and then populate it
DataTable ret = new DataTable(service_name);
//Create the DataSet
DataSet ds = new DataSet("AutoMessage");
//first check if config.xml exists or not
//If it already exists then we don't have to recreate the XML schema for it
if( ! File.Exists(filename) )
{
//ret.Columns.Add("Service", Type.GetType("System.String"));
ret.Columns.Add("URL",Type.GetType("System.String"));
ret.Columns.Add("Delay", Type.GetType("System.String"));
ret.Columns.Add("Frequency",Type.GetType("System.String"));
ret.Columns.Add("Username",Type.GetType("System.String"));
ret.Columns.Add("Password",Type.GetType("System.String"));
//Now populate the data table
DataRow row = ret.NewRow();
//row["Service"] = service_name;
row["URL"] = url;
row["Delay"] = delay;
row["Frequency"] = freq;
row["Username"] = username;
row["Password"] = password;
ret.Rows.Add(row);
ds.Tables.Add(ret);
msg = "Config File Created";
}
else
{
//Read the XML File
try
{
fs = new FileStream(filename, FileMode.Open);
xtr = new XmlTextReader(fs);
ds.ReadXml(xtr);
xtr.Close();
DataTable dt = ds.Tables[0];
DataRow row = dt.NewRow();
//row["Service"] = service_name;
row["URL"] = url;
row["Delay"] = delay;
row["Frequency"] = freq;
row["Username"] = username;
row["Password"] = password;
dt.Rows.Add(row);
ds.Tables.Remove(ds.Tables[0].TableName);
ds.Tables.Add(dt);
msg = "Config File Updated";
}
catch(Exception ex) { Console.Error.WriteLine(ex.ToString() ) ; }
fs = null;
}
try
{
fs= new FileStream(filename, FileMode.Append,FileAccess.Write);
xtw = new XmlTextWriter(fs, System.Text.Encoding.Unicode);
ds.WriteXml(xtw);
xtw.Close();
Console.Write(msg);
}
catch(Exception ex) { Console.Error.WriteLine(ex.ToString() ); }
}
Logic here is that if file doesn't exists - it will create the xml schema and the xml file
if it does EXISTS - then it is read into an dataset - new values are appeneded to contents of this dataset it is
written back as a xml file.
- Major problem is that it creates a mal-formed XML (multiple root elements)
-- Any Suggestions
THanx in advance
|
|
|
|
|
Looks like your getting multiple rootelements due to appending of file insteaded of edititing existing xmlstructure.
I've found XmlDocument to be a nice way of modifying xmlstructures.
<br />
public void create_Config_Table(string service_name, string url, string delay, string freq, string username, string password)<br />
{<br />
XmlDocument doc = new XmlDocument();<br />
<br />
if(!File.Exists(_filename))<br />
doc.LoadXml("<'rootname'><\'rootname'>");<br />
else<br />
{<br />
try<br />
{<br />
doc.Load(_filename);<br />
}<br />
catch(Exception ex)<br />
{<br />
Console.Error.WriteLine(ex.ToString());<br />
doc.LoadXml("<'rootname'><\'rootname'>");<br />
}<br />
}<br />
<br />
XmlNode rootNode = doc.DocumentElement;<br />
<br />
rootNode.AppendChild(createTestNode(doc, url, delay, freq, username, password));<br />
<br />
doc.Save(_filename);<br />
}<br />
<br />
<br />
XmlNode createTestNode(XmlDocument doc, string url, string delay, string freq, string username, string password)<br />
{<br />
XmlNode test_node = doc.CreateElement("test");<br />
<br />
XmlNode urlNode = doc.CreateElement("url");<br />
urlNode.InnerText = url;<br />
<br />
XmlNode delayNode = doc.CreateElement("delay");<br />
delayNode.InnerText = delay;<br />
<br />
XmlNode freqNode = doc.CreateElement("freq");<br />
freqNode.InnerText = freq;<br />
<br />
XmlNode usernameNode = doc.CreateElement("username");<br />
usernameNode.InnerText = username;<br />
<br />
XmlNode passwordNode = doc.CreateElement("password");<br />
passwordNode.InnerText = password;<br />
<br />
test_node.AppendChild(urlNode);<br />
test_node.AppendChild(delayNode);<br />
test_node.AppendChild(freqNode);<br />
test_node.AppendChild(usernameNode);<br />
test_node.AppendChild(passwordNode);<br />
<br />
return test_node;<br />
}<br />
Hope this might help you out or make the xmlparsing a bit easier
-Larantz-
for those about to code, we salute you
http://www.tellus-software.com
|
|
|
|
|
I'm having to work around with pinvoke but i´m having difficults in finding a good way to see a list of prototypes procedures in a win32 dll file. I have tried to work around with link.exe (same as dumplbi.exe) but they are not good enough.
Does anyone know a good site that describes the main windows dlls functions, such as kernel and user32?
|
|
|
|
|
MSDN[^] contains documentation for all API functions.
The easiest way to find the signature of a specific method is to google for "msdn" and the methods's name, i.e
"msdn CreateWindowEx[^]".
____________________________________
There is no proof for this sentence.
|
|
|
|
|