• R/O
  • HTTP
  • SSH
  • HTTPS

FooEditor: Commit


Commit MetaInfo

Revisiondbd2848089d86b175ee173c613d52eb1ee5cd8a1 (tree)
Time2019-02-06 14:22:54
Authortest <test@yaho...>
Commitertest

Log Message

ファイル保存時の使い勝手を向上させた

Change Summary

Incremental Difference

--- a/UWP/FooEditor.UWP/Models/FileModel.cs
+++ b/UWP/FooEditor.UWP/Models/FileModel.cs
@@ -37,6 +37,14 @@ namespace FooEditor
3737 }
3838 }
3939
40+ public string Extension
41+ {
42+ get
43+ {
44+ return this.File.FileType;
45+ }
46+ }
47+
4048 public static string TrimFullPath(string filepath)
4149 {
4250 if (filepath == null || filepath == "")
--- a/UWP/FooEditor.UWP/ViewModels/MainPageViewModel.cs
+++ b/UWP/FooEditor.UWP/ViewModels/MainPageViewModel.cs
@@ -262,7 +262,15 @@ namespace FooEditor.UWP.ViewModels
262262 get
263263 {
264264 return new DelegateCommand<System.Text.Encoding>(async (enc) => {
265- await SaveAs(null, enc);
265+ if (this._doc_list.Current.DocumentModel.CurrentFilePath == null)
266+ {
267+ await SaveAs(null, enc);
268+ }
269+ else
270+ {
271+ var fileModel = await FileModel.GetFileModelFromPath(this._doc_list.Current.DocumentModel.CurrentFilePath);
272+ await SaveAs(fileModel, enc);
273+ }
266274 });
267275 }
268276 }
@@ -270,14 +278,27 @@ namespace FooEditor.UWP.ViewModels
270278 private async Task SaveAs(FileModel suggestFile, System.Text.Encoding enc = null)
271279 {
272280 FileSavePicker savePicker = new FileSavePicker();
273- savePicker.FileTypeChoices.Add("Unknown", new List<string>() { "." });
274- ObservableCollection<FileType> collection = AppSettings.Current.FileTypeCollection;
275- foreach (FileType type in collection)
276- savePicker.FileTypeChoices.Add(type.DocumentTypeName, type.ExtensionCollection);
281+
282+ //これをつけないとファイルダイアログで拡張子を変えることができなくなる
283+ List<string> currentFileTypes = new List<string> { "." };
277284 if (suggestFile == null)
285+ {
278286 savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
287+ }
279288 else
289+ {
280290 savePicker.SuggestedSaveFile = suggestFile.File;
291+ //現在開いているファイルの拡張子を追加すると未知の拡張子でもファイルダイアログに表示される
292+ currentFileTypes.Add(suggestFile.Extension);
293+ }
294+ savePicker.FileTypeChoices.Add("Current File Type", currentFileTypes);
295+
296+ ObservableCollection<FileType> collection = AppSettings.Current.FileTypeCollection;
297+ foreach (FileType type in collection)
298+ {
299+ savePicker.FileTypeChoices.Add(type.DocumentTypeName, type.ExtensionCollection);
300+ }
301+
281302 StorageFile file = await savePicker.PickSaveFileAsync();
282303 if (file != null)
283304 {
Show on old repository browser