コード例 #1
0
ファイル: NoteController.cs プロジェクト: jwh5293/Composer
 static NoteController()
 {
     Repository = ServiceLocator.Current.GetInstance<DataServiceRepository<Repository.DataService.Composition>>();
     Ea = ServiceLocator.Current.GetInstance<IEventAggregator>();
     ViewModel = null;
     SubscribeEvents();
 }
コード例 #2
0
        public void GetHubCompositionsAsync()
        {
            DataServiceRepository<Composer.Repository.DataService.Composition> repository =
            new DataServiceRepository<Composer.Repository.DataService.Composition>();

            DataServiceQuery<Composer.Repository.DataService.Composition> qry =
                repository.RetrieveAll<Composer.Repository.DataService.Composition>()
                as DataServiceQuery<Composer.Repository.DataService.Composition>;

            qry = qry.Expand(composition =>
                composition.Verses);

            qry = qry.Expand(composition =>
                composition.Collaborations);

            qry.BeginExecute(new AsyncCallback(a =>
            {
                try
                {
                    IEnumerable<Composer.Repository.DataService.Composition> results = qry.EndExecute(a);
                    if (HubCompositionsLoadingComplete != null)
                    {
                        HubCompositionsLoadingComplete(this, new HubCompositionsLoadingEventArgs(results));
                    }
                }
                catch (Exception ex)
                {
                    if (HubCompositionsLoadingError != null)
                    {
                        HubCompositionsLoadingError(this, new HubCompositionsErrorEventArgs(ex));
                    }
                }
            }), null);
        }
コード例 #3
0
        public LyricsPanelViewModel()
        {
            _repository = ServiceLocator.Current.GetInstance<DataServiceRepository<Repository.DataService.Composition>>();

            DefineCommands();
            SubscribeEvents();
            ResetEditor();
        }
コード例 #4
0
 public void Should_parse_order()
 {
     DataServiceRepository.TryParseOrder(null, out _).Should().BeFalse();
     DataServiceRepository.TryParseOrder("", out _).Should().BeFalse();
     DataServiceRepository.TryParseOrder("A", out var order).Should().BeTrue();
     order.Should().Be(("A", false));
     DataServiceRepository.TryParseOrder("-B", out order).Should().BeTrue();
     order.Should().Be(("B", true));
 }
コード例 #5
0
ファイル: Collaborations.cs プロジェクト: jwh5293/Composer
 static Collaborations()
 {
     if (_repository == null)
     {
         _repository = ServiceLocator.Current.GetInstance<DataServiceRepository<Repository.DataService.Composition>>();
         Ea = ServiceLocator.Current.GetInstance<IEventAggregator>();
         SubscribeEvents();
     }
 }
コード例 #6
0
        public void GetCompositionAsync()
        {
            DataServiceRepository<Composer.Repository.DataService.Composition> repository =
            new DataServiceRepository<Composer.Repository.DataService.Composition>();
            Guid guid;
            Guid.TryParse(this.CompositionId, out guid);

            DataServiceQuery<Composer.Repository.DataService.Composition> qry =
                repository.RetrieveAll<Composer.Repository.DataService.Composition>().Where(c => c.Id == guid)
                as DataServiceQuery<Composer.Repository.DataService.Composition>;

            qry = qry.Expand(composition =>
                composition.Staffgroups.SubExpand(staffgroup =>
                    staffgroup.Staffs.SubExpand(staff =>
                        staff.Measures).SubExpand(measure =>
                            measure.Chords).SubExpand(chord =>
                                chord.Notes)));

            qry = qry.Expand(composition =>
                composition.Verses);

            qry = qry.Expand(composition =>
                composition.Collaborations);

            qry = qry.Expand(composition =>
                  composition.Arcs);

            qry.BeginExecute(new AsyncCallback(a =>
            {
                try
                {
                    IEnumerable<Composer.Repository.DataService.Composition> results = qry.EndExecute(a);

                    if (CompositionLoadingComplete != null)
                    {
                        CompositionLoadingComplete(this, new CompositionLoadingEventArgs(results));
                    }
                }
                catch (Exception ex)
                {
                    if (CompositionLoadingError != null)
                    {
                        CompositionLoadingError(this, new CompositionErrorEventArgs(ex));
                    }
                }
            }), null);
        }
コード例 #7
0
ファイル: LiteDbTests.cs プロジェクト: maxbl4/RaceLogic
        public void Should_generate_long_id_for_bson_document()
        {
            using var repo = new LiteRepository(dbFile).WithUtcDate();
            var doc = new BsonDocument {
                ["Some"] = "123", ["_id"] = 0L
            };
            var col = repo.Database.GetCollection("some", DataServiceRepository.GetAutoId(doc, out var isDefault));

            if (isDefault)
            {
                doc.Remove("_id");
            }
            col.Upsert(doc);
            var id = doc["_id"].AsInt64;

            id.Should().NotBe(0);
            var e = col.FindById(id);

            e["Some"].Should().Be("123");
        }
コード例 #8
0
 public StoreController(DataServiceRepository repository)
 {
     this.repository = repository;
 }
コード例 #9
0
ファイル: StaffgroupManager.cs プロジェクト: jwh5293/Composer
 static StaffgroupManager()
 {
     Repository = ServiceLocator.Current.GetInstance<DataServiceRepository<Repository.DataService.Composition>>();
     SubscribeEvents();
 }
コード例 #10
0
ファイル: ArcManager.cs プロジェクト: jwh5293/Composer
 static ArcManager()
 {
     if (repository == null)
         repository = ServiceLocator.Current.GetInstance<DataServiceRepository<Repository.DataService.Composition>>();
     SubscribeEvents();
 }
コード例 #11
0
ファイル: ArcViewModel.cs プロジェクト: jwh5293/Composer
 public void OnFlipArc(Guid id)
 {
     if (Arc.Id != id) return;
     Top = (SweepDirection == cw) ? Top + Measure.NoteHeight : Top - Measure.NoteHeight;
     SweepDirection = (SweepDirection == cw) ? ccw : cw;
     FlareSweepDirection = (SweepDirection == cw) ? ccw : cw;
     Arc.ArcSweep = SweepDirection;
     Arc.FlareSweep = FlareSweepDirection;
     Arc.Top = (double)Top;
     if (_repository == null)
     {
         _repository = ServiceLocator.Current.GetInstance<DataServiceRepository<Repository.DataService.Composition>>();
     }
     _repository.Update(Arc);
 }
コード例 #12
0
ファイル: MeasureManager.cs プロジェクト: jwh5293/Composer
        public static void Initialize()
        {
            _repository = ServiceLocator.Current.GetInstance<DataServiceRepository<Repository.DataService.Composition>>();
            _ea = ServiceLocator.Current.GetInstance<IEventAggregator>();

            Chord = null;
            ChordNotegroups = null;

            SubscribeEvents();
        }
コード例 #13
0
 public static void Initialize()
 {
     if (_repository == null)
     {
         _repository = ServiceLocator.Current.GetInstance<DataServiceRepository<Repository.DataService.Composition>>();
         SubscribeEvents();
     }
 }
コード例 #14
0
        public static void OnCreateNewComposition(object obj)
        {
            var payload = (Tuple<string, List<string>, _Enum.StaffConfiguration, List<short>>)obj;
            _repository = ServiceLocator.Current.GetInstance<DataServiceRepository<Repository.DataService.Composition>>();

            var verses = new DataServiceCollection<Repository.DataService.Verse>(null, TrackingMode.None);
            var staffgroups = new DataServiceCollection<Staffgroup>(null, TrackingMode.None);
            var collaborations = new DataServiceCollection<Repository.DataService.Collaboration>(null, TrackingMode.None);

            var composition = Create();
            composition.Provenance.TitleLine = payload.Item1;
            composition.StaffConfiguration = (short)payload.Item3;
            ClefIds = payload.Item4;
            for (int sgIndex = 0; sgIndex < Infrastructure.Support.Densities.StaffgroupDensity; sgIndex++)
            {
                var staffgroup = StaffgroupManager.Create(composition.Id, _staffgroupSequence);
                _staffgroupSequence += Defaults.SequenceIncrement;
                var staffs = new DataServiceCollection<Staff>(null, TrackingMode.None);
                _staffSequence = 0;
                for (int sIndex = 0; sIndex < Infrastructure.Support.Densities.StaffDensity; sIndex++)
                {
                    var staff = StaffManager.Create(staffgroup.Id, _staffSequence);

                    //clefIds was populated in NewCompositionPanel. it's a list of selected staff clef Ids top to bottom.
                    //if Dimensions.StaffDensity > then in multi instrument staffconfiguration - each staff clef is the
                    //same as the first staff clef. otherwise the staff clefs are whatever was specified in the newcompositionpanel
                    staff.Clef_Id = (Infrastructure.Support.Densities.StaffDensity > 2) ? ClefIds[0] : ClefIds[sIndex % 2];

                    _staffSequence += Defaults.SequenceIncrement;
                    var measures = new DataServiceCollection<Repository.DataService.Measure>(null, TrackingMode.None);
                    _measureSequence = 0;
                    for (int mIndex = 0; mIndex < Infrastructure.Support.Densities.MeasureDensity; mIndex++)
                    {
                        var measure = MeasureManager.Create(staff.Id, _measureSequence);

                        _measureSequence += Defaults.SequenceIncrement;
                        measure.Index = _measureIndex;
                        _measureIndex++;
                        _repository.Context.AddLink(staff, "Measures", measure);
                        //if this is the last measure on the last staff then measure.bar is the EndBar.
                        if (mIndex == Infrastructure.Support.Densities.MeasureDensity - 1)
                        {
                            if (sgIndex == Infrastructure.Support.Densities.StaffgroupDensity - 1)
                            {
                                if (sIndex == Infrastructure.Support.Densities.StaffDensity - 1)
                                {
                                    measure.Bar_Id = 1;
                                }
                            }
                        }
                        measures.Add(measure);
                    }
                    staff.Measures = measures;
                    _repository.Context.AddLink(staffgroup, "Staffs", staff);
                    staffs.Add(staff);
                }
                staffgroup.Staffs = staffs;
                _repository.Context.AddLink(composition, "Staffgroups", staffgroup);
                staffgroups.Add(staffgroup);
            }

            composition.Staffgroups = staffgroups;
            Repository.DataService.Collaboration collaboration = CollaborationManager.Create(composition, 0);
            _repository.Context.AddLink(composition, "Collaborations", collaboration);
            collaborations.Add(collaboration);
            composition.Collaborations = collaborations;
            composition.Verses = verses;
            Ea.GetEvent<NewComposition>().Publish(composition);
        }
コード例 #15
0
ファイル: CloneComposition.cs プロジェクト: jwh5293/Composer
 public CloneComposition()
 {
     _repository = ServiceLocator.Current.GetInstance<DataServiceRepository<Repository.DataService.Composition>>();
     _ea = ServiceLocator.Current.GetInstance<IEventAggregator>();
     SubscribeEvents();
 }
コード例 #16
0
        public void CreateNewCompositionForPanel()
        {
            _repository = ServiceLocator.Current.GetInstance<DataServiceRepository<Repository.DataService.Composition>>();
            var staffgroups = new DataServiceCollection<Staffgroup>(null, TrackingMode.None);

            int staffDensity = ((short)_staffConfiguration == (short)_Enum.StaffConfiguration.Grand) ?
                Infrastructure.Constants.Defaults.NewCompositionPanelGrandStaffConfigurationStaffDensity : Infrastructure.Constants.Defaults.NewCompositionPanelSimpleStaffConfigurationStaffDensity;

            Repository.DataService.Composition composition = CompositionManager.Create();
            for (int n = 0; n < Infrastructure.Constants.Defaults.NewCompositionPanelStaffgroupDensity; n++)
            {
                var staffgroup = StaffgroupManager.Create(composition.Id, _staffgroupSequence);
                _staffgroupSequence += Defaults.SequenceIncrement;
                var staffs = new DataServiceCollection<Staff>(null, TrackingMode.None);
                _staffSequence = 0;
                for (var j = 0; j < staffDensity; j++)
                {
                    var staff = StaffManager.Create(staffgroup.Id, _staffSequence);
                    _staffSequence += Defaults.SequenceIncrement;

                    //set clef to default grand staff clef, so the next time through this loop, the grand staff gets the correct clef.
                    Preferences.DefaultClefId = 0;

                    var measures = new DataServiceCollection<Repository.DataService.Measure>(null, TrackingMode.None);
                    _measureSequence = 0;
                    for (var k = 0; k < Infrastructure.Constants.Defaults.NewCompositionPanelMeasureDensity; k++)
                    {
                        var measure = MeasureManager.Create(staff.Id, _measureSequence);

                        _measureSequence += Defaults.SequenceIncrement;
                        measure.Index = _measureIndex;
                        _measureIndex++;
                        _repository.Context.AddLink(staff, "Measures", measure);
                        measures.Add(measure);
                    }
                    staff.Measures = measures;
                    _repository.Context.AddLink(staffgroup, "Staffs", staff);
                    staffs.Add(staff);
                }
                staffgroup.Staffs = staffs;
                _repository.Context.AddLink(composition, "Staffgroups", staffgroup);
                staffgroups.Add(staffgroup);
            }
            composition.Staffgroups = staffgroups;
            composition = CompositionManager.Flatten(composition);
            Composition = composition;
        }
コード例 #17
0
ファイル: VerseManager.cs プロジェクト: jwh5293/Composer
 static VerseManager()
 {
     Repository = ServiceLocator.Current.GetInstance<DataServiceRepository<Repository.DataService.Composition>>();
     Words = new ObservableCollection<Word>();
     SubscribeEvents();
 }
コード例 #18
0
ファイル: StaffViewModel.cs プロジェクト: jwh5293/Composer
 private void SetRepository()
 {
     if (_repository == null)
     {
         _repository = ServiceLocator.Current.GetInstance<DataServiceRepository<Repository.DataService.Composition>>();
     }
 }
コード例 #19
0
ファイル: Collaborations.cs プロジェクト: jwh5293/Composer
        public static int GetStatus(Repository.DataService.Note note, int index)
        {
            var result = -1;
            try
            {
                var arr = note.Status.Split(',');

                if (arr.Length < Index + 1)
                {
                    var status = (arr[0] == ((int)_Enum.Status.AuthorOriginal).ToString(CultureInfo.InvariantCulture)) ?
                        (int)_Enum.Status.AuthorOriginal : (int)_Enum.Status.NotApplicable;

                    if (note.Audit.Author_Id != Current.User.Id && note.Audit.Author_Id != CompositionManager.Composition.Audit.Author_Id)
                    {
                        status = (int)_Enum.Status.NotApplicable;
                    }

                    note.Status = string.Format("{0},{1}", note.Status, status);

                    if (_repository == null)
                    {
                        _repository = ServiceLocator.Current.GetInstance<DataServiceRepository<Repository.DataService.Composition>>();
                    }

                    _repository.Update(note);

                    arr = note.Status.Split(',');
                }
                result = int.Parse(arr[index]);
            }
            catch (Exception ex)
            {
                Exceptions.HandleException(ex, "class = Collaborations method = GetStatus(Repository.DataService.Note note, int index)");
            }
            return result;
        }