Esempio n. 1
0
        void ButtonPlay_Click(object sender, RoutedEventArgs e)
        {
            BeepPlayer player  = PlaybackEngine.Player;
            bool       playing = player != null && player.Playing;

            switch (playing)
            {
            case true:
                PlaybackEngine.Stop();     //If playing, stop
                break;

            case false:
                BrowseAndPlay();     //If not playing, start
                break;
            }
        }
Esempio n. 2
0
        public MainWindow()
        {
            InitializeComponent();
            PlaybackEngine.OnPlayerStart += b => UpdateUI();
            PlaybackEngine.OnPlayerStop  += (b, f) => UpdateUI();
            PlaybackEngine.OnThreadStart += (f, t) => UpdateUI();
            PlaybackEngine.OnPlayerStop  += PlayerStop;
            PlaybackEngine.OnPlayerStart += PlayerStart;
            PlaybackEngine.OnThreadStop  += t => UpdateUI();

            string[] args = Environment.GetCommandLineArgs();
            if (args != null && args.Length > 1)
            {
                try {
                    FileInfo playbackFile = new FileInfo(args[1]);
                    if (playbackFile.Exists)
                    {
                        LastLoadedFile = playbackFile;
                        PlaybackEngine.Play(playbackFile);
                    }
                } catch (ArgumentException) { }
            }
        }
Esempio n. 3
0
        public static void BrowseAndPlay()
        {
            OpenFileDialog ofd = new OpenFileDialog {
                Filter           = "ABC Notation File (*.abc)|*.abc|Any File (*.*)|*.*",
                CheckPathExists  = true,
                CheckFileExists  = true,
                RestoreDirectory = true,
                InitialDirectory = RestorePreviousLocation().FullName,
                Multiselect      = false,
                ShowReadOnly     = true
            };

            if (ofd.ShowDialog() == true)
            {
                FileInfo playbackFile = new FileInfo(ofd.FileName);
                if (playbackFile.Exists)
                {
                    Properties.Settings.Default.PreviousLocation = playbackFile.DirectoryName;
                    Properties.Settings.Default.Save();
                    LastLoadedFile = playbackFile;
                    PlaybackEngine.Play(playbackFile);
                }
            }
        }
Esempio n. 4
0
 void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     PlaybackEngine.Stop();
 }
Esempio n. 5
0
 void ButtonReset_Click(object sender, RoutedEventArgs e)
 {
     PlaybackEngine.Stop();
     this.Restart();
 }
Esempio n. 6
0
 public Form1()
 {
     InitializeComponent();
     pEngine = new PlaybackEngine();
 }