Example #1
0
        public MainWindowController()
        {
            GLib.ExceptionManager.UnhandledException += args =>
            {
                Console.Write(args.ToString());
            };
            _collection = new Collection();

            AudioPlayer audioPlayer = new AudioPlayer();
            _filteredTrackListViewController = new FilteredTrackListViewController(_collection, audioPlayer);
            _sourceTreeViewController = new SourceTreeViewController(_filteredTrackListViewController, _collection);
            _playerControlPanelController = new PlayerControlPanelController(audioPlayer);
            _nowPlayingPanelController = new NowPlayingPanelController(audioPlayer, _filteredTrackListViewController);
            _menuBarController = new MenuBarController();

            _window = new MainWindow();
            _window.DeleteEvent += (o, args) => Application.Quit();

            _window.AddWest(_sourceTreeViewController.View);
            _window.AddCenter(_filteredTrackListViewController.View);
            _window.AddEast(_nowPlayingPanelController.View);
            _window.AddSouth(_playerControlPanelController.View);
            _window.AddNorth(_menuBarController.View);

            _window.QueueResize();

            _window.ShowAll();
        }
 public FilteredTrackListViewController(Collection collection, AudioPlayer audioPlayer)
     : base(new FilteredTrackListModel(collection), 
     new BaseTrackListViewControllerSettings("FilteredTrackListView", DefaultColumnPropertyArray, DefaultColumnWidths), 
     audioPlayer)
 {
     TrackListViewColumn column;
     if (PropertiesToColumns.TryGetValue(TrackProperty.Artist, out column))
         ((TreeModelSort) TrackListView.Model).SetSortColumnId(column.SortColumnId, SortType.Ascending);
 }
        public NowPlayingTrackListViewController(AudioPlayer audioPlayer)
            : base(new TrackListStore(new Track[0]), 
            new BaseTrackListViewControllerSettings("NowPlayingTrackListView", DefaultColumnPropertyArray, DefaultColumnWidths), 
            audioPlayer)
        {
            audioPlayer.PlaylistChanged += AudioPlayerOnPlaylistChanged;
            var trackListStore = TrackListView.Model as TrackListStore;

            Debug.Assert(trackListStore != null, "trackListStore != null");
            trackListStore.DefaultSortFunc = (model, iter1, iter2) =>
                {
                    int index1 = (int) model.GetValue(iter1, 1);
                    int index2 = (int) model.GetValue(iter2, 1);
                    return index1.CompareTo(index2);
                };
        }
        public PlayerControlPanelController(AudioPlayer audioPlayer)
        {
            _audioPlayer = audioPlayer;

            View = new PlayerControlPanel();
            View.PlayerButtonPanel.StopButton.Clicked += (sender, args) => _audioPlayer.Stop();
            View.PlayerButtonPanel.PreviousTrackButton.Clicked += (sender, args) => _audioPlayer.PreviousTrack();
            View.PlayerButtonPanel.NextTrackButton.Clicked += (sender, args) => _audioPlayer.NextTrack();
            View.PlayerButtonPanel.PlayPauseButton.Clicked += (sender, args) =>
                {
                    if (!_audioPlayer.IsPlaying)
                        _audioPlayer.Play();
                    else
                        _audioPlayer.Pause();
                };
        }
        protected BaseTrackListViewController(ITrackListModel model, BaseTrackListViewControllerSettings settings,
                                              AudioPlayer audioPlayer)
        {
            _settings = settings;
            _settings.Reload();
            if (_settings.ColumnPropertyList == null || !_settings.ColumnPropertyList.Any())
            {
                _settings.LoadDefaultColumnPropertyArray();
                _settings.Save();
            }
            if (_settings.ColumnWidths == null)
            {
                _settings.LoadDefaultColumnWidths();
                _settings.Save();
            }

            AudioPlayer = audioPlayer;

            TrackListView.Model = model;

            foreach (TrackProperty property in _settings.ColumnPropertyList)
            {
                AddColumn(property);
            }

            TrackListView.RowActivated += TrackListViewOnRowActivated;
            TrackListView.ColumnsChanged += TrackListViewOnColumnsChanged;
            TrackListView.Selection.Changed += SelectionOnChanged;
            TrackListView.Destroyed += (sender, args) =>
                {
                    TrackListView.ColumnsChanged -= TrackListViewOnColumnsChanged;

                    foreach (var column in ColumnsToProperties.Keys)
                    {
                        column.RemoveNotification("width", TrackListViewColumnNotifyHandler);
                    }
                };
            AudioPlayer.TrackChanged += AudioPlayerOnTrackChanged;

            ((ITrackListModel) TrackListView.Model).DefaultSortFunc = DefaultSortFunc;

            View = new ScrolledWindow {TrackListView};
            HeaderMenuController = new TrackListHeaderMenuController(this);
        }
        public NowPlayingPanelController(AudioPlayer audioPlayer, ITrackSelector trackSelector)
        {
            if (_settings.VPanedPosition == 0)
                _settings.VPanedPosition = 500;

            _nowPlayingTrackListViewController = new NowPlayingTrackListViewController(audioPlayer);
            _coverArtPanel = new CoverArtPanel(audioPlayer, trackSelector, _nowPlayingTrackListViewController);

            View = new VPaned();
            View.Pack1(_nowPlayingTrackListViewController.View, true, true);
            View.Pack2(_coverArtPanel, true, true);

            View.Position = _settings.VPanedPosition;
            View.PositionSet = true;

            View.AddNotification("position", (o, args) =>
                {
                    _settings.VPanedPosition = View.Position;
                });
        }
Example #7
0
        public CoverArtPanel(AudioPlayer audioPlayer, params ITrackSelector[] trackSelectors)
            : base(false, 0)
        {
            ButtonBox buttonBox = new HButtonBox();
            _selectedButton = new ToggleButton("Selected");
            _playingButton = new ToggleButton("Playing");
            buttonBox.Add(_playingButton);
            buttonBox.Add(_selectedButton);
            PackStart(buttonBox, false, false, 0);

            EventBox eventBox = new EventBox();
            eventBox.Add(_picture);
            eventBox.ButtonPressEvent += (o, args) =>
                {
                    var window = new Gtk.Window(WindowType.Toplevel);
                    var pixbuf = _currentPixbuf.Copy();
                    AutoScalingImage image = new AutoScalingImage();
                    window.Add(image);
                    int left, top, right, bottom;
                    window.GetFrameDimensions(out left, out top, out right, out bottom);
                    int windowHeightWithFullImage = pixbuf.Height + top + bottom;
                    if (windowHeightWithFullImage > Screen.Height)
                        window.SetDefaultSize(((pixbuf.Width + left + right) * Screen.Height) / windowHeightWithFullImage, Screen.Height);
                    else
                        window.SetDefaultSize(pixbuf.Width + left + right, pixbuf.Height + top + bottom);
                    window.AllowShrink = true;
                    image.Pixbuf = pixbuf;

                    Track track = _selectedButton.Active ? _selectedTrack : _playingTrack;
                    window.Title = String.Format("{0} - {1}",
                        string.Join("; ", track.Album.Artists.Select(a => a.Name)),
                        track.Album.Title);
                    window.ShowAll();
                    image.QueueResize();

                    window.SizeAllocated += (o1, allocatedArgs) =>
                        {
                            Console.WriteLine("window: {0}", window.Allocation);
                            Console.WriteLine("args: {0}", allocatedArgs.Allocation);
                            if (window.Allocation.Width != allocatedArgs.Allocation.Width ||
                                window.Allocation.Height != allocatedArgs.Allocation.Height)
                            {
                                image.SizeAllocate(allocatedArgs.Allocation);
                                image.QueueResize();
                                image.QueueDraw();
                                window.QueueDraw();
                            }
                        };
                };

            PackStart(eventBox, true, true, 0);

            _selectedButton.Toggled += SelectedButtonOnToggled;
            _playingButton.Toggled += PlayingButtonOnToggled;

            foreach (var trackSelector in trackSelectors)
            {
                if (trackSelector.HasFocus)
                    _selectedTrack = trackSelector.CurrentTrack;
                trackSelector.SelectedTrack += TrackSelectorOnSelectedTrack;
            }

            audioPlayer.TrackChanged += AudioPlayerOnTrackChanged;

            _selectedButton.Shown += (sender, args) => _selectedButton.Active = true;

            ShowAll();
        }