• R/O
  • HTTP
  • SSH
  • HTTPS

FooEditEngine: Commit


Commit MetaInfo

Revisionf47c1486e640ab74c09d6ae65fb9a43c059df5f6 (tree)
Time2020-08-23 12:47:29
Authortest <test@yaho...>
Commitertest

Log Message

ファイルを指定した時の状態も指定できるようにした

Change Summary

Incremental Difference

--- a/UWP/Test/App.xaml.cs
+++ b/UWP/Test/App.xaml.cs
@@ -79,6 +79,21 @@ namespace Test
7979 }
8080 }
8181
82+ protected override void OnFileActivated(FileActivatedEventArgs e)
83+ {
84+ base.OnFileActivated(e);
85+ Frame rootFrame = Window.Current.Content as Frame;
86+
87+ if (rootFrame == null)
88+ {
89+ rootFrame = new Frame();
90+ rootFrame.NavigationFailed += OnNavigationFailed;
91+ Window.Current.Content = rootFrame;
92+ }
93+ rootFrame.Navigate(typeof(MainPage), e);
94+ Window.Current.Activate();
95+ }
96+
8297 /// <summary>
8398 /// 特定のページへの移動が失敗したときに呼び出されます
8499 /// </summary>
--- a/UWP/Test/MainPage.xaml.cs
+++ b/UWP/Test/MainPage.xaml.cs
@@ -12,6 +12,10 @@ using Windows.Storage.Pickers;
1212 using Windows.Graphics.Printing;
1313 using Windows.Graphics.Printing.OptionDetails;
1414 using FooEditEngine.UWP;
15+using Windows.UI.Xaml.Navigation;
16+using Windows.ApplicationModel.Activation;
17+using System.Linq;
18+using Windows.Storage.AccessCache;
1519
1620 // 空白ページのアイテム テンプレートについては、http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 を参照してください
1721
@@ -34,6 +38,29 @@ namespace Test
3438 currentView.Hiding += currentView_Hiding;
3539 }
3640
41+ protected override async void OnNavigatedTo(NavigationEventArgs e)
42+ {
43+ var fileargs = e.Parameter as FileActivatedEventArgs;
44+ if (fileargs != null)
45+ {
46+ var filepaths = from file in fileargs.Files
47+ select file.Path;
48+
49+ //MRUに追加しないと後で開けない
50+ foreach (var file in fileargs.Files)
51+ {
52+ StorageApplicationPermissions.MostRecentlyUsedList.Add(file, "mrufile");
53+ this.vm.AddDocument();
54+ await LoadFile(this.vm.CurrentDocument, file as IStorageFile);
55+ }
56+
57+ }
58+ else if(this.vm.DocumentList.Count == 0)
59+ {
60+ this.vm.Initalize();
61+ }
62+ }
63+
3764 void currentView_Hiding(InputPane sender, InputPaneVisibilityEventArgs args)
3865 {
3966 this.Margin = new Thickness(0);
@@ -85,14 +112,19 @@ namespace Test
85112 var filepicker = new FileOpenPicker();
86113 filepicker.FileTypeFilter.Add(".txt");
87114 var file = await filepicker.PickSingleFileAsync();
88- if(file != null)
115+ await LoadFile(this.vm.CurrentDocument, file);
116+ }
117+
118+ private async Task LoadFile(FooEditEngine.Document doc,IStorageFile file)
119+ {
120+ if (file != null)
89121 {
90122 using (var ws = await file.OpenAsync(FileAccessMode.Read))
91123 using (var fs = new StreamReader(ws.AsStream()))
92124 {
93- await this.vm.CurrentDocument.LoadAsync(fs, null);
125+ await doc.LoadAsync(fs, null);
94126 }
95- this.vm.CurrentDocument.RequestRedraw();
127+ doc.RequestRedraw();
96128 }
97129 }
98130
--- a/UWP/Test/MainViewModel.cs
+++ b/UWP/Test/MainViewModel.cs
@@ -16,25 +16,6 @@ namespace Test
1616
1717 public MainViewModel()
1818 {
19- var complete_collection = new CompleteCollection<ICompleteItem>();
20- CompleteHelper.AddComleteWord(complete_collection, "int");
21- CompleteHelper.AddComleteWord(complete_collection, "float");
22- CompleteHelper.AddComleteWord(complete_collection, "double");
23- CompleteHelper.AddComleteWord(complete_collection, "char");
24- CompleteHelper.AddComleteWord(complete_collection, "byte");
25- CompleteHelper.AddComleteWord(complete_collection, "var");
26- CompleteHelper.AddComleteWord(complete_collection, "short");
27-
28- var doc = new Document() { Title = "test1" };
29- doc.AutoComplete = new AutoCompleteBox(doc);
30- doc.AutoComplete.Items = complete_collection;
31- doc.AutoComplete.Enabled = true;
32- this._list.Add(doc);
33-
34- doc = new Document() { Title = "test2" };
35- this._list.Add(doc);
36-
37- this.CurrentDocument = this._list[0];
3819 }
3920
4021 public ObservableCollection<Document> DocumentList
@@ -65,6 +46,29 @@ namespace Test
6546
6647 public event PropertyChangedEventHandler PropertyChanged;
6748
49+ public void Initalize()
50+ {
51+ var complete_collection = new CompleteCollection<ICompleteItem>();
52+ CompleteHelper.AddComleteWord(complete_collection, "int");
53+ CompleteHelper.AddComleteWord(complete_collection, "float");
54+ CompleteHelper.AddComleteWord(complete_collection, "double");
55+ CompleteHelper.AddComleteWord(complete_collection, "char");
56+ CompleteHelper.AddComleteWord(complete_collection, "byte");
57+ CompleteHelper.AddComleteWord(complete_collection, "var");
58+ CompleteHelper.AddComleteWord(complete_collection, "short");
59+
60+ var doc = new Document() { Title = "test1" };
61+ doc.AutoComplete = new AutoCompleteBox(doc);
62+ doc.AutoComplete.Items = complete_collection;
63+ doc.AutoComplete.Enabled = true;
64+ this._list.Add(doc);
65+
66+ doc = new Document() { Title = "test2" };
67+ this._list.Add(doc);
68+
69+ this.CurrentDocument = this._list[0];
70+ }
71+
6872 public void AddDocument()
6973 {
7074 var doc = new Document() { Title = "test" + this._list.Count };
--- a/UWP/Test/Package.appxmanifest
+++ b/UWP/Test/Package.appxmanifest
@@ -1,48 +1,36 @@
11 <?xml version="1.0" encoding="utf-8"?>
2-
3-<Package
4- xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
5- xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
6- xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
7- IgnorableNamespaces="uap mp">
8-
9- <Identity
10- Name="59431542-1ecc-401d-a949-43ef08810b38"
11- Publisher="CN=matin"
12- Version="1.0.0.0" />
13-
14- <mp:PhoneIdentity PhoneProductId="59431542-1ecc-401d-a949-43ef08810b38" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
15-
2+<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="59431542-1ecc-401d-a949-43ef08810b38" Publisher="CN=matin" Version="1.0.0.0" />
4+ <mp:PhoneIdentity PhoneProductId="59431542-1ecc-401d-a949-43ef08810b38" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
165 <Properties>
176 <DisplayName>Test</DisplayName>
187 <PublisherDisplayName>matin</PublisherDisplayName>
198 <Logo>Assets\StoreLogo.png</Logo>
209 </Properties>
21-
2210 <Dependencies>
2311 <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
2412 </Dependencies>
25-
2613 <Resources>
27- <Resource Language="x-generate"/>
14+ <Resource Language="x-generate" />
2815 </Resources>
29-
3016 <Applications>
31- <Application Id="App"
32- Executable="$targetnametoken$.exe"
33- EntryPoint="Test.App">
34- <uap:VisualElements
35- DisplayName="Test"
36- Square150x150Logo="Assets\Square150x150Logo.png"
37- Square44x44Logo="Assets\Square44x44Logo.png"
38- Description="Test"
39- BackgroundColor="transparent">
40- <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
17+ <Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="Test.App">
18+ <uap:VisualElements DisplayName="Test" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="Test" BackgroundColor="transparent">
19+ <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
20+ </uap:DefaultTile>
4121 <uap:SplashScreen Image="Assets\SplashScreen.png" />
4222 </uap:VisualElements>
23+ <Extensions>
24+ <uap:Extension Category="windows.fileTypeAssociation">
25+ <uap:FileTypeAssociation Name="testfilesupport">
26+ <uap:SupportedFileTypes>
27+ <uap:FileType>.txt</uap:FileType>
28+ </uap:SupportedFileTypes>
29+ </uap:FileTypeAssociation>
30+ </uap:Extension>
31+ </Extensions>
4332 </Application>
4433 </Applications>
45-
4634 <Capabilities>
4735 <Capability Name="internetClient" />
4836 </Capabilities>
Show on old repository browser