//Add annotation internal void addAnnotation(Event ev) { EventAnnotation annotation = new EventAnnotation(ev, this, sessionStart, sessionEnd); this.mapFromEventToEventAnnotations[ev] = annotation; currentSession.addEvent(ev); renderEventAnnotation(annotation); }
public EventAnnotation(Event ev, Main mainGUI, int start, int end) { InitializeComponent(); axis.X1 = 10; axis.X2 = 820; this.ev = ev; //MessageBox.Show(txt); if (ev.text != null) textAnnotation.Text = ev.text; this.main = mainGUI; this.start = start; this.end = end; this.slider1Move = false; this.slider2Move = false; Rendering(); rectangleShape.MouseClick += Mark_MouseClick; rowIndexToObjs = new Dictionary<int, object>(); //MessageBox.Show("minimum = " + minimum + ", maximum = " + maximum + " stepX = " + frameStepX); intervalLbl.Text = "Start: " + ev.startFrame + ", Stop: " + ev.endFrame; }
public Action(Event annotation, String semanticType, int start, int end) { this.annotation = annotation; this.semanticType = semanticType; this.start = start; this.end = end; }
public Reference(Event annotation, String refObjectId, int start, int end) { this.annotation = annotation; this.refObjectId = refObjectId; this.start = start; this.end = end; }
public void populate(Event ev, List<Event> allEvents) { this.ev = ev; this.allEvents = allEvents; eventId.Text = ev.id; eventTxt.Text = ev.text; linkEventTypeComboBox.Items.AddRange(Enum.GetValues(typeof(Event.EventLinkType)).Cast<object>().ToArray()); linkToEventIdComboBox.Items.AddRange(allEvents.FindAll(x => x.id != ev.id).Select(e => e.id).ToArray()); }
internal void removeAnnotation(Event ev) { currentSession.removeEvent(ev); mapFromEventToEventAnnotations.Remove(ev); clearMidleBottomPanel(); foreach (EventAnnotation eventAnnotation in mapFromEventToEventAnnotations.Values) { renderEventAnnotation(eventAnnotation); } annoRefView.Rows.Clear(); this.Invalidate(); }
//Add annotation button private void addEventAnnotationBtn_Click(object sender, EventArgs e) { Event annotation = new Event(null, frameTrackBar.Minimum, frameTrackBar.Maximum, ""); addAnnotation(annotation); }
internal void linkSubEvent(Event ev) { LinkEventForm linkEventForm = new LinkEventForm(); linkEventForm.populate(ev, currentSession.events); linkEventForm.StartPosition = FormStartPosition.CenterParent; linkEventForm.ShowDialog(this); }
public static List<Event> readFromXml( Session session, XmlNode xmlNode) { List<Event> annotations = new List<Event>(); foreach (XmlNode node in xmlNode.SelectNodes(ANNOTATION)) { String id = node.Attributes[ID].Value; int start = Int32.Parse(node.SelectSingleNode(DURATION).Attributes[START_FRAME].Value); int end = Int32.Parse(node.SelectSingleNode(DURATION).Attributes[END_FRAME].Value); String text = node.SelectSingleNode(TEXT).InnerText; Event a = new Event(id, start, end, text); XmlNode refs = node.SelectSingleNode(REFS); foreach (XmlNode _ref in refs.SelectNodes(REF)) { int refStart = Int32.Parse(_ref.Attributes[START].Value); int refEnd = Int32.Parse(_ref.Attributes[END].Value); String refObjectId = _ref.Attributes[REF_TO].Value; Reference reference = new Reference(a, refObjectId, refStart, refEnd); a.addReference(reference); } XmlNode events = node.SelectSingleNode(EVENTS); foreach (XmlNode _event in events.SelectNodes(EVENT)) { int eventStart = Int32.Parse(_event.Attributes[START].Value); int eventEnd = Int32.Parse(_event.Attributes[END].Value); String semType = _event.Attributes[SEMANTIC_TYPE].Value; Action e = new Action(a, semType, eventStart, eventEnd); a.addAction(e); } XmlNode links = node.SelectSingleNode(LINK); foreach (XmlNode link in events.SelectNodes(LINKTO)) { string linkId = link.Attributes[ID].Value; var linkType = (EventLinkType) Enum.Parse( typeof(EventLinkType), link.Attributes[TYPE].Value); a.addLinkTo(linkId, linkType); } annotations.Add(a); } return annotations; }
internal void findObjectForEvent(Event ev) { currentSession.resetTempoEmpty(ev); currentSession.findObjectsByNames(ev); }
/// <summary> /// /// </summary> /// <param name="startFrame"></param> /// <param name="skipLength"></param> /// <param name="duration"></param> /// <param name="templateDescription"></param> /// <param name="overwriteMode"></param> /// <returns></returns> internal List<Event> addEventTemplate(int startFrame, int skipLength, int duration, string templateDescription, Options.OverwriteMode overwriteMode) { var addedEvents = new List<Event>(); int noOfEventTemplate = (this.sessionLength - startFrame - duration) / skipLength + 1; /// Process before looping through generated event templates /// switch (overwriteMode) { case Options.OverwriteMode.REMOVE_EXISTING: this.events = new List<Event>(); break; } for (int i = 0; i < noOfEventTemplate; i++) { int start = startFrame + skipLength * i; int end = startFrame + skipLength * i + duration; Event e = new Event(null, start, end, templateDescription); switch (overwriteMode) { case Options.OverwriteMode.ADD_SEPARATE: this.addEvent(e); this.findObjectsByNames(e); addedEvents.Add(e); break; case Options.OverwriteMode.REMOVE_EXISTING: this.addEvent(e); this.findObjectsByNames(e); addedEvents.Add(e); break; case Options.OverwriteMode.OVERWRITE: foreach (Event ev in this.events) { if (ev.startFrame == e.startFrame && ev.endFrame == e.endFrame) { this.removeEvent(ev); break; } } this.addEvent(e); this.findObjectsByNames(e); addedEvents.Add(e); break; case Options.OverwriteMode.NO_OVERWRITE: foreach (Event ev in this.events) { if (ev.startFrame == e.startFrame && ev.endFrame == e.endFrame) break; } break; } } return addedEvents; }
internal void removeEvent(Event a) { events.Remove(a); }
internal void resetTempoEmpty(Event e) { // Event must exist if (events.Find(ev => ev.id == e.id) == null) return; e.resetTempoToEmpty(); }
/// <summary> /// Match the object names with text span in text description of event /// </summary> /// <param name="e"></param> internal void findObjectsByNames(Event e) { if (events.Find(ev => ev.id == e.id) == null) return; // Some text preprocessing foreach (var o in objects.Values) { if (o.name != "") { if (e.text.IndexOf(o.name) != -1) { int startRef = e.text.IndexOf(o.name); int endRef = startRef + o.name.Length - 1; e.addTempoReference(startRef, endRef, o.id); } } } }
//Add annotation internal void addEvent(Event e) { if (events.Find(ev => ev.id == e.id) != null) return; events.Add(e); e.id = "a" + ++annotationID; }