public void PrcSetVehicleToSection(int vh_num, string seg_num, string adr_id, SCAppConstants.PassEvent passType)
        {
            uctlVehicle Vhcl       = m_objItemVhcl[vh_num];
            GroupRails  groupRails = findMatchGroupRail(seg_num, adr_id);

            switch (passType)
            {
            case SCAppConstants.PassEvent.Pass:
                if (Vhcl.p_CurrentSecID != groupRails.Section_ID)
                {
                    if (!string.IsNullOrWhiteSpace(Vhcl.p_CurrentSecID))
                    {
                        m_DicSectionGroupRails[Vhcl.p_CurrentSecID].VehicleLeave(Vhcl);
                    }
                }
                groupRails.VehicleEnterSection(Vhcl, adr_id, 0);

                break;

            case SCAppConstants.PassEvent.ArrivalFromAdr:
                groupRails.VehicleArrivalsStartAdr(Vhcl);
                break;

            case SCAppConstants.PassEvent.ArrivalToAdr:
                m_DicSectionGroupRails[Vhcl.p_CurrentSecID].VehicleLeave(Vhcl);
                groupRails.VehicleArrivalsEndAdr(Vhcl);
                break;
            }
        }
 public void VehicleEnterSection(uctlVehicle vh, string address_id, double sec_dis)
 {
     //vehicles.Add(vh);
     if (!dicVehicles.ContainsKey(address_id))
     {
         dicVehicles.Add(address_id, new List <uctlVehicle>());
     }
     dicVehicles[address_id].Add(vh);
     vh.p_CurrentSecID = Section_ID;
     refreshVehicleLoaction(vh, sec_dis);
 }
        private bool readVehicleDatas()
        {
            bool bRet       = false;
            int  iVhSize    = 32;
            int  iVhclCount = 0;
            Font objFont    = new Font("Verdana", 5, FontStyle.Regular);

            try
            {
                //List<Equipment> lstEq = mainForm.BCApp.SCApplication.getEQObjCacheManager().getAllEquipment();
                List <AVEHICLE> lstEq = mainForm.BCApp.SCApplication.getEQObjCacheManager().getAllVehicle();
                iVhclCount = lstEq.Count;

                m_objItemVhcl = new uctlVehicle[iVhclCount];

                for (int ii = 0; ii < iVhclCount; ii++)
                {
                    m_objItemVhcl[ii]            = new uctlVehicle(lstEq[ii], this);
                    m_objItemVhcl[ii].p_VhPt     = ii;
                    m_objItemVhcl[ii].p_Num      = ii + 65;
                    m_objItemVhcl[ii].p_SizeW    = m_objItemVhcl[ii].Width;
                    m_objItemVhcl[ii].p_SizeH    = m_objItemVhcl[ii].Height;
                    m_objItemVhcl[ii].p_LocX     = iVhSize / 2;
                    m_objItemVhcl[ii].p_LocY     = iVhSize / 2;
                    m_objItemVhcl[ii].p_Presence = false;
                    m_objItemVhcl[ii].p_Status   = E_MAP_VHSTS.enDisconnect;
                    m_objItemVhcl[ii].p_Font     = objFont;
                    m_objItemVhcl[ii].Tag        = m_objItemVhcl[ii].Top + "|" + m_objItemVhcl[ii].Left + "|"
                                                   + m_objItemVhcl[ii].Height + "|" + m_objItemVhcl[ii].Width;
                }
                if (iVhclCount > 0)
                {
                    this.pnl_Map.Controls.AddRange(m_objItemVhcl);
                }
                bRet = true;
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception");
                bRet = false;
            }

            return(bRet);
        }
 public void VehicleLeave(uctlVehicle vh)
 {
     //vehicles.Remove(vh);
 }
        private void refreshVehicleLoaction(uctlVehicle vh, double sec_dis)
        {
            double distance_scale = 1;
            double distanceTemp   = 0;

            if (RealDistance > 10)
            {
                distance_scale = sec_dis / RealDistance;
            }
            else
            {
            }
            distanceTemp = Distance * distance_scale;
            int railInterval = 0;


            uctlRail matchRail        = findTheMatchingRail((int)distanceTemp, out railInterval);
            int      railInterval_Pix = (int)BCUtility.RealLengthToPixelsWidthByScale((double)railInterval);

            int Location_X = 0;
            int Location_Y = 0;

            KeyValuePair <uctlRail, E_RAIL_DIR> keyValuePairTemp = uctlRails.Where(keyValue => keyValue.Key == matchRail).SingleOrDefault();

            if (keyValuePairTemp.Equals(default(KeyValuePair <uctlRail, E_RAIL_DIR>)))
            {
                return;
            }
            E_RAIL_DIR railDIR = keyValuePairTemp.Value;

            //switch (RailDircetion)
            switch (railDIR)
            {
            case E_RAIL_DIR.F:
                Location_X = (int)matchRail.p_Points[0].RealPointf.X;
                Location_Y = (int)matchRail.p_Points[0].RealPointf.Y;
                if (matchRail.p_RailType == E_RAIL_TYPE.Straight_Horizontal)
                {
                    vh.PrcSetLocation(Location_X + railInterval_Pix, Location_Y);
                }
                else if (matchRail.p_RailType == E_RAIL_TYPE.Straight_Vertical)
                {
                    vh.PrcSetLocation(Location_X, Location_Y + railInterval_Pix);
                }
                else
                {
                    vh.PrcSetLocation((int)matchRail.p_RealCenterPoint.X, (int)matchRail.p_RealCenterPoint.Y);
                }
                break;

            case E_RAIL_DIR.R:
                Location_X = (int)matchRail.p_Points[1].RealPointf.X;
                Location_Y = (int)matchRail.p_Points[1].RealPointf.Y;
                if (matchRail.p_RailType == E_RAIL_TYPE.Straight_Horizontal)
                {
                    vh.PrcSetLocation(Location_X - railInterval_Pix, Location_Y);
                }
                else if (matchRail.p_RailType == E_RAIL_TYPE.Straight_Vertical)
                {
                    vh.PrcSetLocation(Location_X, Location_Y - railInterval_Pix);
                }
                else
                {
                    vh.PrcSetLocation((int)matchRail.p_RealCenterPoint.X, (int)matchRail.p_RealCenterPoint.Y);
                }
                break;
            }
        }
 public void VehicleArrivalsEndAdr(uctlVehicle vh)
 {
     vh.PrcSetLocation((int)m_pPoints[1].RealPointf.X, (int)m_pPoints[1].RealPointf.Y);
 }