[runtime] Fix corlib out of date error with disabled COM
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / View / TreeView / TreeViewItemKeyValuePairModelItemViewModel.cs
1 //----------------------------------------------------------------
2 // <copyright company="Microsoft Corporation">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //----------------------------------------------------------------
6
7 namespace System.Activities.Presentation.View.TreeView
8 {
9     using System;
10     using System.Activities.Presentation.Internal.PropertyEditing;
11     using System.Activities.Presentation.Model;
12     using System.Collections.Generic;
13     using System.Diagnostics.CodeAnalysis;
14
15     internal sealed class TreeViewItemKeyValuePairModelItemViewModel : TreeViewItemViewModel<KeyValuePair<ModelItem, ModelItem>>
16     {
17         public TreeViewItemKeyValuePairModelItemViewModel(TreeViewItemViewModel parent, KeyValuePair<ModelItem, ModelItem> value) : base(parent)
18         {
19             this.Value = value;
20             this.VisualValue = value;
21             this.UpdateState();
22             if (this.HasChildren)
23             {
24                 this.InternalChildren.Add(TreeViewItemViewModel.DummyNode);
25             }
26         }
27
28         internal override void LoadChildren()
29         {
30             if (this.PerfEventProvider != null)
31             {
32                 this.PerfEventProvider.DesignerTreeViewLoadChildrenStart();
33             }
34
35             base.LoadChildren();
36             if (this.Value.Value != null)
37             {
38                 ChangeNotificationTracker tracker = this.Parent.GetTracker(this);
39
40                 this.AddChild(TreeViewItemViewModel.CreateViewModel(this, this.Value.Value), tracker.ParentProperty);
41             }
42
43             if (this.PerfEventProvider != null)
44             {
45                 this.PerfEventProvider.DesignerTreeViewLoadChildrenEnd();
46             }
47         }
48
49         internal override void UpdateChildren(ChangeNotificationTracker tracker, EventArgs e)
50         {
51             if (this.PerfEventProvider != null)
52             {
53                 this.PerfEventProvider.DesignerTreeViewUpdateStart();
54             }
55
56             base.UpdateChildren(tracker, e);
57             tracker.CleanUp();
58             if (this.Value.Value != null)
59             {
60                 this.AddChild(TreeViewItemViewModel.CreateViewModel(this, this.Value.Value), tracker.ParentProperty);
61             }
62
63             if (this.PerfEventProvider != null)
64             {
65                 this.PerfEventProvider.DesignerTreeViewUpdateEnd();
66             }
67         }
68
69         internal override void UpdateState()
70         {
71             base.UpdateState();
72             if (this.Value.Value != null)
73             {
74                 this.State |= TreeViewItemState.HasChildren;
75             }
76         }
77
78         protected override EditingContext GetEditingContext()
79         {
80             if (this.Value.Key != null)
81             {
82                 return this.Value.Key.GetEditingContext();
83             }
84             else
85             {
86                 return base.GetEditingContext();
87             }
88         }
89     }
90 }