704dbd9ba117a99bbc6e381d94c5e5ccf0fbe42b
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / View / GenericActivityTypeDesigner.xaml.cs
1 // <copyright>
2 //   Copyright (c) Microsoft Corporation.  All rights reserved.
3 // </copyright>
4
5 namespace System.Activities.Presentation.View
6 {
7     using System.Activities.Presentation.Model;
8     using System.Collections.Generic;
9     using System.Linq;
10     using System.Windows;
11     using System.Windows.Controls;
12     using System.Windows.Input;
13
14     internal partial class GenericActivityTypeDesigner
15     {
16         private static AttachedProperty<string> displayNameProperty = new AttachedProperty<string>
17             {
18                 Name = "DisplayName",
19                 OwnerType = typeof(ActivityBuilder<>),
20                 Getter = (modelItem) => ViewUtilities.GetActivityBuilderDisplayName(modelItem)
21             };
22
23         public GenericActivityTypeDesigner()
24         {
25             this.InitializeComponent();
26             DesignerView.SetCommandMenuMode(this, CommandMenuMode.NoCommandMenu);
27         }
28
29         protected override void OnContextMenuLoaded(ContextMenu menu)
30         {
31             menu.IsOpen = false;
32         }
33
34         private void RegisterDisplayNameProperty()
35         {
36             AttachedPropertiesService attachedPropertiesService = 
37                 this.Context.Services.GetService<AttachedPropertiesService>();
38             if (attachedPropertiesService == null)
39             {
40                 return;
41             }
42
43             IEnumerable<AttachedProperty> properties = attachedPropertiesService.GetAttachedProperties(typeof(ActivityBuilder<>));
44             if (properties != null && properties.Contains(displayNameProperty))
45             {
46                 return;
47             }
48
49             attachedPropertiesService.AddProperty(displayNameProperty);
50         }
51     }
52 }