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(true); } public override void Update (bool full) { if(fullUpdFlag || full) FullUpdate(); UpdateValues(); timeLabel.LabelProp = sequenceur.TimeStamp.ToString(); } 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(); fullUpdFlag = true; } protected void OnCloseActionActivated (object sender, EventArgs e) { Destroy(); } Dictionary tirettes = new Dictionary(); static VScale NouvelleTirette () { VScale tirette = new VScale (null); tirette.WidthRequest = 25; tirette.HeightRequest = 150; tirette.CanFocus = true; tirette.Inverted = true; tirette.Adjustment.Upper = 255; 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(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 = "" + c.ShortName + ""; 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; sequenceur.ChangeValeur(c,(int)(t.Value)); } protected void UpdateValues() { foreach (Circuit c in tirettes.Keys) { tirettes[c].Value = sequenceur.ValeurCircuit(c); } } protected void OnZoneWidSizeAllocated (object o, SizeAllocatedArgs args) { if (!fullUpdFlag) { if(lastKnownWidth != args.Allocation.Width) FullUpdate (); } } } }