コード例 #1
0
        private static bool IsOutofRange(int grid, CarrierUIElement carrierUIElement)
        {
            double length    = carrierUIElement.Dimension.XLength;
            int    gridsNeed = (int)(Math.Ceiling(length / (double)Worktable.DistanceBetweenAdjacentPins));

            return(grid + gridsNeed - 1 > Configurations.Instance.Worktable.GridCount);
        }
コード例 #2
0
        private void UpdateCarrierGrid(BasewareUIElement _selectedUIElement, Point ptCurrent)
        {
            if (!(_selectedUIElement is CarrierUIElement))
            {
                return;
            }
            CarrierUIElement carrierUIElement = _selectedUIElement as CarrierUIElement;
            Carrier          carrier          = carrierUIElement.Carrier;

            int newGrid = VisualCommon.FindCorrespondingGrid(ptCurrent.X);
            int orgGrid = carrier.GridID;

            carrier.GridID = newGrid;
            if (carrier.Labwares.Count == 0)
            {
                return;
            }
            if (newGrid == orgGrid)
            {
                return;
            }

            foreach (Labware labware in carrier.Labwares)
            {
                labware.Refresh();
            }
        }
コード例 #3
0
        public static bool IsOverlapped(Grid uiContainer, CarrierUIElement newCarrierUI, int newUICurGrid)
        {
            bool   bOverlapped      = false;
            double newCarrierXStart = newCarrierUI.GetBoundingRectXStart(newUICurGrid);
            double newCarrierXEnd   = newCarrierXStart + newCarrierUI.Dimension.XLength;

            foreach (UIElement uiElement in uiContainer.Children)
            {
                //jump self
                if (!(uiElement is CarrierUIElement))
                {
                    continue;
                }
                CarrierUIElement carrierUIElement = uiElement as CarrierUIElement;
                if (carrierUIElement == newCarrierUI)
                {
                    continue;
                }

                double oldCarrierXStart = carrierUIElement.GetBoundingRectXStart();
                double oldCarrierXEnd   = oldCarrierXStart + carrierUIElement.Dimension.XLength;
                bOverlapped = IsOverlapped(newCarrierXStart, newCarrierXEnd, oldCarrierXStart, oldCarrierXEnd);
                if (bOverlapped)
                {
                    break;
                }
            }
            return(bOverlapped);
        }
コード例 #4
0
        private static bool HasSuitableSite(Point pt, string labwareTypeName, Grid container)
        {
            CarrierUIElement carrierUIElement = null;
            int siteID = -1;

            return(FindSuitableCarrier(pt, labwareTypeName, container, ref carrierUIElement, ref siteID));
        }
コード例 #5
0
        public static void MountThis(BasewareUIElement baseUIElement, Point position, Grid container, Layout workingLayout)
        {
            bool bValid = IsValid(baseUIElement, position, container);

            if (!bValid)
            {
                if (baseUIElement is LabwareUIElement) //if labware has parent, let it go back
                {
                    LabwareUIElement labwareUIElement = (LabwareUIElement)baseUIElement;
                    if (labwareUIElement.Labware.ParentCarrier != null)
                    {
                        return;
                    }
                }

                container.Children.Remove(baseUIElement);
                if (baseUIElement is CarrierUIElement)
                {
                    RemoveUIElementsOnCarrier(container, baseUIElement as CarrierUIElement);
                }
                baseUIElement = null;
                return;
            }

            int grid = VisualCommon.FindCorrespondingGrid(position.X);

            if (baseUIElement is CarrierUIElement)
            {
                CarrierUIElement carrierUIElement = (CarrierUIElement)baseUIElement;
                carrierUIElement.Grid = grid;
            }

            if (baseUIElement is LabwareUIElement)
            {
                LabwareUIElement labwareUIElement = (LabwareUIElement)baseUIElement;
                Labware          labware          = labwareUIElement.Labware;
                CarrierUIElement carrierUIElement = null;
                int  siteID = -1;
                bool bFound = FindSuitableCarrier(position, labware.TypeName, container, ref carrierUIElement, ref siteID);
                if (bFound)
                {
                    if (labware.ParentCarrier != null)
                    {
                        labware.ParentCarrier.Labwares.Remove(labware);
                    }
                    labware.SiteID = siteID;
                    if (labware.IsDitiBox)
                    {
                        var ditiInfo = workingLayout.DitiInfo.DitiBoxInfos.Find(x => x.label == labware.Label);
                        if (ditiInfo == null)
                        {
                            DitiType ditiType = DitiBox.Parse(labware.TypeName);
                            workingLayout.DitiInfo.DitiBoxInfos.Add(new DitiBoxInfo(ditiType, labware.Label, 96));
                        }
                    }
                }
                carrierUIElement.Carrier.AddLabware(labware);
            }
        }
コード例 #6
0
        //private static bool NotMoved(Point position, Labware labware, Grid container)
        //{
        //    CarrierUIElement carrierUIElement;
        //    foreach (UIElement uiElement in container.Children)
        //    {
        //        if (!(uiElement is CarrierUIElement))
        //            continue;
        //        carrierUIElement = uiElement as CarrierUIElement;
        //        if(carrierUIElement.Carrier.Labwares.Contains(labware))
        //        {
        //            int siteID = CarrierUIElement.InvalidSiteIndex;
        //            bool bFound = carrierUIElement.GetSiteIDAcceptsTheLabware(position, labware.TypeName, ref siteID);
        //            if (bFound && siteID == labware.SiteID)
        //                return true;
        //        }
        //    }
        //    return false;
        //}

        private static void RemoveUIElementsOnCarrier(Grid container, CarrierUIElement carrierUIElement)
        {
            Carrier carrier = carrierUIElement.Carrier;

            foreach (var labware in carrier.Labwares)
            {
                RemoveLabware(container, labware);
            }
            carrier.Labwares.Clear();
        }
コード例 #7
0
        private void InitializeWares(Layout layout)
        {
            if (layout == null)
            {
                return;
            }

            foreach (Carrier carrier in layout.Carriers)
            {
                foreach (Labware labware in carrier.Labwares)
                {
                    var labwareUIElement = new LabwareUIElement(labware);
                    Grid.SetZIndex(labwareUIElement, 20); //closer to user
                    _myCanvas.Children.Add(labwareUIElement);
                }
                var carrierUIElement = new CarrierUIElement(carrier);
                Grid.SetZIndex(carrierUIElement, 10);
                _myCanvas.Children.Add(carrierUIElement);
            }
        }
コード例 #8
0
        /// <summary>
        /// create UIElement
        /// </summary>
        /// <param name="wareBase"></param>
        /// <param name="existingUIElements"/>
        /// <returns></returns>
        public static BasewareUIElement CreateUIElement(WareBase wareBase, UIElementCollection existingUIElements)
        {
            BasewareUIElement newUIElement;

            if (wareBase is Labware)
            {
                Labware       labware        = ((Labware)wareBase).Clone() as Labware;
                List <string> existingLabels = GetExistingLabels(existingUIElements);
                string        newLabel       = FindNextLabelName(existingLabels);
                labware.Label = newLabel;
                newUIElement  = new LabwareUIElement(labware);
            }
            else
            {
                Carrier carrier = ((Carrier)wareBase).Clone() as Carrier;
                newUIElement = new CarrierUIElement((Carrier)carrier);
            }
            newUIElement.Selected = true;
            return(newUIElement);
        }
コード例 #9
0
        private static bool IsValid(BasewareUIElement baseUIElement, Point position, Grid container)
        {
            int gridPos   = VisualCommon.FindCorrespondingGrid(position.X);
            int totalGrid = Configurations.Instance.Worktable.GridCount;

            //1 moves out of worktable
            if (gridPos < 1 || gridPos > totalGrid)
            {
                return(false);
            }

            //2 if is Carrier, see whether there are enough grids for it
            if (baseUIElement is CarrierUIElement)
            {
                CarrierUIElement carrierUIElement = (CarrierUIElement)baseUIElement;
                bool             outOfRange       = IsOutofRange(gridPos, carrierUIElement);
                if (outOfRange)
                {
                    return(false);
                }

                bool overLapped = OverlapChecker.IsOverlapped(container, carrierUIElement, gridPos);
                if (overLapped)
                {
                    return(false);
                }
            }

            //3 if is labware, see whether there are suitable carrier for mounting onto
            if (baseUIElement is LabwareUIElement)
            {
                bool hasSuitableSite2Mount = HasSuitableSite(position, baseUIElement.Ware.TypeName, container);
                if (!hasSuitableSite2Mount)
                {
                    return(false);
                }
            }

            //baseUIElement.Selected = false;
            return(true);
        }
コード例 #10
0
        private void UpdateCarrier(Carrier exampleCarrier, CarrierUIElement carrierUIElement)
        {
            Carrier currentCarrier = carrierUIElement.Carrier;

            currentCarrier.CarryInfo(exampleCarrier);
        }
コード例 #11
0
        private static bool FindSuitableCarrier(Point pt, string labwareTypeName, Grid container, ref CarrierUIElement carrierUIElement, ref int siteID)
        {
            bool bFound = false;

            foreach (UIElement uiElement in container.Children)
            {
                if (!(uiElement is CarrierUIElement))
                {
                    continue;
                }
                carrierUIElement = uiElement as CarrierUIElement;

                bFound = carrierUIElement.GetSiteIDAcceptsTheLabware(pt, labwareTypeName, ref siteID);
                if (bFound)
                {
                    break;
                }
            }
            return(bFound);
        }