示例#1
0
        private void ClickPrevious(object sender, RoutedEventArgs e)
        {
            MediaElementPlayer.Stop();
            ViewModelPlayer context = this.DataContext as ViewModelPlayer;

            if (context._playlist != null && !context._playlist.Empty())
            {
                int index = context._playlist.Files.FindIndex(x => x.Path.Equals(MediaElementPlayer.Source.OriginalString));
                try
                {
                    if (index > 0)
                    {
                        MediaElementPlayer.Source = new Uri(context._playlist.Files[index - 1].Path);
                        MediaElementPlayer.Play();
                    }
                    else
                    {
                        MediaElementPlayer.Position = TimeSpan.FromSeconds(0);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
        }
示例#2
0
        private void MediaEnded(object sender, RoutedEventArgs e)
        {
            MediaElementPlayer.Stop();
            ViewModelPlayer context = this.DataContext as ViewModelPlayer;

            if (context._playlist != null && !context._playlist.Empty())
            {
                int index = context._playlist.Files.FindIndex(x => x.Path.Equals(MediaElementPlayer.Source.OriginalString));
                try
                {
                    if (context._playlist.Files.Count > index + 1)
                    {
                        MediaElementPlayer.Source = new Uri(context._playlist.Files[index + 1].Path);
                        MediaElementPlayer.Play();
                    }
                    else if (_bIsBoucle)
                    {
                        MediaElementPlayer.Source = new Uri(context._playlist.Files[0].Path);
                        MediaElementPlayer.Play();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            else if (_bIsBoucle)
            {
                MediaElementPlayer.Play();
            }
        }
示例#3
0
        public MainWindow()
        {
            controller = new ControllerPlayer();
            viewModel  = new ViewModelPlayer();
            InitializeComponent();

            this.DataContext = viewModel;
        }
        static public bool DeleteFrom_CanExecute(object parameter)
        {
            ViewModelPlayer context = parameter as ViewModelPlayer;

            if (context._playlist != null)
            {
                return(true);
            }
            return(false);
        }
        static public bool Add_CanExecute(object parameter)
        {
            ViewModelPlayer context = parameter as ViewModelPlayer;

            if (context != null && context._media != null && context._media.Source != null)
            {
                return(true);
            }
            return(false);
        }
        static public void DeleteFrom_Execute(object parameter)
        {
            ViewModelPlayer context    = parameter as ViewModelPlayer;
            var             msgBoxRslt = MessageBox.Show("Etes vous sûr de vouloir supprimer cette musique de la playlist ?",
                                                         "Attention !", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (msgBoxRslt == MessageBoxResult.Yes)
            {
                string path = context._media.Source.ToString();
                context._playlist.RemoveFromPlaylist(path);
            }
        }
        static public void Add_Execute(object parameter)
        {
            ViewModelPlayer context = parameter as ViewModelPlayer;
            var             newWin  = new PlaylistWindow();

            newWin.ShowDialog();
            if (newWin.bHasReturned == true)
            {
                string path = context._media.Source.ToString();
                newWin.playlist.AddToPlaylist(path, false);
            }
        }
示例#8
0
        public static List <ViewModelPlayer> MapPlayersList(List <Player> playersList)
        {
            List <ViewModelPlayer> viewModelPlayersList = new List <ViewModelPlayer>();

            foreach (var p in playersList)
            {
                ViewModelPlayer viewModelPlayer = MapPlayer(p);
                viewModelPlayersList.Add(viewModelPlayer);
            }

            return(viewModelPlayersList);
        }
示例#9
0
        public static ViewModelPlayer MapPlayer(Player player)
        {
            ViewModelPlayer viewModelPlayer = new ViewModelPlayer()
            {
                Id         = player.Id,
                Cards      = MapCardsList(player.Cards.ToList()),
                Name       = player.Name,
                PlayerType = player.PlayerType
            };

            return(viewModelPlayer);
        }
        public PlayerView()
        {
            InitializeComponent();
            this.vm          = new ViewModelPlayer(MainWindow.getModel());
            this.DataContext = this.vm;
            this.fg          = new FG();

            App.Current.Exit += delegate(object sender, ExitEventArgs e)
            {
                this.close();
            };
        }
        static public void Open_Execute(object parameter)
        {
            ViewModelPlayer context = parameter as ViewModelPlayer;
            var             newWin  = new PlaylistWindow();

            newWin.ShowDialog();
            if (newWin.bHasReturned == true)
            {
                context._playlist = newWin.playlist;
                if (context._playlist.Empty() == false)
                {
                    context._media.Source = new Uri(context._playlist.Files[0].Path);
                }
                context._media.Play();
            }
        }
示例#12
0
 public NextCommand(ViewModelPlayer player)
 {
     Player = player;
 }
        public ActionResult List(string playerPlatformFilter = "", string playerNameFilter = "", int pageNumber = 1, int pageSize = 25)
        {
            ViewBag.Message = "Players";

            var model = new ViewModelPlayerList();

            model.PageSize = pageSize;

            if (pageNumber < 0)
            {
                model.PageNumber = 0;
            }

            (List <PlayerListModel> players, int count)result = (null, 0);
            if (Enum.TryParse <PlatformType>(playerPlatformFilter, out var platformType))
            {
                result = _playerController.ListPlayers(platformType, playerNameFilter, pageNumber - 1, pageSize);
            }
            else
            {
                result = _playerController.ListPlayers(PlatformType.NONE, playerNameFilter, pageNumber - 1, pageSize);
            }

            model.Players = new List <ViewModelPlayer>();
            result.players.ForEach(a =>
            {
                var vmP  = new ViewModelPlayer();
                vmP.name = a.Name;
                if (a.LastAction != null)
                {
                    vmP.actionCount = a.ActionCount;
                    var lastAction  = a.LastAction;
                    if (lastAction != null)
                    {
                        vmP.lastAction = lastAction.Time;
                    }
                }
                else
                {
                    vmP.actionCount = 0;
                    vmP.lastAction  = default(DateTime);
                }
                vmP.id        = a.Id;
                vmP.platform  = PlayerPlatformResolver.ResolvePlatformFromPlayer(a).ToString();
                model.Players = model.Players;
                model.Players.Add(vmP);
            });


            model.PageNumber           = pageNumber;
            model.PlayerNameFilter     = playerNameFilter;
            model.PlayerPlatformFilter = playerPlatformFilter;
            model.NumberOfPages        = (result.count - 1) / pageSize;
            model.TotalPlayersCount    = result.count;

            if (model.Players.Count == 0 && model.PageNumber > 1)
            {
                return(List(playerPlatformFilter, playerNameFilter, model.NumberOfPages));
            }

            return(View(model));
        }
示例#14
0
 public PauseCommand(ViewModelPlayer player)
 {
     Player = player;
 }