Esempio n. 1
0
        public void Unlock(string tracks, string sectors)
        {
            int[] unlockSectors = { -1 };
            int[] unlockTracks  = { -1 };

            if (sectors != "")
            {
                unlockSectors = Parse(sectors);
                for (int i = 0; i < unlockSectors.Length; i++)
                {
                    unlockSectors[i] -= 1;
                }
            }
            unlockTracks = Parse(tracks);

            if (unlockTracks[0] != -1)
            {
                if (sectors == "")
                {
                    foreach (Track track in AllTracks)
                    {
                        int pos = Array.IndexOf(unlockTracks, track.Number);
                        if (pos > -1)
                        {
                            BeheerTrack beheerTrack = track == null ? null : BeheerTrack.ToBeheerTrack(track);
                            beheerTrack.UnlockTrack();
                            repo.EditTrack(beheerTrack);
                        }
                    }
                }
                else
                {
                    foreach (BeheerTrack track in AllTracks)
                    {
                        int pos = Array.IndexOf(unlockTracks, track.Number);
                        if (pos > -1)
                        {
                            for (int i = 0; i < track.Sectors.Count - 1; i++)
                            {
                                pos = Array.IndexOf(unlockSectors, i);
                                if (pos > -1)
                                {
                                    BeheerSector beheerSector = track.Sectors[i] == null ? null : BeheerSector.ToBeheerSector(track.Sectors[i]);
                                    beheerSector.UnLock();
                                    repo.EditSector(beheerSector);
                                }
                            }
                        }
                    }
                }
                Update();
            }
        }
Esempio n. 2
0
 public void FetchUpdates()
 {
     AllTracks = new List <BeheerTrack>();
     foreach (Track track in repo.GetTracksAndSectors())
     {
         AllTracks.Add(track == null ? null : BeheerTrack.ToBeheerTrack(track));
     }
     AllTrams = new List <BeheerTram>();
     foreach (Tram tram in repo.GetAllTrams())
     {
         AllTrams.Add(tram == null ? null : BeheerTram.ToBeheerTram(tram));
     }
 }
Esempio n. 3
0
        public void Lock(string tracks, string sectors)
        {
            int[] lockSectors = { -1 };
            int[] lockTracks  = { -1 };

            if (sectors != "")
            {
                lockSectors = Parse(sectors);
                for (int i = 0; i < lockSectors.Length; i++)
                {
                    lockSectors[i] -= 1;
                }
            }

            lockTracks = Parse(tracks);

            if (lockTracks[0] != -1)
            {
                if (sectors == "")
                {
                    foreach (Track track in AllTracks)
                    {
                        int pos = Array.IndexOf(lockTracks, track.Number);
                        if (pos > -1)
                        {
                            BeheerTrack beheerTrack = track == null ? null : BeheerTrack.ToBeheerTrack(track);
                            beheerTrack.LockTrack();
                            repo.EditTrack(beheerTrack);
                        }
                    }
                }
                else
                {
                    foreach (BeheerTrack track in AllTracks)
                    {
                        int pos = Array.IndexOf(lockTracks, track.Number);
                        if (pos > -1)
                        {
                            for (int i = 0; i < track.Sectors.Count - 1; i++)
                            {
                                pos = Array.IndexOf(lockSectors, i);
                                if (pos > -1)
                                {
                                    bool         lockTrack    = true;
                                    BeheerSector beheerSector = track.Sectors[i] == null ? null : BeheerSector.ToBeheerSector(track.Sectors[i]);
                                    if (beheerSector.OccupyingTram != null)
                                    {
                                        DialogResult dialogResult = MessageBox.Show("There are trams on the location you are trying to lock, are you sure?", "Warning", MessageBoxButtons.YesNo);
                                        if (dialogResult == DialogResult.No)
                                        {
                                            lockTrack = false;
                                        }
                                    }
                                    if (lockTrack == true)
                                    {
                                        beheerSector.Lock();
                                        repo.EditSector(beheerSector);
                                    }
                                }
                            }
                        }
                    }
                }
                Update();
            }
        }