The Mpc class implements all commands for the MPD. It takes care of command building and parsing the response into .net objects.
        public MiniPlayerWindow(Mpc mpc, Settings settings)
        {
            InitializeComponent();

              m_Settings = settings;
              playerControl.Mpc = mpc;
        }
Example #2
0
    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Build ();

        entry_address.ModifyBase(StateType.Normal, new Gdk.Color(255,0,0));
        led_matrix = new LedMatrix("0.0.0.0");
        led_matrix_thread = new Thread(led_matrix.Runner);
        winamp = new Winamp_httpQ();
        rss = new RssPlugin();
        no_tray_icon = false;
        IPEndPoint mpc_endpoint;
        led_matrix.rss = rss;
        mpc_plugin = new Mpc();

        mpd_timer = new System.Timers.Timer();
        mpd_timer.Elapsed += new ElapsedEventHandler(mpd_timer_elapsed);
        mpd_timer.Interval = 1000; //1s
        mpd_timer.Start();

        try
        {
            tray_icon = new StatusIcon(new Gdk.Pixbuf("icon.png"));
        }
        catch(Exception)
        {
            no_tray_icon = true;
        }
        if(no_tray_icon == false)
        {
            tray_icon.Visible = true;
            tray_icon.Tooltip = "LedMatrix Control";
            tray_icon.Activate += delegate { this.Visible = !this.Visible; };
        }

        loadConfig();
        led_matrix.connection_status_changed_handler += led_matrix_connection_changed;
        led_matrix_thread.Start();
        winamp.title_changed_handler += led_matrix.setWinampPlaylisttitle;
        winamp.connection_changed_handler += winamp_connection_changed;
        try
        {
            //mpc_endpoint = new IPEndPoint(Dns.GetHostAddresses("dockstar-bo-hdd")[0], 6600);
            mpc_endpoint = new IPEndPoint(Dns.GetHostAddresses(entry_mpd.Text)[0], 6600);
            mpc_con = new MpcConnection(mpc_endpoint);
            mpc_plugin.Connection = mpc_con;
            mpc_plugin.Connection.AutoConnect = true;
        }
        catch(Exception)
        {
        }
        user_lines_table = new userLinesTable(ref treeview2, ref led_matrix);
    }
        public MpcPlayer(IPEndPoint endpoint)
        {
            log.Debug(m => m("Connect to MPD"));

            _mpc = new Libmpc.Mpc
            {
                Connection = new MpcConnection
                {
                    Server = endpoint,
                    AutoConnect = true
                }
            };
        }
Example #4
0
        public override List<IRCResponse> GetResponse(BotMessage message)
        {
            if (Regex.IsMatch(message.Command, "^(m(odd)?t(unes)?)$", RegexOptions.IgnoreCase))
            {
                Mpc mpc = new Mpc();

                var addresses = System.Net.Dns.GetHostAddresses("moddington.net");
                if (addresses.Length > 0)
                {
                    mpc.Connection = new MpcConnection(new IPEndPoint(addresses[0], 6600));

                    var song = mpc.CurrentSong();
                    string songMsg = "";
                    if (song.HasTitle || song.HasArtist)
                    {
                        if (song.HasTitle) songMsg += song.Title;
                        else songMsg += "<Unknown Title>";
                        if (song.HasArtist) songMsg += " - " + song.Artist;
                        else songMsg += "<Unknown Artist>";
                    }
                    else
                    {
                        songMsg += song.File;
                    }

                    var status = mpc.Status();
                    TimeSpan elapsed = TimeSpan.FromSeconds(status.TimeElapsed);
                    TimeSpan total = TimeSpan.FromSeconds(status.TimeTotal);
                    string timeMsg = (elapsed.Hours > 0 ? elapsed.Hours + ":" : "") + elapsed.Minutes + ":" + elapsed.Seconds.ToString("D2") + "/" +
                        (total.Hours > 0 ? total.Hours + ":" : "") + total.Minutes + ":" + total.Seconds.ToString("D2");

                    string output = "Playing: " + songMsg +
                        " [" + timeMsg + "] - Listen here: " + ChannelList.EvadeChannelLinkBlock(message, "http://moddington.net:8000/moddtunes.ogg");

                    return new List<IRCResponse>() { new IRCResponse(ResponseType.Say, output, message.ReplyTo) };
                }
                else
                {
                    return new List<IRCResponse>() { new IRCResponse(ResponseType.Say, "Moddington's internet radio seems to be down", message.ReplyTo) };
                }
            }

            return null;
        }
Example #5
0
        private void MpcIdleSubsystemsChanged(Mpc connection, Mpc.Subsystems subsystems)
        {
            if (m_Mpc == null || !m_Mpc.Connected)
            return;

              MpdStatus status = null;
              try{
            status = m_Mpc.Status();
              }catch{
            return;
              }
              if ((subsystems & Mpc.Subsystems.output) != 0) {
            var os = m_Mpc.Outputs();
            Outputs.Where(o => !os.Any(_ => _.Name == o.Name && ((o.IsEnabled = _.IsEnabled) || true))).ToList().Count(Outputs.Remove);
            os.Where(o => o.Name != "Quiet" && !Outputs.Any(_ => _.Name == o.Name)).Select(o => new Output() {
              Name = o.Name,
              Id = o.Id,
              IsEnabled = o.IsEnabled,
              Mpc = m_Mpc,
             }).Do(Outputs.Add);
              }
              if ((subsystems & Mpc.Subsystems.player) != 0 || (subsystems & Mpc.Subsystems.mixer) != 0 ||
              (subsystems & Mpc.Subsystems.options) != 0){
            Dispatcher.BeginInvoke(new Action(() =>
            {
              MenuItem m = m_NotifyIconMenu.Items[1] as MenuItem;
              m.Visibility = status.State != MpdState.Play ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
              m = m_NotifyIconMenu.Items[2] as MenuItem;
              m.Visibility = status.State == MpdState.Play ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;

              MpdFile file = m_Mpc.CurrentSong();
              if (file != null)
              {
            ListboxEntry album;
            if (Albums.TryGetValue(file.Artist + ":" + file.Album, out album))
              file.AlbumEntry = album;
            else
            {
              file.AlbumEntry = album = new ListboxEntry();
              album.Info = new ObservableCollection<object>();
              Action<IList<object>, string, int, System.Windows.Threading.Dispatcher> find = FindInfo;
              find.BeginInvoke(
                album.Info, dir.Replace(file.File, "$1"), 5, Dispatcher,
                find.EndInvoke, null
              );
            }
              }
              playerControl.Update(status, file);
              if (m_MiniPlayer != null)
            m_MiniPlayer.Update(status, file);

              if (m_CurrentTrack == null || file == null || m_CurrentTrack.Id != file.Id) {
            TrackChanged(file);
            m_CurrentTrack = file;
            CurrentTrackId = file != null ? file.Id : 0;
            m_CurrentTrackStart = DateTime.Now;
              }
            }));
              }

              if ((subsystems & Mpc.Subsystems.playlist) != 0){
            Dispatcher.BeginInvoke(new Action(() =>
            {
              PopulatePlaylist();
            }));
              }

              if ((subsystems & Mpc.Subsystems.update) != 0){
            int lastUpdate = m_LastStatus != null ? m_LastStatus.UpdatingDb : -1;
            Dispatcher.BeginInvoke(new Action(() =>
            {
              btnUpdate.IsEnabled = status.UpdatingDb <= 0;
              // Update db finished:
              if (lastUpdate > 0 && status.UpdatingDb <= 0)
              UpdateDbFinished();
            }));
              }

              if ((subsystems & Mpc.Subsystems.subscription) != 0)
            PopulateChannels();
              if ((subsystems & Mpc.Subsystems.message) != 0)
            PopulateMessages();

              m_LastStatus = status;
        }
Example #6
0
    public MainWindow()
    {
      InitializeComponent();
      This = this;

      Title = string.Format("WpfMpdClient v.{0}", Assembly.GetExecutingAssembly().GetName().Version);
      stcAbout.DataContext = m_About;
      try {
        txtLicense.Text = File.ReadAllText("LICENSE.TXT");
      } catch (Exception){ 
        txtLicense.Text = "LICENSE not found!!!";
      }

      m_Settings = Settings.Deserialize(Settings.GetSettingsFileName());
      if (m_Settings != null) {
        txtServerAddress.Text = m_Settings.ServerAddress;
        txtServerPort.Text = m_Settings.ServerPort.ToString();
        txtPassword.Password = m_Settings.Password;
        chkAutoreconnect.IsChecked = m_Settings.AutoReconnect;
        chkShowStop.IsChecked = m_Settings.ShowStopButton;
        chkShowFilesystem.IsChecked = m_Settings.ShowFilesystemTab;
        chkMinimizeToTray.IsChecked = m_Settings.MinimizeToTray;
        chkCloseToTray.IsChecked = m_Settings.CloseToTray;
        chkShowMiniPlayer.IsChecked = m_Settings.ShowMiniPlayer;
        chkScrobbler.IsChecked = m_Settings.Scrobbler;
        cmbLastFmLang.SelectedIndex = m_Languages.IndexOf(m_Settings.InfoLanguage);
        if (cmbLastFmLang.SelectedIndex == -1)
          cmbLastFmLang.SelectedIndex = 0;
        cmbPlaylistStyle.SelectedIndex = m_Settings.StyledPlaylist ? 1 : 0;

        chkTray_Changed(null, null);

        lstTracks.SetColumnsInfo(m_Settings.TracksListView);
        lstPlaylist.SetColumnsInfo(m_Settings.PlayListView);
      } else
        m_Settings = new Settings();
      m_LastfmScrobbler = new LastfmScrobbler(Utilities.DecryptString(m_Settings.ScrobblerSessionKey));

      if (m_Settings.WindowWidth > 0 && m_Settings.WindowHeight > 0){
        Width = m_Settings.WindowWidth;
        Height = m_Settings.WindowHeight;
      }
      if (m_Settings.WindowLeft >= 0 && m_Settings.WindowHeight >= 0){
        Left = m_Settings.WindowLeft;
        Top = m_Settings.WindowTop;
      }else
        WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
      if (m_Settings.WindowMaximized)
        WindowState = System.Windows.WindowState.Maximized;

      m_Mpc = new Mpc();
      m_Mpc.OnConnected += MpcConnected;
      m_Mpc.OnDisconnected += MpcDisconnected;

      m_MpcIdle = new Mpc();
      m_MpcIdle.OnConnected += MpcIdleConnected;
      m_MpcIdle.OnSubsystemsChanged += MpcIdleSubsystemsChanged;

      cmbSearch.SelectedIndex = 0;

      tabFileSystem.Visibility = m_Settings.ShowFilesystemTab ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
      playerControl.ShowStopButton = m_Settings.ShowStopButton;
      playerControl.Mpc = m_Mpc;
      lstPlaylist.Visibility = m_Settings.StyledPlaylist ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible;
      lstPlaylistStyled.Visibility = m_Settings.StyledPlaylist ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;

      lstTracks.Visibility = m_Settings.StyledPlaylist ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible;
      lstTracksStyled.Visibility = m_Settings.StyledPlaylist ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;


      m_NotifyIcon = new System.Windows.Forms.NotifyIcon();
      m_NotifyIcon.Icon = new System.Drawing.Icon("mpd_icon.ico", new System.Drawing.Size(32,32));
      m_NotifyIcon.MouseDown += new System.Windows.Forms.MouseEventHandler(NotifyIcon_MouseDown);
      m_NotifyIconMenu = (ContextMenu)this.FindResource("TrayIconContextMenu");
      Closing += CloseHandler;

      if (!string.IsNullOrEmpty(m_Settings.ServerAddress)){
        m_StartTimer = new System.Timers.Timer();
        m_StartTimer.Interval = 500;
        m_StartTimer.Elapsed += StartTimerHandler;
        m_StartTimer.Start();
      }

      m_Updater = new Updater(new Uri("http://www.sakya.it/updater/updater.php"), "WpfMpdClient", "Windows");
      m_Updater.AppCurrentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
      m_Updater.CheckCompletedDelegate += CheckCompleted;
      m_Updater.Check();

      lstArtist.ItemsSource = m_ArtistsSource;
      Type t = typeof(ListboxEntry);
      lstArtist.SearchProperty = t.GetProperty("Artist");

      lstAlbums.ItemsSource = m_AlbumsSource;
      lstAlbums.SearchProperty = t.GetProperty("Album");

      lstGenresAlbums.ItemsSource = m_GenresAlbumsSource;
      lstGenresAlbums.SearchProperty = t.GetProperty("Album");

      lstPlaylist.ItemsSource = m_PlaylistTracks;
      lstPlaylistStyled.ItemsSource = m_PlaylistTracks;
      m_DragDropManager = new ListViewDragDropManager<MpdFile>(m_Settings.StyledPlaylist ? lstPlaylistStyled : lstPlaylist);
      m_DragDropManager.ProcessDrop += dragMgr_ProcessDrop;

      lstChannels.ItemsSource = m_Channels;
      cmbChannnels.ItemsSource = m_Channels;
      lstMessages.ItemsSource = m_Messages;
      CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(lstMessages.ItemsSource);
      PropertyGroupDescription group = new PropertyGroupDescription("Channel");
      view.GroupDescriptions.Add(group);

      m_ArtDownloader.Start();      
      txtStatus.Text = "Not connected";
    }
Example #7
0
 private void OnSubsystemsChangedHandler(MpcConnection connection, Mpc.Subsystems subsystems)
 {
     if (this.OnSubsystemsChanged != null)
     this.OnSubsystemsChanged(this, subsystems);
 }
Example #8
0
 public Context(Mpc m_Mpc)
 {
     this.m_Mpc = m_Mpc;
     Primary = new Vis();
     Tracks = new Vis() { Empty = GridLength.Auto };
 }
Example #9
0
    private async void MpcConnected(Mpc connection)
    {
        if (!string.IsNullOrEmpty(m_Settings.Password)) {
          if (!m_Mpc.Password(m_Settings.Password)) {
            await Dispatcher.BeginInvoke(new Action(() =>
            {
              MessageBox.Show("Error connecting to server:\r\nWrong password", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }));
            return;
          }
        }

        List<string> commands = await Task.Factory.StartNew(() => m_Mpc.Commands());
        await Dispatcher.BeginInvoke(new Action(() =>
        {
          if (!commands.Contains("channels"))
            tabMessages.Visibility = System.Windows.Visibility.Collapsed;

          txtStatus.Text = string.Format("Connected to {0}:{1} [MPD v.{2}]", m_Settings.ServerAddress, m_Settings.ServerPort, m_Mpc.Connection.Version);
        }));

        MpdStatistics stats = await Task.Factory.StartNew(() => m_Mpc.Stats());
        await Dispatcher.BeginInvoke(new Action( async() =>
        {
          lstGenres.ItemsSource = null;
          lstPlaylists.ItemsSource = null;
          treeFileSystem.Items.Clear();

          if (tabBrowse.SelectedIndex == 0)
            await PopulateArtists();
          else if (tabBrowse.SelectedIndex == 1)
            await PopulateGenres();
          else if (tabBrowse.SelectedIndex == 2)
            await PopulatePlaylists();
          else if (tabBrowse.SelectedIndex == 3)
            await PopulateFileSystemTree();

          await PopulatePlaylist();
        }));
    }
Example #10
0
 private void MpcDisconnected(Mpc connection)
 {
   if (!connection.Connected){
     txtStatus.Text = "Not connected";
     if (!m_IgnoreDisconnect  && m_Settings.AutoReconnect && m_ReconnectTimer == null){
       m_ReconnectTimer = new System.Timers.Timer();
       m_ReconnectTimer.Interval = m_Settings.AutoReconnectDelay * 1000;
       m_ReconnectTimer.Elapsed += ReconnectTimerHandler;
       m_ReconnectTimer.Start();
     }
   }
 }
Example #11
0
    } // CheckMpdConnection

    private void MpcIdleConnected(Mpc connection)
    {
      if (!string.IsNullOrEmpty(m_Settings.Password)){
        if (!m_MpcIdle.Password(m_Settings.Password))
          return;
      }

      MpcIdleSubsystemsChanged(m_MpcIdle, Mpc.Subsystems.All);

      Mpc.Subsystems subsystems = Mpc.Subsystems.player | Mpc.Subsystems.playlist | Mpc.Subsystems.stored_playlist | Mpc.Subsystems.update |
                                  Mpc.Subsystems.mixer | Mpc.Subsystems.options;
      if (m_Mpc.Commands().Contains("channels"))
        subsystems |= Mpc.Subsystems.message | Mpc.Subsystems.subscription;
      m_MpcIdle.Idle(subsystems);
    }
Example #12
0
    private async void MpcIdleSubsystemsChanged(Mpc connection, Mpc.Subsystems subsystems)
    {
      if (!CheckMpdConnection())
        return;

      MpdStatus status = null;
      try{
        status = await Task.Factory.StartNew(() => m_Mpc.Status());
      }catch{
        return;
      }
      if ((subsystems & Mpc.Subsystems.player) != 0 || (subsystems & Mpc.Subsystems.mixer) != 0 ||
          (subsystems & Mpc.Subsystems.options) != 0){
        await Dispatcher.BeginInvoke(new Action( async () =>
        {
          MenuItem m = m_NotifyIconMenu.Items[1] as MenuItem;
          m.Visibility = status.State != MpdState.Play ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
          m = m_NotifyIconMenu.Items[2] as MenuItem;
          m.Visibility = status.State == MpdState.Play ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;

          MpdFile file = await Task.Factory.StartNew(() => m_Mpc.CurrentSong());
          playerControl.Update(status, file);          
          if (m_MiniPlayer != null)
            m_MiniPlayer.Update(status, file);

          if (m_CurrentTrack == null || file == null || m_CurrentTrack.Id != file.Id) {
            TrackChanged(file);
            m_CurrentTrack = file;
            CurrentTrackId = file != null ? file.Id : 0;
            m_CurrentTrackStart = DateTime.Now;
          }
        }));
      }

      if ((subsystems & Mpc.Subsystems.playlist) != 0){        
        await PopulatePlaylist();
      }

      if ((subsystems & Mpc.Subsystems.update) != 0){
        int lastUpdate = m_LastStatus != null ? m_LastStatus.UpdatingDb : -1;
        await Dispatcher.BeginInvoke(new Action(() =>
        {
          btnUpdate.IsEnabled = status.UpdatingDb <= 0;
          // Update db finished:
          if (lastUpdate > 0 && status.UpdatingDb <= 0)
              UpdateDbFinished();
        }));
      }

      //if ((subsystems & Mpc.Subsystems.subscription) != 0)
      //  PopulateChannels();
      //if ((subsystems & Mpc.Subsystems.message) != 0)
      //  PopulateMessages();

      m_LastStatus = status;
    }
Example #13
0
        private void MpcConnected(Mpc connection)
        {
            if (!string.IsNullOrEmpty(m_Settings.Password)){
            if (!m_Mpc.Password(m_Settings.Password)){
              MessageBox.Show("Error connecting to server:\r\nWrong password", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
              return;
            }
              }

              List<string> commands = m_Mpc.Commands();
              if (!commands.Contains("channels"))
            tabMessages.Visibility = System.Windows.Visibility.Collapsed;

              txtStatus.Text = string.Format("Connected to {0}:{1} [MPD v.{2}]", m_Settings.ServerAddress, m_Settings.ServerPort, m_Mpc.Connection.Version);
              MpdStatistics stats = m_Mpc.Stats();
              PopulateGenres();
              PopulatePlaylists();
              PopulateFileSystemTree();
              PopulatePlaylist();
              PopulateArtists();
        }
Example #14
0
        /// <summary>
        /// Puts the client in idle mode for the given subsystems
        /// </summary>
        /// <param name="subsystems">The subsystems to listen to.</param>
        public void Idle(Mpc.Subsystems subsystems)
        {
            StringBuilder subs = new StringBuilder();
              foreach (Mpc.Subsystems s in Enum.GetValues(typeof(Mpc.Subsystems))){
            if (s != Mpc.Subsystems.All && (subsystems & s) != 0)
              subs.AppendFormat(" {0}", s.ToString());
              }
              string command = string.Format("idle {0}", subs.ToString());

              try {
            while (true){
              this.CheckConnected();
              m_SocketManager.WriteLine(command);
              MpdResponse res = this.readResponse();

              Mpc.Subsystems eventSubsystems = Mpc.Subsystems.None;
              foreach (string m in res.Message){
            List<string> values = res.getValueList();
            foreach (string sub in values){
              Mpc.Subsystems s = Mpc.Subsystems.None;
              if (Enum.TryParse<Mpc.Subsystems>(sub, out s)){
                eventSubsystems |= s;
              }
            }
              }

              if (eventSubsystems != Mpc.Subsystems.None && this.OnSubsystemsChanged != null)
            this.OnSubsystemsChanged(this, eventSubsystems);
            }
              }
              catch (Exception) {
            try {
              this.Disconnect();
            }
            catch (Exception) { }
              }
        }
 private void MpcDisconnected(Mpc connection)
 {
     if (m_Settings.AutoReconnect && m_ReconnectTimer == null){
     m_ReconnectTimer = new Timer();
     m_ReconnectTimer.Interval = m_Settings.AutoReconnectDelay * 1000;
     m_ReconnectTimer.Elapsed += ReconnectTimerHandler;
     m_ReconnectTimer.Start();
       }
 }
        private void MpcConnected(Mpc connection)
        {
            if (!string.IsNullOrEmpty(m_Settings.Password)) {
            bool res = m_Mpc.Password(m_Settings.Password);
              }
              MpdStatistics stats = m_Mpc.Stats();
              PopulateGenres();
              PopulatePlaylists();
              PopulateFileSystemTree();
              PopulatePlaylist();
              PopulateArtists();

              m_Timer.Interval = 500;
              m_Timer.Elapsed += TimerHandler;
              m_Timer.Start();
        }
        public MainWindow()
        {
            InitializeComponent();
              This = this;

              Title = string.Format("WpfMpdClient v.{0}", Assembly.GetExecutingAssembly().GetName().Version);
              stcAbout.DataContext = m_About;
              try {
            txtLicense.Text = File.ReadAllText("LICENSE.TXT");
              } catch (Exception){
            txtLicense.Text = "LICENSE not found!!!";
              }

              m_Settings = Settings.Deserialize(Settings.GetSettingsFileName());
              if (m_Settings != null) {
            txtServerAddress.Text = m_Settings.ServerAddress;
            txtServerPort.Text = m_Settings.ServerPort.ToString();
            txtPassword.Password = m_Settings.Password;
            chkAutoreconnect.IsChecked = m_Settings.AutoReconnect;
            chkShowStop.IsChecked = m_Settings.ShowStopButton;
            chkShowFilesystem.IsChecked = m_Settings.ShowFilesystemTab;
            chkMinimizeToTray.IsChecked = m_Settings.MinimizeToTray;
            chkCloseToTray.IsChecked = m_Settings.CloseToTray;
            chkScrobbler.IsChecked = m_Settings.Scrobbler;
              } else
            m_Settings = new Settings();
              m_LastfmScrobbler = new LastfmScrobbler(Utilities.DecryptString(m_Settings.ScrobblerSessionKey));

              if (m_Settings.WindowWidth > 0 && m_Settings.WindowHeight > 0){
            Width = m_Settings.WindowWidth;
            Height = m_Settings.WindowHeight;
              }
              if (m_Settings.WindowLeft >= 0 && m_Settings.WindowHeight >= 0){
            Left = m_Settings.WindowLeft;
            Top = m_Settings.WindowTop;
              }else
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
              if (m_Settings.WindowMaximized)
            WindowState = System.Windows.WindowState.Maximized;

              m_Mpc = new Mpc();
              m_Mpc.OnConnected += MpcConnected;
              m_Mpc.OnDisconnected += MpcDisconnected;

              m_Timer = new Timer();

              cmbSearch.SelectedIndex = 0;

              tabFileSystem.Visibility = m_Settings.ShowFilesystemTab ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
              playerControl.ShowStopButton = m_Settings.ShowStopButton;
              playerControl.Mpc = m_Mpc;
              playerControl.PlayClicked += PlayClickedHandler;
              playerControl.PauseClicked += PauseClickedHandler;
              playerControl.BackClicked += BackClickedHandler;
              playerControl.ForwardClicked += ForwardClickedHandler;
              playerControl.RandomClicked += RandomClickedHandler;
              playerControl.RepeatClicked += RepeatClickedHandler;
              playerControl.StopClicked += StopClickedHandler;

              m_NotifyIcon = new System.Windows.Forms.NotifyIcon();
              m_NotifyIcon.Icon = new System.Drawing.Icon("mpd_icon.ico", new System.Drawing.Size(32,32));
              m_NotifyIcon.MouseDown += new System.Windows.Forms.MouseEventHandler(NotifyIcon_MouseDown);
              m_NotifyIconMenu = (ContextMenu)this.FindResource("TrayIconContextMenu");
              Closing += CloseHandler;

              if (!string.IsNullOrEmpty(m_Settings.ServerAddress)){
            m_StartTimer = new Timer();
            m_StartTimer.Interval = 500;
            m_StartTimer.Elapsed += StartTimerHandler;
            m_StartTimer.Start();
              }

              m_Updater = new Updater(new Uri("http://www.sakya.it/updater/updater.php"), "WpfMpdClient", "Windows");
              m_Updater.CheckCompletedDelegate += CheckCompleted;
              m_Updater.Check();
        }