How do I make another class pop up in another window in c sharp?

dai-ken dhi

New member
I want the class on this program to popup when the button I created is pressed.

namespace MusicPlayer
{
public partial class Form1 : Form
{
private string _command;
private bool isOpen;

[DllImport("winmm.dll")]
private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr hwndCallback);

public Form1()
{
InitializeComponent();
}


private void buttonPlay_Click(object sender, EventArgs e)
{
//This is the class that I want to throw to another window and run at the same time.
Matrix.MatrixEffect();

try
{
this.OpenPlayer(this.textBox1.Text);
this.Play(false);

}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}

}

private void buttonStop_Click(object sender, EventArgs e)
{
try
{
this.ClosePlayer();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}

public void ClosePlayer()
{
_command = "close MediaFile";
mciSendString(_command, null, 0, IntPtr.Zero);
isOpen = false;
}

public void OpenPlayer(string sFileName)
{
_command = "open \"" + sFileName + "\" type mpegvideo alias MediaFile";
mciSendString(_command, null, 0, IntPtr.Zero);
isOpen = true;
}

public void Play(bool loop)
{
if (isOpen)
{
_command = "play MediaFile";
if (loop)
_command += " REPEAT";
mciSendString(_command, null, 0, IntPtr.Zero);
}
}

private void loadToolStripMenuItem_Click(object sender, EventArgs e)
{
Loadist.loadMusic(textBox1);
}

private void closeToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}

private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Is this program really that hard to use?");
}


}

public class Loadist : Form1
{
public static void loadMusic(TextBox textBox1)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = Environment.SpecialFolder.MyMusic.ToStri…
ofd.Filter = "mp3 files|*.mp3|All files (*.*)|*.*";
ofd.FilterIndex = 1;

if (ofd.ShowDialog() == DialogResult.OK)
{
textBox1.Text = ofd.FileName.ToString();
}
}
}
}
 
Back
Top