Ejemplo n.º 1
0
        public void CreateSonglist(SonglistDTO songlistDTO)
        {
            if (songlistDTO == null)
            {
                throw new ArgumentNullException("Songlist Service - CreateSonglist(...) songlistDTO cannot be null");
            }

            Songlist songlist = Mapper.Map <Songlist>(songlistDTO);

            using (var uow = UnitOfWorkProvider.Create())
            {
                if (songlistDTO.SongIDs != null)
                {
                    foreach (int ID in songlistDTO.SongIDs)
                    {
                        if (songlist.Songs == null)
                        {
                            songlist.Songs = new List <Song>();
                        }
                        Song song = GetSonglistSong(ID);
                        songlist.Songs.Add(song);
                    }
                }

                songlist.Owner = GetSonglistCreator(songlistDTO.OwnerID);

                songlistRepository.Insert(songlist);
                uow.Commit();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 对选中歌曲项进行操作
        /// </summary>
        /// <param name="operation">操作内容</param>
        public void OperateSelectedItems(SelectionOperation operation)
        {
            Action <SongModel> action = null;

            switch (operation)
            {
            case SelectionOperation.Delete:
                while (Songlist.SelectedIndex >= 0)
                {
                    (Songlist.ItemsSource as IList <SongModel>).RemoveAt(Songlist.SelectedIndex);
                }
                return;

            case SelectionOperation.Love:
                action = model => model.IsLoved = true;     // TODO: 在这更改设置的时候会抛出错误
                break;

            case SelectionOperation.SelectAll:
                Songlist.SelectAll();
                return;

            case SelectionOperation.SelectOther:
                OperateAllItems((item) => item.IsSelected = !item.IsSelected);
                return;
            }
            foreach (var item in Songlist.SelectedItems)
            {
                action?.Invoke(item as SongModel);
            }
        }
Ejemplo n.º 3
0
 private void LabelLayout(List <Song> LstSong)
 {
     if (LstSong.Count < 1)
     {
         this.Songlist.FlowLayoutPanel.Controls.Clear();
         Label label = new Label();
         label.Location  = new Point(0, 0);
         label.Text      = " 没有找到相关歌曲";
         label.ForeColor = itemColor;
         label.FlatStyle = FlatStyle.Flat;
         label.AutoSize  = false;
         label.Size      = new Size(Songlist.Width - 20, 31);
         label.TextAlign = ContentAlignment.MiddleCenter;
         this.Songlist.FlowLayoutPanel.Controls.Add(label);
         return;
     }
     this.Songlist.FlowLayoutPanel.Controls.Clear();
     foreach (Song song in LstSong)
     {
         ItemSong item = new ItemSong(song.Filename, CastToFen(song.DurationStr), song.MvHash);
         item.Size = new Size(Songlist.FlowLayoutPanel.Width - 20, 31);
         //item.BackColor = Color.Beige;
         item.DoubleClick     += new EventHandler(this.ItemSongDoublick);
         item.MvIconClick     += new ItemSong.Callback(MvIconClick);
         item.Tag              = song;
         item.ContextMenuStrip = Menu;
         item.MouseLeave      += new EventHandler(this.label1_MouseLeave);
         item.MouseEnter      += new EventHandler(this.label1_MouseHover);
         Songlist.FlowLayoutPanel.Controls.Add(item);
     }
     Songlist.Refresh();
 }
Ejemplo n.º 4
0
 private void OperateAllItems(Action <ListViewItem> action)
 {
     for (int i = 0; i < Songlist.Items.Count; i++)
     {
         var item = Songlist.ContainerFromIndex(i) as ListViewItem;
         if (item == null)
         {
             continue;
         }
         action.Invoke(item);
     }
 }
Ejemplo n.º 5
0
 public void wplayer_PlayStateChange(int NewState)
 {
     if (wplayer.playState == WMPLib.WMPPlayState.wmppsMediaEnded)
     {
         SkipForward();
         wplayer.URL = Songlist.SelectedItem.ToString();
         Songlist.ScrollIntoView(Songlist.SelectedItem);
         Durationlbl.Content   = wplayer.currentMedia.durationString;
         Volumebar.Value       = wplayer.settings.volume;
         Titlelbl.Content      = wplayer.currentMedia.getItemInfo("Title");
         Songtrigger.IsEnabled = true;
     }
 }
Ejemplo n.º 6
0
        public Player()
        {
            this.currentSong       = null;
            this.musicPlayer       = new WaveOut();
            this.Songlist          = new Songlist();
            positionTimer.Interval = TimeSpan.FromMilliseconds(50);
            positionTimer.Tick    += positionTimer_Tick;


            waveformGenerateWorker.DoWork                    += waveformGenerateWorker_DoWork;
            waveformGenerateWorker.RunWorkerCompleted        += waveformGenerateWorker_RunWorkerCompleted;
            waveformGenerateWorker.WorkerSupportsCancellation = true;
        }
Ejemplo n.º 7
0
        public static bool Select()
        {
            if (selectedFolderIndex == -1)
            {
                selectedFolderIndex = currentFolderIndex;
                switch (FolderParams[selectedFolderIndex].Type)
                {
                case SortType.Title:
                    Songlist = Songlist.OrderBy(x => x.Title).ToList();
                    UpdateMetaLabels();
                    break;

                case SortType.Artist:
                    Songlist = Songlist.OrderBy(x => x.Artist).ToList();
                    UpdateMetaLabels();
                    break;

                case SortType.Level:
                    selectedLevelIndex = -1;
                    break;

                case SortType.Genre:
                    break;

                default:
                    break;
                }
            }
            else if (FolderParams[selectedFolderIndex].Type == SortType.Level && selectedLevelIndex == -1)
            {
                selectedLevelIndex = currentLevelIndex;
                Songlist           = Songlist.OrderBy(x => x.GetLevel(currentSongLevelIndex)).ToList();
                currentSongIndex   = Songlist.FindLastIndex(x => x.GetLevel(currentSongLevelIndex) < (selectedLevelIndex + 1)) + 1;
                UpdateMetaLabels();
                if (currentSongIndex >= Songlist.Count)
                {
                    currentSongIndex--;
                }
            }
            else
            {
                if (!IsSongReady())
                {
                    return(false);
                }

                return(true);
            }

            return(false);
        }
Ejemplo n.º 8
0
    } = 0;                                                             // Used to track difficulty switches

    public static void ImportSongs(string songsFolder)
    {
        if (!Directory.Exists(songsFolder))
        {
            return;
        }
        //DirectoryInfo di = new DirectoryInfo(songsFolder);
        //var folders = di.EnumerateDirectories();
        var folders = Directory.EnumerateDirectories(songsFolder);

        foreach (var folder in folders)
        {
            // If a folder contains an *.ssi file, use that to load charts
            // Otherwise, load each chart individually
            //var files = folder.EnumerateFiles();
            var files = Directory.EnumerateFiles(folder);
            var info  = files.Where(f => f.EndsWith(Defines.InfoExtension));
            if (info != null && info.Count() > 0)
            {
                foreach (var file in info)
                {
                    Songlist.Add(new SongMetadata(file));
                }
            }
            else
            {
                var charts = files.Where(f => f.EndsWith(Defines.ChartExtension));
                if (charts != null && charts.Count() > 0)
                {
                    foreach (var chart in charts)
                    {
                        Songlist.Add(new SongMetadata(chart));
                    }
                }
            }
        }
        FolderParams.Add(new FolderParams()
        {
            Type = SortType.Title, Name = ConfigFile.GetLocalizedString("Sort_Title")
        });
        FolderParams.Add(new FolderParams()
        {
            Type = SortType.Artist, Name = ConfigFile.GetLocalizedString("Sort_Artist")
        });
        FolderParams.Add(new FolderParams()
        {
            Type = SortType.Level, Name = ConfigFile.GetLocalizedString("Sort_Level")
        });
    }
Ejemplo n.º 9
0
 private void skipbackbutton(object sender, RoutedEventArgs e)
 {
     if (wplayer != null)
     {
         if (Songlist.SelectedIndex > 0)
         {
             Songlist.ScrollIntoView(Songlist.SelectedItem);
             Songlist.SelectedIndex = Songlist.SelectedIndex - 1;
             wplayer.URL            = Songlist.SelectedItem.ToString();
             Durationlbl.Content    = wplayer.currentMedia.durationString;
             Titlelbl.Content       = wplayer.currentMedia.getItemInfo("Title");
             wplayer.controls.play();
         }
     }
 }
Ejemplo n.º 10
0
        public static void ImportSongs(string songsFolder)
        {
            DirectoryInfo di      = new DirectoryInfo("Songs");
            var           folders = di.EnumerateDirectories();

            foreach (var folder in folders)
            {
                // If a folder contains an *.ssi file, use that to load charts
                // Otherwise, load each chart individually
                var files = folder.EnumerateFiles();
                var info  = files.Where(f => f.FullName.EndsWith(Defines.InfoExtension));
                if (info != null && info.Count() > 0)
                {
                    foreach (var file in info)
                    {
                        Songlist.Add(new SongMetadata(file.FullName));
                    }
                }
                else
                {
                    var charts = files.Where(f => f.FullName.EndsWith(Defines.ChartExtension));
                    if (charts != null && charts.Count() > 0)
                    {
                        foreach (var chart in charts)
                        {
                            Songlist.Add(new SongMetadata(chart.FullName));
                        }
                    }
                }
            }
            FolderParams.Add(new FolderParams()
            {
                Type = SortType.Title, Name = "SORT BY\nTITLE"
            });
            FolderParams.Add(new FolderParams()
            {
                Type = SortType.Artist, Name = "SORT BY\nARTIST"
            });
            FolderParams.Add(new FolderParams()
            {
                Type = SortType.Level, Name = "SORT BY\nLEVEL"
            });
        }
Ejemplo n.º 11
0
    // Use this for initialization
    void Start()
    {
        for (int f = 0; f < birdUIfills.Length; f++)
        {
            birdUIfills [f].fillAmount = 0f;
        }

        song            = GetComponent <Songlist> ();
        characterani    = GameObject.FindWithTag("PlayerCharacter").GetComponent <Animator> ();
        endBk           = GameObject.FindWithTag("SunriseCanvas").GetComponent <Animator> ();
        treeLight       = GameObject.FindWithTag("Tree").GetComponent <Animator> ();
        birdGenerator   = birdGeneratorObj.GetComponent <BirdGenerator> ();
        playerParticles = player.GetComponentInChildren <ParticleSystem> ();
        callUI          = mainCamera.GetComponent <Call_UI> ();

        audios = new List <GameObject> ();
        currentlyPlayingAudio = new bool[10];
        currentlyFadingOut    = new bool[10];
        for (int i = 0; i < 10; i++)
        {
            currentlyPlayingAudio [i] = false;
            currentlyFadingOut [i]    = false;
        }
        keyPressed          = false;
        keyPressedThisFrame = false;

        UpperBodyTurn = GameObject.FindWithTag("UpperBodyTurn");

        audioSource  = GetComponent <AudioSource> ();
        note         = 0;
        ifFinish     = false;
        birdsPresent = false;

        matrixSize       = 10;
        transitionMatrix = new int[matrixSize, matrixSize];
        tripletList      = new List <int[]> ();
        ParseTransitionMatrix();

        currentActiveTripletIndex = 0;
        currentActiveNoteIndex    = 0;
        currentMaxTripletIndex    = 0;
        prevIndex = 0;
    }
Ejemplo n.º 12
0
 private void skipbutton(object sender, RoutedEventArgs e)
 {
     try
     {
         SkipForward();
         wplayer.URL = Songlist.SelectedItem.ToString();
         Songlist.ScrollIntoView(Songlist.SelectedItem);
         Durationlbl.Content = wplayer.currentMedia.durationString;
         Titlelbl.Content    = wplayer.currentMedia.getItemInfo("Title");
         wplayer.controls.play();
         if (Songlist.SelectedIndex > Songlist.Items.Count - 1)
         {
             Songlist.SelectedIndex = -1;
         }
     }
     catch
     {
         Titlelbl.Content = "no";
     }
 }
Ejemplo n.º 13
0
        private void Instance_CurrentIndexChanged(object sender, Template10.Common.ChangedEventArgs <int> e)
        {
            //TODO: 针对播放中的打乱顺序进行处理
            ListViewItem t;

            if (ListType == PlaylistType.LocalPlaylist)
            {
                if (e.OldValue >= 0)
                {
                    t = Songlist.ContainerFromIndex(e.OldValue) as ListViewItem;
                    VisualStateManager.GoToState((t.Tag as SongItem), "NotPlaying", true);
                }
                if (e.NewValue >= 0)
                {
                    t = Songlist.ContainerFromIndex(e.NewValue) as ListViewItem;
                    VisualStateManager.GoToState((t.Tag as SongItem), "Playing", true);
                    //TODO: 增加新专辑的时候会存在Item不为空但是container为空的情况
                }
            }
            else
            {
                //TODO: 刷新所有歌曲的播放状态?
            }
        }
Ejemplo n.º 14
0
        public static void CycleDifficulty()
        {
            if (selectedFolderIndex < 0)
            {
                return;
            }

            currentSongLevelIndex++;
            if (currentSongLevelIndex > 2)
            {
                currentSongLevelIndex = 0;
            }

            if (FolderParams[selectedFolderIndex].Type == SortType.Level)
            {
                // Find out which song that's currently selected before reorganization
                var title  = Songlist[currentSongIndex].Title;
                var artist = Songlist[currentSongIndex].Artist;

                // Reorganize list here
                Songlist         = Songlist.OrderBy(x => x.GetLevel(currentSongLevelIndex)).ToList();
                currentSongIndex = Songlist.IndexOf(Songlist.First(x => x.Title == title && x.Artist == artist));
            }
        }
Ejemplo n.º 15
0
 private void button1_Click(object sender, EventArgs e)
 {
     Search(txt_Songname.Text.Trim());
     Songlist.Refresh();
 }
Ejemplo n.º 16
0
 public Playlist(string playlistName)
 {
     this.PlaylistName = playlistName;
     this.SongList     = new Songlist();
 }
Ejemplo n.º 17
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     this.logger         = new Logger();
     this.songlist       = new Songlist(logger);
     this.displayedSongs = new List <DisplaySong>();
 }