using System; using System.Collections.Generic; using System.ComponentModel; using System.Text.Json.Serialization; using System.Windows.Media; using static QuikDawEditor.EDITING.StaticProperties; namespace QuikDawEditor.EditingClasses; public partial class Track : INotifyPropertyChanged { public bool AutomationDPEnabled { get { return !IsRecordingArmed; } } public bool AutomationLanesCBEnabled { get { return !IsAutomationRecording; } } private bool _IsAutomationRecording = false; [JsonIgnore(Condition = JsonIgnoreCondition.Always)] public bool IsAutomationRecording { get { return _IsAutomationRecording; } set { _IsAutomationRecording = value; NotifyPropertyChanged(nameof(IsAutomationRecording)); NotifyPropertyChanged(nameof(AutomationArmedBackgroundBrush)); NotifyPropertyChanged(nameof(AutomationLanesCBEnabled)); } } //public void UpdateAutomationArmed() { NotifyPropertyChanged(nameof(IsAutomationRecording)); NotifyPropertyChanged(nameof(AutomationArmedBackgroundBrush)); } internal double AutomationRecordingStartMs = 0; internal List compareAutoPoints; public LinearGradientBrush AutomationArmedBackgroundBrush { get { switch (IsAutomationRecording) { case true: Color leftColor = Colors.Gainsboro; Color midColor = Colors.Crimson; Color rightColor = Colors.Red; return new LinearGradientBrush() { GradientStops = new GradientStopCollection() { new GradientStop (leftColor, 0.0), new GradientStop(midColor, 0.7), new GradientStop(rightColor, 1.0) } }; case false: return new LinearGradientBrush() { GradientStops = new GradientStopCollection() { new GradientStop ((Color)ColorConverter.ConvertFromString("#FFA0868C"), 0.0), } }; } } } public Transform AutomationLanesShowButTransform { get { double rotval = AutomationLanesVisible ? 180 : 0; return new RotateTransform(rotval) ; } } private bool _AutomationLanesVisible = false; public bool AutomationLanesVisible { get { return _AutomationLanesVisible; } set { _AutomationLanesVisible = value; NotifyPropertyChanged(nameof(AutomationLanesVisible)); NotifyPropertyChanged(nameof(AutomationLanesShowButTransform)); } } public bool IsAutomationRecordingEnabled { get { return editingProject.AutomationRecordingEnabled || this.IsAutomationRecording; } } public void UpdateAutomationRecordingEnabled() { NotifyPropertyChanged(nameof(IsAutomationRecordingEnabled)); } public float trackAutomationFactor = 1; private float _panAutomationFactor; private float panAutomationFactor { get { return _panAutomationFactor; } set { _panAutomationFactor = value; float adjustedPan = Math.Max(-1, Math.Min(1, m_pan + _panAutomationFactor)); normPan = (-adjustedPan + 1) / 2; LPan = Convert.ToSingle(Math.Sin(normPan * HalfPi)); RPan = Convert.ToSingle(Math.Cos(normPan * HalfPi)); } } private int _SelectedAutomationLaneIndex = -1; public int SelectedAutomationLaneIndex { get { return _SelectedAutomationLaneIndex; } set { _SelectedAutomationLaneIndex = value; foreach (AutomationLane autolane in this.AutomationLanes) autolane.IsShown = false; if (value != -1 && this.AutomationLanes.Count > value) this.AutomationLanes[value].IsShown = true; NotifyPropertyChanged(nameof(SelectedAutomationLaneIndex)); } } }