OSDN Git Service

実際の使用シーンに合わせた
authorgdkhd812 <test@yahoo.co.jp>
Mon, 8 May 2017 12:53:51 +0000 (21:53 +0900)
committergdkhd812 <test@yahoo.co.jp>
Mon, 8 May 2017 12:53:51 +0000 (21:53 +0900)
UWP/Test/MainPage.xaml
UWP/Test/MainPage.xaml.cs

index f277b5c..0d186ad 100644 (file)
 
     <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
         <Grid.RowDefinitions>
-            <RowDefinition Height="Auto"/>
+            <RowDefinition/>
             <RowDefinition/>
         </Grid.RowDefinitions>
-        <StackPanel Orientation="Horizontal" Grid.Row="0">
-            <ComboBox ItemsSource="{Binding DocumentList}" SelectedItem="{Binding CurrentDocument,Mode=TwoWay}">
-                <ComboBox.ItemTemplate>
-                    <DataTemplate>
-                        <TextBlock Text="{Binding Title}"/>
-                    </DataTemplate>
-                </ComboBox.ItemTemplate>
-            </ComboBox>
+        <Pivot ItemsSource="{Binding DocumentList}" Grid.Row="0" SelectedItem="{Binding CurrentDocument,Mode=TwoWay}">
+            <Pivot.HeaderTemplate>
+                <DataTemplate>
+                    <TextBlock Text="{Binding Title}"/>
+                </DataTemplate>
+            </Pivot.HeaderTemplate>
+            <Pivot.ItemTemplate>
+                <DataTemplate>
+                    <foo:FooTextBox Name="fooTextBox" Document="{Binding }" AllowFocusOnInteraction="True"></foo:FooTextBox>
+                </DataTemplate>
+            </Pivot.ItemTemplate>
+        </Pivot>
+        <StackPanel Grid.Row="1" >
             <Button Content="Load" Click="Button_Click"/>
             <Button Content="Print" Click="Print_Button_Click"/>
-        <foo:FooTextBox  Grid.Row="1" Name="fooTextBox" Document="{Binding CurrentDocument,Mode=TwoWay}" AllowFocusOnInteraction="True"></foo:FooTextBox>
+        </StackPanel>
     </Grid>
 </Page>
index 995d4af..5ae0671 100644 (file)
@@ -27,7 +27,6 @@ namespace Test
         {
             this.InitializeComponent();
             this.DataContext = this.vm;
-            this.fooTextBox.Document = this.vm.CurrentDocument;
             //this.fooTextBox.AllowFocusOnInteraction = true;
             PrintManager.GetForCurrentView().PrintTaskRequested += MainPage_PrintTaskRequested;
             InputPane currentView = InputPane.GetForCurrentView();
@@ -37,13 +36,13 @@ namespace Test
 
         void currentView_Hiding(InputPane sender, InputPaneVisibilityEventArgs args)
         {
-            this.fooTextBox.Margin = new Thickness(0);
+            this.Margin = new Thickness(0);
             args.EnsuredFocusedElementInView = true;
         }
 
         void currentView_Showing(InputPane sender, InputPaneVisibilityEventArgs args)
         {
-            this.fooTextBox.Margin = new Thickness(0, 0, 0, args.OccludedRect.Height);
+            this.Margin = new Thickness(0, 0, 0, args.OccludedRect.Height);
             args.EnsuredFocusedElementInView = true;
         }
 
@@ -51,16 +50,17 @@ namespace Test
         {
             IAsyncAction async = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
             {
-                var source = new DocumentSource(this.fooTextBox.Document, new FooEditEngine.Padding(20, 20, 20, 20), this.fooTextBox.FontFamily.Source, this.fooTextBox.FontSize);
+                var doc = this.vm.CurrentDocument;
+                var source = new DocumentSource(doc, new FooEditEngine.Padding(20, 20, 20, 20), this.FontFamily.Source, this.FontSize);
                 source.ParseHF = (s,e)=> { return e.Original; };
                 source.Header = "header";
                 source.Fotter = "footer";
-                source.Forground = this.fooTextBox.Foreground;
-                source.Keyword1 = this.fooTextBox.Keyword1;
-                source.Keyword2 = this.fooTextBox.Keyword2;
-                source.Literal = this.fooTextBox.Literal;
-                source.Comment = this.fooTextBox.Comment;
-                source.Url = this.fooTextBox.URL;
+                source.Forground = new Windows.UI.Color() { R = 0, A = 255, B = 0, G = 0};
+                source.Keyword1 = new Windows.UI.Color() { R = 0, A = 255, B = 255, G = 0 };
+                source.Keyword2 = new Windows.UI.Color() { R = 128, A = 255, B = 255, G = 0 };
+                source.Literal = new Windows.UI.Color() { R = 128, A = 255, B = 128, G = 0 };
+                source.Comment = new Windows.UI.Color() { R = 255, A = 255, B = 0, G = 0 };
+                source.Url = new Windows.UI.Color() { R = 0, A = 255, B = 255, G = 0 };
 
                 PrintTask task = null;
                 task = args.Request.CreatePrintTask("test", (e) =>
@@ -90,8 +90,9 @@ namespace Test
                 using (var ws = await file.OpenAsync(FileAccessMode.Read))
                 using (var fs = new StreamReader(ws.AsStream()))
                 {
-                    await this.fooTextBox.LoadFileAsync(fs, null);
+                    await this.vm.CurrentDocument.LoadAsync(fs, null);
                 }
+                this.vm.CurrentDocument.RequestRedraw();
             }
         }