Example #1
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) { }
            }
        }
Example #2
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);
                }
            }
        }