|
I have an application where a customers may want to restrict access to specific features so I want to have some kind of user database to control access.
Now using this 'Login' is optional, the customers may not require/want to restrict access, so there is an option to 'show the login screen' (or not).
The idea I had was, if the users do not login using the login screen, there is another option which can restrict the users access because the app logs them in as an 'anonymous' user if the login is not used and privelages can be assigned to the anonymous user.
Now it appeared that as this is a windows forms app, the normal start-up form named 'MainForm' was not what I needed. I needed some kind of loop so that the login was shown (if required) and the main form was shown only if a valid user was logged in (this incudes anonymous).
I rigged up a couple of test applications and have come up with the following sample code:
private static void Start()
{
MainMenu mainMenu = new MainMenu();
Login login = new Login();
Config.load();
ShowLogin = Config.LoginRequired;
while ( !Shutdown )
{
if ( ShowLogin )
{
login.ShowDialog();
} else {
UserName = "Anonymous";
}
if ( !Shutdown && UserName != null )
{
mainMenu.ShowDialog();
}
}
}
[STAThread]
public static void Main(string[] args)
{
Application.Start();
System.Windows.Forms.Application.Run();
}
Now, as you can see, by using Application.Run() I don't start the app by loading a form.
Its the Start method of my Application class which actually decides what should be shown.
Now what I don't like is:
1) I have to use System.Windows.Forms.Application.Exit(); in my main menu and login form if I want to exit the app.
2) Its not very Object Oriented code, it is very procedural in style.
My questions are:
Is there a better way, perhaps more Object Oriented?
Is it good practice to start and end an application in this manor?
As always, your thoughts/comments are appreciated.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
Hi folks
I have recently upgraded to Visual Studio 2005 and am horrified by the speed at which the UI appears to respond on a reasonable spec machine, even on small solutions.
Does anyone have any tips & tricks to get it to respond better.
Cheers
Rich
|
|
|
|
|
I agree and I have 1 GB RAM. If you find any tips let me know! The Tool Windows are particularly slow, as is Help.
Maybe SP1 will improve things?
Kevin
|
|
|
|
|
Imagine my shock! Microsoft conspiring with the hardware manufacturers to keep you locked into the "upgrade cycle". Add extra computer cycles, a little unecessary disk access. Hey, you can only speculate until an insider whistleblows about it. It is like how VSStudio help has inexplicably slow access. It is to encourage you to access online so Microsoft can profile usage. I would not be surprised if hardware manufacturers, such as USB memory manufacturers, included firmware in their products that would causes the hardware to "fail" sometime after the warranty period.
|
|
|
|
|
Unfortunately, VS 2005 does run slower than VS 2003 (and VS 6.) I have found no way to improve this except to get a faster computer. I believe this is largely due to more extensive use of .NET in the UI and lack of time to do much of the performance tweaking it required. I am hoping SP1 fixes at least some of this.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hi,
I'm trying to create a report using Crystal Reports in VS.NET 2005 without explicitly creating a dataset at design time. Say... my dataset is created at runtime. Its contents depend on what a user specifies - different options, different datasets. What I'm trying to do is to link a blank report (created at design time) with the dataset (created at runtime). Is there anyway to do so?
One more problem is if somehow the previous problem is solved, how can i design the report? (since there's no dataset at design time, so nothing to design).
Thank you very much.
KiT
|
|
|
|
|
For designing the report you can use an xml as the schema.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/crystlmn/html/crconreportdataaccess.asp
As for the first part of your question, if i am not understanding it wrongly, do you mean that that single report will going to show data with different schema base on user selecting the options? I wouldn't suggest you to do that. You should have different reports for each option, and generate the report according to the user's selection.
|
|
|
|
|
I have a problem when using richtextbox. I use richtextbox to display the content of a file. In the richtetxtbox, it automatically inserts a space in the first word. For example, in my file " Doctor John is very kind". And in my richtextbox "D octor John is very kind". Why do I meet this problem and how can I overcome this problem?
Thanks a lot.
|
|
|
|
|
What type of file are you trying to load, and which richTextBoxStreamType are you using?
|
|
|
|
|
here is my function to load the file
void OpenFile()
{
openFileDlg.DefaultExt = "*.txt";
openFileDlg.Filter = "Text Files|*.txt";
if(openFileDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
openFileDlg.FileName.Length > 0)
{
rtxt.LoadFile(openFileDlg.FileName, RichTextBoxStreamType.UnicodePlainText);
}
}
|
|
|
|
|
Load it as PlainText instead of UnicodePlainText
This should solve your problem
James
|
|
|
|
|
I know that if I used PlainText, this problem wouldn't happen. But I have to use UnicodePlainText because my file is Vietnamese, it needs font Unicode.
|
|
|
|
|
Hello all,
I'm trying to create an EventHandler delegate from a MethodInfo object. When I call Delegate.CreateDelegate and pass it the EventHandler type and my MethodInfo object, I get the following error.
Error Binding to Target Method
Now, the signature of the method I am attempting to bind is of the correct type (it will allow me to bind to it directly as an EventHandler), but I can't get it working using MethodInfo.
Does anyone have any ideas? This is driving me nuts.
Will
|
|
|
|
|
i made an edge detection to a face and i want to fill the region inside the edges with white color in order to obtain the face from the original picture to this face.......can any one tell me how to fill the entire region of the edges with the white color?
i made a face detection before using the skin color detection but the results wasn't satisfy so i decided to try this algorithm and i wish to success
haitham
|
|
|
|
|
If you have a point inside the region and can be sure the edges don't have any gaps, you should start reading into flood filling algorithms.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
|
which algorithm do u prefer?
1-skin detection but the brightness inside the picture will be harmful in the segmentation(i can adjust the environment while taking pictures)
2-this algorithm but i don't have experience with gaps through the edges....but this algorithm will give the full face and the lightness will not affect as in the first choice
haitham
|
|
|
|
|
I have a form with 2 controls a textbox and a button.When i press the button i'd like it says the text in the textbox.It likes text to speech of Microsoft.How to do it?
|
|
|
|
|
Hi,
Ok, according to my knowledge, you have two choices, one is using SAPI class, another is using Microsoft Agent. Microsoft Agent is more tempting and attractive, but in order to explain easily, I am showing you using SAPI way.
Add reference from COM tab: Microsoft Speech Object library
then use these statements at the top of your class,
using SpeechLib;
using System.Threading;
Then use background Worker named "backgroundWorkerLetterTalker" , You can proceed without background worker but then your controls will be held frozen until speak method is finished.
Say your speak button name is "btnSpeakLetter"
and textbox name is "bodyRichTextBox"
Add event handler for Background worker DoWork named "speakLetter"
Add event handler for background worker Completed named "skeapLetter_Completed"
Add event handler for button btnSpeakLetter named "btnSpeakLetter_Click"
Now add these following code
// ///////////////////////////// SPEAK Method // //////////////////////////////////////
private void btnSpeakLetter_Click(object sender, EventArgs e)
{
btnSpeakLetter.Enabled = false;
backgroundWorkerLetterTalker.RunWorkerAsync(bodyRichTextBox.Text);
}
private void speakLetter(object sender, DoWorkEventArgs e)
{
string arg = (string)e.Argument;
SpVoice objSpeech = new SpVoice();
objSpeech.Speak(arg, SpeechVoiceSpeakFlags.SVSFlagsAsync);
objSpeech.WaitUntilDone(Timeout.Infinite);
}
private void skeapLetter_Completed(object sender, RunWorkerCompletedEventArgs e)
{
btnSpeakLetter.Enabled = true;
}
// ///////////////////////////////////////// X ///////////////////////////////////////
Nicely working in .NET 2.0 C# Express 2005. I did not test in the previous version.
EMRAN
-- modified at 8:12 Saturday 25th February, 2006
|
|
|
|
|
I used
using SpeechLib;
using System.Threading;
and copy your code but when i debug it generated an error.It does not understand DoWorkEventArgs and RunWorkerCompletedEventArgs.By the way could you tell me which class that the object backgroundWorkerLetterTalker belongs to?How to create this object?
Regards.
|
|
|
|
|
Hello,
Ok, The code file where I am using BackgroundWorker i have following using statements, you can just copy all of them for the time being for debugging purpose.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using SpeechLib;
using System.Threading;
Moreover Backgroundworker is a control available in your C# ToolBox. It is a new component in .NET 2.0 (2005 Express Editition). So, if you are using .Net 1.1 (Visual Studio 2003) then dont use this code.
"By the way could you tell me which class that the object backgroundWorkerLetterTalker belongs to ?"
:: backgroundWorkerLetterTalker was an instance variable name of BackgroundWorker Control, not any standard .net class name.
OK, If you have too much trouble about Background worker, then forget about backgroundWorker.
For simplicity, just to test Text to Speech, put this code without background worker. At least you will hear voice from machine.
private void btnSpeak_Click(object sender, EventArgs e)
{
///////////////////////////////////////////////////////////
string arg = "HEllo I am speaking";
SpVoice objSpeech = new SpVoice();
objSpeech.Speak(arg, SpeechVoiceSpeakFlags.SVSFlagsAsync);
objSpeech.WaitUntilDone(Timeout.Infinite);
///////////////////////////////////////////////////////////
}
-- modified at 13:30 Monday 27th February, 2006
|
|
|
|
|
HI,thanks for your reply
I've tried your code.It had no error but nothing happened either.I can not hear anything.
|
|
|
|
|
Hi I have built a project for you and sent you email with an zip file attachment. This project is working perfectly in my PC. If it is not working in your pc, then may be your pc is not equipped with microsoft speech features or may be something else wrong. And this project is built in .NET 2.0 (C# express 2005). If you have the previous version, then just open the file form1.cs and see the code and then use in your previous version IDE.
|
|
|
|
|
HI my email address is khoilvthu@yahoo.com.Please send the zip file to this address.Thanks lots
|
|
|
|
|
I'm thinking of making a VoIP program because the voice convo's in MSN messenger only connect like half the time. Can anyone direct me to some good articles or give me some advice on where to start?
Wacky waving inflateable arm flailing tube man!
- Family Guy
|
|
|
|