Skip to content

Commit

Permalink
Merge pull request #250 from nestquik/commands
Browse files Browse the repository at this point in the history
Added View.FullScreen command.
  • Loading branch information
tgjones committed Oct 18, 2016
2 parents ad13cda + 32ba382 commit fe1727a
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 66 deletions.
5 changes: 5 additions & 0 deletions src/Gemini/Gemini.csproj
Expand Up @@ -186,6 +186,7 @@
<Compile Include="Modules\Settings\Views\SettingsView.xaml.cs">
<DependentUpon>SettingsView.xaml</DependentUpon>
</Compile>
<Compile Include="Modules\Shell\Commands\ViewFullscreenCommandDefinition.cs" />
<Compile Include="Modules\Shell\Commands\CloseFileCommandDefinition.cs" />
<Compile Include="Modules\Shell\Commands\CloseFileCommandHandler.cs" />
<Compile Include="Modules\Shell\Commands\SaveFileAsCommandDefinition.cs" />
Expand All @@ -198,6 +199,7 @@
<Compile Include="Modules\Shell\Commands\NewFileCommandHandler.cs" />
<Compile Include="Modules\Shell\Commands\OpenFileCommandDefinition.cs" />
<Compile Include="Modules\Shell\Commands\ExitCommandHandler.cs" />
<Compile Include="Modules\Shell\Commands\ViewFullscreenCommandHandler.cs" />
<Compile Include="Modules\Shell\Controls\LayoutInitializer.cs" />
<Compile Include="Modules\MainMenu\Controls\MenuItemEx.cs" />
<Compile Include="Modules\MainMenu\Controls\MenuEx.cs" />
Expand Down Expand Up @@ -457,6 +459,9 @@
<ItemGroup>
<Resource Include="Resources\Icons\Save.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\Icons\FullScreen.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
@@ -0,0 +1,37 @@
using System;
using System.ComponentModel.Composition;
using System.Windows.Input;
using Gemini.Framework.Commands;
using Gemini.Properties;

namespace Gemini.Modules.Shell.Commands
{
[CommandDefinition]
public class ViewFullScreenCommandDefinition : CommandDefinition
{
public const string CommandName = "View.FullScreen";

public override string Name
{
get { return CommandName; }
}

public override string Text
{
get { return Resources.ViewFullScreenCommandText; }
}

public override string ToolTip
{
get { return Resources.ViewFullScreenCommandToolTip; }
}

public override Uri IconSource
{
get { return new Uri("pack://application:,,,/Gemini;component/Resources/Icons/FullScreen.png"); }
}

[Export]
public static CommandKeyboardShortcut KeyGesture = new CommandKeyboardShortcut<ViewFullScreenCommandDefinition>(new KeyGesture(Key.Enter, ModifierKeys.Shift | ModifierKeys.Alt));
}
}
23 changes: 23 additions & 0 deletions src/Gemini/Modules/Shell/Commands/ViewFullscreenCommandHandler.cs
@@ -0,0 +1,23 @@
using System.Threading.Tasks;
using System.Windows;
using Gemini.Framework.Commands;
using Gemini.Framework.Threading;

namespace Gemini.Modules.Shell.Commands
{
[CommandHandler]
public class ViewFullScreenCommandHandler : CommandHandlerBase<ViewFullScreenCommandDefinition>
{
public override Task Run(Command command)
{
var window = Application.Current.MainWindow;
if (window == null)
return TaskUtility.Completed;
if (window.WindowState != WindowState.Maximized)
window.WindowState = WindowState.Maximized;
else
window.WindowState = WindowState.Normal;
return TaskUtility.Completed;
}
}
}
4 changes: 4 additions & 0 deletions src/Gemini/Modules/Shell/MenuDefinitions.cs
Expand Up @@ -42,5 +42,9 @@ public static class MenuDefinitions
[Export]
public static MenuItemDefinition WindowDocumentList = new CommandMenuItemDefinition<SwitchToDocumentCommandListDefinition>(
MainMenu.MenuDefinitions.WindowDocumentListMenuGroup, 0);

[Export]
public static MenuItemDefinition ViewFullscreenItem = new CommandMenuItemDefinition<ViewFullScreenCommandDefinition>(
MainMenu.MenuDefinitions.ViewPropertiesMenuGroup, 0);
}
}

0 comments on commit fe1727a

Please sign in to comment.