예제 #1
0
        private void BassEngine_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            BassEngine engine = BassEngine.Instance;

            switch (e.PropertyName)
            {
            case "FileTag":
                if (engine.FileTag != null)
                {
                    TagLib.Tag tag = engine.FileTag.Tag;
                    if (tag.Pictures.Length > 0)
                    {
                        using (MemoryStream albumArtworkMemStream = new MemoryStream(tag.Pictures[0].Data.Data))
                        {
                            try
                            {
                                BitmapImage albumImage = new BitmapImage();
                                albumImage.BeginInit();
                                albumImage.CacheOption  = BitmapCacheOption.OnLoad;
                                albumImage.StreamSource = albumArtworkMemStream;
                                albumImage.EndInit();
                                albumArtPanel.AlbumArtImage = albumImage;
                            }
                            catch (NotSupportedException)
                            {
                                albumArtPanel.AlbumArtImage = null;
                                // System.NotSupportedException:
                                // No imaging component suitable to complete this operation was found.
                            }
                            albumArtworkMemStream.Close();
                        }
                    }
                    else
                    {
                        albumArtPanel.AlbumArtImage = null;
                    }
                }
                else
                {
                    albumArtPanel.AlbumArtImage = null;
                }
                break;

            case "ChannelPosition":
                clockDisplay.Time = TimeSpan.FromSeconds(engine.ChannelPosition);
                break;

            default:
                // Do Nothing
                break;
            }
        }
예제 #2
0
        public MainWindow()
        {
            InitializeComponent();

            BassEngine bassEngine = BassEngine.Instance;

            bassEngine.PropertyChanged += BassEngine_PropertyChanged;
            UIHelper.Bind(bassEngine, "CanStop", StopButton, Button.IsEnabledProperty);
            UIHelper.Bind(bassEngine, "CanPlay", PlayButton, Button.IsEnabledProperty);
            UIHelper.Bind(bassEngine, "CanPause", PauseButton, Button.IsEnabledProperty);
            UIHelper.Bind(bassEngine, "SelectionBegin", repeatStartTimeEdit, TimeEditor.ValueProperty, BindingMode.TwoWay);
            UIHelper.Bind(bassEngine, "SelectionEnd", repeatStopTimeEdit, TimeEditor.ValueProperty, BindingMode.TwoWay);

            spectrumAnalyzer.RegisterSoundPlayer(bassEngine);
            waveformTimeline.RegisterSoundPlayer(bassEngine);

            LoadExpressionDarkTheme();
        }