void initActionBar()
 {
     //ActionBarService.RegisterContext("1", userPage, "IsLoggedIn");
     ActionBarService.RegisterContext("0", list_search, "SelectCount");
     ActionBarService.RegisterContext("1", list_download, "SelectCount");
     ActionBarService.RegisterContext("2", list_complete, "SelectCount");
 }
        void f_Changed(object sender, FileSystemEventArgs e)
        {
            while (true)
            {
                try
                {
                    using (var s = File.Open(e.FullPath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                    }
                    break;
                }
                catch (Exception)
                {
                    System.Threading.Thread.Sleep(100);
                }
            }
            System.Media.SystemSounds.Beep.Play();
            var cmd = File.ReadAllText(e.FullPath);

            if (cmd == "next")
            {
                UIHelper.RunOnUI(() => btn_next_Click(null, null));
            }
            else if (cmd == "pause")
            {
                UIHelper.RunOnUI(() => btn_plause_Click(null, null));
            }
            UIHelper.RunOnUI(() => ActionBarService.Refresh());
        }
Exemple #3
0
        protected virtual void btn_play_Click(object sender, RoutedEventArgs e)
        {
            var item = SelectedSongs.FirstOrDefault() ?? Items.OfType <SongViewModel>().FirstOrDefault();

            if (item == null)
            {
                return;
            }
            var location = item.Song.DownloadState == "complete" ? item.Song.FilePath : item.Song.UrlMp3;

            if (string.IsNullOrEmpty(location))
            {
                return;
            }
            if (Mp3Player.GetPlayOrPause(item.Id))
            {
                if (!PlayList.Contains(item))
                {
                    PlayList.NeedsRefresh();
                    PlayList.Refresh(Items.OfType <SongViewModel>());
                }
                else if (isMultiSelect(this))
                {
                    PlayList.NeedsRefresh();
                    PlayList.Refresh(SelectedSongs);
                }
            }
            Mp3Player.Play(location, item.Id);
            ActionBarService.Refresh();
        }
Exemple #4
0
        private void charmBarAct(object sender, RoutedEventArgs e)
        {
            var sel = (sender as FrameworkElement).DataContext as CharmAction;

            if (sel == null)
            {
                return;
            }
            sel.Action(sel, null);
            ActionBarService.Refresh();
        }
        private void charmBarAct(object sender, RoutedEventArgs e)
        {
            var sel = (sender as FrameworkElement).DataContext as CharmAction;

            if (sel == null)
            {
                return;
            }
            more_actions.IsOpen = false;
            sel.Action(sel, null);
            if (sel != open_more && sel != close_more)
            {
                ActionBarService.Refresh();
            }
        }
 void OnMp3PlayerSongChanged(object sender, SongChangedEventArgs e)
 {
     if (SongViewModel.NowPlaying != null)
     {
         SongViewModel.NowPlaying.IsNowPlaying = false;
     }
     SongViewModel.NowPlaying = SongViewModel.GetId(e.Id);
     if (SongViewModel.NowPlaying != null)
     {
         Task.Run(() =>
         {
             if (!Mp3Player.IsPlaying)
             {
                 return;
             }
             var id = SongViewModel.NowPlaying.Id;
             System.Threading.Thread.Sleep(10000);
             if (SongViewModel.NowPlaying.Id != id)
             {
                 return;
             }
             NetAccess.Json(XiamiUrl.url_playlog, "uid", Global.AppSettings["xiami_uid"], "id", id);
             // XiamiClient.GetDefault().Call_xiami_api("Playlog.add",
             //    "id=" + SongViewModel.NowPlaying.Id,
             //    "time=" + XiamiClient.DateTimeToUnixTimestamp(DateTime.Now).ToString(),
             //    "type=20"
             //);
         });
         SongViewModel.NowPlaying.IsNowPlaying = true;
         var now = SongViewModel.NowPlaying;
         info_now.Visibility         = Visibility.Visible;
         part_nowPlaying.DataContext = now;
         Title   = string.Format("{0} - {1}      ", now.Name, now.ArtistName);
         counter = 0;
         if (trayIcon != null && Global.AppSettings["ShowNowPlaying"] != "0" && Mp3Player.IsPlaying)
         {
             balloonTip           = new MyBalloonTip();
             balloonTip.ViewModel = now;
             trayIcon.ShowCustomBalloon(balloonTip, PopupAnimation.Fade, 3000);
         }
     }
     ActionBarService.Refresh();
     refreshPlause();
     currentList.PerformAction("选中正在播放");
 }
 public MainWindow()
 {
     Global.LoadSettings();
     Global.ListenToEvent("EnableMagnet", SetEnableMagnet);
     Global.ListenToEvent("ColorSkin", SetColorSkin);
     Global.ListenToEvent("Theme", SetTheme);
     Loaded  += MainWindow_Loaded;
     Closing += MainWindow_Closing;
     InitializeComponent();
     Global.ListenToEvent("PlayNextMode", SetPlayNextMode);
     Artwork.DataBus.DataBus.Set("MainWindow", this);
     DataContext = this;
     MessageBus.Instance.Subscribe(this);
     loadSongLists();
     ActionBarService.RegisterActionBar(this.charmBar);
     Artwork.DataBus.DataBus.Set("list_download", list_download);
     Mp3Player.SongChanged += OnMp3PlayerSongChanged;
     Global.ListenToEvent("TitleMarquee", SetTitleMarquee);
     btn_sync_left.Click  += btn_sync_left_Click;
     btn_sync_right.Click += btn_sync_right_Click;
     new MusicSliderConnector(slider);
     lists = new List <SongListControl> {
         list_search,
         list_download,
         list_complete,
     };
     foreach (var item in lists)
     {
         item.PropertyChanged           += songlist_PropertyChanged;
         item.ListView.SelectionChanged += ListView_SelectionChanged;
     }
     content_mask.MouseLeftButtonUp += btn_toggle_detail_Click;
     info_now.MouseLeftButtonUp     += btn_toggle_detail_Click;
     headingSource = new List <CharmAction>
     {
         new CharmAction("在线", "\xE11a", (a, b) => Page = 0),
         new CharmAction("下载", "\xE118", (a, b) => Page = 1),
         new CharmAction("本地", "\xE142", (a, b) => Page = 2),
         new CharmAction("配置", "\xE115", (a, b) => Page = 3),
     };
 }
 protected override void item_double_click(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     btn_play_Click(sender, e);
     ActionBarService.Refresh();
 }