187 lines
4.9 KiB
C#
187 lines
4.9 KiB
C#
/*
|
|
|
|
Copyright (C) Arnaud Houdelette 2012-2014
|
|
Copyright (C) Emmanuel Langlois 2012-2014
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using Gtk;
|
|
|
|
namespace DMX2
|
|
{
|
|
[System.ComponentModel.ToolboxItem(true)]
|
|
public partial class SeqSonUI : SequenceurUI
|
|
{
|
|
|
|
ListStore lsFiles = null;
|
|
|
|
SequenceurSon sequenceur;
|
|
|
|
public void buildListFiles ()
|
|
{
|
|
lsFiles = new ListStore(typeof(string));
|
|
|
|
listFiles.EnableGridLines= TreeViewGridLines.Both;
|
|
|
|
var idCol = new Gtk.TreeViewColumn ();
|
|
var idCell = new Gtk.CellRendererText ();
|
|
idCol.Title = "N°";
|
|
idCol.PackStart (idCell, true);
|
|
idCol.SetCellDataFunc (idCell, new Gtk.TreeCellDataFunc (RenderNum));
|
|
listFiles.AppendColumn (idCol);
|
|
|
|
var fileCol = new Gtk.TreeViewColumn ();
|
|
var fileCell = new Gtk.CellRendererText ();
|
|
fileCol.Title = "Nom";
|
|
fileCol.PackStart (fileCell, true);
|
|
fileCol.SetCellDataFunc (fileCell, new Gtk.TreeCellDataFunc (RenderFile));
|
|
listFiles.AppendColumn (fileCol);
|
|
|
|
listFiles.Model = lsFiles;
|
|
}
|
|
|
|
void UpdListFiles ()
|
|
{
|
|
lsFiles.Clear();
|
|
foreach (var file in sequenceur.Files) {
|
|
lsFiles.AppendValues(file);
|
|
}
|
|
}
|
|
|
|
void RenderNum (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter)
|
|
{
|
|
if (Conduite.Courante==null) return;
|
|
string num=string.Empty;
|
|
string l = tree_model.GetValue (iter, 0) as string;
|
|
if( sequenceur.CurFile == l )
|
|
num+= "->";
|
|
(cell as Gtk.CellRendererText).Text = num + (sequenceur.Files.IndexOf(l)+1).ToString();
|
|
}
|
|
|
|
void RenderFile (TreeViewColumn tree_column, CellRenderer cell, TreeModel tree_model, TreeIter iter)
|
|
{
|
|
if (Conduite.Courante==null) return;
|
|
string l = tree_model.GetValue (iter, 0) as string;
|
|
(cell as Gtk.CellRendererText).Text = l;
|
|
}
|
|
|
|
public SeqSonUI (SequenceurSon s):base(s)
|
|
{
|
|
this.Build ();
|
|
sequenceur = s;
|
|
buildListFiles();
|
|
}
|
|
#region implemented abstract members of DMX2.SequenceurUI
|
|
public override void Update (bool full)
|
|
{
|
|
//throw new System.NotImplementedException ();
|
|
}
|
|
|
|
int IndexSelection()
|
|
{
|
|
var sel = listFiles.Selection.GetSelectedRows();
|
|
if(sel.Length ==0) return -1;
|
|
return listFiles.Selection.GetSelectedRows()[0].Indices[0];
|
|
}
|
|
|
|
protected void OnActAddFileActivated (object sender, EventArgs e)
|
|
{
|
|
FileChooserDialog fcd = new FileChooserDialog ("Ouvrir ...", this.Parent as Gtk.Window,
|
|
FileChooserAction.Open,
|
|
"Annuler", ResponseType.Cancel,
|
|
"Ouvrir", ResponseType.Accept);
|
|
fcd.SelectMultiple = true;
|
|
/*fcd.Filter = new FileFilter ();
|
|
fcd.Filter.AddPattern ("*.mp3");*/
|
|
if ((ResponseType)fcd.Run () == ResponseType.Cancel || fcd.Filename == null) {
|
|
fcd.Destroy ();
|
|
return;
|
|
}
|
|
|
|
int pos = IndexSelection ();
|
|
foreach (var file in fcd.Filenames) {
|
|
pos = sequenceur.AddFile (pos + 1, file );
|
|
if(sequenceur.CurFile.Equals(string.Empty))
|
|
sequenceur.Index=0;
|
|
}
|
|
fcd.Destroy ();
|
|
UpdListFiles();
|
|
|
|
}
|
|
|
|
protected void OnActDelFileActivated (object sender, EventArgs e)
|
|
{
|
|
int pos = IndexSelection();
|
|
if (pos==-1) return;
|
|
sequenceur.DelFile(pos);
|
|
UpdListFiles();
|
|
}
|
|
|
|
protected void OnBtnNextClicked (object sender, EventArgs e)
|
|
{
|
|
sequenceur.Index+=1;
|
|
listFiles.QueueDraw();
|
|
}
|
|
|
|
|
|
protected void OnBtnPlayClicked (object sender, EventArgs e)
|
|
{
|
|
sequenceur.Play();
|
|
}
|
|
|
|
protected void OnBtnPauseClicked (object sender, EventArgs e)
|
|
{
|
|
sequenceur.Pause();
|
|
}
|
|
|
|
protected void OnBtnStopClicked (object sender, EventArgs e)
|
|
{
|
|
sequenceur.Stop();
|
|
}
|
|
|
|
protected void OnBtnPrevClicked (object sender, EventArgs e)
|
|
{
|
|
sequenceur.Index-=1;
|
|
listFiles.QueueDraw();
|
|
}
|
|
|
|
protected void OnBtnRewindPressed (object sender, EventArgs e)
|
|
{
|
|
Console.WriteLine("Rew Pressed");
|
|
}
|
|
protected void OnBtnRewindReleased (object sender, EventArgs e)
|
|
{
|
|
Console.WriteLine("Rew Released");
|
|
}
|
|
protected void OnBtnForwardPressed (object sender, EventArgs e)
|
|
{
|
|
Console.WriteLine("FF Pressed");
|
|
}
|
|
|
|
protected void OnBtnForwardReleased (object sender, EventArgs e)
|
|
{
|
|
Console.WriteLine("FF Released");
|
|
}
|
|
|
|
protected void OnSclVolumeValueChanged (object sender, EventArgs e)
|
|
{
|
|
sequenceur.Volume = (uint)(sclVolume.Value);
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
|