Beispiel #1
0
 private SongButton(Song aSong, StackPanel aPanel, MainWindow aMainWindow, GUIHandler aHandler, Playlist aPlaylist)
 {
     mySong       = aSong;
     myPlaylist   = aPlaylist;
     myGUIHandler = aHandler;
     myMainWindow = aMainWindow;
 }
Beispiel #2
0
        public Playlist(string aName, string aSavePath, StackPanel aSongPanel, StackPanel aPlaylistPanel, StackPanel aPlaylistPickPanel, MainWindow someMainWindow, GUIHandler aHandler)
        {
            GetName         = aName;
            mySavePath      = aSavePath;
            mySongPanel     = aSongPanel;
            myPlaylistPanel = aPlaylistPanel;
            myMainWindow    = someMainWindow;
            myGUIHander     = aHandler;
            mySongs         = new List <Song>();

            // Playlist already exists.
            if (File.Exists(aSavePath + "/" + aName + ".xml"))
            {
                ReadPlaylistFile();
            }

            if (aName != "Local")
            {
                PlaylistButton.Create(this, aPlaylistPanel, someMainWindow, aHandler);
                Button tempButton = new Button();
                tempButton.Click  += PlaylistPick_Click;
                tempButton.Content = aName;

                aPlaylistPickPanel.Children.Add(tempButton);
            }
        }
Beispiel #3
0
        private PlaylistButton(Playlist aPlaylist, StackPanel aPanel, MainWindow aMainWindow, Button myButton, GUIHandler aHandler)
        {
            myPlaylist   = aPlaylist;
            myPanel      = aPanel;
            myMainWindow = aMainWindow;
            myHandler    = aHandler;

            myButton.Click += ShowPlaylist;
        }
Beispiel #4
0
        public MainWindow()
        {
            InitializeComponent();

            // Discord Rich Presence initialization.
            client = new DiscordRpcClient("573842291517685821");
            client.Initialize();
            DiscordRPC();

            myGUIHandler = new GUIHandler(this);

            // Getting file paths.
            string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            myAppdataFolder   = System.IO.Path.Combine(appdata, ".MusicPlayer");
            myLocalFolder     = System.IO.Path.Combine(myAppdataFolder, "Music", "Local/");
            myPlaylistsFolder = System.IO.Path.Combine(myAppdataFolder, "Playlists");

            // Creating new file paths.
            if (!Directory.Exists(myLocalFolder))
            {
                Directory.CreateDirectory(myLocalFolder);
            }

            if (!Directory.Exists(myPlaylistsFolder))
            {
                Directory.CreateDirectory(myPlaylistsFolder);
            }

            // Loads local playlist before all other playlists making local always have index 0.
            myPlaylists.Add(new Playlist("Local", myPlaylistsFolder, pnlLocalSongs, pnlPlaylists, pnlPlaylists, this, myGUIHandler));

            // Adding timeline timer.
            DispatcherTimer timer = new DispatcherTimer();

            timer.Interval = TimeSpan.FromSeconds(1f);
            timer.Tick    += Timer_Tick;
            timer.Start();

            // Subscribing to event.
            mediaPlayer.MediaOpened += MediaOpened;

            LoadPlaylists();

            // Sets local playlist to default playlist.
            myActivePlaylist = myPlaylists[0];
        }
Beispiel #5
0
        /// <summary>
        /// Creates a button for a song.
        /// </summary>
        /// <param name="aSong"></param>
        /// <param name="aPanel"></param>
        /// <param name="aMainWindow"></param>
        /// <param name="aHandler"></param>
        /// <param name="aPlaylist"></param>
        /// <returns></returns>
        public static SongButton Create(Song aSong, StackPanel aPanel, MainWindow aMainWindow, GUIHandler aHandler, Playlist aPlaylist)
        {
            SongButton songButton = new SongButton(aSong, aPanel, aMainWindow, aHandler, aPlaylist);

            Button tempButton = new Button();

            tempButton.Width             = 880;
            tempButton.Height            = 25;
            tempButton.Content           = aSong.AccessName;
            tempButton.VerticalAlignment = VerticalAlignment.Top;

            ContextMenu menu  = new ContextMenu();
            MenuItem    items = new MenuItem();

            items.Header = "Add to playlist";
            menu.Items.Add(items);
            tempButton.ContextMenu = menu;
            items.Click           += songButton.ContextAddToPlaylist;

            aPanel.Children.Add(tempButton);
            tempButton.Click += songButton.SongClicked;

            return(songButton);
        }
Beispiel #6
0
        /// <summary>
        /// Creates a button for a playlist.
        /// </summary>
        /// <param name="aPlaylist"></param>
        /// <param name="aPanel"></param>
        /// <param name="aMainWindow"></param>
        /// <param name="aHandler"></param>
        /// <returns></returns>
        public static PlaylistButton Create(Playlist aPlaylist, StackPanel aPanel, MainWindow aMainWindow, GUIHandler aHandler)
        {
            Button tempButton = new Button();

            tempButton.Width             = 880;
            tempButton.Height            = 25;
            tempButton.Content           = aPlaylist.GetName;
            tempButton.VerticalAlignment = VerticalAlignment.Top;

            aPanel.Children.Add(tempButton);

            PlaylistButton playlistButton = new PlaylistButton(aPlaylist, aPanel, aMainWindow, tempButton, aHandler);

            return(playlistButton);
        }