0% found this document useful (0 votes)
83 views6 pages

Using Using Using Using Using Using Namespace: "Calibri"

The document describes classes for creating buttons to control a media player application. It defines classes for play, pause, stop, volume up, and volume down buttons. The classes override the OnPaint method to draw the buttons and set properties like color, text, and region. The main form initializes instances of the button classes and adds click event handlers to control the Windows Media Player.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views6 pages

Using Using Using Using Using Using Namespace: "Calibri"

The document describes classes for creating buttons to control a media player application. It defines classes for play, pause, stop, volume up, and volume down buttons. The classes override the OnPaint method to draw the buttons and set properties like color, text, and region. The main form initializes instances of the button classes and adds click event handlers to control the Windows Media Player.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

using using using using using using

System; System.Collections.Generic; System.Linq; System.Text; System.Drawing; System.Windows.Forms;

namespace ClaseMP3 { public class botonplay: System.Windows.Forms.Control { public String mplay { set; get; } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { Graphics hoja; hoja = e.Graphics; SolidBrush brocha = new SolidBrush(Color.Gold); Pen lapiz = new Pen(Color.White, 1); Point[] puntos = new Point[3]; puntos[0] = new Point(0,0); puntos[1] = new Point(30,15); puntos[2] = new Point(0,30); hoja.FillPolygon(brocha, puntos); hoja.DrawPolygon(lapiz, puntos); hoja.DrawString(mplay, new Font("Calibri", 10), new SolidBrush(Color.Black), new Point(0,35)); System.Drawing.Drawing2D.GraphicsPath forma = new System.Drawing.Drawing2D.GraphicsPath(); forma.AddPolygon(puntos); this.Region = new Region(forma); } } public class botonpause : System.Windows.Forms.Control { public String mpause { set; get; } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { Graphics hoja; hoja = e.Graphics; SolidBrush brocha = new SolidBrush(Color.Yellow); Pen lapiz = new Pen(Color.White, 1); Point[] puntos = new Point[3]; puntos[0] = new Point(0,5); puntos[1] = new Point(20, 12); puntos[2] = new Point(0, 20); hoja.DrawRectangle(new Pen(Color.Aqua, 4), new Rectangle(25, 6, 2, 15)); hoja.FillPolygon(brocha, puntos); hoja.DrawPolygon(lapiz, puntos); hoja.DrawString(mpause, new Font("Calibri", 9), new SolidBrush(Color.Black), new Point(0, 35)); System.Drawing.Drawing2D.GraphicsPath forma = new System.Drawing.Drawing2D.GraphicsPath(); forma.AddPolygon(puntos);

this.Region = new Region(forma); } } public class botonstop : System.Windows.Forms.Control { public String mstop { set; get; } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { Graphics hoja; hoja = e.Graphics; SolidBrush brocha = new SolidBrush(Color.Red); Pen lapiz = new Pen(Color.White, 1); hoja.FillRectangle(brocha, new Rectangle(0,0,30,30)); hoja.DrawString(mstop, new Font("Calibri", 10), new SolidBrush(Color.Black), new Point(0, 35)); System.Drawing.Drawing2D.GraphicsPath forma = new System.Drawing.Drawing2D.GraphicsPath(); forma.AddRectangle(new Rectangle(0, 0, 30, 30)); this.Region = new Region(forma); } } public class botonsube : System.Windows.Forms.Control { public String msube { set; get; } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { Graphics hoja; hoja = e.Graphics; SolidBrush brocha = new SolidBrush(Color.Green); Pen lapiz = new Pen(Color.White, 1); Point[] puntos = new Point[3]; puntos[0] = new Point(0,30); puntos[1] = new Point(30,30); puntos[2] = new Point(15,0); hoja.FillPolygon(brocha, puntos); hoja.DrawPolygon(lapiz, puntos); hoja.DrawString(msube, new Font("Calibri", 10), new SolidBrush(Color.Black), new Point(0, 35)); System.Drawing.Drawing2D.GraphicsPath forma = new System.Drawing.Drawing2D.GraphicsPath(); forma.AddPolygon(puntos); this.Region = new Region(forma); } } public class botonbaja : System.Windows.Forms.Control { public String mbaja { set; get; } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { Graphics hoja; hoja = e.Graphics;

SolidBrush brocha = new SolidBrush(Color.Blue); Pen lapiz = new Pen(Color.White, 1); Point[] puntos = new Point[3]; puntos[0] = new Point(0,0); puntos[1] = new Point(30,0); puntos[2] = new Point(15,30); hoja.FillPolygon(brocha, puntos); hoja.DrawPolygon(lapiz, puntos); hoja.DrawString(mbaja, new Font("Calibri", 10), new SolidBrush(Color.Black), new Point(0, 35)); System.Drawing.Drawing2D.GraphicsPath forma = new System.Drawing.Drawing2D.GraphicsPath(); forma.AddPolygon(puntos); this.Region = new Region(forma); } } }

using System;
using using using using using using using using using using using System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms; MediaPlayer; System.IO; ClaseMP3; WMPLib;

namespace ReproductorHerenciaUTP { public partial class Form1 : Form { string cancion = ""; public Form1() { InitializeComponent(); ClaseMP3.botonplay play = new ClaseMP3.botonplay(); play.Size = new Size(40,60); play.mplay = "Play"; play.Location = new Point(10,100); this.Controls.Add(play); play.Click += new EventHandler(play_Click);

ClaseMP3.botonpause pause = new ClaseMP3.botonpause(); pause.Size = new Size(40, 60); pause.mpause = "Pause";

pause.Location = new Point(70, 100); this.Controls.Add(pause); pause.Click += new EventHandler(pause_Click); ClaseMP3.botonstop stop = new ClaseMP3.botonstop(); stop.Size = new Size(40, 60); stop.mstop = "Stop"; stop.Location = new Point(130, 100); this.Controls.Add(stop); stop.Click += new EventHandler(stop_Click); ClaseMP3.botonbaja baja = new ClaseMP3.botonbaja(); baja.Size = new Size(40, 60); baja.mbaja = "Vol -"; baja.Location = new Point(190, 100); this.Controls.Add(baja); baja.Click += new EventHandler(baja_Click); ClaseMP3.botonsube sube = new ClaseMP3.botonsube(); sube.Size = new Size(40, 60); sube.msube = "Vol +"; sube.Location = new Point(250, 100); this.Controls.Add(sube); sube.Click += new EventHandler(sube_Click);

} void baja_Click(object sender, EventArgs e) { WMP1.settings.volume -= 10; } void sube_Click(object sender, EventArgs e) { WMP1.settings.volume += 10; } void stop_Click(object sender, EventArgs e) { WMP1.Ctlcontrols.stop(); } void pause_Click(object sender, EventArgs e) { WMP1.Ctlcontrols.pause(); } void play_Click(object sender, EventArgs e) { WMP1.Ctlcontrols.play(); } void boton1_Click(object sender, EventArgs e) { if (cancion != "") { WMP1.Ctlcontrols.play(); }

else { MessageBox.Show("No has seleccionado ninguna cancin", "Seleccionar Cancin"); } }

private void Form1_Load(object sender, EventArgs e) { }

private void BuscaCarpeta_Click(object sender, EventArgs e) { using (FolderBrowserDialog dlg = new FolderBrowserDialog())// creo el examinador de carpetas { dlg.Description = "Seleccione la carpeta de canciones";//le pongo un nombre a mostrar al examinar if (dlg.ShowDialog() == DialogResult.OK)// si el usuario selecciona carpeta y da clic en aceptar entra { RutaCanciones.Text = dlg.SelectedPath;//guardo la ruta de la carpeta de canciones en el textbox RutaCanciones string[] ListaCanciones = Directory.GetFiles(dlg.SelectedPath);//entro a la ruta de canciones y las guardo en un arreglo for (int i = 0; i < ListaCanciones.Length; i++) // recorro todas las canciones que encontre { Canciones.Rows.Add(ListaCanciones[i]);//meto en el gridview una por una todas las canciones que encontre }

} } } private void Canciones_MouseDoubleClick(object sender, MouseEventArgs e) { if (Canciones.SelectedCells.Count > 0)// valido que alguna celda este seleccionada { var index = Canciones.CurrentCell.RowIndex;// obtengo que index esta selecciona cancion = Canciones.Rows[index].Cells[0].Value.ToString();//obtengo la ruta de la cancion de acuerdo al index seleccionado WMP1.URL = @"" + cancion; } } private void Canciones_CellContentClick(object sender, DataGridViewCellEventArgs e)

{ } private void WMP1_Enter(object sender, EventArgs e) { } } }

You might also like