easy to add sequences now
This commit is contained in:
@@ -20,7 +20,7 @@ namespace SequenceEditor
|
||||
|
||||
void toolStripButton1_Click(object sender, EventArgs e)
|
||||
{
|
||||
var shp = GetTextForm.GetString( "Add SHP..." );
|
||||
var shp = GetTextForm.GetString( "Add SHP...", "" );
|
||||
if (shp == null) return;
|
||||
Program.Shps.Add(shp, Program.LoadAndResolve(shp));
|
||||
}
|
||||
|
||||
@@ -16,10 +16,11 @@ namespace SequenceEditor
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public static string GetString(string title)
|
||||
public static string GetString(string title, string defaultValue)
|
||||
{
|
||||
using (var f = new GetTextForm())
|
||||
{
|
||||
f.textBox1.Text = defaultValue;
|
||||
f.Text = title;
|
||||
if (DialogResult.OK != f.ShowDialog())
|
||||
return null;
|
||||
|
||||
@@ -84,5 +84,7 @@ namespace SequenceEditor
|
||||
? Program.Shps[shp].Length - start
|
||||
: ((a == "") ? 1 : int.Parse(a));
|
||||
}
|
||||
|
||||
public Sequence() { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,10 @@ namespace SequenceEditor
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
mousePos = e.Location;
|
||||
|
||||
if (e.Button == MouseButtons.Left)
|
||||
isDragging = true;
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
@@ -37,7 +41,7 @@ namespace SequenceEditor
|
||||
{
|
||||
foreach (var shp in items)
|
||||
{
|
||||
var sel = shp.Value.FirstOrDefault(a => a.Value.Contains(mousePos));
|
||||
var sel = shp.Value.FirstOrDefault(a => a.Value.Contains(p));
|
||||
if (!sel.Value.IsEmpty)
|
||||
return Pair.New(shp.Key, sel.Key);
|
||||
}
|
||||
@@ -46,8 +50,46 @@ namespace SequenceEditor
|
||||
return null;
|
||||
}
|
||||
|
||||
string lastName = "";
|
||||
|
||||
protected override void OnMouseUp(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseUp(e);
|
||||
|
||||
if (isDragging && e.Button == MouseButtons.Left)
|
||||
{
|
||||
isDragging = false;
|
||||
|
||||
/* create a new sequence! */
|
||||
var start = FindFrameAt(clickPos);
|
||||
var end = FindFrameAt(mousePos);
|
||||
|
||||
if (start != null && end != null
|
||||
&& start.Value.First == end.Value.First)
|
||||
{
|
||||
var s = new Sequence()
|
||||
{
|
||||
start = start.Value.Second,
|
||||
length = end.Value.Second - start.Value.Second + 1,
|
||||
shp = start.Value.First
|
||||
};
|
||||
|
||||
var name = GetTextForm.GetString("Name of new sequence", lastName);
|
||||
if (name == null) return;
|
||||
|
||||
Program.Sequences.Add(name, s);
|
||||
lastName = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
|
||||
if (e.Button == MouseButtons.Left)
|
||||
clickPos = e.Location;
|
||||
|
||||
if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
var frameAtPoint = FindFrameAt(e.Location);
|
||||
@@ -63,6 +105,8 @@ namespace SequenceEditor
|
||||
}
|
||||
}
|
||||
|
||||
Sequence tempSequence;
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
@@ -82,6 +126,21 @@ namespace SequenceEditor
|
||||
toolText = frameAtPoint.Value.Second.ToString();
|
||||
}
|
||||
|
||||
tempSequence = null;
|
||||
if (isDragging)
|
||||
{
|
||||
/* create a new sequence! */
|
||||
var start = FindFrameAt(clickPos);
|
||||
var end = FindFrameAt(mousePos);
|
||||
|
||||
if (start != null && end != null
|
||||
&& start.Value.First == end.Value.First)
|
||||
tempSequence = new Sequence() {
|
||||
start = start.Value.Second,
|
||||
length = end.Value.Second - start.Value.Second + 1,
|
||||
shp = start.Value.First };
|
||||
}
|
||||
|
||||
items.Clear();
|
||||
|
||||
foreach (var shp in Program.Shps)
|
||||
@@ -117,7 +176,11 @@ namespace SequenceEditor
|
||||
var brushes = new[] { Brushes.Green, Brushes.Red, Brushes.Blue, Brushes.Magenta, Brushes.DarkOrange, Brushes.Navy };
|
||||
|
||||
var seqid = 0;
|
||||
foreach (var seq in Program.Sequences)
|
||||
var seqs = Program.Sequences.Select(a => a); /* shorter than teh typename!! */
|
||||
if (tempSequence != null)
|
||||
seqs = seqs.Concat(new[] { new KeyValuePair<string, Sequence>("New sequence...", tempSequence) });
|
||||
|
||||
foreach (var seq in seqs)
|
||||
{
|
||||
var firstFrame = seq.Value.start;
|
||||
var r = items[seq.Value.shp][firstFrame];
|
||||
|
||||
Reference in New Issue
Block a user