-
-
Notifications
You must be signed in to change notification settings - Fork 298
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from diluculo/215_SaveAllCommand
Add SaveAllCommand
- Loading branch information
Showing
6 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/Gemini/Modules/Shell/Commands/SaveAllFilesCommandDefinition.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Gemini.Framework.Commands; | ||
using Gemini.Properties; | ||
using System; | ||
using System.ComponentModel.Composition; | ||
using System.Windows.Input; | ||
|
||
namespace Gemini.Modules.Shell.Commands | ||
{ | ||
[CommandDefinition] | ||
public class SaveAllFilesCommandDefinition : CommandDefinition | ||
{ | ||
public const string CommandName = "File.SaveAllFiles"; | ||
|
||
public override string Name | ||
{ | ||
get { return CommandName; } | ||
} | ||
|
||
public override string Text | ||
{ | ||
get { return Resources.FileSaveAllCommandText; } | ||
} | ||
|
||
public override string ToolTip | ||
{ | ||
get { return Resources.FileSaveAllCommandToolTip; } | ||
} | ||
|
||
public override Uri IconSource | ||
{ | ||
get | ||
{ | ||
return new Uri("pack://application:,,,/Gemini;component/Resources/Icons/SaveAll.png"); | ||
} | ||
} | ||
|
||
[Export] | ||
public static CommandKeyboardShortcut KeyGesture = new CommandKeyboardShortcut<SaveAllFilesCommandDefinition>(new KeyGesture(Key.S, ModifierKeys.Control | ModifierKeys.Shift)); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/Gemini/Modules/Shell/Commands/SaveAllFilesCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Gemini.Framework; | ||
using Gemini.Framework.Commands; | ||
using Gemini.Framework.Services; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.Composition; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Gemini.Modules.Shell.Commands | ||
{ | ||
[CommandHandler] | ||
public class SaveAllFilesCommandHandler : CommandHandlerBase<SaveAllFilesCommandDefinition> | ||
{ | ||
private readonly IShell _shell; | ||
|
||
[ImportingConstructor] | ||
public SaveAllFilesCommandHandler(IShell shell) | ||
{ | ||
_shell = shell; | ||
} | ||
|
||
public override async Task Run(Command command) | ||
{ | ||
var tasks = new List<Task<Tuple<IPersistedDocument, bool>>>(); | ||
|
||
foreach (var document in _shell.Documents.OfType<IPersistedDocument>().Where(x => !x.IsNew)) | ||
{ | ||
await document.Save(document.FilePath); | ||
} | ||
|
||
// TODO: display "Item(s) saved" in statusbar | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.