Hey people.
I have an pieace of code now which creates an Window. The problem is:
I cant put source in it? here is the code:
using System;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Web;
using System.IO;
namespace MusicBeePlugin
{
public partial class Plugin
{
private MusicBeeApiInterface mbApiInterface;
private PluginInfo about = new PluginInfo();
public PluginInfo Initialise(IntPtr apiInterfacePtr)
{
mbApiInterface = (MusicBeeApiInterface)Marshal.PtrToStructure(apiInterfacePtr, typeof(MusicBeeApiInterface));
about.PluginInfoVersion = PluginInfoVersion;
about.Name = "Plugin Name";
about.Description = "A brief description of what this plugin does";
about.Author = "Author";
about.TargetApplication = "Yahoo Messenger"; // current only applies to artwork, lyrics or instant messenger name that appears in the provider drop down selector or target Instant Messenger
about.Type = PluginType.InstantMessenger;
about.VersionMajor = 1; // your plugin version
about.VersionMinor = 0;
about.Revision = 1;
about.MinInterfaceVersion = MinInterfaceVersion;
about.MinApiRevision = MinApiRevision;
about.ReceiveNotifications = ReceiveNotificationFlags.PlayerEvents;
about.ConfigurationPanelHeight = 0; // not implemented yet: height in pixels that musicbee should reserve in a panel for config settings. When set, a handle to an empty panel will be passed to the Configure function
PluginStartup();
return about;
}
static void PluginStartup()
{
Application.Run(new MyWindow());
}
class MyWindow : Form
{
public MyWindow() : base()
{
this.Text = "Twitter App";
this.Size = new Size(400, 400);
this.StartPosition = FormStartPosition.CenterScreen;
// Label
Label lblGreeting = new Label();
lblGreeting.Text = "Just to tweet my songs!";
lblGreeting.Location = new Point(50, 50);
}
public static void PostTweet(string username, string password, string tweet)
{
try {
// encode the username/password
string user = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password));
// determine what we want to upload as a status
byte[] bytes = System.Text.Encoding.ASCII.GetBytes("status=" + tweet);
// connect with the update page
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("
http://twitter.com/statuses/update.xml");
// set the method to POST
request.Method="POST";
request.ServicePoint.Expect100Continue = false; // thanks to argodev for this recent change!
// set the authorisation levels
request.Headers.Add("Authorization", "Basic " + user);
request.ContentType="application/x-www-form-urlencoded";
// set the length of the content
request.ContentLength = bytes.Length;
// set up the stream
Stream reqStream = request.GetRequestStream();
// write to the stream
reqStream.Write(bytes, 0, bytes.Length);
// close the stream
reqStream.Close();
} catch (Exception ex) {/* DO NOTHING */}
}
}
public bool Configure(IntPtr panelHandle)
{
// save any persistent settings in a sub-folder of this path
string dataPath = mbApiInterface.Setting_GetPersistentStoragePath();
// panelHandle will only be set if you set about.ConfigurationPanelHeight to a non-zero value
// keep in mind the panel width is scaled according to the font the user has selected
if (panelHandle != IntPtr.Zero)
{
Panel configPanel = (Panel)Panel.FromHandle(panelHandle);
Label prompt = new Label();
prompt.AutoSize = true;
prompt.Location = new Point(0, 0);
prompt.Text = "prompt:";
TextBox textBox = new TextBox();
textBox.Bounds = new Rectangle(60, 0, 100, textBox.Height);
textBox.TextChanged += textBox_TextChanged;
configPanel.Controls.AddRange(new Control[] { prompt, textBox });
}
return false;
}
private void textBox_TextChanged(object sender, EventArgs e)
{
// save the value
}
// MusicBee is closing the plugin (plugin is being disabled by user or MusicBee is shutting down)
public void Close(PluginCloseReason reason)
{
}
// uninstall this plugin - clean up any persisted files
public void Uninstall()
{
}
// receive event notifications from MusicBee
// only required if about.ReceiveNotificationFlags = PlayerEvents
public void ReceiveNotification(string sourceFileUrl, NotificationType type)
{
// perform some action depending on the notification type
switch (type)
{
case NotificationType.PluginStartup:
// perform startup initialisation
switch (mbApiInterface.Player_GetPlayState())
{
case PlayState.Playing:
case PlayState.Paused:
// ...
break;
}
break;
case NotificationType.TrackChanged:
string artist = mbApiInterface.NowPlaying_GetFileTag(MetaDataType.Artist);
// ...
break;
}
}
// 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()
{
return null;
}
// return lyrics for the requested artist/title from the requested provider
// only required if PluginType = LyricsRetrieval
// return null if no lyrics are found
public string RetrieveLyrics(string sourceFileUrl, string artist, string trackTitle, string album, bool synchronisedPreferred, string provider)
{
return null;
}
// return Base64 string representation of the artwork binary data from the requested provider
// only required if PluginType = ArtworkRetrieval
// return null if no artwork is found
public string RetrieveArtwork(string sourceFileUrl, string albumArtist, string album, string provider)
{
//Return Convert.ToBase64String(artworkBinaryData)
return null;
}
}
}