Ejemplo n.º 1
0
        public MainWindow(SovndClient client, ChannelDirectory channels, IPlayerFactory playerFactory, ISettingsProvider settings, Scrobbler scrobbler)
        {
            InitializeComponent();

            toast = new Toast();
            toast.Show();

            _scrobbler     = scrobbler;
            _client        = client;
            _playerFactory = playerFactory;
            _settings      = settings.GetSettings();

            AllowDrop = true;
            channelbox.ItemsSource = channels.channels;

            PreviewDragOver  += OnPreviewDragEnter;
            PreviewDragEnter += OnPreviewDragEnter;
            DragEnter        += OnPreviewDragEnter;
            DragOver         += OnPreviewDragEnter;

            Drop += OnDrop;

            Loaded += (_, __) =>
            {
                BindingOperations.EnableCollectionSynchronization(channels.channels, channels.channels);
                App.WindowHandle = new WindowInteropHelper(this).Handle;
                synchronization  = SynchronizationContext.Current;

                _client.Run();

                if (!string.IsNullOrWhiteSpace(_settings.LastChannel))
                {
                    _player = _playerFactory.CreatePlayer(_settings.LastChannel);
                    _client.SubscribeToChannel(_settings.LastChannel);
                    SetupChannel();
                    Logging.Event("Switched to previously set channel");
                }
            };

            Closed += (_, __) =>
            {
                _client.Disconnect();
                Spotify.ShutDown();
                Process.GetCurrentProcess().Kill(); // TODO That's really inelegant
            };
        }
Ejemplo n.º 2
0
 public NewChannelViewModel(NewChannelModel model, SovndClient client)
 {
     _model  = model;
     _client = client;
 }
Ejemplo n.º 3
0
 public NewChannelViewModel(SovndClient client)
     : this(new NewChannelModel(), client)
 {
 }