From 2f48724ac679e1a62ce0a1860443ba9be4ce3c2f Mon Sep 17 00:00:00 2001 From: ddummy Date: Tue, 28 Jan 2014 17:52:15 +0400 Subject: [PATCH] first commit --- .gitignore | 29 + .tfignore | 1 + XeniumPlaylist.sln | 20 + XeniumPlaylist/App.config | 6 + XeniumPlaylist/InputBox.Designer.cs | 101 +++ XeniumPlaylist/InputBox.cs | 32 + XeniumPlaylist/InputBox.resx | 120 ++++ XeniumPlaylist/PlaylistModel.cs | 173 ++++++ XeniumPlaylist/PlaylistResource.Designer.cs | 99 +++ XeniumPlaylist/PlaylistResource.resx | 132 ++++ XeniumPlaylist/PlaylistResource.ru.resx | 132 ++++ XeniumPlaylist/Program.cs | 35 ++ XeniumPlaylist/Properties/AssemblyInfo.cs | 36 ++ .../Properties/Resources.Designer.cs | 63 ++ XeniumPlaylist/Properties/Resources.resx | 117 ++++ .../Properties/Settings.Designer.cs | 26 + XeniumPlaylist/Properties/Settings.settings | 7 + XeniumPlaylist/XeniumPlaylist.csproj | 113 ++++ XeniumPlaylist/frmPlaylist.Designer.cs | 219 +++++++ XeniumPlaylist/frmPlaylist.cs | 389 ++++++++++++ XeniumPlaylist/frmPlaylist.resx | 578 ++++++++++++++++++ XeniumPlaylist/frmPlaylist.ru.resx | 165 +++++ 22 files changed, 2593 insertions(+) create mode 100644 .gitignore create mode 100644 .tfignore create mode 100644 XeniumPlaylist.sln create mode 100644 XeniumPlaylist/App.config create mode 100644 XeniumPlaylist/InputBox.Designer.cs create mode 100644 XeniumPlaylist/InputBox.cs create mode 100644 XeniumPlaylist/InputBox.resx create mode 100644 XeniumPlaylist/PlaylistModel.cs create mode 100644 XeniumPlaylist/PlaylistResource.Designer.cs create mode 100644 XeniumPlaylist/PlaylistResource.resx create mode 100644 XeniumPlaylist/PlaylistResource.ru.resx create mode 100644 XeniumPlaylist/Program.cs create mode 100644 XeniumPlaylist/Properties/AssemblyInfo.cs create mode 100644 XeniumPlaylist/Properties/Resources.Designer.cs create mode 100644 XeniumPlaylist/Properties/Resources.resx create mode 100644 XeniumPlaylist/Properties/Settings.Designer.cs create mode 100644 XeniumPlaylist/Properties/Settings.settings create mode 100644 XeniumPlaylist/XeniumPlaylist.csproj create mode 100644 XeniumPlaylist/frmPlaylist.Designer.cs create mode 100644 XeniumPlaylist/frmPlaylist.cs create mode 100644 XeniumPlaylist/frmPlaylist.resx create mode 100644 XeniumPlaylist/frmPlaylist.ru.resx diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..176c449 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +Thumbs.db +*.obj +*.exe +*.pdb +*.user +*.aps +*.pch +*.vspscc +*_i.c +*_p.c +*.ncb +*.suo +*.sln.docstates +*.tlb +*.tlh +*.bak +*.cache +*.ilk +*.log +[Bb]in +[Dd]ebug*/ +*.lib +*.sbr +obj/ +[Rr]elease*/ +_ReSharper*/ +[Tt]est[Rr]esult* +*.vssscc +$tf*/ \ No newline at end of file diff --git a/.tfignore b/.tfignore new file mode 100644 index 0000000..e37a9f1 --- /dev/null +++ b/.tfignore @@ -0,0 +1 @@ +\.git \ No newline at end of file diff --git a/XeniumPlaylist.sln b/XeniumPlaylist.sln new file mode 100644 index 0000000..c0f23e4 --- /dev/null +++ b/XeniumPlaylist.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XeniumPlaylist", "XeniumPlaylist\XeniumPlaylist.csproj", "{C01C12AE-6129-460D-BA75-1A55B577581A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C01C12AE-6129-460D-BA75-1A55B577581A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C01C12AE-6129-460D-BA75-1A55B577581A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C01C12AE-6129-460D-BA75-1A55B577581A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C01C12AE-6129-460D-BA75-1A55B577581A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/XeniumPlaylist/App.config b/XeniumPlaylist/App.config new file mode 100644 index 0000000..58262a1 --- /dev/null +++ b/XeniumPlaylist/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/XeniumPlaylist/InputBox.Designer.cs b/XeniumPlaylist/InputBox.Designer.cs new file mode 100644 index 0000000..60bf21d --- /dev/null +++ b/XeniumPlaylist/InputBox.Designer.cs @@ -0,0 +1,101 @@ +namespace XeniumPlaylist +{ + partial class InputBox + { + /// + /// 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() + { + this.txtInput = new System.Windows.Forms.TextBox(); + this.lblInput = new System.Windows.Forms.Label(); + this.btnOk = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // txtInput + // + this.txtInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtInput.Location = new System.Drawing.Point(12, 33); + this.txtInput.Name = "txtInput"; + this.txtInput.Size = new System.Drawing.Size(468, 22); + this.txtInput.TabIndex = 1; + // + // lblInput + // + this.lblInput.AutoSize = true; + this.lblInput.Location = new System.Drawing.Point(8, 13); + this.lblInput.Name = "lblInput"; + this.lblInput.Size = new System.Drawing.Size(0, 17); + this.lblInput.TabIndex = 0; + // + // btnOk + // + this.btnOk.DialogResult = System.Windows.Forms.DialogResult.OK; + this.btnOk.Location = new System.Drawing.Point(100, 73); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(100, 26); + this.btnOk.TabIndex = 2; + this.btnOk.Text = "OK"; + this.btnOk.UseVisualStyleBackColor = true; + // + // btnCancel + // + this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(300, 73); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(100, 26); + this.btnCancel.TabIndex = 3; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + // + // InputBox + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(492, 117); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOk); + this.Controls.Add(this.lblInput); + this.Controls.Add(this.txtInput); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "InputBox"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox txtInput; + private System.Windows.Forms.Label lblInput; + private System.Windows.Forms.Button btnOk; + private System.Windows.Forms.Button btnCancel; + } +} \ No newline at end of file diff --git a/XeniumPlaylist/InputBox.cs b/XeniumPlaylist/InputBox.cs new file mode 100644 index 0000000..2255e6c --- /dev/null +++ b/XeniumPlaylist/InputBox.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 XeniumPlaylist +{ + public partial class InputBox : Form + { + public static string Show(string caption, string label, string text) + { + InputBox inputBox = new InputBox(); + inputBox.Text = caption; + inputBox.lblInput.Text = label; + inputBox.txtInput.Text = text; + if (inputBox.ShowDialog() == DialogResult.OK) + return inputBox.txtInput.Text; + else + return ""; + } + + public InputBox() + { + InitializeComponent(); + } + } +} diff --git a/XeniumPlaylist/InputBox.resx b/XeniumPlaylist/InputBox.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/XeniumPlaylist/InputBox.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/XeniumPlaylist/PlaylistModel.cs b/XeniumPlaylist/PlaylistModel.cs new file mode 100644 index 0000000..efeca1d --- /dev/null +++ b/XeniumPlaylist/PlaylistModel.cs @@ -0,0 +1,173 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +using System.Threading.Tasks; + +namespace XeniumPlaylist +{ + public class StringListFile + { + protected int blockSize; + + protected List items = new List(); + public List Items { get { return items; } } + + public StringListFile(int blockSize) + { + this.blockSize = blockSize; + } + + public void Load(string fileName) + { + items.Clear(); + + if (!File.Exists(fileName)) + return; + using (BinaryReader reader = new BinaryReader(File.Open(fileName, FileMode.Open))) + { + byte[] nameBuffer; + char[] charsToTrim = { '\0' }; + while ((nameBuffer = reader.ReadBytes(blockSize)).Length == blockSize) + { + string itemName = Encoding.Unicode.GetString(nameBuffer).TrimEnd(charsToTrim); + items.Add(itemName); + } + } + } + + public void Save(string fileName) + { + FileInfo fileInfo = new FileInfo(fileName); + FileAttributes fileAttributes = fileInfo.Attributes; + fileInfo.Attributes &= ~FileAttributes.Hidden; + try + { + using (BinaryWriter writer = new BinaryWriter(File.Open(fileName, FileMode.Create))) + { + foreach (string itemName in items) + { + byte[] nameBuffer = Encoding.Unicode.GetBytes(itemName); + Array.Resize(ref nameBuffer, blockSize); + writer.Write(nameBuffer); + } + } + } + finally + { + fileInfo.Attributes = fileAttributes; + } + } + } + + public class PlaylistSet + { + protected StringListFile stringListFile = new StringListFile(512); + protected string driveName = null; + + public List Items { get { return stringListFile.Items; } } + + public static string GetPlaylistSetFileName(string driveName) + { + return Path.Combine(driveName, "@playlist@", "audio_play_playlist_name.txt"); + } + + public void Load(string driveName) + { + this.driveName = driveName; + if (driveName != null) + { + stringListFile.Load(GetPlaylistSetFileName(driveName)); + Items.Sort(); + } + } + + public void Load() + { + Load(driveName); + } + + public void Save() + { + if (driveName != null) + stringListFile.Save(GetPlaylistSetFileName(driveName)); + } + + public void Add(string itemName) + { + if (driveName != null) + { + Items.Add(itemName); + Items.Sort(); + Save(); + + string fileName = Playlist.GetPlaylistFileName(driveName, itemName); + File.Create(fileName).Close(); + FileInfo fileInfo = new FileInfo(fileName); + fileInfo.Attributes |= FileAttributes.Hidden; + } + } + + public void Delete(int itemIndex) + { + if ((driveName != null) && (itemIndex >= 0)) + { + string itemName = Items[itemIndex]; + Items.RemoveAt(itemIndex); + Save(); + + string fileName = Playlist.GetPlaylistFileName(driveName, itemName); + if (File.Exists(fileName)) + File.Delete(fileName); + } + } + + public void Rename(int itemIndex, string itemName) + { + if ((driveName != null) && (itemIndex >= 0) && (!Items.Contains(itemName))) + { + string oldItemName = Items[itemIndex]; + + Items[itemIndex] = itemName; + Items.Sort(); + Save(); + + string oldFileName = Playlist.GetPlaylistFileName(driveName, oldItemName); + string fileName = Playlist.GetPlaylistFileName(driveName, itemName); + if (File.Exists(oldFileName)) + { + if (File.Exists(fileName)) + File.Delete(fileName); + File.Move(oldFileName, fileName); + } + } + } + } + + public class Playlist + { + protected StringListFile stringListFile = new StringListFile(522); + protected string driveName = null; + + public List Items { get { return stringListFile.Items; } } + + public static string GetPlaylistFileName(string driveName, string playlistName) + { + return Path.Combine(driveName, "@playlist@", playlistName + "00.txt"); + } + + public void Load(string driveName, string playlistName) + { + if (driveName != null) + //stringListFile.Load(Directory.GetFiles(Path.Combine(driveName, "@playlist@"), playlistName + "*.txt").First()); + stringListFile.Load(GetPlaylistFileName(driveName, playlistName)); + } + + public void Save(string driveName, string playlistName) + { + if (driveName != null) + stringListFile.Save(GetPlaylistFileName(driveName, playlistName)); + } + } +} diff --git a/XeniumPlaylist/PlaylistResource.Designer.cs b/XeniumPlaylist/PlaylistResource.Designer.cs new file mode 100644 index 0000000..dc2337a --- /dev/null +++ b/XeniumPlaylist/PlaylistResource.Designer.cs @@ -0,0 +1,99 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.1008 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace XeniumPlaylist { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class PlaylistResource { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal PlaylistResource() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("XeniumPlaylist.PlaylistResource", typeof(PlaylistResource).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Error. + /// + internal static string ErrorMessageBoxCaption { + get { + return ResourceManager.GetString("ErrorMessageBoxCaption", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to You should drag files from {0} drive!. + /// + internal static string PlaylistFileDragDropErrorText { + get { + return ResourceManager.GetString("PlaylistFileDragDropErrorText", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Playlist name:. + /// + internal static string PlaylistNamePrompt { + get { + return ResourceManager.GetString("PlaylistNamePrompt", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Are you sure to remove playlist?. + /// + internal static string PlaylistRemoveConfirmPrompt { + get { + return ResourceManager.GetString("PlaylistRemoveConfirmPrompt", resourceCulture); + } + } + } +} diff --git a/XeniumPlaylist/PlaylistResource.resx b/XeniumPlaylist/PlaylistResource.resx new file mode 100644 index 0000000..f502a3c --- /dev/null +++ b/XeniumPlaylist/PlaylistResource.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 + + + Error + + + You should drag files from {0} drive! + + + Playlist name: + + + Are you sure to remove playlist? + + \ No newline at end of file diff --git a/XeniumPlaylist/PlaylistResource.ru.resx b/XeniumPlaylist/PlaylistResource.ru.resx new file mode 100644 index 0000000..f3a1843 --- /dev/null +++ b/XeniumPlaylist/PlaylistResource.ru.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 + + + Ошибка + + + Вы должны перещить файлы с диска {0}! + + + Имя плейлиста: + + + Вы уверены, что хотите далить плейлист? + + \ No newline at end of file diff --git a/XeniumPlaylist/Program.cs b/XeniumPlaylist/Program.cs new file mode 100644 index 0000000..ae13492 --- /dev/null +++ b/XeniumPlaylist/Program.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Threading; +using System.Globalization; + +namespace XeniumPlaylist +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main(string[] args) + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + string cultureInfoName = (args.Length > 1 ? args[0] : null); + try + { + if (cultureInfoName != null) + Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureInfoName); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Error (check command line)", MessageBoxButtons.OK, MessageBoxIcon.Stop); + return; + } + Application.Run(new frmPlaylist()); + } + } +} diff --git a/XeniumPlaylist/Properties/AssemblyInfo.cs b/XeniumPlaylist/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4cb74cd --- /dev/null +++ b/XeniumPlaylist/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("XeniumPlaylist")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("XeniumPlaylist")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("98a69bb8-8990-4287-82f6-5786559c2a29")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/XeniumPlaylist/Properties/Resources.Designer.cs b/XeniumPlaylist/Properties/Resources.Designer.cs new file mode 100644 index 0000000..9e7d03b --- /dev/null +++ b/XeniumPlaylist/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.1008 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace XeniumPlaylist.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("XeniumPlaylist.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/XeniumPlaylist/Properties/Resources.resx b/XeniumPlaylist/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/XeniumPlaylist/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/XeniumPlaylist/Properties/Settings.Designer.cs b/XeniumPlaylist/Properties/Settings.Designer.cs new file mode 100644 index 0000000..d0e4a1f --- /dev/null +++ b/XeniumPlaylist/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.1008 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace XeniumPlaylist.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/XeniumPlaylist/Properties/Settings.settings b/XeniumPlaylist/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/XeniumPlaylist/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/XeniumPlaylist/XeniumPlaylist.csproj b/XeniumPlaylist/XeniumPlaylist.csproj new file mode 100644 index 0000000..ae839cc --- /dev/null +++ b/XeniumPlaylist/XeniumPlaylist.csproj @@ -0,0 +1,113 @@ + + + + + Debug + AnyCPU + {C01C12AE-6129-460D-BA75-1A55B577581A} + WinExe + Properties + XeniumPlaylist + XeniumPlaylist + v4.0 + 512 + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + Form + + + InputBox.cs + + + Form + + + frmPlaylist.cs + + + + True + True + PlaylistResource.resx + + + + + frmPlaylist.cs + + + InputBox.cs + + + frmPlaylist.cs + + + ResXFileCodeGenerator + PlaylistResource.Designer.cs + + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + \ No newline at end of file diff --git a/XeniumPlaylist/frmPlaylist.Designer.cs b/XeniumPlaylist/frmPlaylist.Designer.cs new file mode 100644 index 0000000..6ea1f81 --- /dev/null +++ b/XeniumPlaylist/frmPlaylist.Designer.cs @@ -0,0 +1,219 @@ +namespace XeniumPlaylist +{ + partial class frmPlaylist + { + /// + /// 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() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmPlaylist)); + this.dlgAudioFolder = new System.Windows.Forms.FolderBrowserDialog(); + this.cboDrive = new System.Windows.Forms.ComboBox(); + this.cboPlaylistSet = new System.Windows.Forms.ComboBox(); + this.lblDrive = new System.Windows.Forms.Label(); + this.lblPlaylistSet = new System.Windows.Forms.Label(); + this.cboIntDrive = new System.Windows.Forms.ComboBox(); + this.lblIntDrive = new System.Windows.Forms.Label(); + this.btnCreatePlaylist = new System.Windows.Forms.Button(); + this.btnRemovePlaylist = new System.Windows.Forms.Button(); + this.btnSavePlaylistChanges = new System.Windows.Forms.Button(); + this.btnCancelPlaylistChanges = new System.Windows.Forms.Button(); + this.btnRenamePlaylist = new System.Windows.Forms.Button(); + this.ttpCommon = new System.Windows.Forms.ToolTip(this.components); + this.lvwPlaylist = new System.Windows.Forms.ListView(); + this.clhName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.SuspendLayout(); + // + // dlgAudioFolder + // + resources.ApplyResources(this.dlgAudioFolder, "dlgAudioFolder"); + // + // cboDrive + // + resources.ApplyResources(this.cboDrive, "cboDrive"); + this.cboDrive.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cboDrive.FormattingEnabled = true; + this.cboDrive.Name = "cboDrive"; + this.ttpCommon.SetToolTip(this.cboDrive, resources.GetString("cboDrive.ToolTip")); + this.cboDrive.DropDown += new System.EventHandler(this.cboDrive_DropDown); + this.cboDrive.SelectedIndexChanged += new System.EventHandler(this.cboDrive_SelectedIndexChanged); + // + // cboPlaylistSet + // + resources.ApplyResources(this.cboPlaylistSet, "cboPlaylistSet"); + this.cboPlaylistSet.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cboPlaylistSet.FormattingEnabled = true; + this.cboPlaylistSet.Name = "cboPlaylistSet"; + this.ttpCommon.SetToolTip(this.cboPlaylistSet, resources.GetString("cboPlaylistSet.ToolTip")); + this.cboPlaylistSet.SelectedIndexChanged += new System.EventHandler(this.cboPlaylistSet_SelectedIndexChanged); + // + // lblDrive + // + resources.ApplyResources(this.lblDrive, "lblDrive"); + this.lblDrive.Name = "lblDrive"; + this.ttpCommon.SetToolTip(this.lblDrive, global::XeniumPlaylist.PlaylistResource.PlaylistFileDragDropErrorText); + // + // lblPlaylistSet + // + resources.ApplyResources(this.lblPlaylistSet, "lblPlaylistSet"); + this.lblPlaylistSet.Name = "lblPlaylistSet"; + this.ttpCommon.SetToolTip(this.lblPlaylistSet, global::XeniumPlaylist.PlaylistResource.PlaylistFileDragDropErrorText); + // + // cboIntDrive + // + resources.ApplyResources(this.cboIntDrive, "cboIntDrive"); + this.cboIntDrive.BackColor = System.Drawing.SystemColors.Control; + this.cboIntDrive.FormattingEnabled = true; + this.cboIntDrive.Items.AddRange(new object[] { + resources.GetString("cboIntDrive.Items"), + resources.GetString("cboIntDrive.Items1")}); + this.cboIntDrive.Name = "cboIntDrive"; + this.ttpCommon.SetToolTip(this.cboIntDrive, resources.GetString("cboIntDrive.ToolTip")); + // + // lblIntDrive + // + resources.ApplyResources(this.lblIntDrive, "lblIntDrive"); + this.lblIntDrive.Name = "lblIntDrive"; + this.ttpCommon.SetToolTip(this.lblIntDrive, global::XeniumPlaylist.PlaylistResource.PlaylistFileDragDropErrorText); + // + // btnCreatePlaylist + // + resources.ApplyResources(this.btnCreatePlaylist, "btnCreatePlaylist"); + this.btnCreatePlaylist.Name = "btnCreatePlaylist"; + this.btnCreatePlaylist.TabStop = false; + this.ttpCommon.SetToolTip(this.btnCreatePlaylist, resources.GetString("btnCreatePlaylist.ToolTip")); + this.btnCreatePlaylist.UseVisualStyleBackColor = true; + this.btnCreatePlaylist.Click += new System.EventHandler(this.btnCreatePlaylist_Click); + // + // btnRemovePlaylist + // + resources.ApplyResources(this.btnRemovePlaylist, "btnRemovePlaylist"); + this.btnRemovePlaylist.Name = "btnRemovePlaylist"; + this.btnRemovePlaylist.TabStop = false; + this.ttpCommon.SetToolTip(this.btnRemovePlaylist, resources.GetString("btnRemovePlaylist.ToolTip")); + this.btnRemovePlaylist.UseVisualStyleBackColor = true; + this.btnRemovePlaylist.Click += new System.EventHandler(this.btnRemovePlaylist_Click); + // + // btnSavePlaylistChanges + // + resources.ApplyResources(this.btnSavePlaylistChanges, "btnSavePlaylistChanges"); + this.btnSavePlaylistChanges.Name = "btnSavePlaylistChanges"; + this.btnSavePlaylistChanges.TabStop = false; + this.ttpCommon.SetToolTip(this.btnSavePlaylistChanges, resources.GetString("btnSavePlaylistChanges.ToolTip")); + this.btnSavePlaylistChanges.UseVisualStyleBackColor = true; + this.btnSavePlaylistChanges.Click += new System.EventHandler(this.btnSavePlaylistChanges_Click); + // + // btnCancelPlaylistChanges + // + resources.ApplyResources(this.btnCancelPlaylistChanges, "btnCancelPlaylistChanges"); + this.btnCancelPlaylistChanges.Name = "btnCancelPlaylistChanges"; + this.btnCancelPlaylistChanges.TabStop = false; + this.ttpCommon.SetToolTip(this.btnCancelPlaylistChanges, resources.GetString("btnCancelPlaylistChanges.ToolTip")); + this.btnCancelPlaylistChanges.UseVisualStyleBackColor = true; + this.btnCancelPlaylistChanges.Click += new System.EventHandler(this.btnCancelPlaylistChanges_Click); + // + // btnRenamePlaylist + // + resources.ApplyResources(this.btnRenamePlaylist, "btnRenamePlaylist"); + this.btnRenamePlaylist.Name = "btnRenamePlaylist"; + this.btnRenamePlaylist.TabStop = false; + this.ttpCommon.SetToolTip(this.btnRenamePlaylist, resources.GetString("btnRenamePlaylist.ToolTip")); + this.btnRenamePlaylist.UseVisualStyleBackColor = true; + this.btnRenamePlaylist.Click += new System.EventHandler(this.btnRenamePlaylist_Click); + // + // ttpCommon + // + this.ttpCommon.AutoPopDelay = 5000; + this.ttpCommon.InitialDelay = 500; + this.ttpCommon.ReshowDelay = 100; + this.ttpCommon.ShowAlways = true; + // + // lvwPlaylist + // + resources.ApplyResources(this.lvwPlaylist, "lvwPlaylist"); + this.lvwPlaylist.AllowDrop = true; + this.lvwPlaylist.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.clhName}); + this.lvwPlaylist.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; + this.lvwPlaylist.Name = "lvwPlaylist"; + this.ttpCommon.SetToolTip(this.lvwPlaylist, resources.GetString("lvwPlaylist.ToolTip")); + this.lvwPlaylist.UseCompatibleStateImageBehavior = false; + this.lvwPlaylist.View = System.Windows.Forms.View.Details; + this.lvwPlaylist.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.lvwPlaylist_ItemDrag); + this.lvwPlaylist.DragDrop += new System.Windows.Forms.DragEventHandler(this.lvwPlaylist_DragDrop); + this.lvwPlaylist.DragEnter += new System.Windows.Forms.DragEventHandler(this.lvwPlaylist_DragEnter); + this.lvwPlaylist.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.lvwPlaylist_QueryContinueDrag); + this.lvwPlaylist.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lvwPlaylist_KeyDown); + // + // clhName + // + resources.ApplyResources(this.clhName, "clhName"); + // + // frmPlaylist + // + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.lvwPlaylist); + this.Controls.Add(this.btnRenamePlaylist); + this.Controls.Add(this.btnCancelPlaylistChanges); + this.Controls.Add(this.btnSavePlaylistChanges); + this.Controls.Add(this.btnRemovePlaylist); + this.Controls.Add(this.btnCreatePlaylist); + this.Controls.Add(this.lblIntDrive); + this.Controls.Add(this.cboIntDrive); + this.Controls.Add(this.lblPlaylistSet); + this.Controls.Add(this.lblDrive); + this.Controls.Add(this.cboPlaylistSet); + this.Controls.Add(this.cboDrive); + this.Name = "frmPlaylist"; + this.ttpCommon.SetToolTip(this, resources.GetString("$this.ToolTip")); + this.Load += new System.EventHandler(this.frmPlaylist_Load); + this.Resize += new System.EventHandler(this.frmPlaylist_Resize); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.FolderBrowserDialog dlgAudioFolder; + private System.Windows.Forms.ComboBox cboDrive; + private System.Windows.Forms.ComboBox cboPlaylistSet; + private System.Windows.Forms.Label lblDrive; + private System.Windows.Forms.Label lblPlaylistSet; + private System.Windows.Forms.ComboBox cboIntDrive; + private System.Windows.Forms.Label lblIntDrive; + private System.Windows.Forms.Button btnCreatePlaylist; + private System.Windows.Forms.Button btnRemovePlaylist; + private System.Windows.Forms.Button btnSavePlaylistChanges; + private System.Windows.Forms.Button btnCancelPlaylistChanges; + private System.Windows.Forms.ToolTip ttpCommon; + private System.Windows.Forms.Button btnRenamePlaylist; + private System.Windows.Forms.ListView lvwPlaylist; + private System.Windows.Forms.ColumnHeader clhName; + } +} + diff --git a/XeniumPlaylist/frmPlaylist.cs b/XeniumPlaylist/frmPlaylist.cs new file mode 100644 index 0000000..4e7600a --- /dev/null +++ b/XeniumPlaylist/frmPlaylist.cs @@ -0,0 +1,389 @@ +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; +using System.Resources; +using System.Threading; +using System.Globalization; + + +namespace XeniumPlaylist +{ + public partial class frmPlaylist : Form + { + class DriveItem + { + public string Name { get; set; } + public int? InternalIndex { get; set; } + }; + + //ResourceManager rm = new ResourceManager("XeniumPlaylist.PlaylistResource", typeof(PlaylistResource).Assembly); + + PlaylistSet playlistSet = new PlaylistSet(); + Playlist playlist = new Playlist(); + + /* + Form actions + */ + + public frmPlaylist() + { + InitializeComponent(); + } + + private void frmPlaylist_Load(object sender, EventArgs e) + { + btnCreatePlaylist.Enabled = false; + btnRemovePlaylist.Enabled = false; + btnRenamePlaylist.Enabled = false; + + btnSavePlaylistChanges.Enabled = false; + btnCancelPlaylistChanges.Enabled = false; + + LoadDrives(); + } + + private void frmPlaylist_Resize(object sender, EventArgs e) + { + AdjustPlaylistControl(); + } + + /* + Phone drive actions + */ + + private void LoadDrives() + { + try + { + // Get drive list and detect internal drive name by it's size + var driveItems = DriveInfo.GetDrives().Where(d => (d.DriveType == DriveType.Removable) && (d.IsReady == true) && Directory.Exists(Path.Combine(d.Name, "@playlist@"))).Select(d => new { Name = d.Name, Size = d.TotalSize }).ToArray(); + long minSize = (driveItems.Length > 0 ? driveItems.Min(d => d.Size) : 0); + long maxSize = (driveItems.Length > 0 ? driveItems.Max(d => d.Size) : 0); + + cboDrive.Items.Clear(); + cboDrive.DisplayMember = "Name"; + cboDrive.ValueMember = "InternalIndex"; + cboDrive.Items.AddRange(driveItems.Select(d => new DriveItem { Name = d.Name, InternalIndex = (d.Size == minSize ? (int?)0 : (d.Size == maxSize ? (int?)1 : null)) }).ToArray()); + cboDrive.SelectedIndex = (cboDrive.Items.Count > 0 ? 0 : -1); + if (cboDrive.SelectedIndex == -1) + cboDrive_SelectedIndexChanged(null, null); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, PlaylistResource.ErrorMessageBoxCaption); + } + } + + private void cboDrive_DropDown(object sender, EventArgs e) + { + if (cboDrive.Items.Count == 0) + LoadDrives(); + } + + private void cboDrive_SelectedIndexChanged(object sender, EventArgs e) + { + cboIntDrive.SelectedIndex = ((cboDrive.SelectedItem != null) && (((DriveItem)cboDrive.SelectedItem).InternalIndex != null) ? (int)((DriveItem)cboDrive.SelectedItem).InternalIndex : -1); + cboIntDrive.Enabled = (cboDrive.SelectedIndex >= 0); + LoadPlaylistSet(cboDrive.Text); + } + + + /* + Playlist set actions + */ + + private void LoadPlaylistSet(string driveName) + { + try + { + cboPlaylistSet.Items.Clear(); + playlistSet.Load(driveName); + cboPlaylistSet.Items.AddRange(playlistSet.Items.ToArray()); + cboPlaylistSet.SelectedIndex = (cboPlaylistSet.Items.Count > 0 ? 0 : -1); + if (cboPlaylistSet.SelectedIndex == -1) + cboPlaylistSet_SelectedIndexChanged(null, null); + cboPlaylistSet.Enabled = (cboDrive.SelectedIndex >= 0); + btnCreatePlaylist.Enabled = (cboDrive.SelectedIndex >= 0); + btnRemovePlaylist.Enabled = (cboPlaylistSet.SelectedIndex >= 0); + btnRenamePlaylist.Enabled = (cboPlaylistSet.SelectedIndex >= 0); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, PlaylistResource.ErrorMessageBoxCaption); + } + } + + private void SavePlaylistSet(string driveName) + { + try + { + playlistSet.Items.Clear(); + playlistSet.Items.AddRange(cboPlaylistSet.Items.OfType()); + playlistSet.Save(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, PlaylistResource.ErrorMessageBoxCaption); + } + } + + private void CreatePlaylist() + { + try + { + //string playlistName = InputBox.Show(ttpCommon.GetToolTip(btnCreatePlaylist), "Playlist name:", ""); + //string playlistName = InputBox.Show(ttpCommon.GetToolTip(btnCreatePlaylist), rm.GetString("strPlaylistNamePrompt"), ""); + string playlistName = InputBox.Show(ttpCommon.GetToolTip(btnCreatePlaylist), PlaylistResource.PlaylistNamePrompt, ""); + if (playlistName != "") + { + playlistSet.Add(playlistName); + LoadPlaylistSet(cboDrive.Text); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, PlaylistResource.ErrorMessageBoxCaption); + } + } + + private void RemovePlaylist(int playlistIndex) + { + try + { + //if (MessageBox.Show("Are you sure to remove playlist?", ttpCommon.GetToolTip(btnRemovePlaylist), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) + if (MessageBox.Show(PlaylistResource.PlaylistRemoveConfirmPrompt, ttpCommon.GetToolTip(btnRemovePlaylist), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) + { + playlistSet.Delete(playlistIndex); + LoadPlaylistSet(cboDrive.Text); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, PlaylistResource.ErrorMessageBoxCaption); + } + } + + private void RenamePlaylist(int playlistIndex) + { + try + { + //string playlistName = InputBox.Show(ttpCommon.GetToolTip(btnRenamePlaylist), "Playlist name:", cboPlaylistSet.Text); + string playlistName = InputBox.Show(ttpCommon.GetToolTip(btnRenamePlaylist), PlaylistResource.PlaylistNamePrompt, cboPlaylistSet.Text); + if (playlistName != "") + { + playlistSet.Rename(playlistIndex, playlistName); + LoadPlaylistSet(cboDrive.Text); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, PlaylistResource.ErrorMessageBoxCaption); + } + } + + private void cboPlaylistSet_SelectedIndexChanged(object sender, EventArgs e) + { + LoadPlaylist(cboDrive.Text, cboPlaylistSet.Text); + } + + private void btnCreatePlaylist_Click(object sender, EventArgs e) + { + CreatePlaylist(); + } + + private void btnRemovePlaylist_Click(object sender, EventArgs e) + { + RemovePlaylist(cboPlaylistSet.SelectedIndex); + } + + private void btnRenamePlaylist_Click(object sender, EventArgs e) + { + RenamePlaylist(cboPlaylistSet.SelectedIndex); + } + + + /* + Playlist actions + */ + + private void LoadPlaylist(string driveName, string playlistName) + { + try + { + playlist.Load(driveName, playlistName); + + lvwPlaylist.BeginUpdate(); + lvwPlaylist.Items.Clear(); + foreach (string s in playlist.Items) + //lvwPlaylist.Items.Add(new ListViewItem(s)); + lvwPlaylist.Items.Add(s); + if (lvwPlaylist.Items.Count > 0) + lvwPlaylist.Items[0].Selected = true; + AdjustPlaylistControl(); + lvwPlaylist.EndUpdate(); + + lvwPlaylist.Enabled = ((cboDrive.SelectedIndex >= 0) && (cboPlaylistSet.SelectedIndex >= 0)); + btnSavePlaylistChanges.Enabled = false; + btnCancelPlaylistChanges.Enabled = false; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, PlaylistResource.ErrorMessageBoxCaption); + } + } + + private void SavePlaylist(string driveName, string playlistName) + { + try + { + playlist.Items.Clear(); + //playlist.Items.AddRange(lstPlaylist.Items.OfType()); + playlist.Items.AddRange(lvwPlaylist.Items.OfType().Select(i => i.Text)); + playlist.Save(driveName, playlistName); + btnSavePlaylistChanges.Enabled = false; + btnCancelPlaylistChanges.Enabled = false; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, PlaylistResource.ErrorMessageBoxCaption); + } + } + + private void AdjustPlaylistControl() + { + lvwPlaylist.Columns[0].Width = lvwPlaylist.ClientSize.Width - SystemInformation.VerticalScrollBarWidth - 4; + } + + private void btnSavePlaylistChanges_Click(object sender, EventArgs e) + { + SavePlaylist(cboDrive.Text, cboPlaylistSet.Text); + } + + private void btnCancelPlaylistChanges_Click(object sender, EventArgs e) + { + LoadPlaylist(cboDrive.Text, cboPlaylistSet.Text); + } + + private void lvwPlaylist_KeyDown(object sender, KeyEventArgs e) + { + if ((e.KeyCode == Keys.Delete) && (e.Modifiers == Keys.None)) + foreach (int i in lvwPlaylist.SelectedIndices.OfType().OrderByDescending(i => i)) + lvwPlaylist.Items.RemoveAt(i); + btnSavePlaylistChanges.Enabled = true; + btnCancelPlaylistChanges.Enabled = true; + } + + private void lvwPlaylist_ItemDrag(object sender, ItemDragEventArgs e) + { + lvwPlaylist.DoDragDrop(lvwPlaylist.SelectedIndices, DragDropEffects.Move); + } + + private void lvwPlaylist_DragEnter(object sender, DragEventArgs e) + { + if (cboPlaylistSet.SelectedIndex == -1) + { + e.Effect = DragDropEffects.None; + return; + } + if (e.Data.GetDataPresent(typeof(ListView.SelectedIndexCollection))) + e.Effect = DragDropEffects.Move; + else + if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) + e.Effect = DragDropEffects.All; + else + e.Effect = DragDropEffects.None; + } + + private void lvwPlaylist_DragDrop(object sender, DragEventArgs e) + { + //Point p = lvwPlaylist.PointToClient(new Point(e.X, e.Y)); + ListViewItem lvi = lvwPlaylist.GetItemAt(0, lvwPlaylist.PointToClient(new Point(e.X, e.Y)).Y); + int dropIndex = (lvi != null ? lvi.Index : lvwPlaylist.Items.Count); + int dropCount = 0; + + lvwPlaylist.BeginUpdate(); + + var files = (string[])e.Data.GetData(DataFormats.FileDrop, false); + if (files != null) + { + int fileCount = 0; + foreach (string s in files) + if (s.StartsWith(cboDrive.Text, StringComparison.CurrentCultureIgnoreCase)) + { + if (Directory.Exists(s)) + //lvwPlaylist.Items.AddRange(Directory.GetFiles(s).Select(f => cboIntDrive.Text + f.Substring(cboDrive.Text.Length)).ToArray()); + foreach (string f in Directory.GetFiles(s).Select(f => cboIntDrive.Text + f.Substring(cboDrive.Text.Length))) + { + lvwPlaylist.Items.Insert(dropIndex++, f); + dropCount++; + } + else + { + lvwPlaylist.Items.Insert(dropIndex++, cboIntDrive.Text + s.Substring(cboDrive.Text.Length)); + dropCount++; + } + fileCount++; + } + if (fileCount == 0) + MessageBox.Show(String.Format(PlaylistResource.PlaylistFileDragDropErrorText, cboDrive.Text), PlaylistResource.ErrorMessageBoxCaption); + } + + var items = (ListView.SelectedIndexCollection)e.Data.GetData(typeof(ListView.SelectedIndexCollection)); + if (items != null) + { + int delta = 0; + foreach (int selectedIndex in items) + { + int i = selectedIndex - delta; + if (dropIndex != i) + { + lvwPlaylist.Items.Insert(dropIndex, new ListViewItem(lvwPlaylist.Items[i].Text)).Selected = true; + if (dropIndex < i) + { + lvwPlaylist.Items.RemoveAt(i + 1); + dropIndex++; + } + else + { + lvwPlaylist.Items.RemoveAt(i); + delta++; + } + } + dropCount++; + } + } + + if (dropCount > 0) + { + btnSavePlaylistChanges.Enabled = true; + btnCancelPlaylistChanges.Enabled = true; + } + + //AdjustPlaylistControl(); + lvwPlaylist.EndUpdate(); + } + + private void lvwPlaylist_QueryContinueDrag(object sender, QueryContinueDragEventArgs e) + { + const int scroll_margin = 5; + + Point p = lvwPlaylist.PointToClient(new Point(Cursor.Position.X, Cursor.Position.Y)); + ListViewItem lvi = lvwPlaylist.GetItemAt(0, p.Y); + int i = (lvi != null ? lvi.Index : lvwPlaylist.Items.Count); + int h = lvwPlaylist.ClientRectangle.Height; + + if ((p.Y < scroll_margin) && (i > 0)) + lvwPlaylist.Items[i - 1].EnsureVisible(); + else + if ((p.Y > h - scroll_margin) && (i < lvwPlaylist.Items.Count - 1)) + lvwPlaylist.Items[i + 1].EnsureVisible(); + } + } +} diff --git a/XeniumPlaylist/frmPlaylist.resx b/XeniumPlaylist/frmPlaylist.resx new file mode 100644 index 0000000..7a693da --- /dev/null +++ b/XeniumPlaylist/frmPlaylist.resx @@ -0,0 +1,578 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + Top, Bottom, Left, Right + + + You should drag files from {0} drive! + + + + 85, 24 + + + Top, Right + + + Playlists on the drive + + + 12, 27 + + + 62, 17 + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 6 + + + cboIntDrive + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 9 + + + $this + + + System + + + Phone drive in the computer (if drop-down list is empty connect phone to USB and open list again) + + + 748, 27 + + + 12, 57 + + + Philips Xenium phones playlist editor + + + btnCancelPlaylistChanges + + + ~ + + + + True + + + E:\ + + + 85, 24 + + + 24, 24 + + + 11 + + + $this + + + (none) + + + 1 + + + lvwPlaylist + + + 8, 16 + + + You should drag files from {0} drive! + + + You should drag files from {0} drive! + + + $this + + + Rename playlist + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + btnCreatePlaylist + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 9 + + + Microsoft Sans Serif, 7.8pt, style=Bold + + + 194, 27 + + + 10 + + + cboDrive + + + 6 + + + You should drag files from {0} drive! + + + System.Windows.Forms.ToolTip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System + + + Top, Right + + + ttpCommon + + + lblPlaylistSet + + + 3 + + + 724, 27 + + + v + + + frmPlaylist + + + 9, 7 + + + $this + + + Top, Right + + + 7 + + + 1 + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Windows.Forms.ColumnHeader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + lblIntDrive + + + Add audio files by dragging them from Windows Explorer folders. +Remove files by pressing "Delete" key. +Rearrange files by drag and drop selected items within a list. + + + clhName + + + 648, 27 + + + $this + + + btnRenamePlaylist + + + 0 + + + CenterScreen + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + Top, Right + + + Save playlist changes + + + 41, 17 + + + 2 + + + btnRemovePlaylist + + + 24, 24 + + + 24, 24 + + + $this + + + 760, 401 + + + x + + + C:\ + + + 7 + + + You should drag files from {0} drive! + + + System.Windows.Forms.ListView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + + + btnSavePlaylistChanges + + + Top, Left, Right + + + lblDrive + + + 5 + + + System + + + System + + + 103, 27 + + + $this + + + Microsoft Sans Serif, 7.8pt, style=Bold + + + System + + + - + + + You should drag files from {0} drive! + + + 8 + + + Create playlist... + + + Cancel playlist changes + + + 138, 17 + + + 24, 24 + + + Drive + + + 11 + + + System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + cboPlaylistSet + + + 446, 24 + + + (none) + + + $this + + + 4 + + + Microsoft Sans Serif, 7.8pt, style=Bold + + + 191, 7 + + + (none) + + + You should drag files from {0} drive! + + + 2 + + + You should drag files from {0} drive! + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 100, 7 + + + You should drag files from {0} drive! + + + Int. drive + + + 24, 24 + + + 0 + + + 0, 0, 0, 0 + + + 8 + + + 784, 470 + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 696, 27 + + + Remove playlist + + + $this + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + dlgAudioFolder + + + 3 + + + $this + + + True + + + Top, Right + + + Name + + + 5 + + + 672, 27 + + + 10 + + + 4 + + + Microsoft Sans Serif, 7.8pt, style=Bold + + + Microsoft Sans Serif, 7.8pt, style=Bold + + + $this + + + System.Windows.Forms.FolderBrowserDialog, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Internal name of the drive in the phone (detected automatically but can be changed manually) + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 164, 17 + + + 17, 17 + + + True + + \ No newline at end of file diff --git a/XeniumPlaylist/frmPlaylist.ru.resx b/XeniumPlaylist/frmPlaylist.ru.resx new file mode 100644 index 0000000..9c3585f --- /dev/null +++ b/XeniumPlaylist/frmPlaylist.ru.resx @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + USB-диск телефона на копьютере (если выпадающий список пуст, подключите телефон к USB и вновь откройте список) + + + Диск + + + + 198, 17 + + + Список плейлистов на диске + + + Внутреннее имя диска в телефоне (определяется автоматически, но может быть откорректировано вручную) + + + 86, 17 + + + Диск в тлф. + + + Создать плейлист... + + + Удалить плейлист + + + Сохранить изменения плейлиста + + + Отменить изменения плейлиста + + + Переименовать плейлист + + + Добавляйте файлы перетаскиванием их из папок проводника Windows. +Удаляйте файлы клавишей "Delete". +Упорядочивайте файлы перетаскиванием выбранных элементов внутри списка. + + + Редактор плейлистов для телефонов Philips Xenium + + \ No newline at end of file