ソースを参照

Merge pull request #439 from VitalElement/master

Added Folder Browse to Test App and Fixed UndoRedoHelper
Steven Kirk 9 年 前
コミット
33efd9beb1

+ 22 - 0
samples/XamlTestApplicationPcl/ViewModels/MainWindowViewModel.cs

@@ -4,6 +4,7 @@
 using System;
 using System.Collections.Generic;
 using ReactiveUI;
+using Perspex.Controls;
 
 namespace XamlTestApplication.ViewModels
 {
@@ -59,6 +60,23 @@ namespace XamlTestApplication.ViewModels
             CollapseNodesCommand.Subscribe(_ => ExpandNodes(false));
             ExpandNodesCommand = ReactiveCommand.Create();
             ExpandNodesCommand.Subscribe(_ => ExpandNodes(true));
+
+            OpenFileCommand = ReactiveCommand.Create();
+            OpenFileCommand.Subscribe(_ =>
+            {
+                var ofd = new OpenFileDialog();
+
+                ofd.ShowAsync();
+            });
+
+            OpenFolderCommand = ReactiveCommand.Create();
+            OpenFolderCommand.Subscribe(_ =>
+            {
+                var ofd = new OpenFolderDialog();
+
+                ofd.ShowAsync();
+            });
+
         }
 
         public List<TestItem> Items { get; }
@@ -68,6 +86,10 @@ namespace XamlTestApplication.ViewModels
 
         public ReactiveCommand<object> ExpandNodesCommand { get; }
 
+        public ReactiveCommand<object> OpenFileCommand { get; }
+
+        public ReactiveCommand<object> OpenFolderCommand { get; }
+
         public void ExpandNodes(bool expanded)
         {
             foreach (var node in Nodes)

+ 4 - 2
samples/XamlTestApplicationPcl/Views/MainWindow.paml

@@ -6,11 +6,13 @@
         Title="Perspex Test Application" Width="800" Height="600">
   <Grid RowDefinitions="Auto,*,Auto" ColumnDefinitions="*,*">
     <Menu Grid.ColumnSpan="2">
-      <MenuItem Header="_File" Background="Red">
+      <MenuItem Header="_File">
+        <MenuItem Header="_Open" Command="{Binding OpenFileCommand}" />
+        <MenuItem Header="_Open Folder" Command="{Binding OpenFolderCommand}" />
         <MenuItem Header="_Hello">
           <MenuItem Header="_Goodbye"/>
           <Separator/>
-          <MenuItem Header="_World" Background="Red"/>
+          <MenuItem Header="_World" />
         </MenuItem>
         <Separator Background="Red"/>
         <MenuItem Header="_Test"/>

+ 2 - 2
src/Perspex.Controls/Utils/UndoRedoHelper.cs

@@ -42,7 +42,7 @@ namespace Perspex.Controls.Utils
 				_currentNode = _currentNode.Previous;
 			}
 
-			_host.UndoRedoState = _currentNode?.Value;            
+			_host.UndoRedoState = _currentNode.Value;            
         }
 
         public bool IsLastState => _currentNode.Next == null;
@@ -72,7 +72,7 @@ namespace Perspex.Controls.Utils
 				_currentNode = _currentNode.Next;
 			}
 
-			_host.UndoRedoState = _currentNode?.Value;
+			_host.UndoRedoState = _currentNode.Value;
         }
 
         public void Snapshot()