Skip to content

Commit

Permalink
cria tela de aviso e ajusta classe informações adicionais
Browse files Browse the repository at this point in the history
  • Loading branch information
adolfoIN committed Jul 23, 2021
1 parent 0048aae commit c701b4a
Show file tree
Hide file tree
Showing 19 changed files with 795 additions and 451 deletions.
Binary file modified .vs/SoundCloud/v16/.suo
Binary file not shown.
16 changes: 16 additions & 0 deletions SoundCloud/Entidade/InformacoesAdicionais.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SoundCloud.Entidade
{
public class InformacoesAdicionais
{

public double Tamanho { get; set; }

public string Extensao { get; set; }
}
}
249 changes: 182 additions & 67 deletions SoundCloud/FrmMain.Designer.cs

Large diffs are not rendered by default.

113 changes: 79 additions & 34 deletions SoundCloud/FrmMain.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Windows.Forms;
using Bunifu.UI.WinForms;
using NAudio.Wave;
using NAudio.WaveFormRenderer;
using SoundCloud.Entidade;
using SoundCloud.Error;
using SoundCloud.Mensagem;

namespace SoundCloud
{
Expand All @@ -14,12 +18,13 @@ public partial class FrmMain : Form
private IWavePlayer wavePlayer = new WaveOutEvent();
private AudioFileReader audioFileReader;
private FileInfo file;
public IList<InformacoesAdicionais> informacoesAdicionais = new List<InformacoesAdicionais>();
public Boolean _botaoAdicionado = false;

public FrmMain()
{
InitializeComponent();
grid.Columns[0].DefaultCellStyle.NullValue = null;
grid.Rows.Clear();
}

private void btnMin_Click(object sender, EventArgs e)
Expand All @@ -40,6 +45,7 @@ private void dataGridView1_DragEnter(object sender, DragEventArgs e)

private void dataGridView1_DragDrop(object sender, DragEventArgs e)
{

string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);

foreach (string item in files)
Expand All @@ -56,9 +62,33 @@ private void dataGridView1_DragDrop(object sender, DragEventArgs e)

});

informacoesAdicionais.Add(new InformacoesAdicionais { Extensao = fi.Extension, Tamanho = double.Parse((fi.Length/1000).ToString(@"#\,###", CultureInfo.InvariantCulture)) });


grid.Rows[r].Tag = fi;
}

if(_botaoAdicionado != true)
AdicionarColuna();





}

private void AdicionarColuna()
{
_botaoAdicionado = true;

grid.Columns.Add(new DataGridViewButtonColumn()
{
Text = "Ver",
UseColumnTextForButtonValue = true,
AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill,
HeaderText = "Informações Adicionais"

});


}
Expand Down Expand Up @@ -170,37 +200,48 @@ private void btnPlayPause_Click(object sender, EventArgs e)

private void timer1_Tick(object sender, EventArgs e)
{
if(wavePlayer.PlaybackState == PlaybackState.Playing)
if (wavePlayer.PlaybackState == PlaybackState.Playing)
{
lblMusica.Text = file.Name;
picPlay.Enabled = true;
SetSlider();
if (!lblArtista.Text.Contains("🤘"))
{
lblArtista.Text = "Tocando agora 🤘🤘🤘";
lblArtista.Text = "Tocando 🤘🤘🤘";
}
else if (lblArtista.Text.Contains("🤘🤘🤘"))
{
lblArtista.Text = "Tocando agora 🤘🤘";
}else if (lblArtista.Text.Contains("🤘🤘"))
lblArtista.Text = "Tocando 🤘🤘";
}
else if (lblArtista.Text.Contains("🤘🤘"))
{
lblArtista.Text = "Tocando agora 🤘";
lblArtista.Text = "Tocando 🤘";
}
else
{
lblArtista.Text = "Tocando agora";
lblArtista.Text = "Tocando";
}

}
else
{
if(wavePlayer.PlaybackState == PlaybackState.Stopped)
if (wavePlayer.PlaybackState == PlaybackState.Stopped)
{
picWv.Width = 0;
}
lblMusica.Text = "Player inspirado no SoundCloud";
picPlay.Enabled = false;
lblArtista.Text = wavePlayer.PlaybackState.ToString();

switch (wavePlayer.PlaybackState.ToString())
{
case "Paused":
lblArtista.Text = "Pausado";
break;
case "Stopped":
lblArtista.Text = "Parado";
break;
}

}
}

Expand All @@ -216,20 +257,20 @@ private void SetSlider()

private void txtBusca_KeyUp(object sender, KeyEventArgs e)
{
if(txtBusca.Text.Trim().Length != 0 || e.KeyCode == Keys.Enter)
if (txtBusca.Text.Trim().Length != 0 || e.KeyCode == Keys.Enter)
{
var indice = 0;
foreach (DataGridViewRow item in grid.Rows)
{
if (indice < grid.RowCount-1)
if (indice < grid.RowCount)
{
item.Visible = grid.Rows[indice].Cells[1].Value.ToString().ToLower().Contains(txtBusca.Text.Trim().ToLower());

indice++;
}
}


}
}

Expand Down Expand Up @@ -310,41 +351,33 @@ private void btnReplay_Click(object sender, EventArgs e)
}

private void bunifuHSlider1_Scroll(object sender, Utilities.BunifuSlider.BunifuHScrollBar.ScrollEventArgs e)

{
try
var quantidadeDeLinhas = grid.RowCount;

if (quantidadeDeLinhas == 0)
{
if (vol.Value != 0)
{
audioFileReader.Volume = wavePlayer.Volume = (vol.Value - 1) / 100f;
}
var telaErro = new Base("Não é possível alterar o volume sem música adicionada!");
telaErro.Show();
}
catch(Exception ex)
else
{
var telaErro = new Base("Não é possível alterar o volume sem música");
telaErro.Show();


if (vol.Value != 0)
audioFileReader.Volume = wavePlayer.Volume = (vol.Value - 1) / 100f;
}

}


private void pnWaveForm_MouseUp(object sender, MouseEventArgs e)
{
try

if(audioFileReader != null)
{
picWv.Width = e.X;

var max = audioFileReader.Length;
var val = (e.X * max) / pnWaveForm.Width;
audioFileReader.Position = val;


}
catch (Exception)
{

}
}
}

private void picWv_MouseUp(object sender, MouseEventArgs e)
Expand All @@ -359,12 +392,24 @@ private void picWv_MouseUp(object sender, MouseEventArgs e)
//audioFileReader.Position = picWv.Width;

picWv.Width = 0;

}
catch (Exception)
{

}
}

private void grid_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if(grid.Columns[e.ColumnIndex] is DataGridViewButtonColumn)
{
var aviso = new Aviso();

aviso.Carrega(informacoesAdicionais[e.RowIndex].Extensao.ToString(), informacoesAdicionais[e.RowIndex].Tamanho);
aviso.Show();
}

}
}
}
Loading

0 comments on commit c701b4a

Please sign in to comment.