private void AddWellVisuals() { wellVisuals = new List <MyDrawingVisual>(); int cols = _labware.WellsInfo.NumberOfWellsX; int rows = _labware.WellsInfo.NumberOfWellsY; int wellID = 1; int total = cols * rows; for (int col = 0; col < cols; col++) { for (int row = 0; row < rows; row++) { var position = _labware.GetPosition(row, col); wellVisuals.Add(CreateWellVisual(position, wellID++, total)); } } }
/// <summary> /// redraw /// </summary> /// <param name="drawingVisual"></param> protected override void Render(DrawingVisual drawingVisual) { DrawingContext drawingContext = drawingVisual.RenderOpen(); Carrier carrier = _labware.ParentCarrier; if (!NeedMoveOrOnACarrier()) { return; } int mapGrid = 0; if (carrier != null) { mapGrid = carrier.GridID; } if (_isSelected) { mapGrid = VisualCommon.FindCorrespondingGrid(_ptDragPosition.X); } //calculate position & draw border rectangle double xPos = 0, yPos = 0; CalculatePositions(ref xPos, ref yPos, mapGrid, carrier); Size sz = new Size(_labware.Dimension.XLength, _labware.Dimension.YLength); Color border = NeedHighLight() ? Colors.Blue : Colors.Black; Color background = _labware.BackgroundColor; background = Color.FromArgb(160, background.R, background.G, background.B); _labware.BackgroundColor = background; Brush brush = new SolidColorBrush(_labware.BackgroundColor); int thickness = NeedHighLight() ? 2 : 1; VisualCommon.DrawRect(xPos, yPos, sz, drawingContext, border, brush, thickness); VisualCommon.DrawText(new Point(xPos, yPos + sz.Height), _labware.Label, drawingContext); //draw wells int cols = _labware.WellsInfo.NumberOfWellsX; int rows = _labware.WellsInfo.NumberOfWellsY; Vector vector = new Vector(xPos, yPos); for (int row = 0; row < rows; row++) { for (int col = 0; col < cols; col++) { int wellID = col * rows + row + 1; Color wellColor = Colors.Black; bool bFill = false; if (AspirateWellIDs != null && AspirateWellIDs.Contains(wellID)) { wellColor = Colors.Green; bFill = true; } if (DispenseWellIDs != null && DispenseWellIDs.Contains(wellID)) { wellColor = Colors.Red; bFill = true; } //bFill &= blowUp; var position = _labware.GetPosition(row, col) + vector; VisualCommon.DrawCircle(position, _labware.WellsInfo.WellRadius, drawingContext, wellColor, bFill); } } drawingContext.Close(); }