예제 #1
0
 void Launchpad_Add()
 {
     LaunchpadWindow.Create(MIDI.ConnectVirtual(), this);
     MIDI.Update();
 }
예제 #2
0
        async void Window_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Modifiers == Program.ControlKey && e.Key == Key.P)
            {
                if (_track.Launchpad.Available && _track.Launchpad.GetType() != typeof(VirtualLaunchpad) || _track.Launchpad.Window != null)
                {
                    LaunchpadWindow.Create(_track.Launchpad, this);
                }

                return;
            }

            if (Program.WindowKey(this, e) || await Program.Project.HandleKey(this, e) || Program.Project.Undo.HandleKey(e) || Selection.HandleKey(e))
            {
                return;
            }

            if (e.Modifiers != InputModifiers.None && e.Modifiers != InputModifiers.Shift)
            {
                return;
            }

            bool vertical = Selection.Start.GetType() == typeof(Chain);

            if (vertical)
            {
                if (e.Key == Key.Up)
                {
                    Selection.Move(false, e.Modifiers == InputModifiers.Shift);
                }
                else if (e.Key == Key.Down)
                {
                    Selection.Move(true, e.Modifiers == InputModifiers.Shift);
                }
                else if (e.Key == Key.Right)
                {
                    Selection.MoveChild();
                }
                else if (e.Key == Key.Enter)
                {
                    Selection.Expand();
                }
                else if (e.Key == Key.Left && Selection.Start.IParent.GetType() == typeof(Multi))
                {
                    Selection.Select(((Multi)Selection.Start.IParent).Preprocess.Devices.Last());
                }
            }
            else if (e.Key == Key.Left)
            {
                ISelect left = Selection.Selection.First();

                if (left.IParentIndex.Value == 0)
                {
                    if (InChoke())
                    {
                        Selection.Select((ISelect)((Chain)Selection.Start.IParent).Parent, e.Modifiers == InputModifiers.Shift);
                        return;
                    }
                    else if (InMultiPreprocess())
                    {
                        return;
                    }
                }

                Selection.Move(false, e.Modifiers == InputModifiers.Shift);
            }
            else if (e.Key == Key.Right)
            {
                ISelect right = Selection.Selection.Last();

                if (right.IParentIndex.Value == right.IParent.IChildren.Count - 1)
                {
                    if (InChoke())
                    {
                        Selection.Select((ISelect)((Chain)Selection.Start.IParent).Parent, e.Modifiers == InputModifiers.Shift);
                        e.Modifiers = InputModifiers.None;
                    }
                    else if (InMultiPreprocess())
                    {
                        Selection.Select((ISelect)((ISelect)Selection.Start.IParent).IParent, e.Modifiers == InputModifiers.Shift);
                        return;
                    }
                }

                Selection.Move(true, e.Modifiers == InputModifiers.Shift);
            }
            else if (e.Key == Key.Down)
            {
                if (Selection.Start.GetType() == typeof(Choke))
                {
                    Chain chain = ((Choke)Selection.Start).Chain;
                    if (chain.Count > 0)
                    {
                        Selection.Select(chain[0]);
                    }
                    return;
                }
                Selection.MoveChild();
            }
        }