From aaa450523a462970cf1f12a75b83f030817ea1fe Mon Sep 17 00:00:00 2001 From: tzim Date: Wed, 2 Oct 2013 08:12:56 +0000 Subject: [PATCH] Ajout dialogue sauvegarde et declaration des fonctions --- DMX-2.0/Conduite.cs | 20 ++++++++++++ DMX-2.0/MainWindow.cs | 50 ++++++++++++++++++++++++++++-- DMX-2.0/SeqLinUI.cs | 1 - DMX-2.0/Sequenceur.cs | 5 ++- DMX-2.0/SequenceurMaitre.cs | 13 ++++++++ DMX-2.0/UniversDMX.cs | 18 +++++++---- DMX-2.0/gtk-gui/DMX2.MainWindow.cs | 2 ++ DMX-2.0/gtk-gui/gui.stetic | 2 ++ 8 files changed, 101 insertions(+), 10 deletions(-) diff --git a/DMX-2.0/Conduite.cs b/DMX-2.0/Conduite.cs index a8af614..1bc5932 100644 --- a/DMX-2.0/Conduite.cs +++ b/DMX-2.0/Conduite.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Collections.ObjectModel; using System.Threading; +using System.Xml; namespace DMX2 @@ -179,6 +180,25 @@ namespace DMX2 } #endregion + #region Sauvegarde + + public XmlDocument Save () + { + XmlDocument doc = new XmlDocument(); + + + + + return doc; + } + + public static Conduite Load (XmlDocument doc) + { + return null; + } + + + #endregion } diff --git a/DMX-2.0/MainWindow.cs b/DMX-2.0/MainWindow.cs index 44ddc2e..6bc4352 100644 --- a/DMX-2.0/MainWindow.cs +++ b/DMX-2.0/MainWindow.cs @@ -2,6 +2,7 @@ using System; using Gtk; using System.Collections.Generic; using System.Diagnostics; +using System.IO; namespace DMX2 @@ -10,8 +11,9 @@ namespace DMX2 { static MainWindow win; static object circuitKey = new object(); - ListStore lsMatrice; - + ListStore lsMatrice = null; + FileInfo conduiteFile=null; + public static MainWindow Win { get { return win; } } @@ -336,9 +338,53 @@ namespace DMX2 Conduite.Courante.Drivers.Add( new DriverBoitierV1()); + } + + protected void OnSaveActionActivated (object sender, EventArgs e) + { + if(conduiteFile==null) + SaveFileAs(); + else + SaveFile(); } + protected void OnSaveAsActionActivated (object sender, EventArgs e) + { + SaveFileAs(); + } + void SaveFileAs () + { + FileChooserDialog fcd = new FileChooserDialog("Sauver sous ...",this,FileChooserAction.Save, + "Annuler",ResponseType.Cancel, + "Ouvrir",ResponseType.Accept); + + fcd.Filter = new FileFilter(); + + fcd.Filter.AddPattern("*.dmx2"); + + if ((ResponseType)fcd.Run() == ResponseType.Cancel) + { + fcd.Destroy(); + return; + } + string file = fcd.Filename; + + if(!file.EndsWith(".dmx2")) + file+=".dmx2"; + + conduiteFile = new FileInfo(fcd.Filename); + if (conduiteFile.Exists); + + + fcd.Destroy(); + + } + + void SaveFile() + { + if(conduiteFile==null)return; + } } } \ No newline at end of file diff --git a/DMX-2.0/SeqLinUI.cs b/DMX-2.0/SeqLinUI.cs index dbff8a9..03acffc 100644 --- a/DMX-2.0/SeqLinUI.cs +++ b/DMX-2.0/SeqLinUI.cs @@ -371,7 +371,6 @@ namespace DMX2 protected void OnSeqMasterScaleValueChanged (object sender, EventArgs e) { - if (fullUpdFlag)return; sequenceur.Master = (int)(seqMasterScale.Value); } diff --git a/DMX-2.0/Sequenceur.cs b/DMX-2.0/Sequenceur.cs index 435861c..a31654c 100644 --- a/DMX-2.0/Sequenceur.cs +++ b/DMX-2.0/Sequenceur.cs @@ -54,7 +54,10 @@ namespace DMX2 { } - public abstract XmlElement Save(); + public abstract XmlElement Save (); + + + } } diff --git a/DMX-2.0/SequenceurMaitre.cs b/DMX-2.0/SequenceurMaitre.cs index e12cc38..4514d79 100644 --- a/DMX-2.0/SequenceurMaitre.cs +++ b/DMX-2.0/SequenceurMaitre.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Xml; namespace DMX2 { @@ -55,5 +56,17 @@ namespace DMX2 { lignes.Add(new Ligne()); } + + public XmlElement Save () + { + return null; + } + + public static SequenceurMaitre Load (XmlElement doc) + { + return null; + } + + } } diff --git a/DMX-2.0/UniversDMX.cs b/DMX-2.0/UniversDMX.cs index 28ae752..a871a0f 100644 --- a/DMX-2.0/UniversDMX.cs +++ b/DMX-2.0/UniversDMX.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Xml; namespace DMX2 { @@ -52,12 +53,6 @@ namespace DMX2 } } - public void Save () - { - } - public void Load () - { - } public void CalculUnivers(byte[] valeurs, int offset, int count) { @@ -89,6 +84,17 @@ namespace DMX2 } } + public XmlElement Save () + { + return null; + } + + public static UniversDMX Load (XmlElement doc) + { + return null; + } + + } } \ No newline at end of file diff --git a/DMX-2.0/gtk-gui/DMX2.MainWindow.cs b/DMX-2.0/gtk-gui/DMX2.MainWindow.cs index b17c8c0..b45e99f 100644 --- a/DMX-2.0/gtk-gui/DMX2.MainWindow.cs +++ b/DMX-2.0/gtk-gui/DMX2.MainWindow.cs @@ -375,6 +375,8 @@ namespace DMX2 this.DefaultHeight = 709; this.Show (); this.DeleteEvent += new global::Gtk.DeleteEventHandler (this.OnDeleteEvent); + this.saveAction.Activated += new global::System.EventHandler (this.OnSaveActionActivated); + this.saveAsAction.Activated += new global::System.EventHandler (this.OnSaveAsActionActivated); this.quitAction.Activated += new global::System.EventHandler (this.OnQuitActionActivated); this.closeAction.Activated += new global::System.EventHandler (this.OnCloseActionActivated); this.circAction.Activated += new global::System.EventHandler (this.OnCircuitsActionActivated); diff --git a/DMX-2.0/gtk-gui/gui.stetic b/DMX-2.0/gtk-gui/gui.stetic index 5ef673e..1c4b678 100644 --- a/DMX-2.0/gtk-gui/gui.stetic +++ b/DMX-2.0/gtk-gui/gui.stetic @@ -75,12 +75,14 @@ False gtk-save + Action False gtk-save-as + Action