-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNoteTreeViewItem.cs
More file actions
143 lines (111 loc) · 3.79 KB
/
NoteTreeViewItem.cs
File metadata and controls
143 lines (111 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
using Notatnik3.Service.Model;
using Notatnik3Service.Model;
using ReactiveUI;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Windows;
using TreeViewExperimentsIntegration;
namespace WPFEmptyProject
{
/// <summary>
/// only keep what is needed to currently show on UI. take the rest from db
/// </summary>
public class NoteTreeViewItem : ReactiveObject, INoteItem
{
public enum NodeType
{
Folder,
Note
}
public NodeType TreeNodeType { get; set; }
public DateTime CreatedDate { get; set; }
public int Id { get; set; }
public NoteTreeViewItem()
{
SubItems = new ObservableCollection<NoteTreeViewItem>();
}
//public TreeViewItem ParentFolder { get; set; }
ObservableCollection<NoteTreeViewItem> subItems;
public ObservableCollection<NoteTreeViewItem> SubItems
{
get { return subItems; }
set { this.RaiseAndSetIfChanged(ref subItems, value); }
}
bool isSelected = false;
public bool IsSelected
{
get { return isSelected; }
set { this.RaiseAndSetIfChanged(ref isSelected, value); }
}
bool isExpanded = false;
public bool IsExpanded
{
get { return isExpanded; }
set { this.RaiseAndSetIfChanged(ref isExpanded, value); }
}
//public Visibility IsNodeVisible { get; set; }
Visibility nodeVisibility = Visibility.Visible;
public Visibility NodeVisibility
{
get { return nodeVisibility; }
set { this.RaiseAndSetIfChanged(ref nodeVisibility, value); }
}
bool isNodeVisible;
public bool IsNodeVisible
{
get { return isNodeVisible; }
set { this.RaiseAndSetIfChanged(ref isNodeVisible, value); }
}
//this can change if note modified thus INotifyPropertyChanged
DateTime? modifyDate;
public DateTime? ModifyDate
{
get { return modifyDate; }
set { this.RaiseAndSetIfChanged(ref modifyDate, value); }
}
//this can change if note modified
DateTime? lastOpenDate;
public DateTime? LastOpenDate
{
get { return lastOpenDate; }
set { this.RaiseAndSetIfChanged(ref lastOpenDate, value); }
}
string name;
public string Name
{
get { return name; }
set { this.RaiseAndSetIfChanged(ref name, value); }
}
string fileName;
public string FileName
{
get { return fileName; }
set { this.RaiseAndSetIfChanged(ref fileName, value); }
}
NoteTreeViewItem parentTreeViewItem;
public NoteTreeViewItem ParentTreeViewItem
{
get { return parentTreeViewItem; }
set { this.RaiseAndSetIfChanged(ref parentTreeViewItem, value); }
}
string description;
public string Description {
get { return description; }
set { this.RaiseAndSetIfChanged(ref description, value); }
}
public NoteTreeViewItem FromNoteItem(INoteItem noteItem)
{
var tvItem = new NoteTreeViewItem();
//this.NodeVisibility = Visibility.Hidden;
tvItem.Name = noteItem.Name;
tvItem.CreatedDate = noteItem.CreatedDate;
tvItem.ModifyDate = noteItem.ModifyDate;
tvItem.Id = noteItem.Id;
tvItem.SubItems = new ObservableCollection<NoteTreeViewItem>();
tvItem.TreeNodeType = (noteItem is Note) ? NodeType.Note : NodeType.Folder;
return tvItem;
}
}
}