~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/Initializers.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using System.Windows.Controls;
 
6
using ICSharpCode.WpfDesign.Extensions;
 
7
using System.Windows;
 
8
using System.Windows.Shapes;
 
9
using System.Windows.Media;
 
10
 
 
11
namespace ICSharpCode.WpfDesign.Designer.Extensions.Initializers
 
12
{
 
13
        [ExtensionFor(typeof(ContentControl))]
 
14
        public class ContentControlInitializer : DefaultInitializer
 
15
        {
 
16
                public override void InitializeDefaults(DesignItem item)
 
17
                {
 
18
                        DesignItemProperty contentProperty = item.Properties["Content"];
 
19
                        if (contentProperty.ValueOnInstance == null) {
 
20
                                contentProperty.SetValue(item.ComponentType.Name);
 
21
                        }
 
22
                }
 
23
        }
 
24
 
 
25
        [ExtensionFor(typeof(HeaderedContentControl), OverrideExtension = typeof(ContentControlInitializer))]
 
26
        public class HeaderedContentControlInitializer : DefaultInitializer
 
27
        {
 
28
                public override void InitializeDefaults(DesignItem item)
 
29
                {
 
30
                        DesignItemProperty headerProperty = item.Properties["Header"];
 
31
                        if (headerProperty.ValueOnInstance == null) {
 
32
                                headerProperty.SetValue(item.ComponentType.Name);
 
33
                        }
 
34
                        
 
35
                        DesignItemProperty contentProperty = item.Properties["Content"];
 
36
                        if (contentProperty.ValueOnInstance == null) {
 
37
                                contentProperty.SetValue(new PanelInstanceFactory().CreateInstance(typeof(Canvas)));
 
38
                        }
 
39
                }
 
40
        }
 
41
 
 
42
    [ExtensionFor(typeof(Shape))]
 
43
        public class ShapeInitializer : DefaultInitializer
 
44
        {
 
45
                public override void InitializeDefaults(DesignItem item)
 
46
                {
 
47
                        DesignItemProperty fillProperty = item.Properties["Fill"];
 
48
                        if (fillProperty.ValueOnInstance == null) {
 
49
                                fillProperty.SetValue(Brushes.YellowGreen);
 
50
                        }
 
51
                }
 
52
        }
 
53
}