private void OnLeftButtonDown(ListBox listBox, Point pt)
        {
            TabItem      tabitem      = (TabItem)tabDynamic.SelectedItem;
            LayoutEditor layoutEditor = GetLayoutEditor();

            if (layoutEditor == null)
            {
                return;
            }

            HitTestResult result = VisualTreeHelper.HitTest(listBox, pt);
            ListBoxItem   lbi    = VisualCommon.FindParent <ListBoxItem>(result.VisualHit);

            if (lbi == null)
            {
                return;
            }
            int index = listBox.ItemContainerGenerator.IndexFromContainer(lbi);

            if (index == -1)
            {
                return;
            }

            layoutEditor.SuggestCandidate((WareBase)listBox.Items[index]);
        }
Beispiel #2
0
        private int GetSiteIndexAcceptsTheLabware(Point ptInCanvas, string labwareTypeName)
        {
            if (Grid <= Carrier.undefinedGrid || !_carrier.AllowedLabwareTypeNames.Contains(labwareTypeName))
            {
                return(InvalidSiteIndex);
            }

            int  xPos = GetBoundingRectXStart(Grid);
            int  yPos = GetBoundingRectYStart();
            Rect rc   = VisualCommon.Physic2Visual(xPos, yPos, new Size(_carrier.Dimension.XLength, _carrier.Dimension.YLength));

            if (!rc.Contains(ptInCanvas))
            {
                return(InvalidSiteIndex);
            }

            int siteIndex = InvalidSiteIndex;

            for (int i = 0; i < _carrier.Sites.Count; i++)
            {
                var site  = _carrier.Sites[i];
                int xSite = (int)(site.XOffset + xPos);
                int ySite = (int)(site.YOffset + yPos);
                rc = VisualCommon.Physic2Visual(xSite, ySite, new Size(site.XSize, site.YSize));
                if (rc.Contains(ptInCanvas))
                {
                    siteIndex = i;
                    break;
                }
            }
            return(siteIndex);
        }
        internal Point GetReferencePositionInCanvas()
        {
            Carrier carrier = null;

            if (_ware is Labware)
            {
                carrier = ((Labware)_ware).ParentCarrier;
            }
            else
            {
                carrier = (Carrier)_ware;
            }
            int    grid   = carrier.GridID;
            int    pinPos = (grid - 1) * Worktable.DistanceBetweenAdjacentPins + (int)_worktable.TopLeftPinPosition.X;
            double xPos   = pinPos;
            double yPos   = _worktable.TopLeftPinPosition.Y;

            xPos  = pinPos - (carrier.XOffset); //get carrier x start pos
            yPos -= carrier.YOffset;

            if (_ware is Labware)
            {
                int siteIndex = ((Labware)_ware).SiteID - 1;
                var site      = carrier.Sites[siteIndex];
                xPos += (int)site.XOffset;       //get site x start pos
                yPos += (int)site.YOffset;
            }
            Rect rc = VisualCommon.Physic2Visual(xPos, yPos, new Size(0, 0));

            return(rc.TopLeft);
        }
Beispiel #4
0
        private void DrawGrid(int grid, DrawingContext drawingContext)
        {
            int y = (int)Configurations.Instance.Worktable.Size.Height;
            int x = GetGridXPosition(grid);

            VisualCommon.DrawText(new Point(x, y), grid.ToString(), drawingContext);
        }
        private void OnContainerSizeChanged(Size newSize)
        {
            if (Configurations.Instance.Worktable == null)
            {
                return;
            }

            VisualCommon.UpdateContainerSize(newSize);
            _worktable.InvalidateVisual();
            VisualCommon.UpdateVisuals(_worktable.Children);
        }
Beispiel #6
0
        /// <summary>
        /// Draw three pins on specified grid on worktable
        /// </summary>
        /// <param name="grid"></param>
        /// <param name="drawingContext"></param>
        private void DrawPinsSameGrid(int grid, DrawingContext drawingContext)
        {
            Point ptStart = worktable.TopLeftPinPosition;
            int   offset  = grid * Worktable.DistanceBetweenAdjacentPins;
            int   topPinX = (int)ptStart.X + offset;
            int   topPinY = (int)ptStart.Y;

            DrawPin(topPinX, topPinY, worktable.PinSize, drawingContext);

            int bottomPinX = topPinX;
            int bottomPinY = worktable.BottomLeftPinYPosition;

            DrawPin(bottomPinX, bottomPinY, worktable.PinSize, drawingContext);
            VisualCommon.DrawGridNumber(grid, topPinX, drawingContext);
        }
Beispiel #7
0
        private void lstboxLabwares_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point         pt     = e.GetPosition(lstboxLabwares);
            HitTestResult result = VisualTreeHelper.HitTest(lstboxLabwares, pt);
            ListBoxItem   lbi    = VisualCommon.FindParent <ListBoxItem>(result.VisualHit);

            if (lbi == null)
            {
                return;
            }
            int index = lstboxLabwares.ItemContainerGenerator.IndexFromContainer(lbi);

            if (index == -1)
            {
                return;
            }
            layoutEditor.SuggestCandidate(wares[index]);
        }
Beispiel #8
0
        /// <summary>
        /// Draw the carrier
        /// </summary>
        /// <param name="drawingVisual"></param>
        override protected void Render(DrawingVisual drawingVisual)
        {
            DrawingContext drawingContext = drawingVisual.RenderOpen();
            //if (Grid == Carrier.undefinedGrid)
            //    return;

            //1 border
            int  xPos = GetBoundingRectXStart(_carrier.GridID);//
            int  yPos = GetBoundingRectYStart();
            Size sz   = new Size(_carrier.Dimension.XLength, _carrier.Dimension.YLength);

            Brush backGroundBrush = new SolidColorBrush(Color.FromArgb(128, _carrier.BackgroundColor.B, _carrier.BackgroundColor.G, _carrier.BackgroundColor.R));

            Color border = _isSelected ? Colors.Blue : Colors.Black;

            VisualCommon.DrawRect(xPos, yPos, sz, drawingContext, border, backGroundBrush);
            DrawGrid(this.Grid, drawingContext);


            //2 each site
            for (int i = 0; i < _carrier.Sites.Count; i++)
            {
                var fillBrsuh = new SolidColorBrush(Color.FromArgb(128, 255, 255, 255));
                var site      = _carrier.Sites[i];
                int xSite     = (int)(site.XOffset + xPos);
                int ySite     = (int)(site.YOffset + yPos);
                border = _isSelected ? Colors.Blue : Colors.Brown;
                bool bNeedHighLight = i == _highLightSiteIndex;

                Size tmpSZ = new Size(site.XSize, site.YSize);
                Rect rc    = new Rect(new Point(xSite, ySite), tmpSZ);
                if (bNeedHighLight)
                {
                    BlowUp(ref rc);
                    border    = Colors.DarkGreen;
                    fillBrsuh = new SolidColorBrush(Color.FromArgb(128, 255, 255, 0));
                }
                VisualCommon.DrawRect((int)rc.X, (int)rc.Y, rc.Size, drawingContext, border, fillBrsuh);
            }
            drawingContext.Close();
        }
        private void lb_labwares_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Point pt = e.GetPosition(lb_labwares);

            HitTestResult result = VisualTreeHelper.HitTest(this.lb_labwares, pt);
            ListBoxItem   lbi    = VisualCommon.FindParent <ListBoxItem>(result.VisualHit);

            if (lbi == null)
            {
                this.lb_labwares.UnselectAll();
            }

            bool isDoubleClick = e.ClickCount > 1;

            if (isDoubleClick)
            {
                return;
            }

            OnLeftButtonDown(lb_labwares, pt);
        }
Beispiel #10
0
        /// <summary>
        /// Draw the worktable with pins, and the current DitiBox
        /// </summary>
        /// <param name="drawingContext"></param>
        public void Draw(DrawingContext drawingContext)
        {
            for (int i = 0; i < worktable.GridCount; i++)
            {
                DrawPinsSameGrid(i, drawingContext);
            }
            DrawBorder(worktable.Size, drawingContext);

            //if(layout.DitiInfo.DitiInfoItems.Count !=)
            foreach (var ditiBoxInfo in layout.DitiInfo.DitiBoxInfos)
            {
                Labware labware = layout.FindLabware(ditiBoxInfo.label);
                if (labware != null)
                {
                    labware.CalculatePositionInLayout();
                    var position = labware.GetAbsPosition(96);
                    position.X += 18;
                    VisualCommon.DrawCircle(position, 6, drawingContext, Colors.Red, true);
                }
            }
        }
Beispiel #11
0
        private void CalculatePositions(ref double xPos, ref double yPos, int mapGrid, Carrier carrier)
        {
            int pinPos = (mapGrid - 1) * Worktable.DistanceBetweenAdjacentPins + (int)_worktable.TopLeftPinPosition.X;

            xPos = pinPos;
            yPos = _worktable.TopLeftPinPosition.Y;
            if (carrier != null && (!Moving))
            {
                xPos  = pinPos - (carrier.XOffset); //get carrier x start pos
                yPos -= carrier.YOffset;
                int siteIndex = _labware.SiteID - 1;
                var site      = carrier.Sites[siteIndex];
                xPos += (int)site.XOffset;          //get site x start pos
                yPos += (int)site.YOffset;
            }
            else
            {
                Point ptPhysical = VisualCommon.Convert2PhysicalXY(_ptDragPosition.X, _ptDragPosition.Y);
                xPos = (int)ptPhysical.X;
                yPos = (int)ptPhysical.Y;
            }
        }
Beispiel #12
0
        /// <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();
        }
Beispiel #13
0
 /// <summary>
 /// Draw a pin on worktable
 /// </summary>
 /// <param name="pinX"></param>
 /// <param name="pinY"></param>
 /// <param name="size"></param>
 /// <param name="drawingContext"></param>
 private void DrawPin(int pinX, int pinY, Size size, DrawingContext drawingContext)
 {
     VisualCommon.DrawSolidRect(pinX, pinY, size, drawingContext, Colors.Black);
 }
Beispiel #14
0
 private void DrawBorder(Size size, DrawingContext drawingContext)
 {
     VisualCommon.DrawRect(0, 0, size, drawingContext, Colors.Black);
 }