~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Src/DelegateCanvasItem.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.Collections.Generic;
 
6
 
 
7
using System.Drawing;
 
8
using System.Drawing.Drawing2D;
 
9
 
 
10
using System.Xml;
 
11
using System.Xml.XPath;
 
12
 
 
13
using ICSharpCode.SharpDevelop;
 
14
using ICSharpCode.SharpDevelop.Dom;
 
15
using ICSharpCode.SharpDevelop.Project;
 
16
 
 
17
using System.Globalization;
 
18
 
 
19
using Tools.Diagrams;
 
20
using Tools.Diagrams.Drawables;
 
21
 
 
22
namespace ClassDiagram
 
23
{
 
24
        // TODO - perhaps abandon this base class and implement styles mechanism instead?
 
25
        public class EnumDelegateCanvasItem : ClassCanvasItem
 
26
        {
 
27
                public EnumDelegateCanvasItem (IClass ct) : base (ct) {}
 
28
 
 
29
                private InteractiveItemsStack items = new InteractiveItemsStack();
 
30
                
 
31
                public InteractiveItemsStack Items {
 
32
                        get { return items; }
 
33
                }
 
34
 
 
35
                protected override DrawableRectangle InitContentBackground()
 
36
                {
 
37
                        if (RoundedCorners)
 
38
                        {
 
39
                                int radius = CornerRadius;
 
40
                                return new DrawableRectangle(ContentBG, null, 0, 0, radius, 0);
 
41
                        }
 
42
                        else
 
43
                                return new DrawableRectangle(ContentBG, null, 0, 0, 0, 0);
 
44
                }
 
45
                
 
46
                protected override DrawableItemsStack InitContentContainer(params IDrawableRectangle[] items)
 
47
                {
 
48
                        DrawableItemsStack decorator = new DrawableItemsStack();
 
49
                        decorator.OrientationAxis = Axis.X;
 
50
                        DrawableRectangle rect;
 
51
                        if (RoundedCorners)
 
52
                        {
 
53
                                int radius = CornerRadius;
 
54
                                rect = new DrawableRectangle(TitleBG, null, 0, 0, 0, radius);
 
55
                        }
 
56
                        else
 
57
                        {
 
58
                                rect = new DrawableRectangle(TitleBG, null, 0, 0, 0, 0);
 
59
                        }
 
60
                        
 
61
                        rect.Width = 20;
 
62
                        
 
63
                        decorator.Add(rect);
 
64
                        decorator.Add(base.InitContentContainer(items));
 
65
                        return decorator;
 
66
                }
 
67
                
 
68
                protected override IDrawableRectangle InitContent()
 
69
                {
 
70
                        items.Border = 5;
 
71
                        items.OrientationAxis = Axis.Y;
 
72
                        return items;
 
73
                }
 
74
        }
 
75
        
 
76
        public class DelegateCanvasItem : EnumDelegateCanvasItem
 
77
        {
 
78
                public DelegateCanvasItem (IClass ct) : base (ct) {}
 
79
                
 
80
                static Color titlesBG = Color.FromArgb(255, 237, 219, 221);
 
81
                protected override Color TitleBackground
 
82
                {
 
83
                        get { return titlesBG; }
 
84
                }
 
85
                
 
86
                static Brush contentBG = new SolidBrush(Color.FromArgb(255, 247, 240, 240));
 
87
                protected override Brush ContentBG
 
88
                {
 
89
                        get { return contentBG; }
 
90
                }
 
91
 
 
92
                protected override void PrepareMembersContent()
 
93
                {
 
94
                        Items.Clear();
 
95
                        IMethod invokeMethod = RepresentedClassType.SearchMember("Invoke", RepresentedClassType.ProjectContent.Language) as IMethod;
 
96
                        IAmbience ambience = GetAmbience();
 
97
                        foreach (IParameter par in invokeMethod.Parameters)
 
98
                        {
 
99
                                TextSegment ts = new TextSegment(Graphics, par.Name  + " : " + ambience.Convert(par.ReturnType), MemberFont, true);
 
100
                                Items.Add(ts);
 
101
                        }
 
102
                }
 
103
                
 
104
                // TODO - remove - for debug only.
 
105
                public override void DrawToGraphics(Graphics graphics)
 
106
                {
 
107
                        base.DrawToGraphics(graphics);
 
108
                }
 
109
                
 
110
                protected override XmlElement CreateXmlElement(XmlDocument doc)
 
111
                {
 
112
                        return doc.CreateElement("Delegate");
 
113
                }
 
114
        }
 
115
        
 
116
        public delegate TestEnum TestDelegate (int num, string str);
 
117
}