Giter VIP home page Giter VIP logo

radialmenu's Introduction

RadialMenu

A custom control to create radial-menu into your WPF application.

RadialMenu Demo

How to use

Import the RadialMenu.dll into your project (do not forget to reference it), then into your Xaml View, import the custom control

xmlns:Controls="clr-namespace:RadialMenu.Controls;assembly=RadialMenu"

To create the main component of the RadialMenu, simply type

<Controls:RadialMenu>
    ...
</Controls:RadialMenu>

To create the central menu item of the RadialMenu, simply type

<Controls:RadialMenuCentralItem>
    ...
</Controls:RadialMenuCentralItem>

To create a menu item of the RadialMenu, simply type

<Controls:RadialMenuItem>
    ...
</Controls:RadialMenuItem>

Full example

A tipical example of what can be done

<RadialMenu:RadialMenu IsOpen="{Binding IsOpen}">

    <!-- CentralMenuItem -->

    <RadialMenu:RadialMenu.CentralItem>
        <RadialMenu:RadialMenuCentralItem Command="{Binding CloseRadialMenuCommand}">
            <TextBlock>Close</TextBlock>
        </RadialMenu:RadialMenuCentralItem>
    </RadialMenu:RadialMenu.CentralItem>

    <!-- MenuItems Around -->

    <RadialMenu:RadialMenuItem Command="{Binding NewFileCommand}">
        <TextBlock>New file</TextBlock>
    </RadialMenu:RadialMenuItem>

    <RadialMenu:RadialMenuItem Command="{Binding EditCommand}">
        <TextBlock>Edit</TextBlock>
    </RadialMenu:RadialMenuItem>

    <RadialMenu:RadialMenuItem Command="{Binding SaveCommand}">
        <TextBlock>Save</TextBlock>
    </RadialMenu:RadialMenuItem>

    <RadialMenu:RadialMenuItem Command="{Binding DeleteCommand}">
        <TextBlock>Delete</TextBlock>
    </RadialMenu:RadialMenuItem>

    <RadialMenu:RadialMenuItem Command="{Binding ExitCommand}">
        <TextBlock>Exit</TextBlock>
    </RadialMenu:RadialMenuItem>

    <!-- Add items as you want... -->

</RadialMenu:RadialMenu>

which results in

RadialMenu Example

Customization

You can even create your own style of RadialMenu (do not forget to add style for disabled, hovered and pressed item states if desired)

<Style x:Key="FancyRadialMenuCentralItem" TargetType="Controls:RadialMenuCentralItem" BasedOn="{StaticResource {x:Type Controls:RadialMenuCentralItem}}">

    <Setter Property="Background" Value="AliceBlue"/>
    <Setter Property="BorderBrush" Value="DarkBlue"/>
    <Setter Property="BorderThickness" Value="4"/>
    <Setter Property="Width" Value="64"/>
    <Setter Property="Height" Value="64"/>

</Style>

<Style x:Key="FancyRadialMenuItem" TargetType="Controls:RadialMenuItem" BasedOn="{StaticResource {x:Type Controls:RadialMenuItem}}">

    <Setter Property="Background" Value="AliceBlue"/>
    <Setter Property="Padding" Value="2"/>
    <Setter Property="InnerRadius" Value="40"/>
    <Setter Property="OuterRadius" Value="150"/>
    <Setter Property="ContentRadius" Value="85"/>

    <Setter Property="EdgeBackground" Value="DarkBlue"/>
    <Setter Property="EdgePadding" Value="7"/>
    <Setter Property="EdgeInnerRadius" Value="130"/>
    <Setter Property="EdgeOuterRadius" Value="145"/>

    <Setter Property="ArrowBackground" Value="Cyan"/>
    <Setter Property="ArrowRadius" Value="138"/>

</Style>

which results in

RadialMenu Custom

Advanced Usage

  • The radial menu will not scale by default (and transform controls will break it). To modify the size you want to adjust the Radius properties on the style. You will most likely need to adjust OuterRadius, ContentRadius, EdgeInnerRadius, EdgeOuterRadius, and ArrowRadius to resize the control
  • When creating RadialMenuItems try to stick the text in a TextBlock for the best formatting results
  • You can hide the arrow on a RadialMenuItem by setting its ArrowBackground to Transparent
  • To update the control from code behind after creation you cannot simply update the radialMenu.Items list, you must replace it with a new collection. For example:
MyRadialMenu.Items = new List<RadialMenuItem>
{
    new RadialMenuItem
    {
        Content = new TextBlock { Text = "Hello" }
    },
    new RadialMenuItem
    {
        Content = new TextBlock { Text = "World" }
    }
};

Multi-level menu

You can easily create multi-level radial menus by using the arrow as a visual queue and then replacing the items with an updated set. For example:

<RadialMenu:RadialMenu x:Name="MyRadialMenu" IsOpen="{Binding IsOpen}">
    ...
</RadialMenu:RadialMenu>
// Main menu
var MainMenuItems = new List<RadialMenuItem>
{
    new RadialMenuItem
    {
        Content = new TextBlock { Text = "Item 1" },
        ArrowBackground = Brushes.Transparent
    },
    new RadialMenuItem
    {
        Content = new TextBlock { Text = "Item 2" },
        ArrowBackground = Brushes.Transparent
    },
    new RadialMenuItem
    {
        Content = new TextBlock { Text = "Sub Menu" }
    }
};

// Sub menu
var SubMenuItems = new List<RadialMenuItem>
{
    new RadialMenuItem
    {
        Content = new TextBlock { Text = "Sub Item 1" },
        ArrowBackground = Brushes.Transparent
    },
    new RadialMenuItem
    {
        Content = new TextBlock { Text = "Sub Item 2" },
        ArrowBackground = Brushes.Transparent
    },
    new RadialMenuItem
    {
        Content = new TextBlock { Text = "Sub Item 3" },
        ArrowBackground = Brushes.Transparent
    }
};

// Go to Sub menu when clicking on the third item
MainMenuItems[2].Click += async (sender, args) =>
{
    IsOpen = false;
    await Task.Delay(400);
    MyRadialMenu.Items = SubMenuItems;
    IsOpen = true;
};

// Set default menu to Main menu
MyRadialMenu.Items = MainMenuItems;

Which results in

RadialMenu Multi-Levels

radialmenu's People

Contributors

julien-marcou avatar mitchcapper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

radialmenu's Issues

Possibility to change the flow order?

I'd like to be able to have a single arrow centered at the top of the menu rather than at the bottom.

For example this:
menu

Would become like this:
menuangle

With the labels the proper way of course. If you don't understand what I'm trying to say let me know.

Content property can only be set once

When using the control I found I had to add the child items to a Items collection rather than following the example code listed on the website:

        <rm:RadialMenu IsOpen="True">
            <rm:RadialMenu.CentralItem>
                <rm:RadialMenuCentralItem>
                    <TextBlock>Close</TextBlock>
                </rm:RadialMenuCentralItem>
            </rm:RadialMenu.CentralItem>

            <rm:RadialMenu.Items>
                <rm:RadialMenuItem>
                    <TextBlock>A</TextBlock>
                </rm:RadialMenuItem>
                <rm:RadialMenuItem>
                    <TextBlock>B</TextBlock>
                </rm:RadialMenuItem>
            </rm:RadialMenu.Items>
            
        </rm:RadialMenu>

I'm running .NET 4.2. Is this behaviour expected?

Request Feature(s): Override grey background on mouse over, mouse pressed

Love your control, it works great! After reading about the Styles in your documentation, and playing around with the Styles on the RadialMenuItem, I noticed that when you hover the mouse over the EdgeBackground, or when you press on it, the color is always a hardcoded shade of grey. It would be great if those colors could be controlled by the application developer as well. Perhaps two new dependency properties: HoverEdgeBackground, PressedEdgeBackground

Thanks for reading, and much appreciated what you've already created!

Current Demo broken

I am guessing its due to the commit from 9 hours ago but I get a blank screen on the demo after compiling currently. The sample from the readme however works just fine. Haven't had a chance to fully debug the demo yet.

Add drag cursor as clic effect

First of all thanks for the awesome work you put in the Radial Menu.

second. is there a way make this happen:
when the user moves the cursor in the direction of a RadialMenuItem and passes the outer radius it will be the same as click in the button?.

i think this will be a good alternative since the user can "pull" the cursor in one direction and execute the command...

Creating a new List

Working on creating a dynamic list and running into problems, maybe somebody has a solution I havent come across.

So I read in a group of "names" from an xml document. What I'd like to do is then create a new RadialMenu List from this group of names so that as time goes on, the menu can grow (considering models of an item here). Anybody have an idea or solution to this?

I've tried doing it inside the

MainMenu.Items = new List {

}

but cannot do for example a for each loop thru this area to create the new items.

Thanks in advance.

Missing 'X'

When 'Open Half-Shifted' is the first command, the menu loads without an 'X' for cosing in the middle. In any other tested circumstance the 'X' is present. The menu works fine, regardless of this graphical bug.

Top corner menu

Hi Julien, It is possible to place the menu in the upper right corner or in any corner of the window, as in this example:

.net framework 4.0

I want to download this control for my .net 4.0 . Please provide me a link for this.

Avalonia Port

Could you port your awesome library to AvaloniaUI?

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.