瀏覽代碼

XamlTestApp code cleanup

Nikita Tsukanov 10 年之前
父節點
當前提交
01562bd98c

+ 2 - 4
samples/XamlTestApplication/App.cs

@@ -7,13 +7,11 @@ using Perspex.Themes.Default;
 
 namespace XamlTestApplication
 {
-    public class App : Application
+    public class App : XamlTestApp
     {
-        public App()
+        protected override void RegisterPlatform()
         {
-            RegisterServices();
             InitializeSubsystems((int)Environment.OSVersion.Platform);
-            Styles = new DefaultTheme();
         }
     }
 }

+ 2 - 28
samples/XamlTestApplication/Program.cs

@@ -13,23 +13,6 @@ using XamlTestApplication.Views;
 
 namespace XamlTestApplication
 {
-    internal class Item
-    {
-        public string Name { get; set; }
-        public string Value { get; set; }
-    }
-
-    internal class Node
-    {
-        public Node()
-        {
-            Children = new PerspexList<Node>();
-        }
-
-        public string Name { get; set; }
-        public PerspexList<Node> Children { get; set; }
-    }
-
     internal class Program
     {
         private static void Main()
@@ -38,18 +21,9 @@ namespace XamlTestApplication
 
             App application = new App
             {
-                DataTemplates = new DataTemplates
-                {
-                    new TreeDataTemplate<Node>(
-                        x => new TextBlock { Text = x.Name },
-                        x => x.Children,
-                        x => true),
-                },
-            };
-
-            var testCommand = ReactiveCommand.Create();
-            testCommand.Subscribe(_ => Debug.WriteLine("Test command executed."));
 
+            };
+            
             var window = new MainWindow();
             window.Show();
             Application.Current.Run(window);

+ 0 - 52
samples/XamlTestApplicationPcl/MainViewModel.cs

@@ -1,52 +0,0 @@
-// Copyright (c) The Perspex Project. All rights reserved.
-// Licensed under the MIT license. See licence.md file in the project root for full license information.
-
-using System.Collections.Generic;
-using ReactiveUI;
-
-namespace XamlTestApplication
-{
-    public class MainViewModel : ReactiveObject
-    {
-        private string _name;
-
-        public MainViewModel()
-        {
-            Name = "Jos\u00E9 Manuel";
-            People = new List<Person>
-            {
-                new Person("a little bit of Monica in my life"),
-                new Person("a little bit of Erica by my side"),
-                new Person("a little bit of Rita is all I need"),
-                new Person("a little bit of Tina is what I see"),
-                new Person("a little bit of Sandra in the sun"),
-                new Person("a little bit of Mary all night long"),
-                new Person("a little bit of Jessica here I am"),
-            };
-        }
-
-        public string Name
-        {
-            get { return _name; }
-            set { this.RaiseAndSetIfChanged(ref _name, value); }
-        }
-
-        public List<Person> People { get; set; }
-    }
-
-    public class Person
-    {
-        private string _name;
-
-        public Person(string name)
-        {
-            _name = name;
-        }
-
-        public string Name
-        {
-            get { return _name; }
-            set { _name = value; }
-        }
-    }
-}

+ 22 - 0
samples/XamlTestApplicationPcl/XamlTestApp.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Perspex;
+using Perspex.Themes.Default;
+
+namespace XamlTestApplication
+{
+    public abstract class XamlTestApp : Application
+    {
+        protected abstract void RegisterPlatform();
+
+        public XamlTestApp()
+        {
+            RegisterServices();
+            RegisterPlatform();
+            Styles = new DefaultTheme();
+        }
+    }
+}

+ 1 - 1
samples/XamlTestApplicationPcl/XamlTestApplicationPcl.csproj

@@ -40,9 +40,9 @@
     </EmbeddedResource>
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="MainViewModel.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Views\MainWindow.cs" />
+    <Compile Include="XamlTestApp.cs" />
   </ItemGroup>
   <ItemGroup>
     <Content Include="github_icon.png">