示例#1
0
        /// <summary>
        /// Updates this instance.
        /// </summary>
        private static void Update()
        {
            foreach (var Song in File.ReadAllLines(@"Sets/Set.txt"))
            {
                if (!Song.StartsWith("#"))
                {
                    string[] Data = Song.Split(',');
                    MainUI.SetList.Items.Add(Data[0]);
                }
            }

            MainUI.Add.Click += delegate
            {
                MainUI.ShowAddForm();
            };

            MainUI.SetList.DoubleClick += delegate
            {
                if (MainUI.SetList.SelectedItem == null || MainUI.SetList.SelectedIndex < 0)
                {
                    return;
                }

                MainUI.PlaySong(MainUI.SetList.SelectedItem.ToString());
            };

            MainUI.SetList.KeyDown += (Sender, Event) =>
            {
                if (Event.KeyCode == Keys.Delete)
                {
                    if (MainUI.SetList.SelectedItem == null || MainUI.SetList.SelectedIndex < 0)
                    {
                        return;
                    }

                    MainUI.SetList.Items.Remove(MainUI.SetList.SelectedItem);

                    File.WriteAllText("Sets/Set-Temp.txt", File.ReadAllText("Sets/Set.txt"));
                    File.Delete("Sets/Set.txt");

                    foreach (var Item in MainUI.SetList.Items)
                    {
                        string[] Line = Array.Find(File.ReadAllLines(@"Sets\Set-Temp.txt"), Value => Value.Contains(Item.ToString())).Split(',');
                        File.AppendAllText("Sets/Set.txt", $"{Item},{Line[1]},{Line[2]}" + Environment.NewLine);
                    }

                    File.Delete("Sets/Set-Temp.txt");
                }
                if (Event.KeyCode == Keys.E)
                {
                    if (MainUI.SetList.SelectedItem == null || MainUI.SetList.SelectedIndex < 0)
                    {
                        return;
                    }

                    string[] Line = Array.Find(File.ReadAllLines(@"Sets\Set.txt"), Value => Value.Contains(MainUI.SetList.SelectedItem.ToString())).Split(',');

                    MainUI.ShowAddForm(true, Line[0], Line[1], Line[2]);
                }
            };

            MainUI.Up.Click += delegate
            {
                MainUI.MoveItem(-1);
            };

            MainUI.Down.Click += delegate
            {
                MainUI.MoveItem(1);
            };

            Panel Set = new Panel
            {
                Dock    = DockStyle.Left,
                Padding = new Padding(3)
            };

            Set.Controls.Add(MainUI.SetList);
            Set.Controls.Add(MainUI.Add);
            Set.Controls.Add(MainUI.Up);
            Set.Controls.Add(MainUI.Down);

            Panel Prompter = new Panel
            {
                Dock    = DockStyle.Fill,
                Padding = new Padding(3)
            };

            Prompter.Controls.Add(MainUI.Teleprompter);

            MainUI.Form.Controls.Add(Prompter);
            MainUI.Form.Controls.Add(Set);

            MainUI.Form.WindowState = FormWindowState.Maximized;
        }
示例#2
0
 /// <summary>
 /// Initializes this instance.
 /// </summary>
 internal static void Initialize()
 {
     MainUI.Update();
     MainUI.Form.ShowDialog();
 }