public Size ViewToDevice(SizeF szView) { float f1 = 1.0F; float f2 = 1.0F; float f3 = 1.0F; float f4 = 1.0F; if (mModel != null) { if (mModel.MeasurementUnits != GraphicsUnit.Pixel) { f1 = Measurements.UnitsPerInch(mModel.MeasurementUnits); f3 = dpiX / f1; f4 = dpiX / f1; } f2 = mModel.MeasurementScale; } int i = (int)(szView.Width * f2 * f3); int j = (int)(szView.Height * f2 * f4); return(new Size(i, j)); }
public Point ViewToDevice(PointF ptView) { float f1 = 1.0F; float f2 = 1.0F; float f3 = 1.0F; float f4 = 1.0F; if (mModel != null) { if (mModel.MeasurementUnits != GraphicsUnit.Pixel) { f1 = Measurements.UnitsPerInch(mModel.MeasurementUnits); f3 = dpiX / f1; f4 = dpiX / f1; } f2 = mModel.MeasurementScale; } int i = (int)Math.Round((double)(ptView.X * f2 * f3)); int j = (int)Math.Round((double)(ptView.Y * f2 * f4)); return(new Point(i, j)); }
public SizeF DeviceToView(Size szDevice) { float f3 = 1.0F; float f4 = 1.0F; float f5 = 1.0F; float f6 = 1.0F; if (mModel != null) { if (mModel.MeasurementUnits != GraphicsUnit.Pixel) { f3 = Measurements.UnitsPerInch(mModel.MeasurementUnits); f5 = dpiX / f3; f6 = dpiY / f3; } f4 = mModel.MeasurementScale; } float f1 = (float)szDevice.Width / (f4 * f5); float f2 = (float)szDevice.Height / (f4 * f6); return(new SizeF(f1, f2)); }
public PointF DeviceToView(Point ptDevice) { float f3 = 1.0F; float f4 = 1.0F; float f5 = 1.0F; float f6 = 1.0F; if (mModel != null) { if (mModel.MeasurementUnits != GraphicsUnit.Pixel) { f3 = Measurements.UnitsPerInch(mModel.MeasurementUnits); f5 = dpiX / f3; f6 = dpiY / f3; } f4 = mModel.MeasurementScale; } float f1 = (float)ptDevice.X / (f4 * f5); float f2 = (float)ptDevice.Y / (f4 * f6); return(new PointF(f1, f2)); }
public SizeF ViewToDeviceF(SizeF szView) { float f3 = 1.0F; float f4 = 1.0F; float f5 = 1.0F; float f6 = 1.0F; if (mModel != null) { if (mModel.MeasurementUnits != GraphicsUnit.Pixel) { f3 = Measurements.UnitsPerInch(mModel.MeasurementUnits); f5 = dpiX / f3; f6 = dpiX / f3; } f4 = mModel.MeasurementScale; } float f1 = szView.Width * f4 * f5; float f2 = szView.Height * f4 * f6; return(new SizeF(f1, f2)); }
public PointF ViewToDeviceF(PointF ptView) { float f3 = 1.0F; float f4 = 1.0F; float f5 = 1.0F; float f6 = 1.0F; if (mModel != null) { if (mModel.MeasurementUnits != GraphicsUnit.Pixel) { f3 = Measurements.UnitsPerInch(mModel.MeasurementUnits); f5 = dpiX / f3; f6 = dpiX / f3; } f4 = mModel.MeasurementScale; } float f1 = ptView.X * f4 * f5; float f2 = ptView.Y * f4 * f6; return(new PointF(f1, f2)); }
public override void Paint(Graphics g) { if (View == null) { return; } IModel model = View.Model; if (model == null) { return; } float f1 = g.DpiX; MeasurementsUnit measurementsUnit1 = View.RulerUnits; GraphicsUnit graphicsUnit1 = model.MeasurementUnits; float f2 = model.MeasurementScale; Font font = ArtPalette.RulerFont; Matrix matrix = new Matrix(); PointF pointF1 = PointF.Empty; RectangleF rectangleF = Rectangle; g.FillRectangle(ArtPalette.RullerFillBrush, rectangleF); PointF pointF2 = View.Origin; bool flag1 = false; float f3 = (float)rectangleF.Left; float f4 = (float)rectangleF.Right; bool flag2 = true; float f5; GraphicsUnit graphicsUnit2; MeasurementsUnit measurementsUnit2; while (!flag1) { Measurements.MeasurementsUnitToGraphicsUnit(measurementsUnit1, out graphicsUnit2, out f5); float f6 = Measurements.Convert(graphicsUnit2, f5, graphicsUnit1, f2, f1, 1.0F); float f7 = View.ViewToDeviceF(View.WorldToView(new SizeF(f6, f6))).Height; if (f7 > 4.0F) { PointF pointF3 = Measurements.Convert(graphicsUnit1, f2, graphicsUnit2, f5, g, pointF2); int i = (int)Math.Floor((double)pointF3.Y) + 1; PointF pointF4 = new PointF(pointF3.X, (float)i); pointF4 = Measurements.Convert(graphicsUnit2, f5, graphicsUnit1, f2, g, pointF4); float f8 = View.ViewToDeviceF(View.WorldToView(pointF4)).Y; for (float f9 = (float)rectangleF.Bottom; f8 < f9; f8 += f7) { g.DrawLine(ArtPalette.RulerPen, f3, f8, f4, f8); if (flag2) { string str = i.ToString(); SizeF sizeF2 = g.MeasureString(str, font); matrix.Reset(); matrix.Translate(-(sizeF2.Width / 2.0F), -(sizeF2.Height / 2.0F), MatrixOrder.Append); matrix.Rotate(-90.0F, MatrixOrder.Append); matrix.Translate(sizeF2.Width / 2.0F, sizeF2.Height / 2.0F, MatrixOrder.Append); matrix.Translate(f3 + 1.0F, f8 + 1.0F, MatrixOrder.Append); g.Transform = matrix; g.DrawString(str, font, Brushes.Black, pointF1); g.Transform = new Matrix(); } i++; } if (Measurements.GetSmallerUnits(measurementsUnit1, out measurementsUnit2)) { measurementsUnit1 = measurementsUnit2; f3 = f4 - (f4 - f3) / 2.0F; } else { flag1 = true; } flag2 = false; } else { flag1 = true; } } g.DrawRectangle(ArtPalette.RulerPen, rectangleF.X, rectangleF.Y, rectangleF.Width, rectangleF.Height); }
public override void Paint(Graphics g) { if (View == null) { return; } IModel model = View.Model; if (model == null) { return; } float f1 = g.DpiX; MeasurementsUnit measurementsUnit1 = View.RulerUnits; GraphicsUnit graphicsUnit1 = model.MeasurementUnits; float f2 = model.MeasurementScale; Font font = ArtPallet.RulerFont; RectangleF rec = Rectangle; g.FillRectangle(ArtPallet.RullerFillBrush, rec); PointF pointF1 = View.Origin; bool flag1 = false; float f3 = (float)rec.Top; float f4 = (float)rec.Bottom; float f5; bool flag2 = true; GraphicsUnit graphicsUnit2; MeasurementsUnit measurementsUnit2; while (!flag1) { Measurements.MeasurementsUnitToGraphicsUnit(measurementsUnit1, out graphicsUnit2, out f5); float f6 = Measurements.Convert(graphicsUnit2, f5, graphicsUnit1, f2, f1, 1.0F); float f7 = View.ViewToDeviceF(View.WorldToView(new SizeF(f6, f6))).Width; if (f7 > 4.0F) { PointF pointF2 = Measurements.Convert(graphicsUnit1, f2, graphicsUnit2, f5, g, pointF1); int i = (int)Math.Floor((double)pointF2.X) + 1; PointF pointF3 = new PointF((float)i, pointF2.Y); pointF3 = Measurements.Convert(graphicsUnit2, f5, graphicsUnit1, f2, g, pointF3); float f8 = View.ViewToDeviceF(View.WorldToView(pointF3)).X; for (float f9 = (float)rec.Right; f8 < f9; f8 += f7) { g.DrawLine(ArtPallet.RulerPen, f8, f3, f8, f4); if (flag2) { string str = i.ToString(); PointF pointF5 = new PointF(f8 + 1.0F, f3 + 1.0F); g.DrawString(str, font, Brushes.Black, pointF5); } i++; } if (Measurements.GetSmallerUnits(measurementsUnit1, out measurementsUnit2)) { measurementsUnit1 = measurementsUnit2; f3 = f4 - (f4 - f3) / 2.0F; } else { flag1 = true; } flag2 = false; } else { flag1 = true; } } g.DrawRectangle(ArtPallet.RulerPen, rec.X, rec.Y, rec.Width, rec.Height); }