コード例 #1
0
        public TrackControl(Track track)
        {
            InitializeComponent();

            Track = track;
            Controller = new TrackController(this);
        }
コード例 #2
0
 public void TestScheduleTrackWithValidTalkDuration()
 {
     ITrack track = new Track(DateTime.Now);
     ITalk talkA = Factory.Instance.GetNewTalk("Talk A", 60);
     ITalk talkB = Factory.Instance.GetNewTalk("Talk B", 60);
     ITalk talkC = Factory.Instance.GetNewTalk("Talk C", 60);
     ITalk talkD = Factory.Instance.GetNewTalk("Talk D", 60);
     ITalk talkE = Factory.Instance.GetNewTalk("Talk E", 60);
     ITalk talkF = Factory.Instance.GetNewTalk("Talk F", 60);
     var unscheduledTalks = new List<ITalk> { talkA, talkB, talkC, talkD, talkE, talkF };
     bool result = track.ScheduleTrack(unscheduledTalks);
     Assert.True(result && track.BufferDuration == 60
                 && unscheduledTalks.Count == 0
                 && track.MorningSession.RemainingDuration == 0
                 && track.AfternoonSession.RemainingDuration == 0);
 }
コード例 #3
0
 public void TestTrackToString()
 {
     ITrack track = new Track(DateTime.Now);
     ITalk talkA = Factory.Instance.GetNewTalk("Talk A", 60);
     ITalk talkB = Factory.Instance.GetNewTalk("Talk B", 60);
     ITalk talkC = Factory.Instance.GetNewTalk("Talk C", 60);
     ITalk talkD = Factory.Instance.GetNewTalk("Talk D", 60);
     ITalk talkE = Factory.Instance.GetNewTalk("Talk E", 60);
     ITalk talkF = Factory.Instance.GetNewTalk("Talk F", 60);
     var unscheduledTalks = new List<ITalk> { talkA, talkB, talkC, talkD, talkE, talkF };
     bool result = track.ScheduleTrack(unscheduledTalks);
     Assert.True(track.ToString().Equals(new StringBuilder("09:00AM Talk A 60min").Append(Environment.NewLine)
                                         .Append("10:00AM Talk B 60min").Append(Environment.NewLine)
                                         .Append("11:00AM Talk C 60min").Append(Environment.NewLine)
                                         .Append("12:00PM Lunch").Append(Environment.NewLine)
                                         .Append("01:00PM Talk D 60min").Append(Environment.NewLine)
                                         .Append("02:00PM Talk E 60min").Append(Environment.NewLine)
                                         .Append("03:00PM Talk F 60min").Append(Environment.NewLine)
                                         .Append("04:00PM Networking Event").Append(Environment.NewLine).ToString()));
 }
コード例 #4
0
ファイル: Visualize.cs プロジェクト: Geertjan64/CSharpRaceSim
        public static BitmapSource DrawTrack(Model.Track track)
        {
            #region WPF
            bitmap = new Bitmap(1000, 1000);


            g = Graphics.FromImage(bitmap);


            g.FillRectangle(new SolidBrush(Color.Red), 0, 0, 200, 200);

            #endregion


            List <SectionBuildingDetails> buildingDetails = new List <SectionBuildingDetails>();

            FillBuildingDetails(ref buildingDetails, track);
            ShiftPositions(buildingDetails);
            DrawBuildingDetails(ref buildingDetails);

            drawParticipants(ref buildingDetails);

            return(ContentLoader.CreateBitmapSourceFromGdiBitmap(bitmap));
        }
コード例 #5
0
        private void Scan(object sender, DoWorkEventArgs args)
        {
            var repositories = Repository.MediaRepositories.Select(x => x);
            var repositoryCount = 0;
            var totalRepositories = repositories.Count();
            foreach (var repository in repositories)
            {
                var paths = new List<string>();
                var directory = new DirectoryInfo(repository.Location);
                paths.AddRange(FindFiles(directory));
                paths.AddRange(ScanSubDirectories(directory));
                repository.LastScanned = DateTime.Now;

                var pathCount = 0;
                Parallel.ForEach(paths, new ParallelOptions {MaxDegreeOfParallelism = 15}, delegate(string path)
                                            {
                                                var repo = DataAccessContext.GetRepository();
                                                pathCount += 1;
                                                ReportProgress(
                                                    CalculatePercentage(pathCount, paths.Count, repositoryCount, totalRepositories),
                                                    new RepositoryScannerState {CurrentPath = path, CurrentRepository = repository.Location});

                                                var mediaFile = repo.MediaFiles.FirstOrDefault(x => x.FullPath == path);
                                                Track track;
                                                if (mediaFile != null)
                                                {
                                                    if (mediaFile.LastModified <
                                                        (new FileInfo(mediaFile.FullPath)).LastWriteTime.AddMinutes(-1))
                                                    {
                                                        track = repo.Tracks.First(x => x.Id == mediaFile.TrackId);
                                                        //Update Track metadata
                                                        ProcessTrack(path, ref track, ref repo);
                                                        repo.SubmitChanges();
                                                    }
                                                }
                                                else
                                                {
                                                    track = new Track {Id = Guid.NewGuid()};
                                                    //Update Track metadata
                                                    ProcessTrack(path, ref track, ref repo);

                                                    repo.Tracks.InsertOnSubmit(track);
                                                    repo.SubmitChanges();

                                                    var file = new FileInfo(path);
                                                    mediaFile = new MediaFile
                                                                    {
                                                                        Id = Guid.NewGuid(),
                                                                        RepositoryId = repository.Id,
                                                                        FullPath = path,
                                                                        DateAdded = DateTime.Now,
                                                                        LastModified = file.LastWriteTime,
                                                                        FileType = file.Extension,
                                                                        Size = file.Length,
                                                                        TrackId = track.Id
                                                                    };
                                                    repo.MediaFiles.InsertOnSubmit(mediaFile);
                                                    repo.SubmitChanges();
                                                }
                                            });
                repositoryCount += 1;
            }
        }
コード例 #6
0
        private void ProcessTrack(string path, ref Track track, ref Repository repo)
        {
            var file = TagLib.File.Create(path);
            track.Name = file.Tag.Title;
            track.TrackNumber = (int) file.Tag.Track;
            track.Duration = (int) file.Properties.Duration.TotalSeconds;
            track.BPM = (int) file.Tag.BeatsPerMinute;
            track.BitRate = file.Properties.AudioBitrate;
            track.Comments = file.Tag.Comment;
            track.Composer = "";
            foreach (var composer in file.Tag.Composers.Take(file.Tag.Composers.Count() - 1))
            {
                track.Composer += composer + "; ";
            }
            track.Composer += file.Tag.Composers.Count() > 0 ? file.Tag.Composers.Last() : "";
            track.DiscNumber = (int) file.Tag.Disc;
            track.SampleRate = file.Properties.AudioSampleRate;
            track.Year = (int) file.Tag.Year;
            track.MBID = string.IsNullOrEmpty(file.Tag.MusicBrainzTrackId) ? (Guid?)null : new Guid(file.Tag.MusicBrainzTrackId);
            track.Genre = file.Tag.FirstGenre;

            var artistId = GetArtist(file.Tag, ref repo);
            track.ArtistId = artistId;
            track.AlbumId = GetAlbum(artistId, file.Tag, ref repo);

            if (file.Tag.Pictures.Count() > 0)
            {
                var pic = file.Tag.Pictures[0];
                InsertAlbumArt(track.AlbumId, pic, ref repo);
            }
        }
コード例 #7
0
 partial void DeleteTrack(Track instance);
コード例 #8
0
 partial void UpdateTrack(Track instance);
コード例 #9
0
		private void detach_Tracks(Track entity)
		{
			this.SendPropertyChanging();
			entity.Album = null;
		}
コード例 #10
0
 partial void InsertTrack(Track instance);
コード例 #11
0
		private void attach_Tracks(Track entity)
		{
			this.SendPropertyChanging();
			entity.Album = this;
		}
コード例 #12
0
ファイル: Visualize.cs プロジェクト: Geertjan64/CSharpRaceSim
        private static void FillBuildingDetails(ref List <SectionBuildingDetails> buildingDetails, Model.Track t)
        {
            int x = 0;
            int y = 0;

            Heading current = Heading.South;
            Heading last    = current;

            foreach (Model.Section sec in Data.CurrentRace.Track.Sections)
            {
                var a = new SectionBuildingDetails()
                {
                    section = sec, x = x, y = y
                };
                // Determine its heading
                if (sec.SectionType == SectionTypes.LeftCorner)
                {
                    last = current;

                    if (current == Heading.West)
                    {
                        current = Heading.North;
                    }
                    else
                    {
                        current++;
                    }
                }
                if (sec.SectionType == SectionTypes.RightCorner)
                {
                    last = current;

                    if (current == Heading.North)
                    {
                        current = Heading.West;
                    }
                    else
                    {
                        current--;
                    }
                }

                a.direction     = current;
                a.lastDirection = last;

                buildingDetails.Add(a);

                // move postion values based on the direction
                switch (current)
                {
                case (Heading.North):
                    y++;
                    break;

                case (Heading.East):
                    x++;
                    break;

                case (Heading.South):
                    y--;
                    break;

                case (Heading.West):
                    x--;
                    break;
                }
            }
        }