Free cookie consent management tool by TermsFeed Policy Generator

source: tags/3.3.11/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Ruler/VerticalRuler.cs @ 13398

Last change on this file since 13398 was 2768, checked in by mkommend, 14 years ago

added solution folders and sources for the netron library (ticket #867)

File size: 4.5 KB
Line 
1
2
3
4
5using System;
6using System.Drawing;
7using System.Drawing.Drawing2D;
8
9namespace Netron.Diagramming.Core
10{
11    /// <summary>
12    /// Implements the vertical ruler.
13    /// </summary>
14    public class VerticalRuler : RulerBase
15    {
16
17        #region Properties
18        /// <summary>
19        /// Gets the bounding rectangle of this vertical ruler.
20        /// </summary>
21        /// <value>The bounds.</value>
22        public override Rectangle Rectangle
23        {
24            get
25            {
26                if (View != null)
27                    return View.VerticalRulerBounds;
28                else
29                    return Rectangle.Empty;
30            }
31        }
32        #endregion
33
34        #region Constructor
35        public VerticalRuler(IView view)
36            : base(view)
37        {
38        }
39        #endregion
40
41        #region Methods
42        public override void Paint(Graphics g)
43        {
44            if (View == null)
45            {
46                return;
47            }
48            IModel model = View.Model;
49            if (model == null)
50            {
51                return;
52            }
53           
54            float f1 = g.DpiX;
55            MeasurementsUnit measurementsUnit1 = View.RulerUnits;
56            GraphicsUnit graphicsUnit1 = model.MeasurementUnits;
57            float f2 = model.MeasurementScale;
58
59            Font font = ArtPalette.RulerFont;
60            Matrix matrix = new Matrix();
61            PointF pointF1 = PointF.Empty;
62            RectangleF rectangleF = Rectangle;
63            g.FillRectangle(ArtPalette.RullerFillBrush, rectangleF);
64           
65            PointF pointF2 = View.Origin;
66            bool flag1 = false;
67            float f3 = (float)rectangleF.Left;
68            float f4 = (float)rectangleF.Right;
69            bool flag2 = true;
70            float f5;
71            GraphicsUnit graphicsUnit2;
72            MeasurementsUnit measurementsUnit2;
73            while (!flag1)
74            {
75                Measurements.MeasurementsUnitToGraphicsUnit(measurementsUnit1, out graphicsUnit2, out f5);
76                float f6 = Measurements.Convert(graphicsUnit2, f5, graphicsUnit1, f2, f1, 1.0F);
77                float f7 = View.ViewToDeviceF(View.WorldToView(new SizeF(f6, f6))).Height;
78                if (f7 > 4.0F)
79                {
80                    PointF pointF3 = Measurements.Convert(graphicsUnit1, f2, graphicsUnit2, f5, g, pointF2);
81                    int i = (int)Math.Floor((double)pointF3.Y) + 1;
82                    PointF pointF4 = new PointF(pointF3.X, (float)i);
83                    pointF4 = Measurements.Convert(graphicsUnit2, f5, graphicsUnit1, f2, g, pointF4);
84                    float f8 = View.ViewToDeviceF(View.WorldToView(pointF4)).Y;
85                    for (float f9 = (float)rectangleF.Bottom; f8 < f9; f8 += f7)
86                    {
87                        g.DrawLine(ArtPalette.RulerPen, f3, f8, f4, f8);
88                        if (flag2)
89                        {
90                            string str = i.ToString();
91                            SizeF sizeF2 = g.MeasureString(str, font);
92                            matrix.Reset();
93                            matrix.Translate(-(sizeF2.Width / 2.0F), -(sizeF2.Height / 2.0F), MatrixOrder.Append);
94                            matrix.Rotate(-90.0F, MatrixOrder.Append);
95                            matrix.Translate(sizeF2.Width / 2.0F, sizeF2.Height / 2.0F, MatrixOrder.Append);
96                            matrix.Translate(f3 + 1.0F, f8 + 1.0F, MatrixOrder.Append);
97                            g.Transform = matrix;
98                            g.DrawString(str, font, Brushes.Black, pointF1);
99                            g.Transform = new Matrix();
100                        }
101                        i++;
102                    }
103                    if (Measurements.GetSmallerUnits(measurementsUnit1, out measurementsUnit2))
104                    {
105                        measurementsUnit1 = measurementsUnit2;
106                        f3 = f4 - (f4 - f3) / 2.0F;
107                    }
108                    else
109                    {
110                        flag1 = true;
111                    }
112                    flag2 = false;
113                }
114                else
115                {
116                    flag1 = true;
117                }
118            }
119
120            g.DrawRectangle(ArtPalette.RulerPen, rectangleF.X, rectangleF.Y, rectangleF.Width, rectangleF.Height);
121
122        }
123       
124#endregion
125       
126    }
127
128}
Note: See TracBrowser for help on using the repository browser.