sequence editor actually works for editing
This commit is contained in:
21
SequenceEditor/Form1.Designer.cs
generated
21
SequenceEditor/Form1.Designer.cs
generated
@@ -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
|
||||
//
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user