Skip to content

Commit

Permalink
Fixed some G19 bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyd-be committed Jul 1, 2013
1 parent 740e6df commit e360cf9
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 56 deletions.
79 changes: 37 additions & 42 deletions Logitech applet/Logitech.cs
Expand Up @@ -53,7 +53,7 @@ public class Logitech
private string title = "";
private string artwork = "";
private float rating = 0;

private Image backgroundImage = null;

private LcdGdiImage backgroundGdi = null;
Expand Down Expand Up @@ -135,13 +135,6 @@ public void setDuration(int duration)
{
this.duration = duration / 1000;
}

//public int getPlaylistScroll()
//{
// return playlistScroll;
//}


#endregion

public void connect()
Expand All @@ -150,7 +143,6 @@ public void connect()
applet = new LcdApplet("MusicBee V2", appletCapabilities, false);
applet.DeviceArrival += new EventHandler<LcdDeviceTypeEventArgs>(applet_DeviceArrival);
applet.Connect();

}

public void changeArtistTitle(string artist, string album, string title, string rating, string artwork, int duration, int position, bool autoDJ, bool equaliser, bool shuffle, MusicBeePlugin.Plugin.RepeatMode repeat)
Expand All @@ -176,11 +168,6 @@ public void changeArtistTitle(string artist, string album, string title, string
this.rating = 0;
}


timer.Dispose();
TimerCallback tcb = TimerCallback;


if (device != null && progressBarGdi == null)
{
if (device.DeviceType == LcdDeviceType.Monochrome)
Expand Down Expand Up @@ -258,12 +245,9 @@ public void changeArtistTitle(string artist, string album, string title, string
{

}
timer = new Timer(tcb, autoEvent, 1000, 500);
}
}



public static void TimerCallback(Object state)
{
AutoResetEvent autoEvent = (AutoResetEvent)state;
Expand Down Expand Up @@ -314,12 +298,11 @@ public static void TimerCallback(Object state)
}
catch (System.InvalidOperationException)
{

//Noting to dd
}
}
}


private void applet_DeviceArrival(object sender, LcdDeviceTypeEventArgs e)
{
device = applet.OpenDeviceByType(e.DeviceType);
Expand All @@ -343,9 +326,7 @@ private void applet_DeviceArrival(object sender, LcdDeviceTypeEventArgs e)

device.DoUpdateAndDraw();
firstTime = false;

}

else if (device.DeviceType == LcdDeviceType.Qvga)
{
page[0] = new LcdGdiPage(device);
Expand All @@ -362,13 +343,12 @@ private void applet_DeviceArrival(object sender, LcdDeviceTypeEventArgs e)

private void buttonPressed(object sender, LcdSoftButtonsEventArgs e)
{

if (started)
{
LcdDevice device = (LcdDevice)sender;

// First button is pressed, switch to page one
if ((e.SoftButtons & LcdSoftButtons.Button0) == LcdSoftButtons.Button0)
if(((e.SoftButtons & LcdSoftButtons.Button0) == LcdSoftButtons.Button0) || (e.SoftButtons & LcdSoftButtons.Left) == LcdSoftButtons.Left)
{
if (pageNumber == 0)
{
Expand All @@ -383,9 +363,8 @@ private void buttonPressed(object sender, LcdSoftButtonsEventArgs e)
}

// Second button is pressed
else if ((e.SoftButtons & LcdSoftButtons.Button1) == LcdSoftButtons.Button1)
else if (((e.SoftButtons & LcdSoftButtons.Button1) == LcdSoftButtons.Button1) || (e.SoftButtons & LcdSoftButtons.Down) == LcdSoftButtons.Down)
{

if (device.CurrentPage == page[0])
{
if (this.rating != 0)
Expand All @@ -395,12 +374,6 @@ private void buttonPressed(object sender, LcdSoftButtonsEventArgs e)
}
}

//else if (device.CurrentPage == page[1])
//{
// playlistScroll -= 1;
// this.playlist = musicBeePlugin.getPlayList(playlistScroll);
//}

else if (device.CurrentPage == page[1])
{
if (settingSelected != 0)
Expand All @@ -418,7 +391,7 @@ private void buttonPressed(object sender, LcdSoftButtonsEventArgs e)
}

// Third button is pressed
else if ((e.SoftButtons & LcdSoftButtons.Button2) == LcdSoftButtons.Button2)
else if(((e.SoftButtons & LcdSoftButtons.Button2) == LcdSoftButtons.Button2) || (e.SoftButtons & LcdSoftButtons.Up) == LcdSoftButtons.Up)
{
if (device.CurrentPage == page[0])
{
Expand All @@ -428,11 +401,6 @@ private void buttonPressed(object sender, LcdSoftButtonsEventArgs e)
musicBeePlugin.changeRating(this.rating);
}
}
//else if (device.CurrentPage == page[1])
//{
// playlistScroll += 1;
// this.playlist = musicBeePlugin.getPlayList(playlistScroll);
//}

else if (device.CurrentPage == page[1])
{
Expand All @@ -451,7 +419,7 @@ private void buttonPressed(object sender, LcdSoftButtonsEventArgs e)
}

// Fourth button is pressed
else if ((e.SoftButtons & LcdSoftButtons.Button3) == LcdSoftButtons.Button3)
else if (((e.SoftButtons & LcdSoftButtons.Button3) == LcdSoftButtons.Button3) || (e.SoftButtons & LcdSoftButtons.Right) == LcdSoftButtons.Right)
{
if (pageNumber == page.Length - 1)
{
Expand Down Expand Up @@ -487,7 +455,6 @@ private void buttonPressed(object sender, LcdSoftButtonsEventArgs e)
settingsGdi[3].Text = "Repeat: " + repeat;
break;
};

}
else
{
Expand Down Expand Up @@ -575,9 +542,8 @@ private void createMonochrome()
page[0].Children.Add(durationGdi);
page[0].Children.Add(progressBarGdi);


/**
* Create second screen (playlist)
* Create second screen (settings)
* */
settingsGdi[0] = new LcdGdiText("Shuffle: " + shuffle, font2);
settingsGdi[0].HorizontalAlignment = LcdGdiHorizontalAlignment.Center;
Expand Down Expand Up @@ -681,6 +647,36 @@ private void createColor()
page[0].Children.Add(albumGdi);
page[0].Children.Add(artworkGdi);


///**
// * Create second screen (settings)
// * */
//settingsGdi[0] = new LcdGdiText("Shuffle: " + shuffle, font2);
//settingsGdi[0].HorizontalAlignment = LcdGdiHorizontalAlignment.Center;
//settingsGdi[0].Margin = new MarginF(-2, 0, 0, 0);

//settingsGdi[1] = new LcdGdiText("Auto DJ: " + autoDJ, font2);
//settingsGdi[1].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
//settingsGdi[1].VerticalAlignment = LcdGdiVerticalAlignment.Top;
//settingsGdi[1].Margin = new MarginF(-2, 10, 0, 0);

//settingsGdi[2] = new LcdGdiText("Equalizer: " + equaliser, font2);
//settingsGdi[2].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
//settingsGdi[2].VerticalAlignment = LcdGdiVerticalAlignment.Top;
//settingsGdi[2].Margin = new MarginF(-2, 20, 0, 0);

//settingsGdi[3] = new LcdGdiText("Repeat: " + repeat, font2);
//settingsGdi[3].HorizontalAlignment = LcdGdiHorizontalAlignment.Left;
//settingsGdi[3].VerticalAlignment = LcdGdiVerticalAlignment.Top;
//settingsGdi[3].Margin = new MarginF(-2, 30, 0, 0);

//page[1].Children.Add(settingsGdi[0]);
//page[1].Children.Add(settingsGdi[1]);
//page[1].Children.Add(settingsGdi[2]);
//page[1].Children.Add(settingsGdi[3]);



device.CurrentPage = page[0];

device.DoUpdateAndDraw();
Expand Down Expand Up @@ -782,6 +778,5 @@ public void settingsChanged(bool alwaysOnTop_)
this.alwaysOnTop = alwaysOnTop_;
device.SetAsForegroundApplet = alwaysOnTop;
}

}
}
25 changes: 11 additions & 14 deletions Logitech applet/LogitechApplet.cs
Expand Up @@ -7,7 +7,6 @@

namespace MusicBeePlugin
{

public partial class Plugin
{
private MusicBeeApiInterface mbApiInterface;
Expand Down Expand Up @@ -46,7 +45,7 @@ public bool Configure(IntPtr panelHandle)
public void SaveSettings()
{
// save any persistent settings in a sub-folder of this path
string dataPath = mbApiInterface.Setting_GetPersistentStoragePath();
string dataPath = mbApiInterface.Setting_GetPersistentStoragePath();
}

// MusicBee is closing the plugin (plugin is being disabled by user or MusicBee is shutting down)
Expand Down Expand Up @@ -90,7 +89,7 @@ public void ReceiveNotification(string sourceFileUrl, NotificationType type)
break;

case NotificationType.PlayStateChanged:

if (logitech != null && logitech.connected)
{
switch (mbApiInterface.Player_GetPlayState())
Expand Down Expand Up @@ -155,7 +154,8 @@ public void ReceiveNotification(string sourceFileUrl, NotificationType type)
public void changeRating(float number)
{
String url = mbApiInterface.NowPlaying_GetFileUrl();
mbApiInterface.Library_SetFileTag(url, MetaDataType.Rating, number.ToString());
string test = number.ToString();
mbApiInterface.Library_SetFileTag(url, MetaDataType.Rating, "0,5");
}

public void updateTrackText()
Expand All @@ -165,7 +165,6 @@ public void updateTrackText()
string title = mbApiInterface.NowPlaying_GetFileTag(MetaDataType.TrackTitle);
string artwork = mbApiInterface.NowPlaying_GetArtwork();
string rating = mbApiInterface.NowPlaying_GetFileTag(MetaDataType.Rating);
// ArrayList playlist = getPlayList(0);

bool autoDJ = mbApiInterface.Player_GetAutoDjEnabled();
bool equaliser = mbApiInterface.Player_GetEqualiserEnabled();
Expand Down Expand Up @@ -198,7 +197,7 @@ public void changeSettings(bool autoDJ, bool equaliser, bool shuffle, RepeatMode
mbApiInterface.Player_SetEqualiserEnabled(equaliser);
}

if(repeat != repeatMusicbee)
if (repeat != repeatMusicbee)
{

mbApiInterface.Player_SetRepeat(repeat);
Expand All @@ -213,18 +212,16 @@ public void changeSettings(bool autoDJ, bool equaliser, bool shuffle, RepeatMode

public string getTrackName(String url)
{
if(url.Length > 0)
if (url.Length > 0)
{
return mbApiInterface.Library_GetFileTag(url, MetaDataType.TrackTitle);
}
else
{
return "";
}
}
else
{
return "";
}
}



// return an array of lyric or artwork provider names this plugin supports
// the providers will be iterated through one by one and passed to the RetrieveLyrics/ RetrieveArtwork function in order set by the user in the MusicBee Tags(2) preferences screen until a match is found
public string[] GetProviders()
Expand Down
Binary file modified Logitech applet/Logitech_applet.v11.suo
Binary file not shown.

0 comments on commit e360cf9

Please sign in to comment.