From 2ed4c3a80156c8e4b0b26e435b25187f6f297418 Mon Sep 17 00:00:00 2001 From: Tuan Do Date: Tue, 10 Jul 2018 16:09:36 -0400 Subject: [PATCH] Need to fix DeleteRow from annoRefView --- Annotator/LinkEventForm.Designer.cs | 1 + Annotator/LinkEventForm.cs | 2 +- Annotator/Main.Event.cs | 23 ++++++++++++++--------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Annotator/LinkEventForm.Designer.cs b/Annotator/LinkEventForm.Designer.cs index 2b280b1..ad6bf94 100644 --- a/Annotator/LinkEventForm.Designer.cs +++ b/Annotator/LinkEventForm.Designer.cs @@ -108,6 +108,7 @@ private void InitializeComponent() // addLinkEventBtn // this.addLinkEventBtn.Anchor = System.Windows.Forms.AnchorStyles.Right; + this.addLinkEventBtn.DialogResult = System.Windows.Forms.DialogResult.OK; this.addLinkEventBtn.Location = new System.Drawing.Point(510, 51); this.addLinkEventBtn.Name = "addLinkEventBtn"; this.addLinkEventBtn.Size = new System.Drawing.Size(75, 20); diff --git a/Annotator/LinkEventForm.cs b/Annotator/LinkEventForm.cs index f9d053e..b4d5121 100644 --- a/Annotator/LinkEventForm.cs +++ b/Annotator/LinkEventForm.cs @@ -38,7 +38,7 @@ private void linkToEventIdComboBox_SelectedIndexChanged(object sender, EventArgs private void addLinkEventBtn_Click(object sender, EventArgs e) { - Event selectedEvent = allEvents.Find(x => x.id == (string)linkToEventIdComboBox.SelectedItem); + Event selectedEvent = allEvents.Find(x => x.id == (string) linkToEventIdComboBox.SelectedItem); var selectedLinkType = linkEventTypeComboBox.SelectedItem; if (selectedEvent != null && linkEventTypeComboBox.SelectedItem != null) { diff --git a/Annotator/Main.Event.cs b/Annotator/Main.Event.cs index a9727dc..c666409 100644 --- a/Annotator/Main.Event.cs +++ b/Annotator/Main.Event.cs @@ -139,6 +139,8 @@ internal void findObjectForEvent(Event ev) ev.addTempoReference(o.Item1, o.Item2, o.Item3); addRightBottomTableReference(o.Item1, o.Item2, annotationText.Substring(o.Item1, o.Item2 - o.Item1), o.Item3); } + + this.logSession($"{foundObjects.Count} event references are added."); } private void addEventToolStripMenuItem_Click(object sender, EventArgs e) @@ -179,20 +181,18 @@ private void annotationText_MouseDown(object sender, MouseEventArgs e) } } - private void AnnoRefView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e) - { - if (selectedEvent != null && mapFromEventToEventAnnotations.ContainsKey(selectedEvent)) - { - mapFromEventToEventAnnotations[selectedEvent].deleteTempoEventParticipantByRowIndex(e.Row.Index); - } - } - internal void linkSubEvent(Event ev) { LinkEventForm linkEventForm = new LinkEventForm(); linkEventForm.populate(ev, currentSession.events); linkEventForm.StartPosition = FormStartPosition.CenterParent; - linkEventForm.ShowDialog(this); + DialogResult result = linkEventForm.ShowDialog(this); + + // We bind DialogResult = OK to Add button + if (result == DialogResult.OK) + { + logSession($"Add a link for event {ev.id}"); + } } private void annoRefView_CellClick(object sender, DataGridViewCellEventArgs e) @@ -210,6 +210,11 @@ private void annoRefView_CellClick(object sender, DataGridViewCellEventArgs e) private void annoRefView_UserDeletedRow(object sender, DataGridViewRowEventArgs e) { Console.WriteLine("annoRefView_UserDeletedRow"); + + if (selectedEvent != null && mapFromEventToEventAnnotations.ContainsKey(selectedEvent)) + { + mapFromEventToEventAnnotations[selectedEvent].deleteTempoEventParticipantByRowIndex(e.Row.Index); + } } } }