Exemple #1
0
        public TrackUIControl(TrackDescription desc)
        {
            Descriptor = desc;
            QfsFile qfs = new QfsFile(@"Frontend\Art\Control\" + desc.ImageFile);

            Bitmap = qfs.Content.Header.Bitmaps.Find(a => a.Id == "0000");
        }
        static void Main(string[] args)
        {
            Clock clock1 = new Clock();

            TrackOrm         trackOrm   = new TrackOrm();
            string           track1Path = "Data/traintrack1.txt";
            string           track2Path = "Data/traintrack2.txt";
            TrackDescription track1     = trackOrm.LoadTrack(track1Path);
            TrackDescription track2     = trackOrm.LoadTrack(track2Path);

            ITravelPlan travelPlan =
                new TravelPlanner()
                .AddTrack(track2)
                .SelectTrain(2)
                .StartAt(1, "10:00")
                .ArriveAt(2, "10:56")
                .StartAt(2, "12:17")
                .ArriveAt(3, "13:20")
                //.SelectTrain(3)
                //.StartAt(1, "12:30")
                //.ArriveAt(2, "14:46")
                .GeneratePlan();

            travelPlan.Save();

            //  test to see if the trains would crash:
            // ITravelPlan travelPlanShouldCrash =
            // new TravelPlanner()
            // .AddTrack(track2)
            // .SelectTrain(2).StartAt(1, "10:00").ArriveAt(2, "12:12").SelectTrain(3).StartAt(2, "11:30").ArriveAt(1, "17:00").GeneratePlan();
        }
        public void LoadTrack_expect_StationConnections_NotNull()
        {
            var              path     = "Data/mock_track.txt";
            TrackOrm         trackOrm = new TrackOrm();
            TrackDescription track    = trackOrm.LoadTrack(path);

            Assert.NotNull(track.StationConnections);
        }
 public Stream(TrackDescription AudioTrack, TrackType trackType)
 {
     this.Track     = AudioTrack;
     this.TrackType = trackType;
     if (CurrentTrack == AudioTrack.Id)
     {
         IsActive = true;
     }
 }
Exemple #5
0
 public SubtitleFilesModel(TrackDescription trackDescription, int currentid, string path = null)
 {
     this.Directory        = path;
     this.TrackDescription = trackDescription;
     this.Name             = trackDescription.Name;
     this.Id           = TrackDescription.Id;
     this.SubtitleType = SubtitleType.HardCoded;
     if (trackDescription.Id == currentid)
     {
         this.IsSelected = true;
     }
 }
Exemple #6
0
        private void DrawOpenRoadResult()
        {
            WriteLine(GameConfig.SelectedTrackDescription.Name + " - Stage completed", Color.Gray, 20, 30, TitleSize);

            WriteLine("Time: " + TimeSpan.FromSeconds(_race.PlayerStats.LapTimes[0]));

            if (TrackDescription.GetNextOpenRoadStage(GameConfig.SelectedTrackDescription) != null)
            {
                WriteLine("Continue to next stage", _selectedOption == 0, 60, 30, SectionSize);
            }

            WriteLine(" Main menu", _selectedOption == 1, 30, 30, SectionSize);
        }
Exemple #7
0
        public void Update(GameTime gameTime)
        {
            if (UIController.Back)
            {
                Engine.Instance.Screen = new HomeScreen();
            }

            if (UIController.Up && _selectedOption > 0)
            {
                _selectedOption--;
            }
            else if (UIController.Down && _selectedOption < 1)
            {
                _selectedOption++;
            }

            if (UIController.Ok)
            {
                if (_selectedOption == 1)
                {
                    Engine.Instance.Screen = new HomeScreen();
                }
                else
                {
                    if (!GameConfig.SelectedTrackDescription.IsOpenRoad)
                    {
                        Engine.Instance.Screen = new DoRaceScreen(_raceTrack);
                    }
                    else
                    {
                        GameConfig.SelectedTrackDescription = TrackDescription.GetNextOpenRoadStage(GameConfig.SelectedTrackDescription);
                        if (GameConfig.SelectedTrackDescription == null)
                        {
                            Engine.Instance.Screen = new HomeScreen();
                        }
                        else
                        {
                            Engine.Instance.Screen = new LoadRaceScreen();
                        }
                    }
                }
            }
        }
Exemple #8
0
        private void BuildAudioTracksMenu()
        {
            barListItemAudioTracks.Strings.Clear();

            IEnumerable <TrackDescription> tracks = vlcControl7.VlcMediaPlayer.Audio.Tracks.All;
            TrackDescription currentTrack         = vlcControl7.VlcMediaPlayer.Audio.Tracks.Current;
            int selectedIndex = 0;
            int currentIndex  = 0;

            foreach (TrackDescription trackDescription in tracks)
            {
                if (trackDescription.ID == currentTrack.ID)
                {
                    selectedIndex = currentIndex;
                }
                barListItemAudioTracks.Strings.Add(trackDescription.Name);
                ++currentIndex;
            }

            /* TODO: additionally use some infos from media.Tracks?
             * VlcMedia media = vlcControl7.GetCurrentMedia();
             * if (media == null)
             * {
             *      barListItemAudioTracks.Enabled = false;
             *      return;
             * }
             * foreach (MediaTrack track in media.Tracks.Where(item => item.Type == MediaTrackTypes.Audio))
             * {
             *      string bitrateText = track.Bitrate > 0 ? $" {track.Bitrate / 1024.0:#}kbps" : "";
             *      string itemText = $"{track.Language} {track.Description}" + bitrateText;
             *      barListItemAudioTracks.Strings.Add(itemText);
             *      if (media.TrackID == track.Id.ToString())
             *      {
             *              selectedIndex = currentIndex;
             *      }
             * }*/

            barListItemAudioTracks.ItemIndex = selectedIndex;             // when an item is clicked by the user, the checkmark is automatically set by the barListItem control
            barListItemAudioTracks.Enabled   = barListItemAudioTracks.Strings.Count > 0;
        }
Exemple #9
0
 public static void ReleaseTrackDescription(TrackDescription trackDescription)
 {
     _releaseTrackDescriptionFunction.Delegate(trackDescription.Pointer);
 }
Exemple #10
0
 public VlcMediaTrack(TrackDescription trackDescription)
 {
     _trackDescription = trackDescription;
 }
Exemple #11
0
 public TrackUIControl(TrackDescription desc)
 {
     Descriptor = desc;
     QfsFile qfs = new QfsFile(@"Frontend\Art\Control\" + desc.ImageFile);
     Bitmap = qfs.Content.Header.Bitmaps.Find(a => a.Id == "0000");
 }
Exemple #12
0
 public Track(string path, TrackDescription description)
 {
     Path     = path;
     MetaData = description;
 }
Exemple #13
0
        /// <summary>
        /// Shows the dialog to subtitle track.
        /// </summary>
        /// <param name="subTitles">A VclControl class instance's SubTitles.All collection.</param>
        /// <param name="trackDescription">A VclControl class instance's SubTitles.Current member.</param>
        /// <returns>A Vlc.DotNet.Core.TrackDescription class instance or null, if no subtitle was selected.</returns>
        public static TrackDescription Execute(IEnumerable <TrackDescription> subTitles, TrackDescription trackDescription)
        {
            if (subTitles == null || subTitles.Count() == 0) // Nothing to select from so return null
            {
                return(null);
            }

            FormSelectSubtitle selectSubtitleForm = new FormSelectSubtitle(); // Create the form

            int subID = -1;                                                   // Id if a VclControl class instance's SubTitles.Current member was null.

            if (trackDescription != null)                                     // Get the current subtitles ID..
            {
                subID = trackDescription.ID;
            }

            foreach (TrackDescription desc in subTitles) // List the subtitle tracks..
            {
                selectSubtitleForm.lbSubtitles.Items.Add(desc);
            }

            for (int i = 0; i < selectSubtitleForm.lbSubtitles.Items.Count; i++) // if a subtitle with and ID is found on the list, select it..
            {
                if (((TrackDescription)selectSubtitleForm.lbSubtitles.Items[i]).ID == subID)
                {
                    selectSubtitleForm.lbSubtitles.SelectedIndex = i;
                    break; // no reason to iterate them all..
                }
            }

            if (selectSubtitleForm.ShowDialog() == DialogResult.OK) // If user selects OK, then return the selected TrackDescription class instance..
            {
                return(selectSubtitleForm.lbSubtitles.SelectedItem as TrackDescription);
            }
            else // Otherwise, return null
            {
                return(null);
            }
        }
Exemple #14
0
        // Handle all the button clicks (Panel).
        private void CommonClickHandler(object sender, EventArgs e)
        {
            if (sender.GetType() != typeof(Panel)) // only accept panels..
            {
                return;
            }

            Panel btn = (sender as Panel);

            if (btn.Equals(btnWindForward))       // if the wind forward was clicked..
            {
                wind   = !wind;                   // toggle the state..
                rewind = false;                   // disable rewind to avoid "mental" state..
            }
            else if (btn.Equals(btnWindBackward)) // if the wind forward was clicked..
            {
                rewind = !rewind;                 // toggle the state..
                wind   = false;                   // disable wind to avoid "mental" state..
            }
            else if (btn.Equals(btnPause))
            {
                TogglePause();
            }
            else if (btn.Equals(btnPlay))
            {
                if (wind || rewind)
                {
                    wind   = false;
                    rewind = false;
                    if (!vlcControl.IsPlaying)
                    {
                        vlcControl.Play();
                    }
                }
                else if (!vlcControl.IsPlaying) // If pausing is possible..
                {
                    TogglePause();              // .. do the pause thing.
                }
            }
            else if (btn.Equals(btnStop)) // Stop button was clicked..
            {
                if (startPlay)
                {
                    Database.UpdateFile(file.FullName, vlcControl.Time, vlcControl.Length, IsWacthed, Volume);
                }
                closeForm = true;              // signal the timer to close the form..
            }
            else if (btn.Equals(btnSeekStart)) // If to-the-beginning button was clicked
            {
                tmMain.Enabled = false;        // disable the timer from doing it's job..
                // No winding/rewinding
                wind            = false;
                rewind          = false;
                vlcControl.Time = 0;         // Back to start
                tmMain.Enabled  = true;      // .. enable the timer to do it's job.
            }
            else if (btn.Equals(btnSeekEnd)) // If to-the-ending button was clicked
            {
                tmMain.Enabled = false;      // disable the timer from doing it's job..
                // No winding/rewinding
                wind            = false;
                rewind          = false;
                vlcControl.Time = vlcControl.Length - 1;          // To the end
                tmMain.Enabled  = true;                           // .. enable the timer to do it's job.
            }
            else if (btn.Equals(btnVolume))                       // the volume button was clicked..
            {
                int volume = Convert.ToInt32(btn.Tag.ToString()); // get the saved volume, if zero set to hundred (muted by the volume slider)
                volume = volume == 0 ? 100 : volume;

                sliderPosition.Scroll -= sliderPosition_Scroll; // detach the event handler, so the slider does not launch the scroll event..
                if (muted)
                {
                    muted = false;                                     // not muted..
                    btn.BackgroundImage = Properties.Resources.volume; // set the image to not muted..
                    sliderVolume.Value  = volume;                      // set the volume..
                    btn.Tag             = volume;                      // save the volume to the Tag property
                }
                else
                {
                    muted               = true;                            // set to muted..
                    btn.Tag             = sliderVolume.Value;              // save the volume to the Tag property
                    sliderVolume.Value  = 0;                               // set the volume slider to 0 = muted
                    btn.BackgroundImage = Properties.Resources.volume_off; // set the image to muted..
                }
                // set the tool-tip value
                lbToolTip.Text         = DBLangEngine.GetMessage("msgVolumePercentage", "Volume: {0}%|As in a tool-tip to describe volume and its percentage value", (sliderVolume.Value * 300) / sliderVolume.Maximum);
                sliderPosition.Scroll += sliderPosition_Scroll;   // re-attach the event handler back..
            }
            else if (btn.Equals(btnSelectSubtitle))               // Select subtitle was clicked..
            {
                m_GlobalHook.MouseMove -= M_GlobalHook_MouseMove; // don't listen the global events when a dialog is visible..
                m_GlobalHook.MouseDown -= M_GlobalHook_MouseDown; // don't listen the global events when a dialog is visible..

                // as the user which subtitle track one might want..
                TrackDescription desc = FormSelectSubtitle.Execute(vlcControl.SubTitles.All, vlcControl.SubTitles.Current);
                if (desc != null) // if something was selected assign it to be the current subtitle track..
                {
                    vlcControl.SubTitles.Current = desc;
                }
                m_GlobalHook.MouseMove += M_GlobalHook_MouseMove; // start listening the global events again as the dialog closed..
                m_GlobalHook.MouseDown += M_GlobalHook_MouseDown; // start listening the global events again as the dialog closed..
            }
            SetButtonStates();                                    // sets the button states to enabled / disabled depending on the playback "conditions"..
        }