designing a system to disable UI?

G

giddy

hi,

I've finished all the base code to my App. Tested it and everything, now I
need to make a UI.

Its not going to be overly complex but it could get complex later on, so I
want to design it well.

I want a proper way to enable/disable UI but later being able to change
maybe the real control, so far i've come up with.

interface IMainForm
{
IUIController GetUIController(string name);
}
interface IUIController
{
bool Enabled
{ get;set;}
}
The default implementation would be:
class DefUIController : IUIController
{
DefUIController(Control cntrl);
{
}//return the Controls enabled state.
}

And then in the main form I could search for the control and create a new
UIController and return it!?

Is this design good enough or is there a method out there, I don't need
something complex like CAB or something, its not such a big app.

Thanks so much.

Gideon
 
R

rajesh

Looks like a too complex way just to Enable\Disable UI. How are you
planning to return the controls enabled state in DefUIController
constructor?
 
G

giddy

Looks like a too complex way just to Enable\Disable UI. How are you
planning to return the controls enabled state in DefUIController
constructor?

Its the only way I can think of to separate the disabling/enabling and being
able to change the control later on.
This is how I plan to implement in the *main form*:
IUIController GetUIController(string name)
{
foreach(Control crt in this.Controls)
{
if(crt.Name== name)
{
return DefUIController(crt);
}
return null;
}
}

My only concern here is that its a little stupid looping through every
control,
there aren't going to be SO many though.

Thanks so much.
 
F

Family Tree Mike

What does a windows forms app with a disabled UI mean to you? I think you
may be describing running your application in a "no GUI" mode, but I'm not
sure. Doing that is much simpler than what you are describing. You simply
trap the command arguments and don't make the main form visible in such
case.
 
G

giddy

Family Tree Mike said:
What does a windows forms app with a disabled UI mean to you? I think you
may be describing running your application in a "no GUI" mode, but I'm not
sure. Doing that is much simpler than what you are describing. You simply
trap the command arguments and don't make the main form visible in such
case.

I'm sorry for the crappy title, I meant Enable/Disable UI Controls based on
stuff like users, situations etc.

Like, if the selected Customer in the CustomerGridView UserControl doesn't
have a bill yet, _within_ the usercontrol i could do this:
IUIController ui = _mainform.GetUIController("mnuPrintBill");//Menu
ui.Enabled = false;

How this kind of thing done in other apps, I need to enable or disable UI
from many sub UserControls etc, now Each of them will have a Property
IMainForm that allows them to interact with the MainForm, so they call easily
call the right method and control the right UI Control.

Thanks so much
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top