using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace QuikDawEditor { public partial class QuantizeWindow : Window, INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged([CallerMemberName] String propertyName = "") { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } public QuantizeWindow() { InitializeComponent(); DataContext = this; snapTo = 0.125M; //Eighth note default } internal decimal snapTo = 2M; internal string Result = "Cancel"; private bool _ApplyToSelection = false; public bool ApplyToSelection { get { return _ApplyToSelection; } set { _ApplyToSelection = value; NotifyPropertyChanged(nameof(ApplyToSelection)); } } private void QuantizeSnapCB_DropDownClosed(object sender, EventArgs e) { ComboBox snaptocb = (ComboBox)sender; if (snaptocb.SelectedIndex < 1) snapTo = 2; else { if (snaptocb.SelectedIndex > 5) { //Triplets decimal div = 1 / (decimal)Math.Pow(2, snaptocb.SelectedIndex - 5); snapTo = 1M / (3M / div); } else { //Standard beat decimal div = (decimal)Math.Pow(2, snaptocb.SelectedIndex - 1); snapTo = 1M / div; } } } private void OkBut_Click(object sender, RoutedEventArgs e) { Result = "Ok"; this.Close(); } private void CancelBut_Click(object sender, RoutedEventArgs e) { this.Close(); } private void Window_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Escape) this.Close(); } } }