|
arsendem wrote: Hi
Uh... yeah... Hi.Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
i'm trying to understand the usage of settings.setting file, it says u can only change user scoped data at runtime and application scoped data cannot be changed at runtime, to modify the application scope data i have to use the assembly.exe.cofig file . but in my application it isn't there . how can i create it
|
|
|
|
|
|
Hi,
You can right-click on your project (from the solution explorer) and choose Add-->New Item and select Application Configuration File from the dialog box that pops up and click OK. This will add an App.Config file to your project. This will be automatically renamed to Assembly.exe.config when you run your application.
You can use the same XML data as given in the link to the post that d@nish had posted.
Also, if you use
string test1 = System.Configuration.ConfigurationSettings.AppSettings["Key1"];
in your code, the VS compiler might throw a warning that this is deprecated.
To get through that warning, Add reference to System.Configuration component in your project and use :
string test1 = System.Configuration.ConfigurationManager.AppSettings["key1"];
Hope this helps.
Thanks,
Ram
|
|
|
|
|
HI,
I would like to make a small C # application with the overlay video. Can someone help me with a small example?
Thank you!
|
|
|
|
|
|
An event calls method A in some cases and method B in others.
Both A and B return a string.
The event handler returns void.
How do I write the return value from the right method to a textbox in my main Window?
|
|
|
|
|
What event? Where is it called from? It would help if you showed something a little more concrete.
public void SomeEvent(object sender, EventArgs e)
{
if(whatever)
textbox1.Text = MethodA();
else
textbox1.Text = MethodB();
} I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thank you for your fast reply.
Ok here's some code. I'm still learning so you may find this utterly simple
In my main window the event gets called:
private void button1_Click(object sender, RoutedEventArgs e)
{
BallEventArgs bEventArgs = new BallEventArgs(Convert.ToInt16(textBox1.Text), Convert.ToInt16(textBox2.Text));
ball.OnBallInPlay(bEventArgs);
}
Then there's e.g. a pitcher class that subscribes to the ball event being raised
public Fan(Ball b)
{
b.BallInPlay += new EventHandler(b_BallInPlay);
}
void b_BallInPlay(object sender, EventArgs e)
{
if (e is BallEventArgs)
{
BallEventArgs bea = e as BallEventArgs;
if (bea.Distance > 400 && bea.Trajectory >30)
{
Homerun();
}
else
{
Cheer();
}
}
Both Homerun and Cheer return a string. It 's that string that I want to display in a textbox called tbOutput in my Window1.
My problem: I can't seem to access the tbOutput textbox from the Homerun and Cheer methods, because tbOutput is private in Window1.
I don't have a clue...
|
|
|
|
|
You should really have asked this in the WPF forum, as WPF experts are more likely to see it there. Anyway, the simple thing to do here is to have a public property that raises a PropertyChanged event (in other words, the class implements the INotifyPropertyChanged interface). Set the DataContext of your view to this instance, and then bind the Text property of your textbox to the property. That should see you done (strictly speaking, you should look into MVVM for this, but that might be too much for you right now)."WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I see no reason for the BallInPlay event. An event is used when you want to be notified by the object that something has happened (Observer pattern). In this case it appears all you want to do is check a result, so just call a method.
private void button1_Click(object sender, RoutedEventArgs e)
{
Pitcher p = new Pitcher();
textbox.text = p.BallInPlay(Convert.ToInt16(textBox1.Text),
Convert.ToInt16 (textBox2.Text));
}
public class Pitcher
{
public string BallInPlay(int distance, int tragetroy)
{
if (distance > 400 && trajectory > 30)
{
return Homerun();
}
else
{
return Cheer();
}
}
} I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi,
How can I check if 5 minutes have passed with the datetime object?
I've tried a few things, but none of them worked for me.
Thanks in advance!
|
|
|
|
|
How do you do it as a human being, without computer? Substitute wrist watch for System.DateTime.Now
|
|
|
|
|
I know how... But obviously, I'm doing something wrong.
So I thought another developer could help me out here...
|
|
|
|
|
If you know how to do it, and have tried to get something working, but failed, then tell us about it, describe the concept and implementation, give precise symptoms, and show code if and as needed. Such are the rules of these forums.
|
|
|
|
|
I pass 5 min to this function:
DateTime lastTimeCommandWasUsed = DateTime.MaxValue;
private bool AtLeastXMinutesHavePassed(int xMinutes)
{
DateTime currentTime = DateTime.Now;
bool allowUse = false;
if (lastTimeCommandWasUsed == DateTime.MaxValue)
{
allowUse = true;
}
else
{
TimeSpan elapsedTime = currentTime - lastTimeCommandWasUsed;
allowUse = elapsedTime.TotalMinutes > xMinutes;
}
if (allowUse)
{
lastTimeCommandWasUsed = currentTime;
return true;
}
return false;
}
And it returns very fast 'false'. After debugging it, it seems to check for seconds instead of minutes.
Can't figure out what is going wrong.
|
|
|
|
|
Yustme wrote: it returns very fast
of course it does, there are no loops, no delays, it is just a few statements in a straight line, so it returns "immediately".
Yustme wrote: And it returns ... 'false'
I doubt that.
Yustme wrote: it seems to check for seconds
No way.
I suggest you add logging statements to output the value of relevant variables. Example:
Console.WriteLine("now="+currentTime);
Console.WriteLine("last="+lastTimeCommandWasUsed );
FWIW: unrelated to potential problems, your code would be somewhat simpler if you initialized using MinValue instead of MaxValue!
|
|
|
|
|
I think you miss understood my 'very fast'. Instead of 5 min, 5 sec.
this is the loop, which is not in that function:
private void RestartAfterXMin()<br />
{<br />
<br />
while (this.AtLeastXMinutesHavePassed(5))<br />
{<br />
Thread.Sleep(1000);<br />
<br />
if (this.stopRequested)<br />
return;<br />
}<br />
<br />
this.AutoStop();<br />
Application.Restart();<br />
}
It's initialized with minvalue, nothing changed.
|
|
|
|
|
I suggested to add logging statements and debug.
And I told you MinValue was unrelated to the bug, but would allow for simpler code.
Now solve your problem, don't wait to be spoon fed.
|
|
|
|
|
[quote]
I suggested to add logging statements and debug.
[/quote]
How different would that be when I used the debugger?
[quote]
And I told you MinValue was unrelated to the bug, but would allow for simpler code.
[/quote]
I still expected that something would change, not that it would solve the bug.
[quote]
Now solve your problem, don't wait to be spoon fed.
[/quote]
I could say that programming isn't like boxing, where you tell me a few words like 'you can take him down, you're stronger' while i know i'll get my ass wooped by this guy called Muhammed Ali (hypothetically, i'm fighting him in the ring)..
Instead, you know, a few posts back you pointed me out that there is a quideline for asking questions.
Did you know there is one for 'answering questions' too?
A small quote from that guideline:
[quote]
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid..
[/quote]
I'm not asking someone to do my work, pointing me in the right direction is more the enough!
|
|
|
|
|
Yustme wrote: How different would that be when I used the debugger?
Logging leaves a trail which makes it easier to spot a pattern, it shows the results automatically for each consecutive run, and it takes virtually no time, whereas using the debugger requires manual intervention and costs seconds per operation, which in a time-related problem often isn't very wise.
Yustme wrote: pointing me in the right direction is more the enough
that is what you got.
|
|
|
|
|
Why not just use a timer?
Set one up so it triggers in 600 seconds, and use the event to set a flag?
Andy
|
|
|
|
|
Your code will never calculate what you want here.
Only for the first time this command is run, the lastTimeCommandWasUsed will be equal to DateTime.MaxValue . hence allowUse is set to true and lastTimeCommandWasUsed is assigned to currentTime .
Now, when you run this command for the second time,
first condition: if (lastTimeCommandWasUsed == DateTime.MaxValue) is false. Hence allowUse is false still.
This the second condition is false too. Hence you get false back.
there is no place where you are returning the value that you seek.
just make one change here. instead of returning false, return "allowUse"
|
|
|
|
|
I run into a little problem I'm not too sure how to get around.
Let's say I have this grammar xml:
<GRAMMAR LANGID="409">
<DEFINE>
<ID NAME="RID_A" VAL="0"></ID>
<ID NAME="RID_B" VAL="1"></ID>
<ID NAME="RID_C" VAL="2"></ID>
<ID NAME="RID_D" VAL="3"></ID>
<ID NAME="RID_E" VAL="8"></ID>
</DEFINE>
<RULE NAME="A" ID="RID_A" TOPLEVEL="ACTIVE">
<P>something</P>
</RULE>
<RULE NAME="B" ID="RID_B" TOPLEVEL="ACTIVE">
<P>go</P>
<P>
<RULEREF REFID="RID_C" />
</P>
</RULE>
<RULE NAME="C" ID="RID_C">
<L PROPID="RID_C">
<P VAL="RID_D">left</P>
<P VAL="RID_E">right</P>
</L>
</RULE>
</GRAMMAR>
So basically, there are 3 commands, "something", "go left", "go right".
Whenever something gets recognized this gets called:
public void RecoContext_Recognition(int StreamNumber, object StreamPosition, SpeechRecognitionType RecognitionType, ISpeechRecoResult e)
Inside of it I'm using a switch switch (e.PhraseInfo.Rule.Name) . For the rules similar to the "something" command, a simple case "A": is all I need.
My issue comes now. For the "go left" or "go right", the case "B": catches them. However, I have no idea how to determine the 'right' or 'left' part of it.
Ideally, this is what I'm looking for.
[ create ] -> one | two | three -> monkeys | elephants | puppies.
Obviously not those examples, but something that follows that path. Can I accomplish that with the sample XML I provided and the switch in the function? Or do I need a different approach?
|
|
|
|
|
is there any body who knows how to implement hand gesture recognition using haarlike features.
I am using AForge.net for image processing.
thanks
|
|
|
|