-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
148 lines (124 loc) · 4.53 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
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;
using System.IO;
using System.Runtime.InteropServices;
namespace Abdallah_Amir_s_Project
{
public partial class Musicly : Form
{
//Code to get round edges[1]
[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
private static extern IntPtr CreateRoundRectRgn
(
int nLeftRect,
int nTopRect,
int nRightRect,
int nBottomRect,
int nWidthEllipse,
int nHeightEllipse
);
public Musicly()
{
InitializeComponent();
//Code to get round edges[2]
Region = Region.FromHrgn(CreateRoundRectRgn(0, 0, Width, Height, 25, 25));
//Code to make a button highlight[1]
panel1.Height = selectButton.Height;
panel1.Top = selectButton.Top;
panel1.Left = selectButton.Left;
selectButton.BackColor = Color.FromArgb(148, 20, 25);
}
//Code to make a button highlight[2]
[DllImport("user32.DLL", EntryPoint = "ReleaseCapture")]
private extern static void ReleaseCapture();
[DllImport("user32.DLL", EntryPoint = "SendMessage")]
private extern static void SendMessage(System.IntPtr hWnd, int wMsg, int wParam, int lParam);
//Local variables to help us with file selecting
String[] paths, files;
private void musicList_SelectedIndexChanged(object sender, EventArgs e)
{
WDM.URL = paths[musicList.SelectedIndex];
}
private void panel2_MouseDown(object sender, MouseEventArgs e)
{
//Code to drag the window
ReleaseCapture();
SendMessage(this.Handle, 0x112, 0xf012, 0);
}
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
//Code to drag the window
ReleaseCapture();
SendMessage(this.Handle, 0x112, 0xf012, 0);
}
private void exitButton_Click(object sender, EventArgs e)
{
//Exit the application
Application.Exit();
}
private void minButton_Click(object sender, EventArgs e)
{
//Minimize the window
this.WindowState = FormWindowState.Minimized;
}
private void exitButton_MouseHover(object sender, EventArgs e)
{
//Show a small text box when hovered on
ToolTip exitTP = new ToolTip();
exitTP.SetToolTip(this.exitButton, "Exit Musicly");
}
private void minButton_MouseHover(object sender, EventArgs e)
{
//Show a small text box when hovered on
ToolTip minTP = new ToolTip();
minTP.SetToolTip(this.minButton, "Minimize Musicly");
}
private void Musicly_MouseDown(object sender, MouseEventArgs e)
{
//Code to drag the window
ReleaseCapture();
SendMessage(this.Handle, 0x112, 0xf012, 0);
}
private void nextButton_Click(object sender, EventArgs e)
{
WDM.URL = paths[musicList.SelectedIndex + 1];
musicList.SelectedIndex += 1;
}
private void previousButton_Click(object sender, EventArgs e)
{
WDM.URL = paths[musicList.SelectedIndex - 1];
musicList.SelectedIndex -= 1;
}
private void selectButton_Click(object sender, EventArgs e)
{
//Code to make the Select Songs button funtion
//Code to make it highlight when hovered on
panel1.Height = selectButton.Height;
panel1.Top = selectButton.Top;
panel1.Left = selectButton.Left;
selectButton.BackColor = Color.FromArgb(148, 20, 25);
//Code to add all selected items to the music list
musicList.Items.Clear();
Array.Clear(paths, 0, paths.Length);
OpenFileDialog ofd = new OpenFileDialog();
ofd.Multiselect = true;
if(ofd.ShowDialog()==DialogResult.OK)
{
files = ofd.SafeFileNames;
//error here make it so that paths is unlimited
paths = ofd.FileNames;
for (int i = 0; i < files.Length; i++)
{
musicList.Items.Add(files[i]);
}
}
}
}
}