Skip to content
This repository was archived by the owner on Oct 12, 2020. It is now read-only.

Commit 7a29511

Browse files
author
c0derMo
committed
- First working release
1 parent 17f208b commit 7a29511

File tree

13 files changed

+1033
-38
lines changed

13 files changed

+1033
-38
lines changed

SpotifyNowPlaying/SpotifyNowPlaying/NowPlayingInterface.Designer.cs

Lines changed: 89 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SpotifyNowPlaying/SpotifyNowPlaying/NowPlayingInterface.cs

Lines changed: 167 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,181 @@ namespace SpotifyNowPlaying
1212
{
1313
public partial class NowPlayingInterface : Form
1414
{
15+
private String fullName;
16+
private int namePos;
17+
private String nameDirection;
18+
private int nameStoppedTicks;
19+
20+
private String fullArtists;
21+
private int artistPos;
22+
private String artistDirection;
23+
private int artistsStoppedTicks;
24+
25+
private Options opt;
26+
27+
private decimal wait = OptionManager.waitDelay;
28+
1529
public NowPlayingInterface()
1630
{
1731
InitializeComponent();
32+
this.toolTip1.SetToolTip(this, "Right click for more options");
33+
this.timerName.Interval = Decimal.ToInt32(OptionManager.scrollSpeed);
34+
this.timerName.Tick += new EventHandler(this.NameTick);
35+
this.timerArtists.Interval = Decimal.ToInt32(OptionManager.scrollSpeed);
36+
this.timerArtists.Tick += new EventHandler(this.ArtistsTick);
37+
this.ContextMenuStrip = this.contextMenuStrip1;
38+
this.opt = null;
39+
}
40+
41+
protected override void WndProc(ref Message m)
42+
{
43+
switch (m.Msg)
44+
{
45+
case 0x84:
46+
base.WndProc(ref m);
47+
if ((int)m.Result == 0x1)
48+
m.Result = (IntPtr)0x2;
49+
return;
50+
}
51+
base.WndProc(ref m);
52+
}
53+
54+
public void updateValues(decimal speed, decimal wait)
55+
{
56+
this.timerName.Interval = Decimal.ToInt32(speed);
57+
this.timerArtists.Interval = Decimal.ToInt32(speed);
58+
this.wait = wait;
1859
}
1960

2061
public void updateInterface(string title, string artists, string imageURI)
2162
{
22-
this.Invoke((MethodInvoker)delegate
63+
if(title != this.fullName && artists != this.fullArtists) {
64+
this.Invoke((MethodInvoker)delegate
65+
{
66+
this.fullName = title;
67+
if(this.fullName.Length > 20)
68+
{
69+
this.label1.Text = this.fullName.Substring(0, 20);
70+
this.namePos = 0;
71+
this.nameStoppedTicks = 0;
72+
this.nameDirection = "r";
73+
if (!this.timerName.Enabled)
74+
{
75+
this.timerName.Start();
76+
}
77+
} else
78+
{
79+
this.label1.Text = this.fullName;
80+
if(this.timerName.Enabled)
81+
{
82+
this.timerName.Stop();
83+
}
84+
}
85+
this.fullArtists = artists;
86+
if(this.fullArtists.Length > 30)
87+
{
88+
this.label2.Text = this.fullArtists.Substring(0, 30);
89+
this.artistPos = 0;
90+
this.artistsStoppedTicks = 0;
91+
this.artistDirection = "r";
92+
if(!this.timerArtists.Enabled)
93+
{
94+
this.timerArtists.Start();
95+
}
96+
} else
97+
{
98+
this.label2.Text = this.fullArtists;
99+
if(this.timerArtists.Enabled)
100+
{
101+
this.timerArtists.Stop();
102+
}
103+
}
104+
this.pictureBox1.Load(imageURI);
105+
});
106+
}
107+
}
108+
109+
private void NameTick(object sender, EventArgs e)
110+
{
111+
if(this.nameDirection == "r") {
112+
if(this.fullName.Length-this.namePos > 20) {
113+
this.namePos++;
114+
this.label1.Text = this.fullName.Substring(this.namePos, 20);
115+
} else
116+
{
117+
this.nameStoppedTicks++;
118+
if(this.nameStoppedTicks == wait)
119+
{
120+
this.nameDirection = "l";
121+
this.nameStoppedTicks = 0;
122+
}
123+
}
124+
} else
23125
{
24-
this.label1.Text = title;
25-
this.label2.Text = artists;
26-
this.pictureBox1.Load("https://i.scdn.co/image/255621d727d0cf961a422059052965fae600c803");
27-
});
126+
if (this.namePos > 0)
127+
{
128+
this.namePos--;
129+
this.label1.Text = this.fullName.Substring(this.namePos, 20);
130+
} else
131+
{
132+
this.nameStoppedTicks++;
133+
if(this.nameStoppedTicks == wait)
134+
{
135+
this.nameStoppedTicks = 0;
136+
this.nameDirection = "r";
137+
}
138+
}
139+
}
140+
}
141+
142+
private void ArtistsTick(object sender, EventArgs e)
143+
{
144+
if(this.artistDirection == "r")
145+
{
146+
if(this.fullArtists.Length-this.artistPos > 30)
147+
{
148+
this.artistPos++;
149+
this.label2.Text = this.fullArtists.Substring(this.artistPos, 30);
150+
} else
151+
{
152+
this.artistsStoppedTicks++;
153+
if(this.artistsStoppedTicks == wait)
154+
{
155+
this.artistDirection = "l";
156+
this.artistsStoppedTicks = 0;
157+
}
158+
}
159+
} else
160+
{
161+
if (this.artistPos > 0)
162+
{
163+
this.artistPos--;
164+
this.label2.Text = this.fullArtists.Substring(this.artistPos, 30);
165+
}
166+
else
167+
{
168+
this.artistsStoppedTicks++;
169+
if (this.artistsStoppedTicks == wait)
170+
{
171+
this.artistDirection = "r";
172+
this.artistsStoppedTicks = 0;
173+
}
174+
}
175+
}
176+
}
177+
178+
private void optionsToolStripMenuItem_Click(object sender, EventArgs e)
179+
{
180+
if(this.opt == null)
181+
{
182+
this.opt = new Options();
183+
}
184+
this.opt.Show();
185+
}
186+
187+
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
188+
{
189+
Application.Exit();
28190
}
29191
}
30192
}

SpotifyNowPlaying/SpotifyNowPlaying/NowPlayingInterface.resx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,16 @@
117117
<resheader name="writer">
118118
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119119
</resheader>
120+
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121+
<value>17, 17</value>
122+
</metadata>
123+
<metadata name="timerName.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
124+
<value>114, 17</value>
125+
</metadata>
126+
<metadata name="timerArtists.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
127+
<value>201, 17</value>
128+
</metadata>
129+
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
130+
<value>325, 17</value>
131+
</metadata>
120132
</root>

0 commit comments

Comments
 (0)