Dragable songs to playlist working. We only need a better cursor

This commit is contained in:
Janco Kock
2015-11-01 00:18:11 +01:00
parent 68ca3af5ff
commit 918bfd8871
4 changed files with 82 additions and 44 deletions
+16 -14
View File
@@ -129,6 +129,9 @@ namespace MusicPlayer
this.SongsTableView.Size = new System.Drawing.Size(760, 174);
this.SongsTableView.TabIndex = 0;
this.SongsTableView.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.SongsTableView_CellDoubleClick);
this.SongsTableView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.SongsTableView_MouseDown);
this.SongsTableView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.SongsTableView_MouseMove);
this.SongsTableView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.SongsTableView_MouseUp);
//
// GenreListBox
//
@@ -136,7 +139,7 @@ namespace MusicPlayer
| System.Windows.Forms.AnchorStyles.Left)));
this.GenreListBox.BackColor = System.Drawing.SystemColors.Control;
this.GenreListBox.FormattingEnabled = true;
this.GenreListBox.Location = new System.Drawing.Point(3, 3);
this.GenreListBox.Location = new System.Drawing.Point(148, 3);
this.GenreListBox.Name = "GenreListBox";
this.GenreListBox.Size = new System.Drawing.Size(150, 121);
this.GenreListBox.Sorted = true;
@@ -149,10 +152,10 @@ namespace MusicPlayer
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.AlbumListView.BackColor = System.Drawing.SystemColors.Control;
this.AlbumListView.Location = new System.Drawing.Point(309, 3);
this.AlbumListView.Location = new System.Drawing.Point(460, 3);
this.AlbumListView.MultiSelect = false;
this.AlbumListView.Name = "AlbumListView";
this.AlbumListView.Size = new System.Drawing.Size(451, 121);
this.AlbumListView.Size = new System.Drawing.Size(286, 121);
this.AlbumListView.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.AlbumListView.TabIndex = 2;
this.AlbumListView.TileSize = new System.Drawing.Size(140, 30);
@@ -166,7 +169,7 @@ namespace MusicPlayer
| System.Windows.Forms.AnchorStyles.Left)));
this.ArtistListBox.BackColor = System.Drawing.SystemColors.Control;
this.ArtistListBox.FormattingEnabled = true;
this.ArtistListBox.Location = new System.Drawing.Point(156, 3);
this.ArtistListBox.Location = new System.Drawing.Point(304, 3);
this.ArtistListBox.Name = "ArtistListBox";
this.ArtistListBox.Size = new System.Drawing.Size(150, 121);
this.ArtistListBox.Sorted = true;
@@ -200,10 +203,10 @@ namespace MusicPlayer
//
// SplitContainer.Panel1
//
this.SplitContainer.Panel1.Controls.Add(this.PlaylistBox);
this.SplitContainer.Panel1.Controls.Add(this.AlbumListView);
this.SplitContainer.Panel1.Controls.Add(this.ArtistListBox);
this.SplitContainer.Panel1.Controls.Add(this.GenreListBox);
this.SplitContainer.Panel1.Controls.Add(this.PlaylistBox);
//
// SplitContainer.Panel2
//
@@ -215,29 +218,28 @@ namespace MusicPlayer
//
// PlaylistBox
//
this.PlaylistBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.PlaylistBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.PlaylistBox.FormattingEnabled = true;
this.PlaylistBox.Location = new System.Drawing.Point(0, 0);
this.PlaylistBox.Location = new System.Drawing.Point(3, 3);
this.PlaylistBox.Name = "PlaylistBox";
this.PlaylistBox.Size = new System.Drawing.Size(760, 131);
this.PlaylistBox.Size = new System.Drawing.Size(139, 121);
this.PlaylistBox.TabIndex = 4;
this.PlaylistBox.Visible = false;
this.PlaylistBox.SelectedIndexChanged += new System.EventHandler(this.PlaylistBox_SelectedIndexChanged);
//
// PlaylistListLabel
//
this.PlaylistListLabel.AutoSize = true;
this.PlaylistListLabel.Location = new System.Drawing.Point(12, 8);
this.PlaylistListLabel.Location = new System.Drawing.Point(12, 9);
this.PlaylistListLabel.Name = "PlaylistListLabel";
this.PlaylistListLabel.Size = new System.Drawing.Size(39, 13);
this.PlaylistListLabel.TabIndex = 7;
this.PlaylistListLabel.Text = "Playlist";
this.PlaylistListLabel.Visible = false;
//
// AlbumListLabel
//
this.AlbumListLabel.AutoSize = true;
this.AlbumListLabel.Location = new System.Drawing.Point(321, 9);
this.AlbumListLabel.Location = new System.Drawing.Point(483, 8);
this.AlbumListLabel.Name = "AlbumListLabel";
this.AlbumListLabel.Size = new System.Drawing.Size(36, 13);
this.AlbumListLabel.TabIndex = 6;
@@ -246,7 +248,7 @@ namespace MusicPlayer
// ArtistListLabel
//
this.ArtistListLabel.AutoSize = true;
this.ArtistListLabel.Location = new System.Drawing.Point(165, 9);
this.ArtistListLabel.Location = new System.Drawing.Point(327, 8);
this.ArtistListLabel.Name = "ArtistListLabel";
this.ArtistListLabel.Size = new System.Drawing.Size(30, 13);
this.ArtistListLabel.TabIndex = 5;
@@ -255,7 +257,7 @@ namespace MusicPlayer
// GenreListLabel
//
this.GenreListLabel.AutoSize = true;
this.GenreListLabel.Location = new System.Drawing.Point(12, 9);
this.GenreListLabel.Location = new System.Drawing.Point(174, 8);
this.GenreListLabel.Name = "GenreListLabel";
this.GenreListLabel.Size = new System.Drawing.Size(36, 13);
this.GenreListLabel.TabIndex = 4;
+41
View File
@@ -19,6 +19,7 @@ namespace MusicPlayer
public partial class MainForm : Form
{
bool songFinished;
bool draggedstarted;
public Main main
{
@@ -442,5 +443,45 @@ namespace MusicPlayer
int selected = main.currentPlayingList.IndexOf(main.audio.CurrentSong);
SongsTableView.CurrentCell = SongsTableView.Rows[selected].Cells[0];
}
private void SongsTableView_MouseDown(object sender, MouseEventArgs e)
{
draggedstarted = true;
Cursor.Current = Cursors.Hand;
}
private void SongsTableView_MouseUp(object sender, MouseEventArgs e)
{
if (draggedstarted)
{
Cursor.Current = Cursors.Default;
Point point = PlaylistBox.PointToClient(Cursor.Position);
int index = PlaylistBox.IndexFromPoint(point);
if (index < 0) //nope, niet op een playlist gesleept
{
draggedstarted = false;
return;
}
Playlist currentPlaylist = main.pl.GetPlaylistByName(PlaylistBox.Items[index].ToString());
SongsTable s = new SongsTable();
if (SongsTableView.SelectedRows.Count > 0)
{
var drv = SongsTableView.SelectedRows[0].DataBoundItem as DataRowView;
var row = drv.Row as DataRow;
s.ImportRow(row);
currentPlaylist.AddSong((s.Rows[0][5] as Song));
currentPlaylist.WriteToFile();
}
}
}
private void SongsTableView_MouseMove(object sender, MouseEventArgs e)
{
if (draggedstarted)
{
Cursor.Current = Cursors.Hand;
}
}
}
}
+17 -25
View File
@@ -8,10 +8,10 @@
// </auto-generated>
//------------------------------------------------------------------------------
namespace MusicPlayer.Properties
{
namespace MusicPlayer.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
@@ -22,48 +22,40 @@ namespace MusicPlayer.Properties
[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
{
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()
{
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MusicPlayer.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set
{
set {
resourceCulture = value;
}
}
+8 -5
View File
@@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
@@ -68,9 +69,10 @@
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
@@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
@@ -109,9 +112,9 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>