Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
PropertyGridTest1Control.xaml.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Windows;
6 using System.Windows.Controls;
7 using System.Windows.Data;
8 using System.Windows.Documents;
9 using System.Windows.Input;
10 using System.Windows.Media;
11 using System.Windows.Media.Imaging;
12 using System.Windows.Navigation;
13 using System.Windows.Shapes;
14 using SiliconStudio.Paradox.Framework.ViewModel;
15 
16 namespace SiliconStudio.Paradox.DebugTools
17 {
18  /// <summary>
19  /// Interaction logic for PropertyGridTestControl.xaml
20  /// </summary>
21  public partial class PropertyGridTest1Control : UserControl
22  {
24  {
25  InitializeComponent();
26 
27  PropertyItems = new[] { CreateSampleTree() };
28  this.DataContext = this;
29  }
30 
31  public object PropertyItems { get; private set; }
32 
33  private IViewModelNode CreateSampleTree()
34  {
35  MyDateTime now = MyDateTime.FromDateTime(DateTime.Now);
36 
37  var context = new ViewModelContext(new ViewModelGlobalContext());
38  var contextUI = new ViewModelContext(new ViewModelGlobalContext());
39 
40  context.ChildrenPropertyEnumerators.Add(new ChildrenPropertyInfoEnumerator());
41  // add some more here...
42 
43  var testModel = new ViewModelNode("Root", now);
44 
45  var view = ObservableViewModelNode.CreateObservableViewModel(contextUI, testModel);
46 
47  ObservableViewModelNode.Refresh(contextUI, context, new ViewModelState());
48 
49  return view;
50  }
51  }
52 
53  public struct MyDateTime
54  {
55  //
56  // Summary:
57  // Gets the day of the month represented by this instance.
58  //
59  // Returns:
60  // The day component, expressed as a value between 1 and 31.
61  public int Day { get; private set; }
62  //
63  // Summary:
64  // Gets the day of the week represented by this instance.
65  //
66  // Returns:
67  // A System.DayOfWeek enumerated constant that indicates the day of the week
68  // of this System.DateTime value.
69  public DayOfWeek DayOfWeek { get; private set; }
70  //
71  // Summary:
72  // Gets the day of the year represented by this instance.
73  //
74  // Returns:
75  // The day of the year, expressed as a value between 1 and 366.
76  public int DayOfYear { get; private set; }
77  //
78  // Summary:
79  // Gets the hour component of the date represented by this instance.
80  //
81  // Returns:
82  // The hour component, expressed as a value between 0 and 23.
83  public int Hour { get; private set; }
84  //
85  // Summary:
86  // Gets a value that indicates whether the time represented by this instance
87  // is based on local time, Coordinated Universal Time (UTC), or neither.
88  //
89  // Returns:
90  // One of the System.DateTimeKind values. The default is System.DateTimeKind.Unspecified.
91  public DateTimeKind Kind { get; private set; }
92  //
93  // Summary:
94  // Gets the milliseconds component of the date represented by this instance.
95  //
96  // Returns:
97  // The milliseconds component, expressed as a value between 0 and 999.
98  public int Millisecond { get; private set; }
99  //
100  // Summary:
101  // Gets the minute component of the date represented by this instance.
102  //
103  // Returns:
104  // The minute component, expressed as a value between 0 and 59.
105  public int Minute { get; private set; }
106  //
107  // Summary:
108  // Gets the month component of the date represented by this instance.
109  //
110  // Returns:
111  // The month component, expressed as a value between 1 and 12.
112  public int Month { get; private set; }
113  //
114  // Summary:
115  // Gets the seconds component of the date represented by this instance.
116  //
117  // Returns:
118  // The seconds, between 0 and 59.
119  public int Second { get; private set; }
120  //
121  // Summary:
122  // Gets the number of ticks that represent the date and time of this instance.
123  //
124  // Returns:
125  // The number of ticks that represent the date and time of this instance. The
126  // value is between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
127  public long Ticks { get; private set; }
128  //
129  // Summary:
130  // Gets the time of day for this instance.
131  //
132  // Returns:
133  // A System.TimeSpan that represents the fraction of the day that has elapsed
134  // since midnight.
135  public TimeSpan TimeOfDay { get; private set; }
136  //
137  // Summary:
138  // Gets the year component of the date represented by this instance.
139  //
140  // Returns:
141  // The year, between 1 and 9999.
142  public int Year { get; private set; }
143 
144  public static MyDateTime FromDateTime(DateTime dateTime)
145  {
146  return new MyDateTime
147  {
148  Day = dateTime.Day,
149  DayOfWeek = dateTime.DayOfWeek,
150  DayOfYear = dateTime.DayOfYear,
151  Hour = dateTime.Hour,
152  Kind = dateTime.Kind,
153  Millisecond= dateTime.Millisecond,
154  Minute = dateTime.Minute,
155  Month = dateTime.Month,
156  Second = dateTime.Second,
157  Ticks = dateTime.Ticks,
158  TimeOfDay = dateTime.TimeOfDay,
159  Year = dateTime.Year,
160  };
161  }
162  }
163 }
Interaction logic for PropertyGridTestControl.xaml