Skip to content

Commit

Permalink
Merge pull request #1086 from IbraheemOsama/ClassicMenu
Browse files Browse the repository at this point in the history
Classic menu
  • Loading branch information
skendrot authored Jun 27, 2017
2 parents 59038c6 + 9fee708 commit 8a54ae5
Show file tree
Hide file tree
Showing 18 changed files with 1,518 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@
<Content Include="SamplePages\MarkdownTextBlock\MarkdownTextBlock.png" />
<Content Include="SamplePages\Loading\Loading.png" />
<Content Include="SamplePages\MasterDetailsView\MasterDetailsView.png" />
<Content Include="SamplePages\Menu\Menu.png" />
<Content Include="SamplePages\Microsoft Graph Service\OfficeLogo.png" />
<Content Include="SamplePages\Microsoft Graph Service\user.png" />
<Content Include="SamplePages\Microsoft Translator Service\TranslatorService.png" />
Expand Down Expand Up @@ -396,6 +397,7 @@
<Content Include="SamplePages\FocusTracker\FocusTrackerXaml.bind" />
<Content Include="SamplePages\ClipboardHelper\ClipboardHelperCode.bind" />
<Content Include="SamplePages\OrbitView\OrbitViewXaml.bind" />
<Content Include="SamplePages\Menu\Menu.bind" />
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
Expand All @@ -416,6 +418,10 @@
<Compile Include="SamplePages\ClipboardHelper\ClipboardHelperPage.xaml.cs">
<DependentUpon>ClipboardHelperPage.xaml</DependentUpon>
</Compile>
<Compile Include="SamplePages\Menu\Commands\VsCommands.cs" />
<Compile Include="SamplePages\Menu\MenuPage.xaml.cs">
<DependentUpon>MenuPage.xaml</DependentUpon>
</Compile>
<Compile Include="SamplePages\NetworkHelper\NetworkHelperPage.xaml.cs">
<DependentUpon>NetworkHelperPage.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -669,6 +675,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="SamplePages\Menu\MenuPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="SamplePages\OrbitView\OrbitViewPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************

using System;
using System.Windows.Input;
using Windows.UI.Popups;

namespace Microsoft.Toolkit.Uwp.SampleApp.Menu.Commands
{
internal class NewProjectCommand : ICommand
{
public bool CanExecute(object parameter)
{
return true;
}

public async void Execute(object parameter)
{
var dialog = new MessageDialog("Create New Project");
await dialog.ShowAsync();
}

public event EventHandler CanExecuteChanged;
}

internal class NewFileCommand : ICommand
{
public bool CanExecute(object parameter)
{
return true;
}

public async void Execute(object parameter)
{
var dialog = new MessageDialog("Create New File");
await dialog.ShowAsync();
}

public event EventHandler CanExecuteChanged;
}

internal class GenericCommand : ICommand
{
public bool CanExecute(object parameter)
{
return true;
}

public async void Execute(object parameter)
{
var dialog = new MessageDialog(parameter.ToString());
await dialog.ShowAsync();
}

public event EventHandler CanExecuteChanged;
}
}
136 changes: 136 additions & 0 deletions Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/Menu.bind
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<Page x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.MenuPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:commands="using:Microsoft.Toolkit.Uwp.SampleApp.Menu.Commands"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>
<ResourceDictionary>
<commands:NewProjectCommand x:Key="NewProject" />
<commands:NewFileCommand x:Key="NewFile" />
<commands:GenericCommand x:Key="GenericCommand" />
</ResourceDictionary>


</Page.Resources>

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>

<controls:Menu AllowTooltip="@[AllowTooltip:Bool:True]"
Orientation="@[Orientation:Enum:Orientation.Horizontal]"
TooltipPlacement="@[TooltipPlacement:Enum:PlacementMode.Bottom]">

<controls:MenuItem controls:Menu.InputGestureText="Alt+F"
Header="File">
<MenuFlyoutSubItem Text="New">
<MenuFlyoutItem controls:Menu.InputGestureText="Ctrl+Shift+N"
Command="{StaticResource NewProject}"
Text="Project" />
<MenuFlyoutItem controls:Menu.InputGestureText="Ctrl+N"
Command="{StaticResource NewFile}"
Text="File" />
</MenuFlyoutSubItem>
<MenuFlyoutSubItem Text="Open">
<MenuFlyoutItem controls:Menu.InputGestureText="Ctrl+Shift+O"
Command="{StaticResource GenericCommand}"
CommandParameter="Select Project/Solution"
Text="Project/Solution" />
<MenuFlyoutItem controls:Menu.InputGestureText="Ctrl+O"
Command="{StaticResource GenericCommand}"
CommandParameter="Select File"
Text="File" />
</MenuFlyoutSubItem>
<MenuFlyoutSeparator />
<MenuFlyoutItem Text="Page Setup" />
<MenuFlyoutItem controls:Menu.InputGestureText="Ctrl+P"
Command="{StaticResource GenericCommand}"
CommandParameter="Page is Printed!!"
Text="Print" />
<MenuFlyoutSeparator />
<MenuFlyoutSubItem Text="Recent Files">
<MenuFlyoutItem Text="UWP ToolKit GridSplitter" />
<MenuFlyoutItem Text="UWP ToolKit WrapPanel" />
</MenuFlyoutSubItem>
<MenuFlyoutItem controls:Menu.InputGestureText="Ctrl+Shit+E"
Command="{StaticResource GenericCommand}"
CommandParameter="Solution closed"
Text="Exit" />
</controls:MenuItem>


<controls:MenuItem Header="Edit">
<MenuFlyoutSubItem Text="Go To">
<MenuFlyoutItem Text="Go To Line" />
<MenuFlyoutItem Text="Go To All" />
</MenuFlyoutSubItem>

<MenuFlyoutSubItem Text="Find and Replace">
<MenuFlyoutItem Text="Find" />
<MenuFlyoutItem Text="Replace" />
</MenuFlyoutSubItem>
</controls:MenuItem>

<controls:MenuItem Header="View">
<MenuFlyoutSubItem Text="Designer">
<MenuFlyoutItem Text="VS Designer" />
<MenuFlyoutItem Text="Blend" />
</MenuFlyoutSubItem>

<MenuFlyoutSubItem Text="Solution Explorer">
<MenuFlyoutItem Text="Solutions" />
<MenuFlyoutItem Text="Projects" />
</MenuFlyoutSubItem>
</controls:MenuItem>

<controls:MenuItem Header="Project">
<MenuFlyoutSubItem Text="Add Class">
<MenuFlyoutItem Text="Class" />
<MenuFlyoutItem Text="Interface" />
</MenuFlyoutSubItem>

<MenuFlyoutSubItem Text="Add new data source">
<MenuFlyoutItem Text="SQL" />
<MenuFlyoutItem Text="NoSQL" />
</MenuFlyoutSubItem>
</controls:MenuItem>

<controls:MenuItem Header="Build">
<MenuFlyoutItem Text="Build Solution" />
<MenuFlyoutItem Text="Rebuild Solution" />
</controls:MenuItem>

<controls:MenuItem Header="Debug">
<MenuFlyoutSubItem Text="Windows">
<MenuFlyoutItem Text="Windows 8" />
<MenuFlyoutItem Text="Windows 10" />
</MenuFlyoutSubItem>

<MenuFlyoutSubItem Text="Graphics">
<MenuFlyoutItem Text="Canvas" />
<MenuFlyoutItem Text="Grid" />
</MenuFlyoutSubItem>
</controls:MenuItem>

</controls:Menu>

<StackPanel Grid.Row="1">
<TextBlock Text="Click Alt to set focus on Classic Menu" />
<TextBlock Text="To open file menu shortcut: Alt+F" />
<TextBlock Text="Create new project shortcut: Ctrl+Shift+N" />
<TextBlock Text="Create new file shortcut: Ctrl+N" />
<TextBlock Text="Open project shortcut: Ctrl+Shift+O" />
<TextBlock Text="Open file shortcut: Ctrl+O" />
<TextBlock Text="Print shortcut: Ctrl+P" />
<TextBlock Text="Exit solution shortcut: Ctrl+Shit+E" />
</StackPanel>


</Grid>
</Page>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
139 changes: 139 additions & 0 deletions Microsoft.Toolkit.Uwp.SampleApp/SamplePages/Menu/MenuPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<Page x:Class="Microsoft.Toolkit.Uwp.SampleApp.SamplePages.MenuPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:commands="using:Microsoft.Toolkit.Uwp.SampleApp.Menu.Commands"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>
<ResourceDictionary>
<commands:NewProjectCommand x:Key="NewProject" />
<commands:NewFileCommand x:Key="NewFile" />
<commands:GenericCommand x:Key="GenericCommand" />
</ResourceDictionary>
</Page.Resources>

<Grid Background="{StaticResource Brush-Grey-05}">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>

<controls:Menu AllowTooltip="{Binding AllowTooltip.Value, Mode=TwoWay}"
Orientation="{Binding Orientation.Value, Mode=TwoWay}"
TooltipPlacement="{Binding TooltipPlacement.Value, Mode=TwoWay}">

<controls:MenuItem Name="FileMenu"
controls:Menu.InputGestureText="Alt+F"
Header="File">
<MenuFlyoutSubItem Text="New">
<MenuFlyoutItem controls:Menu.InputGestureText="Ctrl+Shift+N"
Command="{StaticResource NewProject}"
Text="Project" />
<MenuFlyoutItem controls:Menu.InputGestureText="Ctrl+N"
Command="{StaticResource NewFile}"
Text="File" />
</MenuFlyoutSubItem>
<MenuFlyoutSubItem Text="Open">
<MenuFlyoutItem controls:Menu.InputGestureText="Ctrl+Shift+O"
Command="{StaticResource GenericCommand}"
CommandParameter="Select Project/Solution"
Text="Project/Solution" />
<MenuFlyoutItem controls:Menu.InputGestureText="Ctrl+O"
Command="{StaticResource GenericCommand}"
CommandParameter="Select File"
Text="File" />
</MenuFlyoutSubItem>
<MenuFlyoutSeparator />
<MenuFlyoutItem Text="Page Setup" />
<MenuFlyoutItem controls:Menu.InputGestureText="Ctrl+P"
Command="{StaticResource GenericCommand}"
CommandParameter="Page is Printed!!"
Text="Print" />
<MenuFlyoutSeparator />
<MenuFlyoutSubItem Text="Recent Files">
<MenuFlyoutItem Text="UWP ToolKit GridSplitter" />
<MenuFlyoutItem Text="UWP ToolKit WrapPanel" />
</MenuFlyoutSubItem>
<MenuFlyoutItem controls:Menu.InputGestureText="Ctrl+Shift+E"
Command="{StaticResource GenericCommand}"
CommandParameter="Solution closed"
Text="Exit" />
</controls:MenuItem>


<controls:MenuItem controls:Menu.InputGestureText="Alt+E"
Header="Edit">
<MenuFlyoutSubItem Text="Go To">
<MenuFlyoutItem Text="Go To Line" />
<MenuFlyoutItem Text="Go To All" />
</MenuFlyoutSubItem>

<MenuFlyoutSubItem Text="Find and Replace">
<MenuFlyoutItem Text="Find" />
<MenuFlyoutItem Text="Replace" />
</MenuFlyoutSubItem>
</controls:MenuItem>

<controls:MenuItem controls:Menu.InputGestureText="Alt+V"
Header="View">
<MenuFlyoutSubItem Text="Designer">
<MenuFlyoutItem Text="VS Designer" />
<MenuFlyoutItem Text="Blend" />
</MenuFlyoutSubItem>

<MenuFlyoutSubItem Text="Solution Explorer">
<MenuFlyoutItem Text="Solutions" />
<MenuFlyoutItem Text="Projects" />
</MenuFlyoutSubItem>
</controls:MenuItem>

<controls:MenuItem controls:Menu.InputGestureText="Alt+P"
Header="Project">
<MenuFlyoutSubItem Text="Add Class">
<MenuFlyoutItem Text="Class" />
<MenuFlyoutItem Text="Interface" />
</MenuFlyoutSubItem>

<MenuFlyoutSubItem Text="Add new data source">
<MenuFlyoutItem Text="SQL" />
<MenuFlyoutItem Text="NoSQL" />
</MenuFlyoutSubItem>
</controls:MenuItem>

<controls:MenuItem controls:Menu.InputGestureText="Alt+B"
Header="Build">
<MenuFlyoutItem Text="Build Solution" />
<MenuFlyoutItem Text="Rebuild Solution" />
</controls:MenuItem>

<controls:MenuItem controls:Menu.InputGestureText="Alt+D"
Header="Debug">
<MenuFlyoutSubItem Text="Windows">
<MenuFlyoutItem Text="Windows 8" />
<MenuFlyoutItem Text="Windows 10" />
</MenuFlyoutSubItem>

<MenuFlyoutSubItem Text="Graphics">
<MenuFlyoutItem Text="Canvas" />
<MenuFlyoutItem Text="Grid" />
</MenuFlyoutSubItem>
</controls:MenuItem>

</controls:Menu>

<StackPanel Grid.Row="1">
<TextBlock Text="Click Alt to set focus on Classic Menu" />
<TextBlock Text="Any menu shortcut is Alt + (The first character of the menu name), ex to open File menu click Alt+F" />
<TextBlock Text="Create new project shortcut: Ctrl+Shift+N" />
<TextBlock Text="Create new file shortcut: Ctrl+N" />
<TextBlock Text="Open project shortcut: Ctrl+Shift+O" />
<TextBlock Text="Open file shortcut: Ctrl+O" />
<TextBlock Text="Print shortcut: Ctrl+P" />
<TextBlock Text="Exit solution shortcut: Ctrl+Shit+E" />
</StackPanel>

</Grid>
</Page>
Loading

0 comments on commit 8a54ae5

Please sign in to comment.