~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/DisplayBindings/ClassDiagram/ClassCanvas/Shapes/CollapseShape.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.Drawing;
 
6
using System.Drawing.Drawing2D;
 
7
 
 
8
namespace ClassDiagram
 
9
{
 
10
        public class CollapseShape : VectorShape
 
11
        {
 
12
                static LinearGradientBrush shade = new LinearGradientBrush(
 
13
                                new PointF(0, 0), new PointF(0, 22),
 
14
                                Color.White, Color.LightSteelBlue);
 
15
                
 
16
                static PointF[] arrowPoints = new PointF[]{
 
17
                        new PointF(5.0f, 10.0f),
 
18
                        new PointF(11.0f, 4.0f),
 
19
                        new PointF(17.0f, 10.0f),
 
20
                        new PointF(16.0f, 12.0f),
 
21
                        new PointF(11.0f, 7.0f),
 
22
                        new PointF(6.0f, 12.0f)
 
23
                };
 
24
                
 
25
                static GraphicsPath roundedButton = InitializeButtonShape();
 
26
                
 
27
                static GraphicsPath InitializeButtonShape()
 
28
                {
 
29
                        GraphicsPath path = new GraphicsPath();
 
30
                        path.AddArc(3, 3, 3, 3, 180, 90);
 
31
                        path.AddArc(18, 3, 3, 3, 270, 90);
 
32
                        path.AddArc(18, 18, 3, 3, 0, 90);
 
33
                        path.AddArc(3, 18, 3, 3, 90, 90);
 
34
                        path.CloseFigure();
 
35
                        return path;
 
36
                }
 
37
                
 
38
                static protected void DrawButton (Graphics graphics)
 
39
                {
 
40
                        if (graphics == null) return;
 
41
                        graphics.FillPath(shade, roundedButton);
 
42
                        graphics.DrawPath(Pens.SteelBlue, roundedButton);                       
 
43
                }
 
44
                
 
45
                static protected void DrawArrow (Graphics graphics)
 
46
                {
 
47
                        if (graphics == null) return;
 
48
                        graphics.FillPolygon (Brushes.DarkBlue, arrowPoints);                   
 
49
                }
 
50
                
 
51
                public override void Draw(Graphics graphics)
 
52
                {
 
53
                        if (graphics == null) return;
 
54
                        CollapseShape.DrawButton(graphics);
 
55
                        
 
56
                        graphics.TranslateTransform(1, 1);
 
57
                        CollapseShape.DrawArrow(graphics);
 
58
                        graphics.TranslateTransform(0, 6);
 
59
                        CollapseShape.DrawArrow(graphics);
 
60
                }
 
61
                        
 
62
                public override float ShapeWidth
 
63
                {
 
64
                        get { return 23; }
 
65
                }
 
66
                
 
67
                public override float ShapeHeight
 
68
                {
 
69
                        get { return 23; }
 
70
                }
 
71
        }
 
72
}