• R/O
  • HTTP
  • SSH
  • HTTPS

FooEditor: Commit


Commit MetaInfo

Revisionae366be519cc00ab82321ad12728db81a3141dfc (tree)
Time2019-09-10 21:11:02
Authortest <test@yaho...>
Commitertest

Log Message

ファイル操作時にダイアログ出さないといけない場面があった

Change Summary

Incremental Difference

--- a/UWP/FooEditor.UWP/Package.appxmanifest
+++ b/UWP/FooEditor.UWP/Package.appxmanifest
@@ -1,6 +1,6 @@
11 <?xml version="1.0" encoding="utf-8"?>
22 <Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
3- <Identity Name="51377FooProject.404123402F54A" Publisher="CN=224662AF-5ED0-4C7C-8B20-13E2E5ECF61F" Version="1.24.12.0" />
3+ <Identity Name="51377FooProject.404123402F54A" Publisher="CN=224662AF-5ED0-4C7C-8B20-13E2E5ECF61F" Version="1.24.13.0" />
44 <mp:PhoneIdentity PhoneProductId="5ae4027c-fa57-4895-9806-b04fc4e5abfe" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
55 <Properties>
66 <DisplayName>FooEditor</DisplayName>
--- a/UWP/FooEditor.UWP/Properties/AssemblyInfo.cs
+++ b/UWP/FooEditor.UWP/Properties/AssemblyInfo.cs
@@ -24,6 +24,6 @@ using System.Runtime.InteropServices;
2424 // You can specify all the values or you can default the Build and Revision Numbers
2525 // by using the '*' as shown below:
2626 // [assembly: AssemblyVersion("1.0.*")]
27-[assembly: AssemblyVersion("1.24.11.0")]
28-[assembly: AssemblyFileVersion("1.24.11.0")]
27+[assembly: AssemblyVersion("1.24.13.0")]
28+[assembly: AssemblyFileVersion("1.24.13.0")]
2929 [assembly: ComVisible(false)]
\ No newline at end of file
--- a/UWP/FooEditor.UWP/Services/MainViewService.cs
+++ b/UWP/FooEditor.UWP/Services/MainViewService.cs
@@ -28,6 +28,7 @@ namespace FooEditor.UWP.Services
2828 set;
2929 }
3030 Task<bool> ConfirmRestoreUserState();
31+ Task MakeMessageBox(string s);
3132 void MakeNotifaction(string text);
3233 }
3334
@@ -51,7 +52,11 @@ namespace FooEditor.UWP.Services
5152 return res.Label == loader.GetString("YesButton");
5253 }
5354
54-
55+ public async Task MakeMessageBox(string s)
56+ {
57+ var msg = new MessageDialog(s);
58+ await msg.ShowAsync();
59+ }
5560
5661 public void MakeNotifaction(string text)
5762 {
--- a/UWP/FooEditor.UWP/ViewModels/MainPageViewModel.cs
+++ b/UWP/FooEditor.UWP/ViewModels/MainPageViewModel.cs
@@ -213,7 +213,13 @@ namespace FooEditor.UWP.ViewModels
213213 get
214214 {
215215 return new DelegateCommand<System.Text.Encoding>(async (s) => {
216- await this._doc_list.AddFromFilePicker(s);
216+ try
217+ {
218+ await this._doc_list.AddFromFilePicker(s);
219+ }catch(Exception ex)
220+ {
221+ await this.MainViewService.MakeMessageBox(ex.Message);
222+ }
217223 });
218224 }
219225 }
@@ -225,10 +231,39 @@ namespace FooEditor.UWP.ViewModels
225231 return new DelegateCommand<IEnumerable<string>>(async (s) => {
226232 if (s == null)
227233 return;
228- foreach(var file_path in s)
234+ try
235+ {
236+ foreach (var file_path in s)
237+ {
238+ var file = await FileModel.GetFileModelFromPath(file_path);
239+ await this.DocumentList.AddFromFile(file.File);
240+ }
241+ }
242+ catch (Exception ex)
243+ {
244+ await this.MainViewService.MakeMessageBox(ex.Message);
245+ }
246+ });
247+ }
248+ }
249+
250+ public DelegateCommand<IEnumerable<IStorageItem>> OpenFilesCommand
251+ {
252+ get
253+ {
254+ return new DelegateCommand<IEnumerable<IStorageItem>>(async (s) => {
255+ if (s == null)
256+ return;
257+ try
229258 {
230- var file = await FileModel.GetFileModelFromPath(file_path);
231- await this.DocumentList.AddFromFile(file.File);
259+ foreach (StorageFile file in s)
260+ {
261+ await this.DocumentList.AddFromFile(file);
262+ }
263+ }
264+ catch (Exception ex)
265+ {
266+ await this.MainViewService.MakeMessageBox(ex.Message);
232267 }
233268 });
234269 }
@@ -244,20 +279,27 @@ namespace FooEditor.UWP.ViewModels
244279 await SaveAs(null);
245280 return;
246281 }
247- var fileModel = await FileModel.GetFileModelFromPath(this._doc_list.Current.DocumentModel.CurrentFilePath);
248- if (fileModel != null)
282+ try
249283 {
250- if (fileModel.IsNeedUserActionToSave())
251- await this.SaveAs(fileModel);
252- else
284+ var fileModel = await FileModel.GetFileModelFromPath(this._doc_list.Current.DocumentModel.CurrentFilePath);
285+ if (fileModel != null)
253286 {
254- await this._doc_list.Current.DocumentModel.SaveFile(fileModel,null);
255- var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
256- var str = string.Format(loader.GetString("NotifySaveCompleteText"), fileModel.Name);
257- this.StatusMessage = str;
258- this.IsRequierDelayCleanStatusMessage = true;
287+ if (fileModel.IsNeedUserActionToSave())
288+ await this.SaveAs(fileModel);
289+ else
290+ {
291+ await this._doc_list.Current.DocumentModel.SaveFile(fileModel, null);
292+ var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
293+ var str = string.Format(loader.GetString("NotifySaveCompleteText"), fileModel.Name);
294+ this.StatusMessage = str;
295+ this.IsRequierDelayCleanStatusMessage = true;
296+ }
259297 }
260298 }
299+ catch (Exception ex)
300+ {
301+ await this.MainViewService.MakeMessageBox(ex.Message);
302+ }
261303 });
262304 }
263305 }
--- a/UWP/FooEditor.UWP/Views/MainPage.xaml.cs
+++ b/UWP/FooEditor.UWP/Views/MainPage.xaml.cs
@@ -145,10 +145,7 @@ namespace FooEditor.UWP.Views
145145 MainPageViewModel vm = this.DataContext as MainPageViewModel;
146146 // ファイルのパス一覧を取得する
147147 var items = await e.DataView.GetStorageItemsAsync();
148- foreach(StorageFile item in items)
149- {
150- await vm.DocumentList.AddFromFile(item);
151- }
148+ vm.OpenFilesCommand.Execute(items);
152149 }
153150
154151 d.Complete();
Show on old repository browser