private void Lower_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int repeats = Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift) ? 10 : 1;
                for (int n = 0; n < repeats; n++)
                {
                    suppressEvents = true;

                    int selectedIndex             = Settings.HitsoundLayers.IndexOf(selectedLayer);
                    List <HitsoundLayer> moveList = new List <HitsoundLayer>();
                    foreach (HitsoundLayer hsl in selectedLayers)
                    {
                        moveList.Add(hsl);
                    }

                    for (int i = Settings.HitsoundLayers.Count - 1; i >= 0; i--)
                    {
                        HitsoundLayer hsl = Settings.HitsoundLayers[i];
                        if (moveList.Contains(hsl))
                        {
                            moveList.Remove(hsl);
                        }
                        else
                        {
                            break;
                        }
                    }

                    for (int i = moveList.Count - 1; i >= 0; i--)
                    {
                        HitsoundLayer hsl   = moveList[i];
                        int           index = Settings.HitsoundLayers.IndexOf(hsl);

                        //Dont move left if it is the first item in the list or it is not in the list
                        if (index >= Settings.HitsoundLayers.Count - 1)
                        {
                            continue;
                        }

                        //Swap with this item with the one to its left
                        Settings.HitsoundLayers.Remove(hsl);
                        Settings.HitsoundLayers.Insert(index + 1, hsl);
                    }

                    LayersList.SelectedItems.Clear();
                    foreach (HitsoundLayer hsl in selectedLayers)
                    {
                        LayersList.SelectedItems.Add(hsl);
                    }

                    suppressEvents = false;

                    RecalculatePriorities();
                    GetSelectedLayers();
                }
            }
            catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); }
        }
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            try {
                if (Tabs.SelectedIndex == 1)
                {
                    // Import one layer
                    HitsoundLayer layer = HitsoundImporter.ImportStack(BeatmapPathBox.Text, XCoordBox.GetDouble(), YCoordBox.GetDouble());
                    layer.Name            = NameBox.Text;
                    layer.SampleSet       = (SampleSet)(SampleSetBox.SelectedIndex + 1);
                    layer.Hitsound        = (Hitsound)HitsoundBox.SelectedIndex;
                    layer.SampleArgs.Path = SamplePathBox.Text;

                    HitsoundLayers.Add(layer);
                }
                else if (Tabs.SelectedIndex == 2)
                {
                    // Import complete hitsounds
                    foreach (string path in BeatmapPathBox2.Text.Split('|'))
                    {
                        HitsoundLayers.AddRange(HitsoundImporter.ImportHitsounds(path, VolumesBox2.IsChecked.GetValueOrDefault(),
                                                                                 DetectDuplicateSamplesBox2.IsChecked.GetValueOrDefault(),
                                                                                 RemoveDuplicatesBox2.IsChecked.GetValueOrDefault(),
                                                                                 IncludeStoryboardBox2.IsChecked.GetValueOrDefault()));
                    }
                    HitsoundLayers.ForEach(o => o.Name = $"{NameBox2.Text}: {o.Name}");
                }
                else if (Tabs.SelectedIndex == 3)
                {
                    // Import MIDI
                    HitsoundLayers = HitsoundImporter.ImportMidi(BeatmapPathBox3.Text, OffsetBox3.GetDouble(0),
                                                                 InstrumentBox3.IsChecked.GetValueOrDefault(), KeysoundBox3.IsChecked.GetValueOrDefault(),
                                                                 LengthBox3.IsChecked.GetValueOrDefault(), LengthRoughnessBox3.GetDouble(2),
                                                                 VelocityBox3.IsChecked.GetValueOrDefault(), VelocityRoughnessBox3.GetDouble(10));
                    HitsoundLayers.ForEach(o => o.Name = $"{NameBox3.Text}: {o.Name}");
                }
                else if (Tabs.SelectedIndex == 4)
                {
                    // Import storyboarded samples
                    foreach (string path in BeatmapPathBox4.Text.Split('|'))
                    {
                        HitsoundLayers.AddRange(HitsoundImporter.ImportStoryboard(path, VolumesBox4.IsChecked.GetValueOrDefault(),
                                                                                  RemoveDuplicatesBox4.IsChecked.GetValueOrDefault()));
                    }
                    HitsoundLayers.ForEach(o => o.Name = $"{NameBox4.Text}: {o.Name}");
                }
                else
                {
                    // Import none
                    HitsoundLayer layer = new HitsoundLayer(NameBox0.Text, ImportType.None, (SampleSet)(SampleSetBox0.SelectedIndex + 1), (Hitsound)HitsoundBox0.SelectedIndex, SamplePathBox0.Text);
                    HitsoundLayers.Add(layer);
                }

                Close();
            }
            catch (Exception ex) {
                ex.Show();
            }
        }
        private void GetSelectedLayers()
        {
            selectedLayers = new List <HitsoundLayer>();

            if (LayersList.SelectedItems.Count == 0)
            {
                selectedLayer = null;
                return;
            }

            foreach (HitsoundLayer hsl in LayersList.SelectedItems)
            {
                selectedLayers.Add(hsl);
            }

            selectedLayer = selectedLayers[0];
        }