GithubHelp home page GithubHelp logo

musva / csdeskband Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dsafa/csdeskband

0.0 0.0 0.0 325 KB

Windows deskband with C#

License: MIT License

C# 98.36% PowerShell 1.34% Batchfile 0.30%

csdeskband's Introduction

CS DeskBand

A Library to create DeskBands on windows using C#. Deskbands are toolbars that are docked on the taskbar and provide additional functionality to an otherwise unused space.

CSDeskBand makes it easy to create a deskband using Winforms or WPF.

Screenshots

Example 1

Example 2

Images taken from the sample projects

Table of Contents

Version 3.1 (latest)

Removed need for DESKBAND_WPF_TRANSPARENCY and references to windows forms dlls. Wpf deskbands work with transparency (tested windows 10 1903, might not work before then).

Version 2 -> version 3 migration

The library is now a single .cs file. This is to help prevent conflicts if explorer loads different versions. The new entry point for the deskband has also changed.

Before:

[ComVisible(true)]
[Guid("5731FC61-8530-404C-86C1-86CCB8738D06")]
[CSDeskBandRegistration(Name = "Sample Winforms Deskband")]
public partial class UserControl1 : CSDeskBandWin
{
}

The main usercontrol would derive from the deskband.

New:

[ComVisible(true)]
[Guid("FB17B6DA-E3D7-4D17-9E43-3416983372A9")]
[CSDeskBand.CSDeskBandRegistration(Name = "Sample winforms")]
public class Deskband : CSDeskBand.CSDeskBandWin
{
    protected override Control Control => new UserControl1();
}

The entry point is a separate class now and instantiates your main window. It also means that the main deskband window can be any control. Remember to re-register the deskband after updating.

Usage

Installation

Available as a single file at output/CSDeskBand.cs. Copy the file and add to your project.

Winforms

  • Add the compilation symbol DESKBAND_WINFORMS to your winforms project.
  • Create a new public class that will host your deskband and make it inherit from the abstract class CSDeskBandWin. Namespace in CSDeskBand
    • Implement the Control property to return your main winforms control.
  • Add [ComVisible(true)], [Guid("xx-xx-xx-xx-xx")], [CSDeskBandRegistration()] attributes to the class.
    • The CSDeskBandRegistration attribute allows you to configure:
      • Name : The name of the deskband shown in the toolbars menu
      • ShowDeskBand : True if the deskband should be shown automatically after registration
using CSDeskBand.Win;
using CSDeskBand;

[ComVisible(true)]
[Guid("5731FC61-8530-404C-86C1-86CCB8738D06")]
[CSDeskBandRegistration(Name = "Sample Winforms Deskband")]
public partial class UserControl1 : CSDeskBandWin
{
    public Deskband()
    {
        Options.MinHorizontalSize = new Size(100, 30);
    }

    protected override Control Control => new UserControl1(); // Returns your main control
}

WPF

  • Add the compilation symbol DESKBAND_WPF to your wpf project.
  • Create a new public class that will host your deskband and make it inherit from the abstract class CSDeskBandWpf. Namespace in CSDeskBand
    • Implement the UIElement property to return your main wpf control
  • Add [ComVisible(true)], [Guid("xx-xx-xx-xx-xx")], [CSDeskBandRegistration()] attributes to the class.
    • The CSDeskBandRegistration attribute allows you to configure:
      • Name : The name of the deskband shown in the toolbars menu
      • ShowDeskBand : True if the deskband should be shown automatically after registration
    [ComVisible(true)]
    [Guid("AA01ACB3-6CCC-497C-9CE6-9211F2EDFC10")]
    [CSDeskBandRegistration(Name = "Sample wpf")]
    public class Deskband : CSDeskBandWpf
    {
        public Deskband()
        {
            Options.ContextMenuItems = ContextMenuItems;
        }

        protected override UIElement UIElement => new UserControl1(); // Return the main wpf control

        private List<DeskBandMenuItem> ContextMenuItems
        {
            get
            {
                var action = new DeskBandMenuAction("Action");
                return new List<DeskBandMenuItem>() { action };
            }
        }
    }

Both

You can access the Options property to change deskband settings such as minimal size or the context menu items available. Now you are ready to start working on the deskband like a normal user control.

Check the Wiki for more configuration options

Notes

The nuget packages are outdated and currently not being updated for versions > 3.

Deskband Installation

You need to start an elevated command prompt and be able to use regasm.exe. Make sure that you use the correct version of regasm that matches your platform (x86/x64).

cd ExampleWinforms\bin\Debug

regasm /codebase ExampleWinforms.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 ExampleWinforms.dll
regasm ExampleWinforms.dll

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

Here is an example .bat file for installing a deskband.

Examples

There are example deskbands included for Winforms and WPF in the Sample winforms and Sample wpf projects.

Compatibility

Tested on Windows 10 x64

Building

Built in Visual studio 2017. The script tools/merge.ps1 is used to merge the files.

csdeskband's People

Contributors

dsafa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.