Beispiel #1
0
        public MainWindow()
        {
            Instance       = this;
            PlayerSwitcher = new AudioPlayer("../../Files/Sounds/PositionSwitcher.wav");

            KeyDown += MainWindow_KeyDown;

            InitializeComponent();

            Frame1.Content = new MainScreens.StartPage();
            Frame2.Content = MainScreens.Learning.Instance;
            Frame3.Content = MainScreens.Standarts.Instance;
            Frame4.Content = new MainScreens.Work();

            Start_Frame.Content = _startTab;

            Closing += (s, e) => RadioConnection.Close();

            Tabs_TabControl.SelectionChanged += (s, e) =>
            {
            };
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            if (!WaveIOHellper.ExistWaveInDevice)
            {
                _startTab.WaveIn_TextBlock.Visibility = Visibility.Visible;
            }

            if (!WaveIOHellper.ExistWaveOutDevice)
            {
                _startTab.WaveOut_TextBlock.Visibility = Visibility.Visible;
            }

            _startTab.IP_TextBlock.Text = "IP: " + AppConfig.IpInfo.GetLocalIpAddress();
        }
Beispiel #2
0
        private void UpdateUI()
        {
            bool have_user        = Account.UserName != null;
            bool have_session_key = Account.SessionKey != null;

            if (have_session_key)
            {
                LastSessionKeySchema.Set(Account.SessionKey);
                LastIsSubscriberSchema.Set(Account.Subscriber);
            }

            if (have_user)
            {
                SetUserName(Account.UserName);
            }
            else
            {
                ClearChildSources();
            }

            if (Connection.Connected)
            {
                HideStatus();
            }
            else
            {
                SetStatus(RadioConnection.MessageFor(Connection.State), Connection.State != ConnectionState.Connecting, Connection.State);
            }

            OnUpdated();
        }
        // Last.fm requires you to 'tune' to a station before requesting a track list/playing it
        public bool ChangeToThisStation()
        {
            if (lastfm.Connection.Station == Station)
            {
                return(false);
            }

            Log.Debug(String.Format("Tuning Last.fm to {0}", Name), null);
            SetStatus(Catalog.GetString("Tuning Last.fm to {0}."), false);
            StationError error = lastfm.Connection.ChangeStationTo(Station);

            if (error == StationError.None)
            {
                Log.Debug(String.Format("Successfully tuned Last.fm to {0}", station), null);
                return(true);
            }
            else
            {
                Log.Debug(String.Format("Failed to tune Last.fm to {0}", Name), RadioConnection.ErrorMessageFor(error));
                SetStatus(String.Format(
                              // Translators: {0} is an error message sentence from RadioConnection.cs.
                              Catalog.GetString("Failed to tune in station. {0}"), RadioConnection.ErrorMessageFor(error)), true
                          );
                return(false);
            }
        }
Beispiel #4
0
        public LastfmSource() : base(lastfm, lastfm, 210, lastfm)
        {
            account = LastfmCore.Account;

            // We don't automatically connect to Last.fm, but load the last Last.fm
            // account information
            if (account.UserName != null)
            {
                account.UserName   = LastUserSchema.Get();
                account.SessionKey = LastSessionKeySchema.Get();
                account.Subscriber = LastIsSubscriberSchema.Get();
            }

            if (LastfmCore.UserAgent == null)
            {
                LastfmCore.UserAgent = Banshee.Web.Browser.UserAgent;
            }

            Browser.Open = Banshee.Web.Browser.Open;

            connection = LastfmCore.Radio;
            Network network = ServiceManager.Get <Network> ();

            connection.UpdateNetworkState(network.Connected);
            network.StateChanged    += HandleNetworkStateChanged;
            Connection.StateChanged += HandleConnectionStateChanged;
            UpdateUI();

            Properties.SetString("GtkActionPath", "/LastfmSourcePopup");
            Properties.SetString("Icon.Name", "lastfm-audioscrobbler");
            Properties.Set <LastfmColumnController> ("TrackView.ColumnController", new LastfmColumnController());

            // Initialize DataCore's UserAgent and CachePath
            DataCore.UserAgent = Banshee.Web.Browser.UserAgent;
            DataCore.CachePath = System.IO.Path.Combine(Hyena.Paths.ExtensionCacheRoot, "lastfm");

            // FIXME this is temporary until we split the GUI part from the non-GUI part
            Properties.Set <ISourceContents> ("Nereid.SourceContents", new LazyLoadSourceContents <LastfmSourceContents> ());
            Properties.Set <bool> ("Nereid.SourceContents.HeaderVisible", false);

            actions     = new LastfmActions(this);
            preferences = new LastfmPreferences(this);

            ServiceManager.SourceManager.AddSource(this);

            if (FirstRunSchema.Get())
            {
                var streaming_addin = AddinManager.Registry.GetAddins()
                                      .Single(a => a.LocalId.Equals("Banshee.LastfmStreaming"));
                if (streaming_addin != null)
                {
                    streaming_addin.Enabled = Account.Subscriber;
                }
                FirstRunSchema.Set(false);
            }
        }
Beispiel #5
0
        public void Dispose()
        {
            ServiceManager.Get <DBusCommandService> ().ArgumentPushed -= OnCommandLineArgument;
            Connection.StateChanged -= HandleConnectionStateChanged;
            Connection.Dispose();
            UninstallPreferences();
            actions.Dispose();

            actions    = null;
            connection = null;
            account    = null;
        }
Beispiel #6
0
        public void Dispose()
        {
            Connection.StateChanged -= HandleConnectionStateChanged;
            ServiceManager.Get <Network> ().StateChanged -= HandleNetworkStateChanged;
            Connection.Dispose();
            preferences.Dispose();
            actions.Dispose();

            actions     = null;
            connection  = null;
            preferences = null;
            account     = null;
        }
Beispiel #7
0
        public LastfmSource() : base(lastfm, lastfm, 210, lastfm)
        {
            account = LastfmCore.Account;

            // We don't automatically connect to Last.fm, but load the last Last.fm
            // username we used so we can load the user's stations.
            if (account.UserName != null)
            {
                account.UserName   = LastUserSchema.Get();
                account.SessionKey = LastSessionKeySchema.Get();
                account.Subscriber = LastIsSubscriberSchema.Get();
            }

            if (LastfmCore.UserAgent == null)
            {
                LastfmCore.UserAgent = Banshee.Web.Browser.UserAgent;
            }

            Browser.Open = Banshee.Web.Browser.Open;

            connection = LastfmCore.Radio;
            Network network = ServiceManager.Get <Network> ();

            connection.UpdateNetworkState(network.Connected);
            network.StateChanged += delegate(object o, NetworkStateChangedArgs args) {
                connection.UpdateNetworkState(args.Connected);
            };

            Connection.StateChanged += HandleConnectionStateChanged;
            UpdateUI();

            Properties.SetString("ActiveSourceUIResource", "ActiveSourceUI.xml");
            Properties.Set <bool> ("ActiveSourceUIResourcePropagate", true);
            Properties.SetString("GtkActionPath", "/LastfmSourcePopup");
            Properties.SetString("Icon.Name", "lastfm-audioscrobbler");
            Properties.SetString("SortChildrenActionLabel", Catalog.GetString("Sort Stations by"));
            Properties.Set <LastfmColumnController> ("TrackView.ColumnController", new LastfmColumnController());

            // FIXME this is temporary until we split the GUI part from the non-GUI part
            Properties.Set <ISourceContents> ("Nereid.SourceContents", new LastfmSourceContents());
            Properties.Set <bool> ("Nereid.SourceContents.HeaderVisible", false);

            actions = new LastfmActions(this);
            InstallPreferences();

            ServiceManager.SourceManager.AddSource(this);

            ServiceManager.Get <DBusCommandService> ().ArgumentPushed += OnCommandLineArgument;
        }
 private void UpdateUI(ConnectionState state)
 {
     if (state == ConnectionState.Connected)
     {
         HideStatus();
         if (this == ServiceManager.SourceManager.ActiveSource)
         {
             TuneAndLoad();
         }
     }
     else
     {
         track_model.Clear();
         SetStatus(RadioConnection.MessageFor(state), state != ConnectionState.Connecting, state);
         OnUpdated();
     }
 }
Beispiel #9
0
        public static void PageChanged(bool state, MainModel Model)
        {
            System.Diagnostics.Trace.WriteLine("state = " + state + ", init = " + IsInitialized);
            if (IsInitialized)
            {
                UnSubscribe();
                RadioConnection.Stop();
                RadioConnection.Player.Pause();
            }

            if (state)
            {
                RadioModel = Model;
                Subscribe();
                RadioConnection.AnalysisPlayNoise(null, null);
            }
        }
Beispiel #10
0
 private static void OnPowerChange()
 {
     if (RadioModel.Power.Value == Turned.On)
     {
         RadioConnection.FlushAll();
         radioLogic.Start();
         radioLogic.Noise.Play();
         RadioConnection.Player.Play();
         OnTangentChange();
     }
     else
     {
         StopStreaming();
         radioLogic.Stop();
         RadioConnection.Player.Pause();
         radioLogic.Noise.Stop();
     }
 }
Beispiel #11
0
        private static void OnTangentChange()
        {
            if (RadioModel.Power.Value != Turned.On)
            {
                return;
            }

            if (RadioModel.WorkMode.Value == WorkModeState.Simplex && RadioModel.Tangent.Value == Turned.On)
            {
                RadioConnection.Player.Pause();
                StartStreaming();
            }
            else
            {
                RadioConnection.FlushAll();
                RadioConnection.Player.Play();
                StopStreaming();
            }
        }
Beispiel #12
0
 private static void StopStreaming()
 {
     radioLogic.Microphone.Stop();
     RadioConnection.SendStateToRemoteMachine(ERadioState.SayingEnd);
 }