/// <summary> /// Creates a new instance of a wrapper for <see cref="AnnoObject"/>. /// </summary> /// <param name="annoObjectToWrap">The <see cref="AnnoObject"/> to wrap. Reference will be kept.</param> /// <param name="coordinateHelperToUse">The <see cref="ICoordinateHelper"/> to use in calculations.</param> /// <param name="brushCacheToUse">The <see cref="IBrushCache"/> used as a cache.</param> public LayoutObject(AnnoObject annoObjectToWrap, ICoordinateHelper coordinateHelperToUse, IBrushCache brushCacheToUse, IPenCache penCacheToUse) { WrappedAnnoObject = annoObjectToWrap; _coordinateHelper = coordinateHelperToUse; _brushCache = brushCacheToUse; _penCache = penCacheToUse; }
public ListExtensionsTests() { mockedCoordinateHelper = new Mock <ICoordinateHelper>().Object; mockedBrushCache = new Mock <IBrushCache>().Object; mockedPenCache = new Mock <IPenCache>().Object; }
/// <summary> /// 绘制网格 /// </summary> public static void DrawNet(int startRow, int startCol, int rows, int cols, double cellWidth, double cellHeight, int canvasWidth, int canvasHeight, Canvas canvas, bool isISO, out ICoordinateHelper coordinateHelper) { List<LinePoint> points = new List<LinePoint>(); //Point topPoint; if (isISO) { double totalWidth = (rows + cols) * cellWidth / 2; double totalHeight = totalWidth / 2; coordinateHelper = new ISOHelper(cellWidth, cellHeight); coordinateHelper.TopPoint = new Point(canvasWidth / 2 - (totalWidth - cellWidth * rows) / 2, (int)Math.Floor((canvasHeight - totalHeight) * 0.5)); double endX = cols * cellWidth / 2; double endY = endX / 2; Point p; for (int row = 0; row <= rows; row++) { p = new Point(coordinateHelper.TopPoint.X - cellWidth / 2 * row, coordinateHelper.TopPoint.Y + cellHeight / 2 * row); points.Add(new LinePoint() { StartPoint = p, EndPoint = p + new Vector(endX, endY) }); } endX = rows * cellWidth / 2; endY = endX / 2; for (int col = 0; col <= cols; col++) { p = new Point(coordinateHelper.TopPoint.X + cellWidth / 2 * col, coordinateHelper.TopPoint.Y + cellHeight / 2 * col); points.Add(new LinePoint() { StartPoint = p, EndPoint = new Point(p.X - endX, p.Y + endY) }); } } else { double totalWidth = cellWidth * cols; double totalHeight = cellHeight * rows; double startX = 0; double startY = 0; startX = (canvasWidth - totalWidth) / 2; startY = (canvasHeight - totalHeight) / 2; coordinateHelper = new RectangularHelper() { Width = cellWidth, Height = cellHeight }; coordinateHelper.TopPoint = new Point(startX, startY); Point index = coordinateHelper.GetItemIndex(new Point(startX, startY)); index = coordinateHelper.GetItemPos((int)index.X, (int)index.Y); startX = (int)index.X; startY = (int)index.Y; for (int row = 0; row <= rows; row++) { points.Add(new LinePoint() { StartPoint = new Point(startX, startY + row * cellHeight), EndPoint = new Point(startX + cols * cellWidth, startY + row * cellHeight) }); } for (int col = 0; col <= cols; col++) { points.Add(new LinePoint() { StartPoint = new Point(startX + col * cellWidth, startY), EndPoint = new Point(startX + col * cellWidth, startY + rows * cellHeight) }); } } Draw(canvas, points, Brushes.Black); }
static LayoutObjectTests() { coordinateHelper = new CoordinateHelper(); }
/// <summary> /// Creates a new instance of a wrapper for <see cref="AnnoObject"/>. /// </summary> /// <param name="annoObjectToWrap">The <see cref="AnnoObject"/> to wrap. Reference will be kept.</param> /// <param name="coordinateHelperToUse">The <see cref="ICoordinateHelper"/> to use in calculations.</param> public LayoutObject(AnnoObject annoObjectToWrap, ICoordinateHelper coordinateHelperToUse) { WrappedAnnoObject = annoObjectToWrap; _coordinateHelper = coordinateHelperToUse; }
/// <summary> /// 绘制网格 /// </summary> public static void DrawNet(int startRow, int startCol, int rows, int cols, double cellWidth, double cellHeight, int canvasWidth, int canvasHeight, Canvas canvas, bool isISO, out ICoordinateHelper coordinateHelper) { List <LinePoint> points = new List <LinePoint>(); //Point topPoint; if (isISO) { double totalWidth = (rows + cols) * cellWidth / 2; double totalHeight = totalWidth / 2; coordinateHelper = new ISOHelper(cellWidth, cellHeight); coordinateHelper.TopPoint = new Point(canvasWidth / 2 - (totalWidth - cellWidth * rows) / 2, (int)Math.Floor((canvasHeight - totalHeight) * 0.5)); double endX = cols * cellWidth / 2; double endY = endX / 2; Point p; for (int row = 0; row <= rows; row++) { p = new Point(coordinateHelper.TopPoint.X - cellWidth / 2 * row, coordinateHelper.TopPoint.Y + cellHeight / 2 * row); points.Add(new LinePoint() { StartPoint = p, EndPoint = p + new Vector(endX, endY) }); } endX = rows * cellWidth / 2; endY = endX / 2; for (int col = 0; col <= cols; col++) { p = new Point(coordinateHelper.TopPoint.X + cellWidth / 2 * col, coordinateHelper.TopPoint.Y + cellHeight / 2 * col); points.Add(new LinePoint() { StartPoint = p, EndPoint = new Point(p.X - endX, p.Y + endY) }); } } else { double totalWidth = cellWidth * cols; double totalHeight = cellHeight * rows; double startX = 0; double startY = 0; startX = (canvasWidth - totalWidth) / 2; startY = (canvasHeight - totalHeight) / 2; coordinateHelper = new RectangularHelper() { Width = cellWidth, Height = cellHeight }; coordinateHelper.TopPoint = new Point(startX, startY); Point index = coordinateHelper.GetItemIndex(new Point(startX, startY)); index = coordinateHelper.GetItemPos((int)index.X, (int)index.Y); startX = (int)index.X; startY = (int)index.Y; for (int row = 0; row <= rows; row++) { points.Add(new LinePoint() { StartPoint = new Point(startX, startY + row * cellHeight), EndPoint = new Point(startX + cols * cellWidth, startY + row * cellHeight) }); } for (int col = 0; col <= cols; col++) { points.Add(new LinePoint() { StartPoint = new Point(startX + col * cellWidth, startY), EndPoint = new Point(startX + col * cellWidth, startY + rows * cellHeight) }); } } Draw(canvas, points, Brushes.Black); }
public MainWindow(ICommons commonsToUse, ICoordinateHelper coordinateHelperToUse = null) : this() { _commons = commonsToUse; _layoutLoader = new LayoutLoader(); _coordinateHelper = coordinateHelperToUse ?? new CoordinateHelper(); }
public void SetRowAndCol(int row, int col, ICoordinateHelper coordinateHelper) { Row = row; Col = col; Point p = coordinateHelper.GetItemPos(row, col); Canvas.SetLeft(this, p.X - data.OffsetX); Canvas.SetTop(this, p.Y - data.OffsetY); }