예제 #1
0
 private void UpdateActiveColors(ShowLightViewModel selectedShowlight)
 {
     if (selectedShowlight.ShowlightType == ShowLightType.Beam)
     {
         ActiveBeamColor = selectedShowlight.Note;
         ActiveFogColor  = FindActiveOrFirstShowlightOfType(ShowLightType.Fog, selectedShowlight.Time)?.Note ?? default;
     }
     else if (selectedShowlight.ShowlightType == ShowLightType.Fog)
     {
         ActiveFogColor  = selectedShowlight.Note;
         ActiveBeamColor = FindActiveOrFirstShowlightOfType(ShowLightType.Beam, selectedShowlight.Time)?.Note ?? default;
     }
     else
     {
         ActiveFogColor  = FindActiveOrFirstShowlightOfType(ShowLightType.Fog, selectedShowlight.Time)?.Note ?? default;
         ActiveBeamColor = FindActiveOrFirstShowlightOfType(ShowLightType.Beam, selectedShowlight.Time)?.Note ?? default;
     }
 }
예제 #2
0
        private void Insert_Impl()
        {
            var newNote = new ShowLightViewModel(InsertColor, (int)(InsertTime * 1000f));

            UndoManager.AddDelegateUndo(
                "Insert",
                undoAction: () =>
            {
                Showlights.Remove(newNote);
                return(newNote);
            },
                redoAction: () =>
            {
                Showlights.AddOrUpdate(newNote);
                return(newNote);
            },
                FileDirty);

            Showlights.AddOrUpdate(newNote);

            SelectedItem = newNote;
            scrollIntoView.OnNext(newNote);
        }
예제 #3
0
        public StrobeEffectViewModel()
        {
            var canGenerate = this.WhenAnyValue(
                x => x.Color1,
                x => x.Color2,
                x => x.HasErrors,
                (c1, c2, err) => !err && c1 != c2 && ShowLightViewModel.GetShowlightType(c1) == ShowLightViewModel.GetShowlightType(c2));

            this.WhenAnyValue(x => x.StartTime, x => x.EndTime)
            .Subscribe(tuple =>
            {
                var(startTime, endTime) = tuple;
                bool errorsChanged      = false;

                if (_errors.ContainsKey(nameof(EndTime)))
                {
                    _errors.Remove(nameof(EndTime));
                    errorsChanged = true;
                }

                if (endTime <= startTime)
                {
                    _errors.Add(nameof(EndTime), "End time cannot be less than start time.");
                    errorsChanged = true;
                }

                if (errorsChanged)
                {
                    ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(nameof(EndTime)));
                    this.RaisePropertyChanged(nameof(HasErrors));
                }
            });

            Generate = ReactiveCommand.Create(GenerateStrobeEffect, canGenerate);
            Generate.BindTo(this, x => x.GeneratedShowlights);
        }