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(); } }
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); } }
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); }