From c4242a3b702e10d0b15b1cf885bd80f6d9b7ef5d Mon Sep 17 00:00:00 2001 From: Wombat Date: Sat, 10 May 2025 16:20:05 +0200 Subject: [PATCH] =?UTF-8?q?Projektdateien=20hinzuf=C3=BCgen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PlaylistManager.sln | 25 + PlaylistManager/Mp3File.cs | 41 ++ PlaylistManager/PlaylistManager.csproj | 16 + PlaylistManager/Program.cs | 17 + PlaylistManager/Settings.cs | 47 ++ PlaylistManager/XLSX.cs | 238 +++++++ PlaylistManager/frmList.Designer.cs | 155 +++++ PlaylistManager/frmList.cs | 21 + PlaylistManager/frmList.resx | 120 ++++ PlaylistManager/frmMain.Designer.cs | 567 ++++++++++++++++ PlaylistManager/frmMain.cs | 658 +++++++++++++++++++ PlaylistManager/frmMain.resx | 156 +++++ PlaylistManager/frmPathSelect.Designer.cs | 110 ++++ PlaylistManager/frmPathSelect.cs | 20 + PlaylistManager/frmPathSelect.resx | 120 ++++ PlaylistManager/frmPlaylistAdapt.Designer.cs | 298 +++++++++ PlaylistManager/frmPlaylistAdapt.cs | 167 +++++ PlaylistManager/frmPlaylistAdapt.resx | 132 ++++ PlaylistManager/frmProgress.Designer.cs | 89 +++ PlaylistManager/frmProgress.cs | 32 + PlaylistManager/frmProgress.resx | 120 ++++ 21 files changed, 3149 insertions(+) create mode 100644 PlaylistManager.sln create mode 100644 PlaylistManager/Mp3File.cs create mode 100644 PlaylistManager/PlaylistManager.csproj create mode 100644 PlaylistManager/Program.cs create mode 100644 PlaylistManager/Settings.cs create mode 100644 PlaylistManager/XLSX.cs create mode 100644 PlaylistManager/frmList.Designer.cs create mode 100644 PlaylistManager/frmList.cs create mode 100644 PlaylistManager/frmList.resx create mode 100644 PlaylistManager/frmMain.Designer.cs create mode 100644 PlaylistManager/frmMain.cs create mode 100644 PlaylistManager/frmMain.resx create mode 100644 PlaylistManager/frmPathSelect.Designer.cs create mode 100644 PlaylistManager/frmPathSelect.cs create mode 100644 PlaylistManager/frmPathSelect.resx create mode 100644 PlaylistManager/frmPlaylistAdapt.Designer.cs create mode 100644 PlaylistManager/frmPlaylistAdapt.cs create mode 100644 PlaylistManager/frmPlaylistAdapt.resx create mode 100644 PlaylistManager/frmProgress.Designer.cs create mode 100644 PlaylistManager/frmProgress.cs create mode 100644 PlaylistManager/frmProgress.resx diff --git a/PlaylistManager.sln b/PlaylistManager.sln new file mode 100644 index 0000000..a06886a --- /dev/null +++ b/PlaylistManager.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.13.35931.197 d17.13 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlaylistManager", "PlaylistManager\PlaylistManager.csproj", "{6174059F-8EC8-401E-A215-AC4B4168645B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6174059F-8EC8-401E-A215-AC4B4168645B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6174059F-8EC8-401E-A215-AC4B4168645B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6174059F-8EC8-401E-A215-AC4B4168645B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6174059F-8EC8-401E-A215-AC4B4168645B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4E1D6FBA-00C7-48FF-ABFD-33013DF4FE1A} + EndGlobalSection +EndGlobal diff --git a/PlaylistManager/Mp3File.cs b/PlaylistManager/Mp3File.cs new file mode 100644 index 0000000..9ce1714 --- /dev/null +++ b/PlaylistManager/Mp3File.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TagLib; + +namespace PlaylistManager +{ + internal class Mp3File + { + + internal string Filename { get; set; } = null!; + // Tag-Parameter + internal string Title { get; set; } = null!; + internal string? Artist { get; set; } + internal string? Album { get; set; } + internal uint? Year { get; set; } + internal string? Genre { get; set; } + internal long Length { get; set; } + internal byte[]? Cover { get; set; } + + internal uint? Track { get; set; } + + public static Mp3File FromFile(string filename) + { + var mp3file = TagLib.File.Create(filename); + Mp3File song = new(); + song.Filename= filename; + song.Title = mp3file.Tag.Title; + song.Artist = mp3file.Tag.FirstPerformer; + song.Album = mp3file.Tag.Album; + song.Track = mp3file.Tag.Track; + if (mp3file.Tag.Year > 0) song.Year = mp3file.Tag.Year; + song.Genre = mp3file.Tag.FirstGenre; + song.Length = mp3file.Length; + song.Cover = mp3file.Tag.Pictures.Where(p => p.Type == PictureType.FrontCover).FirstOrDefault()?.Data.ToArray(); + return song; + } + } +} diff --git a/PlaylistManager/PlaylistManager.csproj b/PlaylistManager/PlaylistManager.csproj new file mode 100644 index 0000000..78fb6b3 --- /dev/null +++ b/PlaylistManager/PlaylistManager.csproj @@ -0,0 +1,16 @@ + + + + WinExe + net8.0-windows + enable + true + enable + + + + + + + + \ No newline at end of file diff --git a/PlaylistManager/Program.cs b/PlaylistManager/Program.cs new file mode 100644 index 0000000..d641aca --- /dev/null +++ b/PlaylistManager/Program.cs @@ -0,0 +1,17 @@ +namespace PlaylistManager +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new frmMain()); + } + } +} \ No newline at end of file diff --git a/PlaylistManager/Settings.cs b/PlaylistManager/Settings.cs new file mode 100644 index 0000000..0534ee4 --- /dev/null +++ b/PlaylistManager/Settings.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.IO; + +namespace PlaylistManager +{ + public class Settings + { + public List ReplacePathList = new(); + + internal void Save(string Filename) + { + string json = JsonSerializer.Serialize(this); + File.WriteAllText(Filename, json); + + } + + internal static Settings Load(string Filename) + { + Settings? result; + if (File.Exists(Filename)) + { + string json = File.ReadAllText(Filename); + result = JsonSerializer.Deserialize(json); + } + else + { + result = new Settings(); + } + if (result == null) throw new Exception($"Invalid content for settingsfile in '{Filename}'"); + return result; + } + + } + + public class ReplacePathItem + { + internal string OriginalPath { get; set; } = null!; + internal string ReplacePath { get; set; } = null!; + + } +} diff --git a/PlaylistManager/XLSX.cs b/PlaylistManager/XLSX.cs new file mode 100644 index 0000000..52d4564 --- /dev/null +++ b/PlaylistManager/XLSX.cs @@ -0,0 +1,238 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DocumentFormat.OpenXml; +using DocumentFormat.OpenXml.Packaging; +using DocumentFormat.OpenXml.Spreadsheet; +using Font = DocumentFormat.OpenXml.Spreadsheet.Font; +using X14 = DocumentFormat.OpenXml.Office2010.Excel; +using X15 = DocumentFormat.OpenXml.Office2013.Excel; +using X18 = DocumentFormat.OpenXml.Office2021.Excel; + +namespace PlaylistManager +{ + internal class XLSX + { + internal static void Serialize(string filename, DataTable table) + { + if (table == null) throw new Exception("Data was empty"); + + using (SpreadsheetDocument document = SpreadsheetDocument.Create(filename, SpreadsheetDocumentType.Workbook)) + { + FillDocument(document, table); + } + } + + internal static string Serialize(DataTable table) + { + if (table == null) throw new Exception("Data was empty"); + + MemoryStream ms = new MemoryStream(); + using (SpreadsheetDocument document = SpreadsheetDocument.Create(ms, SpreadsheetDocumentType.Workbook)) + { + FillDocument(document, table); + } + ms.Seek(0, SeekOrigin.Begin); + return Encoding.UTF8.GetString(ms.ToArray()); + } + + private static SpreadsheetDocument FillDocument(SpreadsheetDocument document, DataTable table) + { + + + // Create Content + SheetData sheetData = new SheetData(); + Row xlrow = new Row(); + foreach (DataColumn col in table.Columns) + { + xlrow.Append(CreateCell(col.ColumnName, 2U)); + } + sheetData.Append(xlrow); + + foreach (DataRow row in table.Rows) + { + xlrow = new Row(); + foreach (DataColumn col in table.Columns) + { + xlrow.Append(CreateCell(row[col.ColumnName], col.DataType)); + } + sheetData.Append(xlrow); + } + + // Generate WorksheetPart Content + Worksheet worksheet1 = new Worksheet() { MCAttributes = new MarkupCompatibilityAttributes() { Ignorable = "x14ac" } }; + worksheet1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); + worksheet1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006"); + worksheet1.AddNamespaceDeclaration("x14ac", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"); + worksheet1.Append(sheetData); + + WorkbookPart workbookPart1 = document.AddWorkbookPart(); + workbookPart1.Workbook = new Workbook(); + workbookPart1.Workbook.Sheets = new Sheets(new Sheet() { Name = "Sheet1", SheetId = (UInt32Value)1U, Id = "rId1" }); + + WorkbookStylesPart workbookStylesPart1 = workbookPart1.AddNewPart("rId3"); + workbookStylesPart1.Stylesheet = CreateStylesheet(); + + WorksheetPart worksheetPart1 = workbookPart1.AddNewPart("rId1"); + worksheetPart1.Worksheet = worksheet1; + document.Save(); + return document; + } + + private static Cell CreateCell(string Text, uint StyleIndex = 0U) + { + return CreateCell(Text, typeof(string), StyleIndex); + } + + private static Cell CreateCell(object? value, Type type, uint StyleIndex = 0U) + { + Cell cell = new Cell(); + cell.StyleIndex = StyleIndex; + if (value == null || value == DBNull.Value) + { + cell.DataType = CellValues.String; + cell.CellValue = new CellValue(""); + } + else if (type == typeof(int) || type == typeof(uint)) + { + cell.DataType = CellValues.Number; + cell.CellValue = new CellValue((int)value); + } + else if (type == typeof(float) || type == typeof(double)) + { + cell.DataType = CellValues.Number; + cell.CellValue = new CellValue((double)value); + } + else if (type == typeof(decimal)) + { + cell.DataType = CellValues.Number; + cell.CellValue = new CellValue((decimal)value); + } + else if (type == typeof(bool) || type == typeof(Boolean)) + { + cell.DataType = CellValues.Boolean; + cell.CellValue = new CellValue((bool)value); + } + else if (type == typeof(DateTime) || type == typeof(DateOnly) || type == typeof(TimeOnly)) + { + cell.StyleIndex = 1U; // Style mit passendem Numberformat + cell.DataType = CellValues.Date; + cell.CellValue = new CellValue(((DateTime)value)); + } + else if (type == typeof(DateTimeOffset)) + { + cell.DataType = CellValues.Date; + cell.CellValue = new CellValue((DateTimeOffset)value); + } + else if (type == typeof(string) || type == typeof(String)) + { + cell.DataType = CellValues.String; + cell.CellValue = new CellValue((string)value); + } + else + { + throw new NotSupportedException($"Unsupported Column type: {type}"); + } + return cell; + } + + private static Stylesheet CreateStylesheet() + { + + uint iExcelIndex = 164; + Stylesheet stylesheet = new Stylesheet(); + + stylesheet.Fonts = new Fonts( + new Font() + { + Color = new() { Theme = (UInt32Value)1U }, + FontSize = new() { Val = 11D }, + FontName = new() { Val = "Calibri" }, + FontFamilyNumbering = new() { Val = 2 }, + FontScheme = new FontScheme() { Val = FontSchemeValues.Minor }, + }, + new Font() + { + Bold = new(), + Color = new() { Theme = (UInt32Value)1U }, + FontSize = new() { Val = 11D }, + FontName = new() { Val = "Calibri" }, + FontFamilyNumbering = new() { Val = 2 }, + FontScheme = new FontScheme() { Val = FontSchemeValues.Minor }, + } + ) + { KnownFonts = true }; + + stylesheet.Fills = new Fills(new Fill());// { Count = (UInt32Value)0U }; + + stylesheet.Borders = new Borders(new Border()); + + // ---- CELL STYLE FORMATS ---- + NumberingFormat nfDateTime = new NumberingFormat() + { + NumberFormatId = iExcelIndex++, + FormatCode = StringValue.FromString("yyyy-MM-dd HH:mm:ss"), + }; + + stylesheet.NumberingFormats = new NumberingFormats(nfDateTime); + + + stylesheet.CellStyleFormats = new CellStyleFormats( + new CellFormat() + { + NumberFormatId = (UInt32Value)0U, + FontId = (UInt32Value)0U, + BorderId = (UInt32Value)0U, + } + ); + + // ---- CELL FORMATS ---- + // NumberFormatID: https://github.com/closedxml/closedxml/wiki/NumberFormatId-Lookup-Table + stylesheet.CellFormats = new CellFormats( + new CellFormat() + { + NumberFormatId = (UInt32Value)0U, + FontId = (UInt32Value)0U, + BorderId = (UInt32Value)0U, + FormatId = (UInt32Value)0U + }, + + // Mit Datumsformat + new CellFormat() + { + NumberFormatId = nfDateTime.NumberFormatId, + FontId = (UInt32Value)0U, + BorderId = (UInt32Value)0U, + FormatId = (UInt32Value)0U + }, + + // Bold (Header) + new CellFormat() + { + NumberFormatId = (UInt32Value)0U, + FontId = (UInt32Value)1U, + BorderId = (UInt32Value)0U, + FormatId = (UInt32Value)0U, + ApplyFont = true + } + ); ; + + stylesheet.CellStyles = new CellStyles( + new CellStyle() + { + Name = "Normal", + FormatId = (UInt32Value)0U, + BuiltinId = (UInt32Value)0U + } + ); + + return stylesheet; + } + + + } +} diff --git a/PlaylistManager/frmList.Designer.cs b/PlaylistManager/frmList.Designer.cs new file mode 100644 index 0000000..e42ff98 --- /dev/null +++ b/PlaylistManager/frmList.Designer.cs @@ -0,0 +1,155 @@ +namespace PlaylistManager +{ + partial class frmList + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + splitContainer1 = new SplitContainer(); + lstGefunden = new ListBox(); + lblGefundeneDateien = new Label(); + lstNichtGefunden = new ListBox(); + lblNichtGefunden = new Label(); + panel1 = new Panel(); + btnOK = new Button(); + ((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit(); + splitContainer1.Panel1.SuspendLayout(); + splitContainer1.Panel2.SuspendLayout(); + splitContainer1.SuspendLayout(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // splitContainer1 + // + splitContainer1.Dock = DockStyle.Fill; + splitContainer1.FixedPanel = FixedPanel.Panel2; + splitContainer1.Location = new Point(0, 0); + splitContainer1.Name = "splitContainer1"; + splitContainer1.Orientation = Orientation.Horizontal; + // + // splitContainer1.Panel1 + // + splitContainer1.Panel1.Controls.Add(lstGefunden); + splitContainer1.Panel1.Controls.Add(lblGefundeneDateien); + // + // splitContainer1.Panel2 + // + splitContainer1.Panel2.Controls.Add(lstNichtGefunden); + splitContainer1.Panel2.Controls.Add(lblNichtGefunden); + splitContainer1.Size = new Size(692, 464); + splitContainer1.SplitterDistance = 316; + splitContainer1.TabIndex = 0; + // + // lstGefunden + // + lstGefunden.Dock = DockStyle.Fill; + lstGefunden.FormattingEnabled = true; + lstGefunden.ItemHeight = 15; + lstGefunden.Location = new Point(0, 15); + lstGefunden.Name = "lstGefunden"; + lstGefunden.Size = new Size(692, 301); + lstGefunden.TabIndex = 1; + // + // lblGefundeneDateien + // + lblGefundeneDateien.AutoSize = true; + lblGefundeneDateien.Dock = DockStyle.Top; + lblGefundeneDateien.Location = new Point(0, 0); + lblGefundeneDateien.Name = "lblGefundeneDateien"; + lblGefundeneDateien.Size = new Size(108, 15); + lblGefundeneDateien.TabIndex = 0; + lblGefundeneDateien.Text = "Gefundene Dateien"; + // + // lstNichtGefunden + // + lstNichtGefunden.Dock = DockStyle.Fill; + lstNichtGefunden.FormattingEnabled = true; + lstNichtGefunden.ItemHeight = 15; + lstNichtGefunden.Location = new Point(0, 15); + lstNichtGefunden.Name = "lstNichtGefunden"; + lstNichtGefunden.Size = new Size(692, 129); + lstNichtGefunden.TabIndex = 2; + // + // lblNichtGefunden + // + lblNichtGefunden.AutoSize = true; + lblNichtGefunden.Dock = DockStyle.Top; + lblNichtGefunden.Location = new Point(0, 0); + lblNichtGefunden.Name = "lblNichtGefunden"; + lblNichtGefunden.Size = new Size(376, 15); + lblNichtGefunden.TabIndex = 1; + lblNichtGefunden.Text = "Nicht gefunden Dateien (Diese Dateien können nicht kopiert werden!):"; + // + // panel1 + // + panel1.Controls.Add(btnOK); + panel1.Dock = DockStyle.Bottom; + panel1.Location = new Point(0, 414); + panel1.Name = "panel1"; + panel1.Size = new Size(692, 50); + panel1.TabIndex = 1; + // + // btnOK + // + btnOK.Anchor = AnchorStyles.Bottom; + btnOK.DialogResult = DialogResult.OK; + btnOK.Location = new Point(237, 6); + btnOK.Name = "btnOK"; + btnOK.Size = new Size(219, 32); + btnOK.TabIndex = 0; + btnOK.Text = "Vorhandene Dateien jetzt kopieren!"; + btnOK.UseVisualStyleBackColor = true; + // + // frmList + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(692, 464); + Controls.Add(panel1); + Controls.Add(splitContainer1); + Name = "frmList"; + Text = "Gefundene Lieder"; + splitContainer1.Panel1.ResumeLayout(false); + splitContainer1.Panel1.PerformLayout(); + splitContainer1.Panel2.ResumeLayout(false); + splitContainer1.Panel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)splitContainer1).EndInit(); + splitContainer1.ResumeLayout(false); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private SplitContainer splitContainer1; + private Label lblGefundeneDateien; + private Label lblNichtGefunden; + private Panel panel1; + private Button btnOK; + internal ListBox lstGefunden; + internal ListBox lstNichtGefunden; + } +} \ No newline at end of file diff --git a/PlaylistManager/frmList.cs b/PlaylistManager/frmList.cs new file mode 100644 index 0000000..918bdd3 --- /dev/null +++ b/PlaylistManager/frmList.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PlaylistManager +{ + public partial class frmList : Form + { + public frmList() + { + InitializeComponent(); + } + + } +} diff --git a/PlaylistManager/frmList.resx b/PlaylistManager/frmList.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/PlaylistManager/frmList.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PlaylistManager/frmMain.Designer.cs b/PlaylistManager/frmMain.Designer.cs new file mode 100644 index 0000000..35afad2 --- /dev/null +++ b/PlaylistManager/frmMain.Designer.cs @@ -0,0 +1,567 @@ +namespace PlaylistManager +{ + partial class frmMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + tcMain = new TabControl(); + tpExtract = new TabPage(); + chkExtractSortFiles = new CheckBox(); + btnExtractTargetfolder = new Button(); + txtExtractTargetfolder = new TextBox(); + lblExtractTargetfolder = new Label(); + btnExtractPlaylist = new Button(); + txtExtractPlaylist = new TextBox(); + lblExtractPlaylistOpen = new LinkLabel(); + lblExtractPlaylist = new Label(); + tpChangepath = new TabPage(); + splCPPlaylists = new SplitContainer(); + lstCPPlaylists = new ListBox(); + cmsCPPlaylists = new ContextMenuStrip(components); + dateiÖffnenToolStripMenuItem = new ToolStripMenuItem(); + dateiHinzufügenToolStripMenuItem = new ToolStripMenuItem(); + ausListeEntfernenToolStripMenuItem = new ToolStripMenuItem(); + lblCPPlaylists = new Label(); + splCPReplacePaths = new SplitContainer(); + dgvRep = new DataGridView(); + colOriginalPath = new DataGridViewTextBoxColumn(); + colOriginalPathBrowse = new DataGridViewButtonColumn(); + colReplaceTo = new DataGridViewTextBoxColumn(); + colReplaceToBrowse = new DataGridViewButtonColumn(); + dgvFoundPaths = new DataGridView(); + colPLPathPath = new DataGridViewTextBoxColumn(); + colPLPathLength = new DataGridViewTextBoxColumn(); + colPLPathMatchcount = new DataGridViewTextBoxColumn(); + colPLPathMatchresult = new DataGridViewCheckBoxColumn(); + lblRepPlaylistpaths = new Label(); + tpList = new TabPage(); + chkListPossibilities = new CheckedListBox(); + lblListPossibilities = new Label(); + btnList = new Button(); + txtList = new TextBox(); + lblListFolder = new Label(); + panBottom = new Panel(); + btnOK = new Button(); + FBD = new FolderBrowserDialog(); + OFD = new OpenFileDialog(); + SFD = new SaveFileDialog(); + tcMain.SuspendLayout(); + tpExtract.SuspendLayout(); + tpChangepath.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)splCPPlaylists).BeginInit(); + splCPPlaylists.Panel1.SuspendLayout(); + splCPPlaylists.Panel2.SuspendLayout(); + splCPPlaylists.SuspendLayout(); + cmsCPPlaylists.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)splCPReplacePaths).BeginInit(); + splCPReplacePaths.Panel1.SuspendLayout(); + splCPReplacePaths.Panel2.SuspendLayout(); + splCPReplacePaths.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dgvRep).BeginInit(); + ((System.ComponentModel.ISupportInitialize)dgvFoundPaths).BeginInit(); + tpList.SuspendLayout(); + panBottom.SuspendLayout(); + SuspendLayout(); + // + // tcMain + // + tcMain.Controls.Add(tpExtract); + tcMain.Controls.Add(tpChangepath); + tcMain.Controls.Add(tpList); + tcMain.Dock = DockStyle.Fill; + tcMain.Location = new Point(10, 10); + tcMain.Name = "tcMain"; + tcMain.SelectedIndex = 0; + tcMain.Size = new Size(582, 425); + tcMain.TabIndex = 0; + // + // tpExtract + // + tpExtract.Controls.Add(chkExtractSortFiles); + tpExtract.Controls.Add(btnExtractTargetfolder); + tpExtract.Controls.Add(txtExtractTargetfolder); + tpExtract.Controls.Add(lblExtractTargetfolder); + tpExtract.Controls.Add(btnExtractPlaylist); + tpExtract.Controls.Add(txtExtractPlaylist); + tpExtract.Controls.Add(lblExtractPlaylistOpen); + tpExtract.Controls.Add(lblExtractPlaylist); + tpExtract.Location = new Point(4, 24); + tpExtract.Name = "tpExtract"; + tpExtract.Padding = new Padding(3); + tpExtract.Size = new Size(574, 397); + tpExtract.TabIndex = 0; + tpExtract.Text = "Playlist extrahieren"; + tpExtract.UseVisualStyleBackColor = true; + // + // chkExtractSortFiles + // + chkExtractSortFiles.AutoSize = true; + chkExtractSortFiles.Checked = true; + chkExtractSortFiles.CheckState = CheckState.Checked; + chkExtractSortFiles.Location = new Point(6, 116); + chkExtractSortFiles.Name = "chkExtractSortFiles"; + chkExtractSortFiles.Size = new Size(176, 19); + chkExtractSortFiles.TabIndex = 6; + chkExtractSortFiles.Text = "Lieder nach Playlist sortieren"; + chkExtractSortFiles.UseVisualStyleBackColor = true; + // + // btnExtractTargetfolder + // + btnExtractTargetfolder.Anchor = AnchorStyles.Top | AnchorStyles.Right; + btnExtractTargetfolder.Location = new Point(452, 87); + btnExtractTargetfolder.Name = "btnExtractTargetfolder"; + btnExtractTargetfolder.Size = new Size(116, 23); + btnExtractTargetfolder.TabIndex = 4; + btnExtractTargetfolder.Text = "Durchsuchen"; + btnExtractTargetfolder.UseVisualStyleBackColor = true; + btnExtractTargetfolder.Click += btnMP3_Click; + // + // txtExtractTargetfolder + // + txtExtractTargetfolder.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + txtExtractTargetfolder.Location = new Point(6, 87); + txtExtractTargetfolder.Name = "txtExtractTargetfolder"; + txtExtractTargetfolder.Size = new Size(440, 23); + txtExtractTargetfolder.TabIndex = 5; + // + // lblExtractTargetfolder + // + lblExtractTargetfolder.AutoSize = true; + lblExtractTargetfolder.Location = new Point(6, 69); + lblExtractTargetfolder.Name = "lblExtractTargetfolder"; + lblExtractTargetfolder.Size = new Size(151, 15); + lblExtractTargetfolder.TabIndex = 3; + lblExtractTargetfolder.Text = "Zielordner für MP3-Dateien"; + // + // btnExtractPlaylist + // + btnExtractPlaylist.Anchor = AnchorStyles.Top | AnchorStyles.Right; + btnExtractPlaylist.Location = new Point(452, 25); + btnExtractPlaylist.Name = "btnExtractPlaylist"; + btnExtractPlaylist.Size = new Size(116, 23); + btnExtractPlaylist.TabIndex = 1; + btnExtractPlaylist.Text = "Durchsuchen"; + btnExtractPlaylist.UseVisualStyleBackColor = true; + btnExtractPlaylist.Click += btnPlaylist_Click; + // + // txtExtractPlaylist + // + txtExtractPlaylist.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + txtExtractPlaylist.Location = new Point(6, 25); + txtExtractPlaylist.Name = "txtExtractPlaylist"; + txtExtractPlaylist.Size = new Size(440, 23); + txtExtractPlaylist.TabIndex = 2; + // + // lblExtractPlaylistOpen + // + lblExtractPlaylistOpen.AutoSize = true; + lblExtractPlaylistOpen.Location = new Point(63, 6); + lblExtractPlaylistOpen.Name = "lblExtractPlaylistOpen"; + lblExtractPlaylistOpen.Size = new Size(94, 15); + lblExtractPlaylistOpen.TabIndex = 1; + lblExtractPlaylistOpen.TabStop = true; + lblExtractPlaylistOpen.Text = "Datei anschauen"; + lblExtractPlaylistOpen.LinkClicked += lblPlaylistOpen_LinkClicked; + // + // lblExtractPlaylist + // + lblExtractPlaylist.AutoSize = true; + lblExtractPlaylist.Location = new Point(6, 6); + lblExtractPlaylist.Name = "lblExtractPlaylist"; + lblExtractPlaylist.Size = new Size(44, 15); + lblExtractPlaylist.TabIndex = 0; + lblExtractPlaylist.Text = "Playlist"; + // + // tpChangepath + // + tpChangepath.Controls.Add(splCPPlaylists); + tpChangepath.Location = new Point(4, 24); + tpChangepath.Name = "tpChangepath"; + tpChangepath.Padding = new Padding(3); + tpChangepath.Size = new Size(574, 397); + tpChangepath.TabIndex = 1; + tpChangepath.Text = "Pfade ändern"; + tpChangepath.UseVisualStyleBackColor = true; + // + // splCPPlaylists + // + splCPPlaylists.Dock = DockStyle.Fill; + splCPPlaylists.Location = new Point(3, 3); + splCPPlaylists.Name = "splCPPlaylists"; + splCPPlaylists.Orientation = Orientation.Horizontal; + // + // splCPPlaylists.Panel1 + // + splCPPlaylists.Panel1.Controls.Add(lstCPPlaylists); + splCPPlaylists.Panel1.Controls.Add(lblCPPlaylists); + // + // splCPPlaylists.Panel2 + // + splCPPlaylists.Panel2.Controls.Add(splCPReplacePaths); + splCPPlaylists.Size = new Size(568, 391); + splCPPlaylists.SplitterDistance = 179; + splCPPlaylists.TabIndex = 0; + // + // lstCPPlaylists + // + lstCPPlaylists.AllowDrop = true; + lstCPPlaylists.ContextMenuStrip = cmsCPPlaylists; + lstCPPlaylists.Dock = DockStyle.Fill; + lstCPPlaylists.FormattingEnabled = true; + lstCPPlaylists.ItemHeight = 15; + lstCPPlaylists.Location = new Point(0, 20); + lstCPPlaylists.Name = "lstCPPlaylists"; + lstCPPlaylists.Size = new Size(568, 159); + lstCPPlaylists.TabIndex = 1; + lstCPPlaylists.DoubleClick += lstCPPlaylists_DoubleClick; + // + // cmsCPPlaylists + // + cmsCPPlaylists.Items.AddRange(new ToolStripItem[] { dateiÖffnenToolStripMenuItem, dateiHinzufügenToolStripMenuItem, ausListeEntfernenToolStripMenuItem }); + cmsCPPlaylists.Name = "cmsCPPlaylists"; + cmsCPPlaylists.Size = new Size(204, 70); + // + // dateiÖffnenToolStripMenuItem + // + dateiÖffnenToolStripMenuItem.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point, 0); + dateiÖffnenToolStripMenuItem.Name = "dateiÖffnenToolStripMenuItem"; + dateiÖffnenToolStripMenuItem.Size = new Size(203, 22); + dateiÖffnenToolStripMenuItem.Text = "Datei öffnen"; + dateiÖffnenToolStripMenuItem.Click += DateiÖffnenToolStripMenuItem_Click; + // + // dateiHinzufügenToolStripMenuItem + // + dateiHinzufügenToolStripMenuItem.Name = "dateiHinzufügenToolStripMenuItem"; + dateiHinzufügenToolStripMenuItem.Size = new Size(203, 22); + dateiHinzufügenToolStripMenuItem.Text = "Datei hinzufügen"; + dateiHinzufügenToolStripMenuItem.Click += DateiHinzufügenToolStripMenuItem_Click; + // + // ausListeEntfernenToolStripMenuItem + // + ausListeEntfernenToolStripMenuItem.Name = "ausListeEntfernenToolStripMenuItem"; + ausListeEntfernenToolStripMenuItem.ShortcutKeys = Keys.Delete; + ausListeEntfernenToolStripMenuItem.Size = new Size(203, 22); + ausListeEntfernenToolStripMenuItem.Text = "Aus Liste entfernen"; + ausListeEntfernenToolStripMenuItem.Click += AusListeEntfernenToolStripMenuItem_Click; + // + // lblCPPlaylists + // + lblCPPlaylists.Dock = DockStyle.Top; + lblCPPlaylists.Location = new Point(0, 0); + lblCPPlaylists.Name = "lblCPPlaylists"; + lblCPPlaylists.Size = new Size(568, 20); + lblCPPlaylists.TabIndex = 0; + lblCPPlaylists.Text = "Zu ändernde Playlists"; + // + // splCPReplacePaths + // + splCPReplacePaths.Dock = DockStyle.Fill; + splCPReplacePaths.Location = new Point(0, 0); + splCPReplacePaths.Name = "splCPReplacePaths"; + // + // splCPReplacePaths.Panel1 + // + splCPReplacePaths.Panel1.Controls.Add(dgvRep); + // + // splCPReplacePaths.Panel2 + // + splCPReplacePaths.Panel2.Controls.Add(dgvFoundPaths); + splCPReplacePaths.Panel2.Controls.Add(lblRepPlaylistpaths); + splCPReplacePaths.Size = new Size(568, 208); + splCPReplacePaths.SplitterDistance = 298; + splCPReplacePaths.TabIndex = 0; + // + // dgvRep + // + dgvRep.BackgroundColor = SystemColors.Window; + dgvRep.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dgvRep.Columns.AddRange(new DataGridViewColumn[] { colOriginalPath, colOriginalPathBrowse, colReplaceTo, colReplaceToBrowse }); + dgvRep.Dock = DockStyle.Fill; + dgvRep.Location = new Point(0, 0); + dgvRep.Name = "dgvRep"; + dgvRep.Size = new Size(298, 208); + dgvRep.TabIndex = 0; + dgvRep.CellContentClick += dgvRep_CellContentClick; + dgvRep.CellValueChanged += dgvRep_CellValueChanged; + // + // colOriginalPath + // + colOriginalPath.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + colOriginalPath.DataPropertyName = "originalpath"; + colOriginalPath.HeaderText = "Ursprungspfad"; + colOriginalPath.Name = "colOriginalPath"; + // + // colOriginalPathBrowse + // + colOriginalPathBrowse.HeaderText = ""; + colOriginalPathBrowse.Name = "colOriginalPathBrowse"; + colOriginalPathBrowse.Width = 20; + // + // colReplaceTo + // + colReplaceTo.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + colReplaceTo.DataPropertyName = "replacepath"; + colReplaceTo.HeaderText = "Neuer Pfad"; + colReplaceTo.Name = "colReplaceTo"; + // + // colReplaceToBrowse + // + colReplaceToBrowse.HeaderText = ""; + colReplaceToBrowse.Name = "colReplaceToBrowse"; + colReplaceToBrowse.Width = 20; + // + // dgvFoundPaths + // + dgvFoundPaths.BackgroundColor = SystemColors.Window; + dgvFoundPaths.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dgvFoundPaths.Columns.AddRange(new DataGridViewColumn[] { colPLPathPath, colPLPathLength, colPLPathMatchcount, colPLPathMatchresult }); + dgvFoundPaths.Dock = DockStyle.Fill; + dgvFoundPaths.Location = new Point(0, 20); + dgvFoundPaths.Name = "dgvFoundPaths"; + dgvFoundPaths.Size = new Size(266, 188); + dgvFoundPaths.TabIndex = 0; + dgvFoundPaths.CellDoubleClick += dgvFoundPaths_CellDoubleClick; + // + // colPLPathPath + // + colPLPathPath.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + colPLPathPath.DataPropertyName = "Path"; + colPLPathPath.HeaderText = "Pfad"; + colPLPathPath.Name = "colPLPathPath"; + colPLPathPath.ReadOnly = true; + // + // colPLPathLength + // + colPLPathLength.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCellsExceptHeader; + colPLPathLength.DataPropertyName = "Length"; + colPLPathLength.HeaderText = "Pfadlänge"; + colPLPathLength.Name = "colPLPathLength"; + colPLPathLength.ReadOnly = true; + colPLPathLength.Visible = false; + // + // colPLPathMatchcount + // + colPLPathMatchcount.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader; + colPLPathMatchcount.DataPropertyName = "Matchcount"; + colPLPathMatchcount.HeaderText = "Ersetzungsübereinstimmungen"; + colPLPathMatchcount.Name = "colPLPathMatchcount"; + colPLPathMatchcount.ReadOnly = true; + colPLPathMatchcount.Visible = false; + // + // colPLPathMatchresult + // + colPLPathMatchresult.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCellsExceptHeader; + colPLPathMatchresult.DataPropertyName = "Matchresult"; + colPLPathMatchresult.HeaderText = "Sicherheitsüberprüfung"; + colPLPathMatchresult.Name = "colPLPathMatchresult"; + colPLPathMatchresult.ReadOnly = true; + colPLPathMatchresult.Width = 21; + // + // lblRepPlaylistpaths + // + lblRepPlaylistpaths.Dock = DockStyle.Top; + lblRepPlaylistpaths.Location = new Point(0, 0); + lblRepPlaylistpaths.Name = "lblRepPlaylistpaths"; + lblRepPlaylistpaths.Size = new Size(266, 20); + lblRepPlaylistpaths.TabIndex = 1; + lblRepPlaylistpaths.Text = "Gefundene Pfade in Playlist"; + // + // tpList + // + tpList.Controls.Add(chkListPossibilities); + tpList.Controls.Add(lblListPossibilities); + tpList.Controls.Add(btnList); + tpList.Controls.Add(txtList); + tpList.Controls.Add(lblListFolder); + tpList.Location = new Point(4, 24); + tpList.Name = "tpList"; + tpList.Padding = new Padding(3); + tpList.Size = new Size(574, 397); + tpList.TabIndex = 2; + tpList.Text = "Tracklist erzeugen"; + tpList.UseVisualStyleBackColor = true; + // + // chkListPossibilities + // + chkListPossibilities.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + chkListPossibilities.CheckOnClick = true; + chkListPossibilities.FormattingEnabled = true; + chkListPossibilities.IntegralHeight = false; + chkListPossibilities.Items.AddRange(new object[] { "Titelnr.", "Dateiname", "Titel", "Interpret - Titel" }); + chkListPossibilities.Location = new Point(6, 79); + chkListPossibilities.Name = "chkListPossibilities"; + chkListPossibilities.Size = new Size(562, 310); + chkListPossibilities.TabIndex = 7; + // + // lblListPossibilities + // + lblListPossibilities.AutoSize = true; + lblListPossibilities.Location = new Point(6, 61); + lblListPossibilities.Name = "lblListPossibilities"; + lblListPossibilities.Size = new Size(156, 15); + lblListPossibilities.TabIndex = 6; + lblListPossibilities.Text = "Aufzulistende Eigenschaften"; + // + // btnList + // + btnList.Anchor = AnchorStyles.Top | AnchorStyles.Right; + btnList.Location = new Point(452, 22); + btnList.Name = "btnList"; + btnList.Size = new Size(116, 23); + btnList.TabIndex = 4; + btnList.Text = "Durchsuchen"; + btnList.UseVisualStyleBackColor = true; + btnList.Click += btnList_Click; + // + // txtList + // + txtList.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + txtList.Location = new Point(6, 23); + txtList.Name = "txtList"; + txtList.Size = new Size(440, 23); + txtList.TabIndex = 5; + // + // lblListFolder + // + lblListFolder.AutoSize = true; + lblListFolder.Location = new Point(6, 3); + lblListFolder.Name = "lblListFolder"; + lblListFolder.Size = new Size(44, 15); + lblListFolder.TabIndex = 3; + lblListFolder.Text = "Ordner"; + // + // panBottom + // + panBottom.BackColor = Color.Transparent; + panBottom.Controls.Add(btnOK); + panBottom.Dock = DockStyle.Bottom; + panBottom.Location = new Point(10, 435); + panBottom.Name = "panBottom"; + panBottom.Size = new Size(582, 48); + panBottom.TabIndex = 1; + // + // btnOK + // + btnOK.Anchor = AnchorStyles.Bottom; + btnOK.Location = new Point(233, 13); + btnOK.Name = "btnOK"; + btnOK.Size = new Size(116, 23); + btnOK.TabIndex = 0; + btnOK.Text = "Vorgang starten"; + btnOK.UseVisualStyleBackColor = true; + btnOK.Click += btnOK_Click; + // + // OFD + // + OFD.Filter = "Playlists (*.m3u, *.m3u8)|*.m3u;*.m3u8|Alle Dateien (*.*)|*.*"; + // + // SFD + // + SFD.Filter = "Playlist (*.m3u, *.m3u8)|*.m3u;*.m3u8|Alle Dateien (*.*)|*.*"; + // + // frmMain + // + AllowDrop = true; + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(602, 493); + Controls.Add(tcMain); + Controls.Add(panBottom); + Name = "frmMain"; + Padding = new Padding(10); + Text = "Playlist-Manager"; + FormClosing += frmMain_FormClosing; + Load += frmMain_Load; + DragDrop += frmMain_DragDrop; + DragEnter += frmMain_DragEnter; + tcMain.ResumeLayout(false); + tpExtract.ResumeLayout(false); + tpExtract.PerformLayout(); + tpChangepath.ResumeLayout(false); + splCPPlaylists.Panel1.ResumeLayout(false); + splCPPlaylists.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)splCPPlaylists).EndInit(); + splCPPlaylists.ResumeLayout(false); + cmsCPPlaylists.ResumeLayout(false); + splCPReplacePaths.Panel1.ResumeLayout(false); + splCPReplacePaths.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)splCPReplacePaths).EndInit(); + splCPReplacePaths.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dgvRep).EndInit(); + ((System.ComponentModel.ISupportInitialize)dgvFoundPaths).EndInit(); + tpList.ResumeLayout(false); + tpList.PerformLayout(); + panBottom.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private TabControl tcMain; + private TabPage tpExtract; + private TabPage tpChangepath; + private TabPage tpList; + private Panel panBottom; + private Button btnOK; + private CheckBox chkExtractSortFiles; + private Button btnExtractTargetfolder; + private TextBox txtExtractTargetfolder; + private Label lblExtractTargetfolder; + private Button btnExtractPlaylist; + private TextBox txtExtractPlaylist; + private LinkLabel lblExtractPlaylistOpen; + private Label lblExtractPlaylist; + private FolderBrowserDialog FBD; + private OpenFileDialog OFD; + private SaveFileDialog SFD; + private ContextMenuStrip cmsCPPlaylists; + private ToolStripMenuItem dateiÖffnenToolStripMenuItem; + private ToolStripMenuItem dateiHinzufügenToolStripMenuItem; + private ToolStripMenuItem ausListeEntfernenToolStripMenuItem; + private SplitContainer splCPPlaylists; + private SplitContainer splCPReplacePaths; + private ListBox lstCPPlaylists; + private Label lblCPPlaylists; + private DataGridView dgvRep; + private DataGridView dgvFoundPaths; + private Label lblRepPlaylistpaths; + private CheckedListBox chkListPossibilities; + private Label lblListPossibilities; + private Button btnList; + private TextBox txtList; + private Label lblListFolder; + private DataGridViewTextBoxColumn colOriginalPath; + private DataGridViewButtonColumn colOriginalPathBrowse; + private DataGridViewTextBoxColumn colReplaceTo; + private DataGridViewButtonColumn colReplaceToBrowse; + private DataGridViewTextBoxColumn colPLPathPath; + private DataGridViewTextBoxColumn colPLPathLength; + private DataGridViewTextBoxColumn colPLPathMatchcount; + private DataGridViewCheckBoxColumn colPLPathMatchresult; + } +} diff --git a/PlaylistManager/frmMain.cs b/PlaylistManager/frmMain.cs new file mode 100644 index 0000000..e74bc2e --- /dev/null +++ b/PlaylistManager/frmMain.cs @@ -0,0 +1,658 @@ +using Microsoft.VisualBasic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics; +using System.DirectoryServices.ActiveDirectory; +using System.IO; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Security.Cryptography; + +namespace PlaylistManager +{ + public partial class frmMain : Form + { + + private DataTable dtReplacePaths = null!; + private DataTable dtPLPaths = null!; + private DataView dvPLPaths = null!; + + private System.Text.Encoding Enc = System.Text.Encoding.UTF8; + + private string settingsfile = Application.StartupPath + @"\settings.json"; + private Settings settings = null!; + + + public enum SortType + { + [Description("Titel")] + Title, + [Description("Titelnr.")] + TitleNo, + [Description("Dateiname")] + Filename, + [Description("Künstler")] + Artist + } + + public frmMain() + { + InitializeComponent(); + } + + private void frmMain_Load(object sender, EventArgs e) + { + Text += " v." + Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? ""; + + prepareReplacePath(); + + settings = Settings.Load(settingsfile); + + /* TODO ERROR: Skipped IfDirectiveTrivia + #If DEBUG Then + */ + txtList.Text = @"D:\Privat\Mixed"; + SFD.FileName = "test.xls"; + /* TODO ERROR: Skipped EndIfDirectiveTrivia + #End If + */ + } + + private void btnPlaylist_Click(object sender, EventArgs e) + { + if (OFD.ShowDialog() == DialogResult.OK) + { + string prevPlaylistFolder = GetPlaylistFolderName(txtExtractPlaylist.Text); + txtExtractPlaylist.Text = OFD.FileName; + + if (txtExtractTargetfolder.Text == "" || txtExtractTargetfolder.Text == prevPlaylistFolder) txtExtractTargetfolder.Text = GetPlaylistFolderName(OFD.FileName); + } + } + + /// + /// Generiert einen Ordnernamen der dem Namen der Playlist entspricht, als Zielordner-Vorschlag + /// + /// + /// + private string GetPlaylistFolderName(string playlistfile) + { + return Path.Combine(Path.GetDirectoryName(playlistfile) ?? "", Path.GetFileNameWithoutExtension(playlistfile)); + } + + private void lblPlaylistOpen_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + OpenFile(txtExtractPlaylist.Text); + } + + private void OpenFile(string datei) + { + if (File.Exists(datei)) + { + Process.Start("notepad.exe", datei); + } + + } + + + private void frmMain_FormClosing(object sender, FormClosingEventArgs e) + { + settings.Save(settingsfile); + } + + private void frmMain_DragEnter(object sender, DragEventArgs e) + { + if (e.Data == null) return; + if (e.Data.GetDataPresent(DataFormats.FileDrop)) + { + switch (tcMain.SelectedTab?.Name ?? "") + { + case var @case when @case == (tpExtract.Name ?? ""): + { + e.Effect = DragDropEffects.Copy; + break; + } + case var case1 when case1 == (tpChangepath.Name ?? ""): + { + e.Effect = DragDropEffects.Copy; + break; + } + + default: + { + e.Effect = DragDropEffects.None; + break; + } + } + + } + } + + private void frmMain_DragDrop(object sender, DragEventArgs e) + { + if (e.Data == null) return; + if (e.Data.GetDataPresent(DataFormats.FileDrop)) + { + string[]? files = (string[]?)e.Data.GetData(DataFormats.FileDrop); + if (files == null) return; + switch (tcMain.SelectedTab?.Name ?? "") + { + case var @case when @case == (tpExtract.Name ?? ""): + { + foreach (string datei in files) + { + if (datei.EndsWith(".m3u8") | datei.EndsWith(".m3u") | datei.EndsWith("bak")) // beim letzten kein Punkt is absicht, da die backupdateien mit .m3ubak und .m3u8bak enden! + { + txtExtractPlaylist.Text = datei; + break; + } + } + + break; + } + case var case1 when case1 == (tpChangepath.Name ?? ""): + { + foreach (string datei in files) + { + if (datei.EndsWith(".m3u8") | datei.EndsWith(".m3u") | datei.EndsWith("bak")) // beim letzten kein Punkt is absicht, da die backupdateien mit .m3ubak und .m3u8bak enden! + { + lstCPPlaylists.Items.Add(datei); + } + } + readPlaylistpaths(); + break; + } + } + + + } + } + + + private void btnOK_Click(object sender, EventArgs e) + { + switch (tcMain.SelectedTab?.Name ?? "") + { + case var @case when @case == (tpExtract.Name ?? ""): + { + ExtractPlaylist(txtExtractPlaylist.Text, txtExtractTargetfolder.Text); + break; + } + case var case1 when case1 == (tpChangepath.Name ?? ""): + { + ChangePaths(); + break; + } + case var case2 when case2 == (tpList.Name ?? ""): + { + CreateTracklist(); + break; + } + } + + } + + + #region Playlist extrahieren + private void btnMP3_Click(object sender, EventArgs e) + { + if (FBD.ShowDialog() == DialogResult.OK) + { + txtExtractTargetfolder.Text = FBD.SelectedPath; + } + } + + + private void ExtractPlaylist(string PlaylistFile, string TargetFolder) + { + if (!TargetFolder.EndsWith("\\")) TargetFolder += "\\"; + + try + { + if (!Directory.Exists(TargetFolder)) Directory.CreateDirectory(TargetFolder); + } + catch (Exception ex) + { + MessageBox.Show($"Unable to create folder '{TargetFolder}':\r\n{ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + var sr = new StreamReader(PlaylistFile, Enc); + string? line; + string alternativePath; + var frm = new frmList(); + + while (sr.EndOfStream == false) + { + line = sr.ReadLine(); + + if (line is not null & line.Substring(0, 1) != "#") + { + alternativePath = Path.GetDirectoryName(PlaylistFile) ?? ""; + if (alternativePath.LastIndexOf(@"\") < alternativePath.Length - 1) + alternativePath += @"\"; + alternativePath += line; + + if (File.Exists(line)) + { + frm.lstGefunden.Items.Add(line); + } + else if (File.Exists(alternativePath)) + { + frm.lstGefunden.Items.Add(alternativePath); + } + else + { + frm.lstNichtGefunden.Items.Add(line); + } + + } + } + sr.Close(); + sr = null; + + int i = 1; + if (frm.ShowDialog() == DialogResult.OK) + { + var frm2 = new frmProgress(); + string datei; + frm2.prgStatus.Maximum = frm.lstGefunden.Items.Count; + frm2.prgStatus.Value = 0; + frm2.Show(); + Application.DoEvents(); + foreach (string itm in frm.lstGefunden.Items) + { + if (frm2.cancelled == false) + { + datei = Path.GetFileName(itm); + frm2.lblFile.Text = datei; + if (chkExtractSortFiles.Checked) + { + File.Copy(itm, TargetFolder + Strings.Format(i, "000") + "." + datei, true); + i += 1; + } + else + { + File.Copy(itm, TargetFolder + datei, true); + } + frm2.prgStatus.PerformStep(); + Application.DoEvents(); + } + else + { + Application.DoEvents(); + break; + } + } + frm2.Close(); + } + } + + + #endregion + + + #region Pfad ändern + + private void prepareReplacePath() + { + dtReplacePaths = new DataTable(); + { + var withBlock = dtReplacePaths.Columns; + withBlock.Add("originalpath", typeof(string)); + withBlock.Add("replacepath", typeof(string)); + } + dgvRep.DataSource = dtReplacePaths; + + dtPLPaths = new DataTable(); + { + var withBlock1 = dtPLPaths.Columns; + withBlock1.Add("Path", typeof(string)); + withBlock1.Add("Length", typeof(int)); + withBlock1.Add("Matchcount", typeof(int)); + withBlock1.Add("Matchresult", typeof(bool)); + } + dvPLPaths = new DataView(dtPLPaths); + dvPLPaths.Sort = "Matchresult, Matchcount, Length, Path"; + dgvFoundPaths.DataSource = dvPLPaths; + } + + private void readPlaylistpaths() + { + dtPLPaths.Rows.Clear(); + DataRow dr; + foreach (string datei in lstCPPlaylists.Items) + { + if (File.Exists(datei)) + { + var sr = new StreamReader(datei, Enc); + string? line; + bool lineexists; + while (!sr.EndOfStream) + { + line = sr.ReadLine(); + if (line == null) break; + if (line.StartsWith("#") == false & line.Trim().Length > 0) + { + line = Path.GetDirectoryName(line); + lineexists = false; + foreach (DataRow row in dtPLPaths.Rows) + { + if ((string)row["Path"] == line) + { + lineexists = true; + break; + } + } + if (lineexists == false) + { + dr = dtPLPaths.NewRow(); + dr["Path"] = line; + dr["Length"] = line.Length; + dr["Matchcount"] = 0; + dr["Matchresult"] = false; + dtPLPaths.Rows.Add(dr); + } + } + } + sr.Close(); + + + } + } + checkMatches(); + } + + private void checkMatches() + { + if (dgvFoundPaths.DataSource is DataView) + { + dgvFoundPaths.EndEdit(); + DataView dv; + dv = (DataView)dgvFoundPaths.DataSource; + + // Matchcount clearen + foreach (DataRowView pathrow in dv) + { + pathrow["Matchcount"] = 0; + pathrow["Matchresult"] = false; + } + + foreach (DataRowView pathrow in dv) + { + foreach (DataRow replrow in dtReplacePaths.Rows) + { + if (replrow["originalpath"] == DBNull.Value) continue; + string origpath = (string)replrow["originalpath"]; + string path = (string)pathrow["path"]; + if (path.ToLower().StartsWith(origpath.ToLower())) + { + pathrow["Matchcount"] = (int)pathrow["Matchcount"] + 1; + } + + } + } + + + // Matchresult überprüfen + // 0 = Keinen Ersetzungspfad gefunden, evtl ist er ja schon korrekt (einer der neuen Pfade?) + // 1 = Genau ein Ergebnis gefunden, passt - wird so ersetzt + // >1 =Mehr als ein Ersetzergebnis - Ersetzliste kontrollieren + foreach (DataRowView row in dv) + { + switch ((int)row["Matchcount"]) + { + case 0: + { + // Neue Pfade überprüfen. Evtl müssen die Pfade ja nicht ersetzt werden, weil es schon Replace-Pfade sind. + foreach (DataRow replrow in dtReplacePaths.Rows) + { + if (replrow["replacepath"] == DBNull.Value) continue; + string replpath = (string)replrow["replacepath"]; + string path = (string)row["Path"]; + if (replpath.Trim().Length > 0) + { + if (path.ToLower().StartsWith(replpath.ToLower())) + { + row["Matchresult"] = true; + break; + } + } + + } + + break; + } + // Matchresult wurde oben schon auf false gesetzt, deshalb hier nicht mehr nötig + case 1: + { + row["Matchresult"] = true; + break; + } + + default: + { + row["Matchresult"] = false; + break; + } + } + } + + } + + + } + + private void dgvRep_CellContentClick(object sender, DataGridViewCellEventArgs e) + { + DataGridView grd = (DataGridView)sender; + if (grd.Columns[e.ColumnIndex] is DataGridViewButtonColumn & e.RowIndex >= 0) + { + if (FBD.ShowDialog() == DialogResult.OK) + { + string path = FBD.SelectedPath; + if (!path.EndsWith("\\")) path += "\\"; + switch (grd.Columns[e.ColumnIndex].Name ?? "") + { + case var @case when @case == colOriginalPathBrowse.Name: + { + grd.Rows[e.RowIndex].Cells[colOriginalPath.Name].Value = path; + break; + } + case var case1 when case1 == colReplaceToBrowse.Name: + { + grd.Rows[e.RowIndex].Cells[colReplaceTo.Name].Value = path; + break; + } + } + } + + } + dtReplacePaths.AcceptChanges(); + + } + + private void dgvRep_CellValueChanged(object sender, DataGridViewCellEventArgs e) + { + checkMatches(); + } + + + + private void ChangePaths() + { + dtReplacePaths.AcceptChanges(); + var notfoundplaylists = new List(); + foreach (string playlistfile in lstCPPlaylists.Items) + { + if (File.Exists(playlistfile)) + { + + // Backup anlegen + string backupfile = Path.GetDirectoryName(playlistfile) + @"\" + Path.GetFileNameWithoutExtension(playlistfile) + "_" + DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss") + Path.GetExtension(playlistfile) + "bak"; + File.Copy(playlistfile, backupfile, true); + + // Erst alle Einträge einlesen + string? line; + var lines = new List(); + var reader = new StreamReader(playlistfile, Enc); + while (reader.EndOfStream == false) + { + line = reader.ReadLine(); + if (line == null) break; + char CommentChar = Convert.ToChar("#"); + if (line[0] != CommentChar) + { + // Jeden Replace-Eintrag durchgehen bis der erste passende gefunden wurde + foreach (DataRow row in dtReplacePaths.Rows) + { + if (row["originalpath"] == DBNull.Value) continue; + string origpath = (string)row["originalpath"]; + string replpath = row["replacepath"] == DBNull.Value ? "" : (string)row["replacepath"]; + if (line.ToLower().StartsWith(origpath.ToLower())) + { + line = line.Replace(origpath, replpath); + break; + } + } + + } + lines.Add(line); + } + reader.Close(); + + // Dann alle Einträge reinschreiben + var writer = new StreamWriter(playlistfile, false, Enc); + foreach (string readline in lines) + writer.WriteLine(readline); + writer.Close(); + } + else + { + notfoundplaylists.Add(playlistfile); + } + } + + if (notfoundplaylists.Count > 0) + { + MessageBox.Show($"Eine oder mehrere Playlistdateien wurden nicht gefunden: {Constants.vbCrLf} {string.Join(Constants.vbCrLf, notfoundplaylists.ToArray())}"); + } + else + { + MessageBox.Show("Vorgang erfolgreich abgeschlossen"); + } + } + + private void dgvFoundPaths_CellDoubleClick(object sender, DataGridViewCellEventArgs e) + { + dtReplacePaths.AcceptChanges(); + + string pathToAdd = (string)dgvFoundPaths.SelectedCells[0].Value; + foreach (DataRow row in dtReplacePaths.Rows) + { + if (row["originalpath"] == DBNull.Value) continue; + string origpath = (string)row["originalpath"]; + if (pathToAdd.ToLower().StartsWith(origpath.ToLower())) + { + // Der Pfad, der durch doppelklick hinuzgefügt werden soll, existiert bereits in einer Form in ReplacePaths + return; + } + + } + + var dr = dtReplacePaths.NewRow(); + dr["originalpath"] = pathToAdd.Trim(); + dtReplacePaths.Rows.Add(dr); + + + } + + #endregion + + #region Tracklist erzeugen + + private void btnList_Click(object sender, EventArgs e) + { + if (FBD.ShowDialog() == DialogResult.OK) + { + txtList.Text = FBD.SelectedPath; + } + } + + private void CreateTracklist() + { + SFD.Title = "Neue Tracklist speichern"; + SFD.Filter = "Excel-Dateien (*.xls, *.xlsx)|*.xlsx;*.xls|Alle Dateien (*.*)|*.*"; + SFD.InitialDirectory = txtList.Text; + if (SFD.ShowDialog() == DialogResult.OK) + { + // Dateien auslesen + var mp3list = new List(); + + foreach (string datei in Directory.GetFiles(txtList.Text, "*.mp3", SearchOption.TopDirectoryOnly)) + mp3list.Add(Mp3File.FromFile(datei)); + + DataTable dtTracklist = new DataTable(); + dtTracklist.Columns.Add("Title"); + dtTracklist.Columns.Add("TitleNo"); + dtTracklist.Columns.Add("Interpret"); + dtTracklist.Columns.Add("Filename"); + + DataRow dr; + foreach (Mp3File mp3 in mp3list) + { + dr = dtTracklist.NewRow(); + dr["TitleNo"] = mp3.Track; + dr["Title"] = mp3.Title; + dr["Interpret"] = mp3.Artist; + dr["Filename"] = mp3.Filename; + dtTracklist.Rows.Add(dr); + } + + XLSX.Serialize(SFD.FileName, dtTracklist); + + MessageBox.Show("Vorgang abgeschlossen"); + } + } + + private void lstCPPlaylists_DoubleClick(object sender, EventArgs e) + { + if (lstCPPlaylists.SelectedItem is not null) + { + OpenFile((string)lstCPPlaylists.SelectedItem); + } + } + + private void DateiHinzufügenToolStripMenuItem_Click(object sender, EventArgs e) + { + if (OFD.ShowDialog() == DialogResult.OK) + { + lstCPPlaylists.Items.Add(OFD.FileName); + readPlaylistpaths(); + } + } + + private void AusListeEntfernenToolStripMenuItem_Click(object sender, EventArgs e) + { + if (lstCPPlaylists.SelectedItems.Count > 0) + { + foreach (string itm in lstCPPlaylists.SelectedItems) + lstCPPlaylists.Items.Remove(itm); + readPlaylistpaths(); + } + } + + private void DateiÖffnenToolStripMenuItem_Click(object sender, EventArgs e) + { + if (lstCPPlaylists.SelectedItem is not null) + { + OpenFile((string)lstCPPlaylists.SelectedItem); + } + } + + + + #endregion + + + } +} diff --git a/PlaylistManager/frmMain.resx b/PlaylistManager/frmMain.resx new file mode 100644 index 0000000..916562a --- /dev/null +++ b/PlaylistManager/frmMain.resx @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 458, 17 + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + True + + + 17, 17 + + + 184, 17 + + + 323, 17 + + \ No newline at end of file diff --git a/PlaylistManager/frmPathSelect.Designer.cs b/PlaylistManager/frmPathSelect.Designer.cs new file mode 100644 index 0000000..a11056e --- /dev/null +++ b/PlaylistManager/frmPathSelect.Designer.cs @@ -0,0 +1,110 @@ +namespace PlaylistManager +{ + partial class frmPathSelect + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + lblPath = new Label(); + txtPath = new TextBox(); + btnPathBrowse = new Button(); + btnOK = new Button(); + btnCancel = new Button(); + SuspendLayout(); + // + // lblPath + // + lblPath.AutoSize = true; + lblPath.Location = new Point(12, 16); + lblPath.Name = "lblPath"; + lblPath.Size = new Size(31, 15); + lblPath.TabIndex = 0; + lblPath.Text = "Pfad"; + // + // txtPath + // + txtPath.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + txtPath.Location = new Point(65, 12); + txtPath.Name = "txtPath"; + txtPath.Size = new Size(360, 23); + txtPath.TabIndex = 1; + // + // btnPathBrowse + // + btnPathBrowse.Anchor = AnchorStyles.Top | AnchorStyles.Right; + btnPathBrowse.Location = new Point(431, 12); + btnPathBrowse.Name = "btnPathBrowse"; + btnPathBrowse.Size = new Size(27, 23); + btnPathBrowse.TabIndex = 2; + btnPathBrowse.Text = "..."; + btnPathBrowse.UseVisualStyleBackColor = true; + // + // btnOK + // + btnOK.Anchor = AnchorStyles.Bottom; + btnOK.Location = new Point(157, 42); + btnOK.Name = "btnOK"; + btnOK.Size = new Size(75, 23); + btnOK.TabIndex = 3; + btnOK.Text = "OK"; + btnOK.UseVisualStyleBackColor = true; + // + // btnCancel + // + btnCancel.Anchor = AnchorStyles.Bottom; + btnCancel.Location = new Point(238, 42); + btnCancel.Name = "btnCancel"; + btnCancel.Size = new Size(75, 23); + btnCancel.TabIndex = 4; + btnCancel.Text = "Abbrechen"; + btnCancel.UseVisualStyleBackColor = true; + // + // frmPathSelect + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(470, 76); + Controls.Add(btnCancel); + Controls.Add(btnOK); + Controls.Add(btnPathBrowse); + Controls.Add(txtPath); + Controls.Add(lblPath); + FormBorderStyle = FormBorderStyle.SizableToolWindow; + Name = "frmPathSelect"; + Text = "Pfad"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label lblPath; + private Button btnPathBrowse; + private Button btnOK; + private Button btnCancel; + internal TextBox txtPath; + } +} \ No newline at end of file diff --git a/PlaylistManager/frmPathSelect.cs b/PlaylistManager/frmPathSelect.cs new file mode 100644 index 0000000..cb0d435 --- /dev/null +++ b/PlaylistManager/frmPathSelect.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PlaylistManager +{ + public partial class frmPathSelect : Form + { + public frmPathSelect() + { + InitializeComponent(); + } + } +} diff --git a/PlaylistManager/frmPathSelect.resx b/PlaylistManager/frmPathSelect.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/PlaylistManager/frmPathSelect.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PlaylistManager/frmPlaylistAdapt.Designer.cs b/PlaylistManager/frmPlaylistAdapt.Designer.cs new file mode 100644 index 0000000..fbc65b6 --- /dev/null +++ b/PlaylistManager/frmPlaylistAdapt.Designer.cs @@ -0,0 +1,298 @@ +namespace PlaylistManager +{ + partial class frmPlaylistAdapt + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + grpSettings = new GroupBox(); + splSettings = new SplitContainer(); + lstMusicFolders = new ListView(); + chFolder = new ColumnHeader(); + cmsMusicFolder = new ContextMenuStrip(components); + menMusicFolderAdd = new ToolStripMenuItem(); + menMusicFolderRemove = new ToolStripMenuItem(); + lblMusicFolders = new Label(); + lstReplaceFolders = new ListView(); + columnHeader1 = new ColumnHeader(); + cmsReplaceFolders = new ContextMenuStrip(components); + menReplaceFolderAdd = new ToolStripMenuItem(); + menReplaceFolderRemove = new ToolStripMenuItem(); + lblReplaceFolders = new Label(); + btnLoadPlaylist = new Button(); + splMain = new SplitContainer(); + listView1 = new ListView(); + chPLBefore = new ColumnHeader(); + chPLAfter = new ColumnHeader(); + OFD = new OpenFileDialog(); + FBD = new FolderBrowserDialog(); + grpSettings.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)splSettings).BeginInit(); + splSettings.Panel1.SuspendLayout(); + splSettings.Panel2.SuspendLayout(); + splSettings.SuspendLayout(); + cmsMusicFolder.SuspendLayout(); + cmsReplaceFolders.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)splMain).BeginInit(); + splMain.Panel1.SuspendLayout(); + splMain.Panel2.SuspendLayout(); + splMain.SuspendLayout(); + SuspendLayout(); + // + // grpSettings + // + grpSettings.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + grpSettings.Controls.Add(splSettings); + grpSettings.Location = new Point(3, 3); + grpSettings.Name = "grpSettings"; + grpSettings.Size = new Size(626, 164); + grpSettings.TabIndex = 0; + grpSettings.TabStop = false; + grpSettings.Text = "Einstellungen"; + // + // splSettings + // + splSettings.Dock = DockStyle.Fill; + splSettings.Location = new Point(3, 19); + splSettings.Name = "splSettings"; + // + // splSettings.Panel1 + // + splSettings.Panel1.Controls.Add(lstMusicFolders); + splSettings.Panel1.Controls.Add(lblMusicFolders); + // + // splSettings.Panel2 + // + splSettings.Panel2.Controls.Add(lstReplaceFolders); + splSettings.Panel2.Controls.Add(lblReplaceFolders); + splSettings.Size = new Size(620, 142); + splSettings.SplitterDistance = 301; + splSettings.TabIndex = 0; + // + // lstMusicFolders + // + lstMusicFolders.Columns.AddRange(new ColumnHeader[] { chFolder }); + lstMusicFolders.ContextMenuStrip = cmsMusicFolder; + lstMusicFolders.Dock = DockStyle.Fill; + lstMusicFolders.Location = new Point(0, 15); + lstMusicFolders.Name = "lstMusicFolders"; + lstMusicFolders.Size = new Size(301, 127); + lstMusicFolders.TabIndex = 2; + lstMusicFolders.UseCompatibleStateImageBehavior = false; + lstMusicFolders.View = View.Details; + // + // chFolder + // + chFolder.Text = "Ordner"; + chFolder.Width = 180; + // + // cmsMusicFolder + // + cmsMusicFolder.Items.AddRange(new ToolStripItem[] { menMusicFolderAdd, menMusicFolderRemove }); + cmsMusicFolder.Name = "cmsMusicFolder"; + cmsMusicFolder.Size = new Size(184, 48); + // + // menMusicFolderAdd + // + menMusicFolderAdd.Name = "menMusicFolderAdd"; + menMusicFolderAdd.Size = new Size(183, 22); + menMusicFolderAdd.Text = "Ordner hinzufügen..."; + menMusicFolderAdd.Click += menMusicFolderAdd_Click; + // + // menMusicFolderRemove + // + menMusicFolderRemove.Name = "menMusicFolderRemove"; + menMusicFolderRemove.Size = new Size(183, 22); + menMusicFolderRemove.Text = "Ordner entfernen"; + menMusicFolderRemove.Click += menMusicFolderRemove_Click; + // + // lblMusicFolders + // + lblMusicFolders.AutoSize = true; + lblMusicFolders.Dock = DockStyle.Top; + lblMusicFolders.Location = new Point(0, 0); + lblMusicFolders.Name = "lblMusicFolders"; + lblMusicFolders.Size = new Size(140, 15); + lblMusicFolders.TabIndex = 1; + lblMusicFolders.Text = "Musik-Stammverzeichnis"; + // + // lstReplaceFolders + // + lstReplaceFolders.Columns.AddRange(new ColumnHeader[] { columnHeader1 }); + lstReplaceFolders.ContextMenuStrip = cmsReplaceFolders; + lstReplaceFolders.Dock = DockStyle.Fill; + lstReplaceFolders.Location = new Point(0, 15); + lstReplaceFolders.Name = "lstReplaceFolders"; + lstReplaceFolders.Size = new Size(315, 127); + lstReplaceFolders.TabIndex = 3; + lstReplaceFolders.UseCompatibleStateImageBehavior = false; + lstReplaceFolders.View = View.Details; + // + // columnHeader1 + // + columnHeader1.Text = "Ordner"; + columnHeader1.Width = 180; + // + // cmsReplaceFolders + // + cmsReplaceFolders.Items.AddRange(new ToolStripItem[] { menReplaceFolderAdd, menReplaceFolderRemove }); + cmsReplaceFolders.Name = "cmsMusicFolder"; + cmsReplaceFolders.Size = new Size(184, 48); + // + // menReplaceFolderAdd + // + menReplaceFolderAdd.Name = "menReplaceFolderAdd"; + menReplaceFolderAdd.Size = new Size(183, 22); + menReplaceFolderAdd.Text = "Ordner hinzufügen..."; + menReplaceFolderAdd.Click += menReplaceFolderAdd_Click; + // + // menReplaceFolderRemove + // + menReplaceFolderRemove.Name = "menReplaceFolderRemove"; + menReplaceFolderRemove.Size = new Size(183, 22); + menReplaceFolderRemove.Text = "Ordner entfernen"; + menReplaceFolderRemove.Click += menReplaceFolderRemove_Click; + // + // lblReplaceFolders + // + lblReplaceFolders.AutoSize = true; + lblReplaceFolders.Dock = DockStyle.Top; + lblReplaceFolders.Location = new Point(0, 0); + lblReplaceFolders.Name = "lblReplaceFolders"; + lblReplaceFolders.Size = new Size(113, 15); + lblReplaceFolders.TabIndex = 2; + lblReplaceFolders.Text = "Zu ersetzende Pfade"; + // + // btnLoadPlaylist + // + btnLoadPlaylist.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + btnLoadPlaylist.Location = new Point(7, 170); + btnLoadPlaylist.Name = "btnLoadPlaylist"; + btnLoadPlaylist.Size = new Size(139, 23); + btnLoadPlaylist.TabIndex = 1; + btnLoadPlaylist.Text = "Playlist einlesen"; + btnLoadPlaylist.UseVisualStyleBackColor = true; + btnLoadPlaylist.Click += btnLoadPlaylist_Click; + // + // splMain + // + splMain.Dock = DockStyle.Fill; + splMain.FixedPanel = FixedPanel.Panel1; + splMain.Location = new Point(0, 0); + splMain.Name = "splMain"; + splMain.Orientation = Orientation.Horizontal; + // + // splMain.Panel1 + // + splMain.Panel1.Controls.Add(grpSettings); + splMain.Panel1.Controls.Add(btnLoadPlaylist); + // + // splMain.Panel2 + // + splMain.Panel2.Controls.Add(listView1); + splMain.Size = new Size(632, 502); + splMain.SplitterDistance = 199; + splMain.TabIndex = 2; + // + // listView1 + // + listView1.Columns.AddRange(new ColumnHeader[] { chPLBefore, chPLAfter }); + listView1.Dock = DockStyle.Fill; + listView1.Location = new Point(0, 0); + listView1.Name = "listView1"; + listView1.Size = new Size(632, 299); + listView1.TabIndex = 3; + listView1.UseCompatibleStateImageBehavior = false; + listView1.View = View.Details; + // + // chPLBefore + // + chPLBefore.Text = "Vorher"; + chPLBefore.Width = 300; + // + // chPLAfter + // + chPLAfter.Text = "Nachher"; + chPLAfter.Width = 300; + // + // OFD + // + OFD.Filter = "Playlists (*.m3u)|*.m3u|Alle Dateien (*.*)|*.*"; + // + // FBD + // + FBD.ShowNewFolderButton = false; + // + // frmPlaylistAdapt + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(632, 502); + Controls.Add(splMain); + Name = "frmPlaylistAdapt"; + Text = "Playlistadapt"; + grpSettings.ResumeLayout(false); + splSettings.Panel1.ResumeLayout(false); + splSettings.Panel1.PerformLayout(); + splSettings.Panel2.ResumeLayout(false); + splSettings.Panel2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)splSettings).EndInit(); + splSettings.ResumeLayout(false); + cmsMusicFolder.ResumeLayout(false); + cmsReplaceFolders.ResumeLayout(false); + splMain.Panel1.ResumeLayout(false); + splMain.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)splMain).EndInit(); + splMain.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private GroupBox grpSettings; + private SplitContainer splSettings; + private ListView lstMusicFolders; + private ColumnHeader chFolder; + private Label lblMusicFolders; + private ListView lstReplaceFolders; + private ColumnHeader columnHeader1; + private Label lblReplaceFolders; + private Button btnLoadPlaylist; + private SplitContainer splMain; + private ContextMenuStrip cmsReplaceFolders; + private ToolStripMenuItem menReplaceFolderAdd; + private ToolStripMenuItem menReplaceFolderRemove; + private ListView listView1; + private ColumnHeader chPLBefore; + private ColumnHeader chPLAfter; + private OpenFileDialog OFD; + private FolderBrowserDialog FBD; + private ContextMenuStrip cmsMusicFolder; + private ToolStripMenuItem menMusicFolderAdd; + private ToolStripMenuItem menMusicFolderRemove; + } +} \ No newline at end of file diff --git a/PlaylistManager/frmPlaylistAdapt.cs b/PlaylistManager/frmPlaylistAdapt.cs new file mode 100644 index 0000000..ea44acd --- /dev/null +++ b/PlaylistManager/frmPlaylistAdapt.cs @@ -0,0 +1,167 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PlaylistManager +{ + public partial class frmPlaylistAdapt : Form + { + public frmPlaylistAdapt() + { + InitializeComponent(); + } + + #region Kontextmenü MusicFolder + + private void menMusicFolderAdd_Click(object sender, EventArgs e) + { + if (FBD.ShowDialog() == DialogResult.OK) + { + bool itmexists = false; + string ordner = FBD.SelectedPath; + if (ordner.EndsWith(@"\") == false) + ordner += @"\"; + + foreach (ListViewItem itm in lstMusicFolders.Items) + { + if ((itm.Text ?? "") == (ordner ?? "")) + { + itmexists = true; + break; + } + } + + if (itmexists == false) + { + var itm = new ListViewItem(ordner); + lstMusicFolders.Items.Add(itm); + } + + } + } + + private void menMusicFolderRemove_Click(object sender, EventArgs e) + { + if (lstMusicFolders.SelectedItems.Count > 0) + { + foreach (ListViewItem itm in lstMusicFolders.SelectedItems) + itm.Remove(); + } + } + + + #endregion + + + #region Kontextmenü Replace + + private void menReplaceFolderRemove_Click(object sender, EventArgs e) + { + if (lstReplaceFolders.SelectedItems.Count > 0) + { + foreach (ListViewItem itm in lstReplaceFolders.SelectedItems) + itm.Remove(); + } + } + + private void menReplaceFolderAdd_Click(object sender, EventArgs e) + { + var frm = new frmPathSelect(); + if (frm.ShowDialog() == DialogResult.OK) + { + bool itmexists = false; + string ordner = frm.txtPath.Text; + + if (ordner.EndsWith(@"\") == false) + ordner += @"\"; + foreach (ListViewItem itm in lstReplaceFolders.Items) + { + if ((itm.Text ?? "") == (ordner ?? "")) + { + itmexists = true; + break; + } + } + + if (itmexists == false) + { + var itm = new ListViewItem(ordner); + lstReplaceFolders.Items.Add(itm); + } + } + } + + + #endregion + + + private void btnLoadPlaylist_Click(object sender, EventArgs e) + { + if (OFD.ShowDialog() == DialogResult.OK) + { + var sr = new StreamReader(OFD.FileName, System.Text.Encoding.Default); + var pfade = new List(); + while (sr.EndOfStream == false) + pfade.Add(new PLLine(sr.ReadLine())); + sr.Close(); + + + string replacepath; + foreach (PLLine pfad in pfade) + { + if (pfad.IsPath & (pfad.Path ?? "") == (pfad.OriginalPath ?? "")) // Line ist Pfad und ist auch noch unverändert + { + replacepath = null; + foreach (ListViewItem replaceitm in lstReplaceFolders.Items) + { + if (pfad.Path.StartsWith(replaceitm.Text)) + { + replacepath = replaceitm.Text; // Zu ersetzenden Teil des Pfades gefunden + break; + } + } + + // pfad.path mit neuem Pfad versehen bis einer gefunden wurde der existiert oder keiner mehr übrig ist. + + } + } + + } + } + + private void frmPlaylistAdapt_Load(object sender, EventArgs e) + { + + } + } + + public class PLLine + { + private string line; + public string? OriginalPath; + public string? Path; + public bool IsPath; + + + public PLLine(string line) + { + this.line = line; + if (line.StartsWith("#") == false) + { + OriginalPath = line; + Path = line; + IsPath = true; + } + + } + + + } +} diff --git a/PlaylistManager/frmPlaylistAdapt.resx b/PlaylistManager/frmPlaylistAdapt.resx new file mode 100644 index 0000000..ec75664 --- /dev/null +++ b/PlaylistManager/frmPlaylistAdapt.resx @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 204, 9 + + + 343, 16 + + + 420, 16 + + \ No newline at end of file diff --git a/PlaylistManager/frmProgress.Designer.cs b/PlaylistManager/frmProgress.Designer.cs new file mode 100644 index 0000000..21cc1a4 --- /dev/null +++ b/PlaylistManager/frmProgress.Designer.cs @@ -0,0 +1,89 @@ +namespace PlaylistManager +{ + partial class frmProgress + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + lblFile = new Label(); + prgStatus = new ProgressBar(); + btnCancel = new Button(); + SuspendLayout(); + // + // lblFile + // + lblFile.AutoSize = true; + lblFile.Location = new Point(12, 9); + lblFile.Name = "lblFile"; + lblFile.Size = new Size(56, 15); + lblFile.TabIndex = 0; + lblFile.Text = "Kopiere..."; + // + // prgStatus + // + prgStatus.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + prgStatus.Location = new Point(12, 27); + prgStatus.Name = "prgStatus"; + prgStatus.Size = new Size(331, 23); + prgStatus.Step = 1; + prgStatus.TabIndex = 1; + // + // btnCancel + // + btnCancel.Anchor = AnchorStyles.Bottom; + btnCancel.Location = new Point(140, 62); + btnCancel.Name = "btnCancel"; + btnCancel.Size = new Size(75, 23); + btnCancel.TabIndex = 2; + btnCancel.Text = "Abbrechen"; + btnCancel.UseVisualStyleBackColor = true; + btnCancel.Click += btnCancel_Click; + // + // frmProgress + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(355, 97); + ControlBox = false; + Controls.Add(btnCancel); + Controls.Add(prgStatus); + Controls.Add(lblFile); + FormBorderStyle = FormBorderStyle.FixedToolWindow; + MaximizeBox = false; + MinimizeBox = false; + Name = "frmProgress"; + Text = "Kopiere Dateien..."; + Load += frmProgress_Load; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + private Button btnCancel; + internal ProgressBar prgStatus; + internal Label lblFile; + } +} \ No newline at end of file diff --git a/PlaylistManager/frmProgress.cs b/PlaylistManager/frmProgress.cs new file mode 100644 index 0000000..8ab1286 --- /dev/null +++ b/PlaylistManager/frmProgress.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace PlaylistManager +{ + public partial class frmProgress : Form + { + public bool cancelled; + public frmProgress() + { + InitializeComponent(); + } + + private void frmProgress_Load(object sender, EventArgs e) + { + + } + + private void btnCancel_Click(object sender, EventArgs e) + { + cancelled = true; + Application.DoEvents(); + } + } +} diff --git a/PlaylistManager/frmProgress.resx b/PlaylistManager/frmProgress.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/PlaylistManager/frmProgress.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file