473,500 Members | 1,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

does a singleton StatusBar controller sound corrrect?

hi ,

Does a singleton statusbas controller sound correct. I mean , is that
how its done?

I have a big app and i need to control the statusbar from within a
number of custom controls , dynamic menus and toolbars etc. So should
i have the aforementioend class? I'm thinking singleton so its
instance is globally accesssible?

Gideon

Jun 12 '07 #1
8 2216
Gideon,

You could, but honestly, I dislike the idea. By exposing the control,
you are really asking for some trouble.

What I like better is a static method which you expose, something like
"UpdateStatus" which takes a string and then updates the status bar
appropriately. This way, you don't expose the status bar and mistakenly
expose functionality you don't want which can be used to compromise main
window.

The option I like the most would be to have all custom controls
implement an interface, something like this:

public interface IMyApp
{
void SetStatus(string status);
}

public interface IMyAppCustomControl
{
void Initialize(IMyApp app);
}

When you create the custom controls in your app, you would call the
implemented Initialize method, passing the IMyApp implementation (which your
main app window would implement). This lets you abstract out the
functionality, in case you make major changes to the main window.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"giddy" <gi*******@gmail.comwrote in message
news:11*********************@z28g2000prd.googlegro ups.com...
hi ,

Does a singleton statusbas controller sound correct. I mean , is that
how its done?

I have a big app and i need to control the statusbar from within a
number of custom controls , dynamic menus and toolbars etc. So should
i have the aforementioend class? I'm thinking singleton so its
instance is globally accesssible?

Gideon

Jun 12 '07 #2
Hi,

"giddy" <gi*******@gmail.comwrote in message
news:11*********************@z28g2000prd.googlegro ups.com...
hi ,

Does a singleton statusbas controller sound correct. I mean , is that
how its done?
IT does not sounds correct, as a matter of fact it DOES sound incorrect. The
statusbar is just another control in a form, you should let the form control
it.
I have a big app and i need to control the statusbar from within a
number of custom controls , dynamic menus and toolbars etc. So should
i have the aforementioend class? I'm thinking singleton so its
instance is globally accesssible?

you better define an interface (that your forms can implement) in such a way
that it return the instance of the correct statusbar. Then you can just call
a method (defined in the interface) to make the update.
Jun 12 '07 #3
HI Nicholas ,

thanks so much for that design =) . I can see why it makes sense , but
besides that it helped me code this taskpane which sometimes needs to
control certain aspects of the main form! =P

Gideon

Jun 13 '07 #4
PS

"giddy" <gi*******@gmail.comwrote in message
news:11*********************@z28g2000prd.googlegro ups.com...
hi ,

Does a singleton statusbas controller sound correct. I mean , is that
how its done?

I have a big app and i need to control the statusbar from within a
number of custom controls , dynamic menus and toolbars etc. So should
i have the aforementioend class? I'm thinking singleton so its
instance is globally accesssible?
I think the other posts did not understand what you were going to do. A
singleton controller class is a good idea. I assume that the status bar will
monitor a Status type event and that the forms will call an OnStatusChange
method. Therefore there is no dependency between the form and the status bar
and the status bar and forms remain closed to direct modification.

PS
Jun 15 '07 #5
PS <ec***********@hotmail.comwrote:
Does a singleton statusbas controller sound correct. I mean , is that
how its done?

I have a big app and i need to control the statusbar from within a
number of custom controls , dynamic menus and toolbars etc. So should
i have the aforementioend class? I'm thinking singleton so its
instance is globally accesssible?

I think the other posts did not understand what you were going to do. A
singleton controller class is a good idea. I assume that the status bar will
monitor a Status type event and that the forms will call an OnStatusChange
method. Therefore there is no dependency between the form and the status bar
and the status bar and forms remain closed to direct modification.
It does, however, make the assumption that there will only be one form
open at a time which needs status information. I'd rather pass around
something which encapsulates the idea of "when you need to indicate
status, use me" than put it in a singleton.

On the other hand, if there definitely *will* only be one instance of
the form, then it's certainly simple to use a singleton. It's just a
somewhat tricky assumption to undo later on.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jun 15 '07 #6
PS

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP********************@msnews.microsoft.com.. .
PS <ec***********@hotmail.comwrote:
Does a singleton statusbas controller sound correct. I mean , is that
how its done?

I have a big app and i need to control the statusbar from within a
number of custom controls , dynamic menus and toolbars etc. So should
i have the aforementioend class? I'm thinking singleton so its
instance is globally accesssible?

I think the other posts did not understand what you were going to do. A
singleton controller class is a good idea. I assume that the status bar
will
monitor a Status type event and that the forms will call an
OnStatusChange
method. Therefore there is no dependency between the form and the status
bar
and the status bar and forms remain closed to direct modification.

It does, however, make the assumption that there will only be one form
open at a time which needs status information. I'd rather pass around
something which encapsulates the idea of "when you need to indicate
status, use me" than put it in a singleton.

On the other hand, if there definitely *will* only be one instance of
the form, then it's certainly simple to use a singleton. It's just a
somewhat tricky assumption to undo later on.
Good point. I am working with the idea of one "main" form that is then
loaded up with controls that then load controls etc in a single document
interface style.
>
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Jun 15 '07 #7
hi ,

Acutually i had only one idea in mind , controling certain aspects of
the Form. Like the other userControls should be able to
1. Add a tab to the main tab.
2. Send a document to the main print engine.(in the main form)
3. Set a label on the status bar
4. Set a progressbar on the status bar and change its progress.

fo i made something like:
public interface IControlableForm
{
void SetStatus(string text);
void SendToPrint(IPrintableDocument);
void AddTabPage(Control control);
void ShowProgressBar(); //not sure about these since i havent added
them yet?
void SetProgress();
void HideProgressBar();
}
So , probably if i have to make a new MainForm , i just need to expose
this interface!?

Thanks

Gideon

Jun 19 '07 #8
Whoops ,

interface for the usercontrols:

public interface IControlsForm
{
public IControlableForm
{
get;
set;
}
}

I just thought it would be better to have property instead of a
method like Nicholas mentioned?

Thanks

Gideon

Jun 19 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
357
by: John Galt | last post by:
I noticed that the Visual Studio.NET statusbar on one of my development machines has disappeared. I.e., the IDE statusbar, not the form control. Does anyone know how to restore it? (It doesn't...
7
3247
by: Ethan | last post by:
Hi, I have a class defined as a "Singleton" (Design Pattern). The codes are attached below. My questions are: 1. Does it has mem leak? If no, when did the destructor called? If yes, how can I...
3
3634
by: TonyM | last post by:
Hi all, I have an application with a few different Windows forms. I am trying to update a statusbar panel's text that is in the main form, from another form. When I set the statusbar and the...
9
2069
by: Christian Blackburn | last post by:
Hi Gang, I've had this happen with a couple of controls now, but my patience has worn thin. Can somebody tell me why I can read/write to most objects on my form from my module, but not when...
4
1535
by: Benton | last post by:
Hi there, I have a child webform (with a ASP.NET calendar control) that opens in a javascript popup window when I click a button in the caller form. Child page has a <title> tag, and javascript...
3
2321
by: S. Viswanathan | last post by:
Hi everybody! In VB.NET 2005, MenuStrip and Statusstrip controls added. When the mouse over on the Menuitem its corresponding Tooptip text should be displayed in the statusstrip. How to...
2
1318
by: juscruise | last post by:
Could someone help me with this, the error reads ' Singleton is not defined ' using VB.NET Web design Imports Logix Partial Class _Default Inherits System.Web.UI.Page '...
14
1645
by: Rob Wilkerson | last post by:
Hey all - Not being a seasoned PHP developer, tonight I started playing with the use of the Singleton pattern to store configuration information. What I was surprised to find was that the...
2
1644
by: midoerin | last post by:
How to connect software with keyboard controller in C# ? So the software can interact with the keyboard controller. i want to build a software about learn piano using a keyboard controller, but i...
0
7018
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7182
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7232
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6906
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5490
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4923
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4611
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3110
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1430
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.