146 lines
2.9 KiB
C#
146 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Gtk;
|
|
|
|
namespace DMX2
|
|
{
|
|
[System.ComponentModel.ToolboxItem(true)]
|
|
public partial class SeqLinUI : SequenceurUI
|
|
{
|
|
|
|
bool fullUpdFlag = true;
|
|
SequenceurLineaire sequenceur;
|
|
|
|
public SeqLinUI (SequenceurLineaire s ) : base (s)
|
|
{
|
|
this.Build ();
|
|
titreLabel.Text = s.Name;
|
|
sequenceur = s;
|
|
Update();
|
|
}
|
|
|
|
public override void Update ()
|
|
{
|
|
if(fullUpdFlag) FullUpdate();
|
|
UpdateValues();
|
|
}
|
|
|
|
protected void OnCircuitsActionActivated (object sender, EventArgs e)
|
|
{
|
|
var dlg = new SelSeqCircuits (sequenceur.Circuits);
|
|
if ((ResponseType)dlg.Run () == ResponseType.Ok) {
|
|
sequenceur.ChangeCircuits(dlg.GetResultList());
|
|
}
|
|
dlg.Destroy();
|
|
|
|
//TODO : a retirer plus tard
|
|
FullUpdate();
|
|
}
|
|
|
|
protected void OnCloseActionActivated (object sender, EventArgs e)
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
|
|
Dictionary<Circuit,VScale> tirettes = new Dictionary<Circuit, VScale>();
|
|
|
|
static VScale NouvelleTirette ()
|
|
{
|
|
VScale tirette = new VScale (null);
|
|
tirette.WidthRequest = 25;
|
|
tirette.HeightRequest = 150;
|
|
tirette.CanFocus = true;
|
|
tirette.Inverted = true;
|
|
tirette.Adjustment.Upper = 100;
|
|
tirette.Adjustment.PageIncrement = 10;
|
|
tirette.Adjustment.StepIncrement = 1;
|
|
tirette.DrawValue = true;
|
|
tirette.Digits = 0;
|
|
return tirette;
|
|
}
|
|
|
|
static Label NouveauLabel ()
|
|
{
|
|
Label l = new Label();
|
|
l.WidthRequest = 50;
|
|
l.HeightRequest = 66;
|
|
l.Xalign = 1F;
|
|
l.Yalign = 0F;
|
|
l.UseMarkup = true;
|
|
l.Angle = 65;
|
|
return l;
|
|
}
|
|
|
|
|
|
int lastKnownWidth =0;
|
|
object circuitKey = new object();
|
|
|
|
protected void FullUpdate ()
|
|
{
|
|
fullUpdFlag=true;
|
|
// TODO : ici : Remise a plat de l'UI , Ajout/agencement des tirettes et descriptions
|
|
|
|
|
|
lastKnownWidth = zoneWid.Allocation.Width;
|
|
|
|
foreach (Widget wid in new List<Widget>(zoneWid.Children))
|
|
zoneWid.Remove (wid);
|
|
|
|
tirettes.Clear();
|
|
|
|
int xpos=10, ypos=0;
|
|
VScale tirette; Fixed.FixedChild fx;
|
|
Label label;
|
|
|
|
foreach (Circuit c in sequenceur.Circuits) {
|
|
tirettes[c] = tirette = NouvelleTirette();
|
|
zoneWid.Add(tirette);
|
|
fx = ( zoneWid[tirette] as Fixed.FixedChild);
|
|
fx.X = xpos; fx.Y = ypos;
|
|
tirette.Show();
|
|
tirette.ValueChanged += TiretteActionee;
|
|
tirette.Data.Add(circuitKey,c);
|
|
|
|
label = NouveauLabel();
|
|
zoneWid.Add(label);
|
|
fx = ( zoneWid[label] as Fixed.FixedChild);
|
|
fx.X = xpos-30;
|
|
fx.Y = ypos+150;
|
|
label.LabelProp = "<small>" + c.ShortName + "</small>";
|
|
label.Show();
|
|
|
|
xpos+=30;
|
|
if(lastKnownWidth < xpos +30)
|
|
{
|
|
xpos =10; ypos+= 215;
|
|
}
|
|
}
|
|
|
|
fullUpdFlag=false;
|
|
}
|
|
|
|
void TiretteActionee (object sender, EventArgs e)
|
|
{
|
|
VScale t = sender as VScale;
|
|
Circuit c = t.Data[circuitKey] as Circuit;
|
|
|
|
}
|
|
|
|
protected void UpdateValues()
|
|
{
|
|
|
|
}
|
|
|
|
protected void OnZoneWidSizeAllocated (object o, SizeAllocatedArgs args)
|
|
{
|
|
if (!fullUpdFlag) {
|
|
if(lastKnownWidth != args.Allocation.Width)
|
|
FullUpdate ();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|