public MusicPage GetMusicPage() { var Out = new MusicPage(PlaylistName); foreach (var data in Tracks) { Out.AddTrack(data.GetTrack()); } Out.Refresh(); return(Out); }
public void SavePlaylist(MusicPage musicPage, string Name) { var fs = new FileStream(Name, FileMode.Create); var formatter = new BinaryFormatter(); var data = new PlaylistData(musicPage); formatter.Serialize(fs, data); fs.Close(); fs = new FileStream(Name, FileMode.Open); fs.Close(); }
public void LoadPlaylists(TabControl MainTabs) { for (int i = 0; i < Num(); i++) { MusicPage musicPage = LoadPlaylist(i); if (musicPage != null) { MainTabs.Controls.Add(musicPage); } } }
public MainTabs() { InitializeComponent(); if (LocalData.Instance.Num() > 0) { LocalData.Instance.LoadPlaylists(MainTab); } else { var mainPage = new MusicPage("New Tab"); MainTab.Controls.Add(mainPage); MainTab.Controls[0].Dock = DockStyle.Fill; } Instance = MainTab; }
public void SwapTabPages(MusicPage src, MusicPage dst) { if (src == dst) { return; } if (src is null || dst is null) { return; } var indexSrc = MainTab.TabPages.IndexOf(src); var indexDst = MainTab.TabPages.IndexOf(dst); MainTab.TabPages[indexDst] = src; MainTab.TabPages[indexSrc] = dst; MainTab.Controls.SetChildIndex(src, indexDst); MainTab.Controls.SetChildIndex(dst, indexSrc); MainTab.Refresh(); }
private void addToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Multiselect = true; openFileDialog.InitialDirectory = "c:\\"; openFileDialog.Filter = "mp3 files (*.mp3)|*.mp3|All files (*.*)|*.*"; openFileDialog.FilterIndex = 2; openFileDialog.RestoreDirectory = true; DialogResult result = openFileDialog.ShowDialog(); if (result == DialogResult.OK) { MusicPage CurrentTab = MainTabs.SelectedTab as MusicPage; foreach(string str in openFileDialog.FileNames) { Debug.WriteLine(str); } CurrentTab.musicTab.AddTrack(openFileDialog.FileNames); } SavePlaylists(); }
//public ConsoleControl.ConsoleControl console; public MainWindow() { //aaaToolStripMenuItem.DropDown.AutoClose = false; InitializeComponent(); InitializeTrackbarTimer(); if (localData.Num() > 0) { localData.LoadPlaylists(MainTabs); } else { MusicPage MainPage = new MusicPage("New Tab"); MainTabs.Controls.Add(MainPage); MainTabs.Controls[0].Dock = DockStyle.Fill; } //ConsoleControl.ConsoleControl console = new ConsoleControl.ConsoleControl(); //panel1.Controls.Add(console); //console.Dock = DockStyle.Fill; //console.Font = new System.Drawing.Font(System.Drawing.FontFamily.GenericMonospace, 8); }
private void addDirectoryToolStripMenuItem_Click(object sender, EventArgs e) { FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); folderBrowserDialog.RootFolder = Environment.SpecialFolder.MyComputer; folderBrowserDialog.ShowNewFolderButton = false; DialogResult result = folderBrowserDialog.ShowDialog(); if (result != DialogResult.OK) return; //{ MusicPage CurrentTab = MainTabs.SelectedTab as MusicPage; string[] FileNames = new string[] { folderBrowserDialog.SelectedPath }; // Debug.WriteLine(folderBrowserDialog.SelectedPath); // CurrentTab.musicTab.AddTrack(FileNames); //} //SavePlaylists(); List<Track> trackList = MusicTab.MakeTracksList(FileNames); CurrentTab?.musicTab?.AddTrack(trackList); MainWindow.SavePlaylists(); }
private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { MusicPage currentPage = MainTabs.SelectedTab as MusicPage; currentPage.DeleteSelectedTracks(); }
public PlaylistData(MusicPage musicPage) { PlaylistName = musicPage.Text; AddTrack(musicPage.musicTab.Tracks); }
private void MainTabs_DragOver(object sender, DragEventArgs e) { TabControl tc = (TabControl)sender; MusicPage dragTab = e.Data.GetData(typeof(MusicPage)) as MusicPage; if (dragTab == null) { return; } int dragTab_index = tc.TabPages.IndexOf(dragTab); // hover over a tab? int hoverTab_index = this.HoverTabIndex(tc); if (hoverTab_index < 0) { e.Effect = DragDropEffects.None; return; } //tc.Controls[0].mar TabPage hoverTab = tc.TabPages[hoverTab_index]; e.Effect = DragDropEffects.Move; // start of drag? if (dragTab == hoverTab) { return; } // swap dragTab & hoverTab - avoids toggeling Rectangle dragTabRect = tc.GetTabRect(dragTab_index); Rectangle hoverTabRect = tc.GetTabRect(hoverTab_index); if (dragTabRect.Width < hoverTabRect.Width) { Point tcLocation = tc.PointToScreen(tc.Location); if (dragTab_index < hoverTab_index) { if ((e.X - tcLocation.X) > ((hoverTabRect.X + hoverTabRect.Width) - dragTabRect.Width)) { this.swapTabPages(tc, dragTab, hoverTab); } } else if (dragTab_index > hoverTab_index) { if ((e.X - tcLocation.X) < (hoverTabRect.X + dragTabRect.Width)) { this.swapTabPages(tc, dragTab, hoverTab); } } } else { this.swapTabPages(tc, dragTab, hoverTab); } // select new pos of dragTab tc.SelectedIndex = tc.TabPages.IndexOf(dragTab); }