diff --git a/SequenceEditor/Form1.Designer.cs b/SequenceEditor/Form1.Designer.cs index 4bc482aae7..2d56b0b3a2 100644 --- a/SequenceEditor/Form1.Designer.cs +++ b/SequenceEditor/Form1.Designer.cs @@ -30,10 +30,10 @@ { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); - this.surface1 = new SequenceEditor.Surface(); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); + this.surface1 = new SequenceEditor.Surface(); this.toolStripContainer1.ContentPanel.SuspendLayout(); this.toolStripContainer1.TopToolStripPanel.SuspendLayout(); this.toolStripContainer1.SuspendLayout(); @@ -58,15 +58,6 @@ // this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.toolStrip1); // - // surface1 - // - this.surface1.Dock = System.Windows.Forms.DockStyle.Fill; - this.surface1.Location = new System.Drawing.Point(0, 0); - this.surface1.Name = "surface1"; - this.surface1.Size = new System.Drawing.Size(708, 518); - this.surface1.TabIndex = 0; - this.surface1.Text = "surface1"; - // // toolStrip1 // this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None; @@ -96,6 +87,16 @@ this.toolStripButton2.Name = "toolStripButton2"; this.toolStripButton2.Size = new System.Drawing.Size(35, 22); this.toolStripButton2.Text = "Save"; + this.toolStripButton2.Click += new System.EventHandler(this.toolStripButton2_Click); + // + // surface1 + // + this.surface1.Dock = System.Windows.Forms.DockStyle.Fill; + this.surface1.Location = new System.Drawing.Point(0, 0); + this.surface1.Name = "surface1"; + this.surface1.Size = new System.Drawing.Size(708, 518); + this.surface1.TabIndex = 0; + this.surface1.Text = "surface1"; // // Form1 // diff --git a/SequenceEditor/Form1.cs b/SequenceEditor/Form1.cs index 4c6c9573fe..a1dd5bbcbb 100644 --- a/SequenceEditor/Form1.cs +++ b/SequenceEditor/Form1.cs @@ -24,5 +24,10 @@ namespace SequenceEditor if (shp == null) return; Program.Shps.Add(shp, Program.LoadAndResolve(shp)); } + + void toolStripButton2_Click(object sender, EventArgs e) + { + Program.Save(); + } } } diff --git a/SequenceEditor/Program.cs b/SequenceEditor/Program.cs index 91bbcedff9..9056a4a4b8 100644 --- a/SequenceEditor/Program.cs +++ b/SequenceEditor/Program.cs @@ -30,6 +30,33 @@ namespace SequenceEditor }).ToArray(); } + public static void Save() + { + var e = Doc.SelectSingleNode(string.Format("//unit[@name=\"{0}\"]", UnitName)) as XmlElement; + if (e == null) + { + e = Doc.CreateElement("unit"); + e.SetAttribute( "name", UnitName ); + e = Doc.SelectSingleNode("sequences").AppendChild(e) as XmlElement; + } + + while (e.HasChildNodes) e.RemoveChild(e.FirstChild); /* what a fail */ + + foreach (var s in Sequences) + { + var seqnode = Doc.CreateElement("sequence"); + seqnode.SetAttribute("name", s.Key); + seqnode.SetAttribute("start", s.Value.start.ToString()); + seqnode.SetAttribute("length", s.Value.length.ToString()); + if (s.Value.shp != UnitName) + seqnode.SetAttribute("src", s.Value.shp); + + e.AppendChild(seqnode); + } + + Doc.Save("sequences.xml"); + } + [STAThread] static void Main( string[] args ) { @@ -44,7 +71,12 @@ namespace SequenceEditor Pal = new Palette(FileSystem.Open("temperat.pal")); - UnitName = args.First(); + UnitName = args.FirstOrDefault(); + if (UnitName == null) + UnitName = GetTextForm.GetString("Unit to edit?", "e1"); + if (UnitName == null) + return; + Shps[UnitName] = LoadAndResolve(UnitName); /* todo: load supplemental SHPs */ diff --git a/sequences.xml b/sequences.xml index 9547d5b2f6..3a55ca610e 100644 --- a/sequences.xml +++ b/sequences.xml @@ -1,5 +1,4 @@ - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file