Skip to content
Brandon edited this page Aug 18, 2018 · 12 revisions

Welcome to the CSDeskBand wiki!

Getting Started

This is a quick guide to get you started. You can decide whether to create your Deskband with Winforms or Wpf.

Project Setup

Winforms project setup

  • Create a new Winforms Control project in Visual Studio
  • Add the CSDeskBand.Win Nuget package
  • Make your control inherit from CSDeskBandWin
    public partial class UserControl1: CSDeskBandWin
    {
        public UserControl1()
        {
            InitializeComponent();
        }
    }

Wpf project setup

  • Create a new Wpf User Control project in Visual Studio
  • Add the CSDeskBand.Wpf Nuget package
  • Make the control inherit from CSDeskBandWpf
<deskband:CSDeskBandWpf x:Class="WpfControlLibrary1.UserControl1"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:WpfControlLibrary1"
             xmlns:deskband="clr-namespace:CSDeskBand.Wpf;assembly=CSDeskBand.Wpf" <!-- Reference the assembly -->
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
            
    </Grid>
</deskband:CSDeskBandWpf>

Attributes

There are 3 attributes that need to be added to your deskband class

  • [ComVisible(true)]
  • [Guid("F61EF213-351A-4EAA-82C8-CB9221AC8ABB")]
  • [CSDeskBandRegistration(Name = "Sample Deskband")]
    [ComVisible(true)]
    [Guid("F61EF213-351A-4EAA-82C8-CB9221AC8ABB")]
    [CSDeskBandRegistration(Name = "Sample Deskband")]
    public partial class UserControl1
    {
        public UserControl1()
        {
            InitializeComponent();
        }
    }

Usage

Deskband Options

Deskband options can be set through the Options property. These options include settings such as min/max size and context menu items (see below).

Options.MinHorizontal.Width = 500;

Context menu

You can add items to the deskband context menu through Options.ContextMenuItems.

var action = new CSDeskBandMenuAction("Action!");
action.Clicked += (sender, args) => Console.WriteLine("Clicked!");
Options.ContextMenuItems.add(action);

Context menu items include CSDeskBandMenuAction CSDeskBandMenu CSDeskBandSeparator

TaskbarInfo

The TaskbarInfo property allows you to get information about the state of the size, orientation and edge of the taskbar.

WPF

  • Transparency : Transparency can be turned off by setting TransparencyEnabled property to false. See notes below to see issues with Wpf and transparency

Deskband Installation

You need to start an elevated command prompt and be able to use regasm.exe An easy way to do this is use the Developer Command Prompt for Visual Studio. Make sure that you use the correct version of regasm that matches your platform.

cd Sample.Win\bin\Debug

regasm /codebase Sample.Win.dll

The /codebase switch will add the path of the dll into the registry entry.

Alternatively, register the assemblies into the Global Assembly Cache.

gacutil -i CSDeskBand.dll
gacutil -i CSDeskBand.Win.dll
gacutil -i Sample.Win.dll
regasm Sample.Win.dll

Note that GAC installation requires the assemblies to be Strong-Named

Now right click the taskbar > Toolbars > your deskband

Notes

There are issues with transparency for WPF. Due to the airspace issue, we can't have a transparent WPF window since the taskbar uses win32 (gdi/gdi+). The current solution is to host the WPF user control in a ElementHost which is then hosted in a Winforms Form that uses a transparency key. This of course creates issues with anti aliasing and can cause artifacts. The color key can be changed through the TransparencyColorKey property.

Clone this wiki locally