locked
Action buttons / Popups ? RRS feed

  • Question

  • How would one go about creating Action buttons for a tab, similar to the "Add"/"Properties"/"Open" buttons that are displayed under the shared folder tab?

    Thanks,

    A.
    Friday, April 27, 2007 8:33 PM

Answers

  • All of the other tabs use controls derived from Tool Strips, which you can also use in your tab. Just add a reference to HomeServerControls.dll to use the controls, and add a using Microsoft.HomeServer.Controls statement as well. There is also a "FancyListView" control if you want to use the list view used in the WHS tabs.

     

    Here is a snippet of what I am doing in the HomeServerTabExtender constructor. (This is just part of my code, but it should be enough to get you up and running.)

     

    Code Snippet

    private Control tabControl;

    private ConsoleToolBarButton propsButton;

    private ConsoleToolBarButton refreshButton;

    private ConsoleToolBarButton stopServiceButton;

    private ConsoleToolBarButton startServiceButton;

     

    public HomeServerTabExtender(int width, int height, IConsoleServices consoleServices)

    {

    Font fontTahoma = new Font("Tahoma", 8, System.Drawing.FontStyle.Regular);

    tabControl = new Panel();

    tabControl.Width = width;

    tabControl.Height = height;

    tabControl.Font = fontTahoma;

    tabControl.Dock = DockStyle.Fill;

     

    ConsoleToolBar topBar = new ConsoleToolBar(tabControl);

    topBar.BackColor = CommonSettings.ConsoleBackgroundColor;

    topBar.Dock = DockStyle.Top;

    propsButton = new ConsoleToolBarButton("Properties");

    propsButton.Image = Microsoft.HomeServer.HomeServerConsoleTab.WHSExtender.Resources.properties.ToBitmap();

    //propsButton.Click += new EventHandler(this.propsButton_Click);

    propsButton.Enabled = false;

    topBar.Items.Add(propsButton);

    refreshButton = new ConsoleToolBarButton("Refresh");

    refreshButton.Image = Microsoft.HomeServer.HomeServerConsoleTab.WHSExtender.Resources.browse.ToBitmap();

    refreshButton.Click += new EventHandler(this.refreshButton_Click);

    refreshButton.Enabled = true;

    topBar.Items.Add(refreshButton);

    tabControl.Controls.Add(topBar);

    ...

    }

     

    I hope this helps.

    Rob

     

    Friday, April 27, 2007 11:19 PM

All replies

  • Actually I think I see.

    I thought custom tabs were in a frame below the border, but they appears to be overlaid so I guess the buttons are just translucent controls.
    Friday, April 27, 2007 8:56 PM
  • In general? They are likely some sort of custom control derived from a standard one in the System.Windows.Forms namespace. They look like a ToolStrip and ToolStripButton controls, but there are lots of other ways to get there from here. Smile

    In specific, it will depend a lot on what exactly you want to do. There's a ton of sample code available, on MSDN and elsewhere. You might want to start here.

    I know that's really not what you're looking for, but (as you've probably seen) there is nothing in the sample code in the WHS SDK that shows exactly how anything in the console was done.

    You can at least make a start with the C# and VB.Net templates I've provided. Those will get you the empty panel, which is where you have to start.
    Friday, April 27, 2007 9:08 PM
    Moderator
  • Thanks, though I'm actually quite far along with my Add-in .

    My prototype had buttons placed randomly on the panel for testing and I'm now attempting to bring the UI more inline with that used for the standard WHS tabs.

    This is proving to be quite difficult though. I'd assumed an area such as the button row (or status bar) would be a separate control that Add-In's could insert items into. Instead it seems each Add-In needs to individually recreate this element if it wishes to maintain a consistent look and feel with the rest of the UI.

    This, quite frankly, sucks Smile



    Friday, April 27, 2007 9:23 PM
  • All of the other tabs use controls derived from Tool Strips, which you can also use in your tab. Just add a reference to HomeServerControls.dll to use the controls, and add a using Microsoft.HomeServer.Controls statement as well. There is also a "FancyListView" control if you want to use the list view used in the WHS tabs.

     

    Here is a snippet of what I am doing in the HomeServerTabExtender constructor. (This is just part of my code, but it should be enough to get you up and running.)

     

    Code Snippet

    private Control tabControl;

    private ConsoleToolBarButton propsButton;

    private ConsoleToolBarButton refreshButton;

    private ConsoleToolBarButton stopServiceButton;

    private ConsoleToolBarButton startServiceButton;

     

    public HomeServerTabExtender(int width, int height, IConsoleServices consoleServices)

    {

    Font fontTahoma = new Font("Tahoma", 8, System.Drawing.FontStyle.Regular);

    tabControl = new Panel();

    tabControl.Width = width;

    tabControl.Height = height;

    tabControl.Font = fontTahoma;

    tabControl.Dock = DockStyle.Fill;

     

    ConsoleToolBar topBar = new ConsoleToolBar(tabControl);

    topBar.BackColor = CommonSettings.ConsoleBackgroundColor;

    topBar.Dock = DockStyle.Top;

    propsButton = new ConsoleToolBarButton("Properties");

    propsButton.Image = Microsoft.HomeServer.HomeServerConsoleTab.WHSExtender.Resources.properties.ToBitmap();

    //propsButton.Click += new EventHandler(this.propsButton_Click);

    propsButton.Enabled = false;

    topBar.Items.Add(propsButton);

    refreshButton = new ConsoleToolBarButton("Refresh");

    refreshButton.Image = Microsoft.HomeServer.HomeServerConsoleTab.WHSExtender.Resources.browse.ToBitmap();

    refreshButton.Click += new EventHandler(this.refreshButton_Click);

    refreshButton.Enabled = true;

    topBar.Items.Add(refreshButton);

    tabControl.Controls.Add(topBar);

    ...

    }

     

    I hope this helps.

    Rob

     

    Friday, April 27, 2007 11:19 PM
  • Perfect, thanks a lot!
    Friday, April 27, 2007 11:49 PM
  • You've obviously had a lot more time to dig into the WHS architecture than I have.

    Thanks, Rob!
    Saturday, April 28, 2007 2:31 PM
    Moderator