/// <summary> /// this method adds the text box entry to the list of event types... /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_New_EventType_Name_Click(object sender, RoutedEventArgs e) { //1. get new item type name from the relevant textbox... string annotation_type_name = txtNew_EventType_Name.Text; if (lst_Current_Event_Types.SelectedItem != null) { Annotation_Rep_Tree_Data_Model tree_node = (Annotation_Rep_Tree_Data_Model)lst_Current_Event_Types.SelectedItem; string tree_node_db_entry = Annotation_Rep_Tree_Data.convert_tree_node_to_delimited_string(tree_node); if (!tree_node_db_entry.Equals("")) { annotation_type_name = tree_node_db_entry + ";" + annotation_type_name; } } if (!annotation_type_name.Equals("")) //let's just make sure the user didn't click the button by mistake... { //2. then add it to the database... Annotation_Rep.AddAnnotationType(annotation_type_name); //3. finally update the display list to reflect this new change... update_list_on_display_with_latest_database_snapshot(); //and also reset the relevant textbox back to appear blank... txtNew_EventType_Name.Text = ""; //let's log this interaction Record_User_Interactions.log_interaction_to_database("EditListofEventTypes_New_Typename", annotation_type_name); } //close error checking... if (!annotation_type_name.Equals("")) } //close method btnAdd_New_EventType_Name_Click()...
public static int SplitEvent( int userID, int sourceEventID, DateTime targetStartTime, string origAnnotation) { //This method splits an event into two separate events. //The new event starts at targetStartTime. SQLiteConnection con = new SQLiteConnection(DbString); SQLiteCommand command = new SQLiteCommand(con); con.Open(); //Find the day of the source event. command.CommandText = Database_Versioning.text_for_stored_procedures.spGet_day_of_source_event( userID, sourceEventID); DateTime sourceEventDay = DateTime.Parse(command.ExecuteScalar().ToString()); //Create a new event where the split images will be sent to. command.CommandText = Database_Versioning.text_for_stored_procedures.spCreate_new_event_and_return_its_ID( userID, sourceEventDay); int newEventID = int.Parse(command.ExecuteScalar().ToString()); //Update Image and Sensor ID tables in DB with new event IDs. command.CommandText = Database_Versioning.text_for_stored_procedures.spUpdate_image_sensors_tables_with_new_event_id_after_target_time( userID, newEventID, sourceEventID, targetStartTime); command.ExecuteNonQuery(); //Update information (start/end time + keyframe) of new/next event. UpdateDBEventInfo(userID, newEventID); //Update information of old/source event. UpdateDBEventInfo(userID, sourceEventID); //add annotation to source event id (if requested) if (!origAnnotation.Equals("")) { //search to see if multiple annotations present for this event string[] anns = origAnnotation.Split(','); foreach (string a in anns) { if (!a.Equals("")) { Annotation_Rep.AddEventAnnotation(userID, newEventID, a); } } } con.Close(); return(newEventID); }
} //close method btnRemove_EventType_Name_Click()... /// <summary> /// this method removes all items from the list of event types... /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnRemove_All_EventType_Names_Click(object sender, RoutedEventArgs e) { Annotation_Rep.RmAllAnnotationTypes(); //and update the display list to reflect this new change... update_list_on_display_with_latest_database_snapshot(); //let's log this interaction Record_User_Interactions.log_interaction_to_database("EditListofEventTypes_Remove_All_Typenames", ""); } //close method btnRemove_All_EventType_Names_Click()...
public static void rewriteEventList( int userId, string csvFile) { //remove all existing annotations Annotation_Rep.RmAllAnnotations(userId); //This method rewrites the whole list of events SQLiteConnection con = new SQLiteConnection(DbString); SQLiteCommand command = new SQLiteCommand(con); con.Open(); //first, for each day, merge all events into one (1st event) DateTime[] dayList = calendar_control.get_list_of_available_days_for_user(userId); for (int d = 0; d < dayList.Length; d++) { //get events in day DateTime day = dayList[d]; List <Event_Rep> dayEvents = GetDayEvents(userId, day, false); int firstEventId = dayEvents[0].eventID; //set id of events 2:n to firstEventId for (int e = 1; e < dayEvents.Count; e++) { int currentEvent = dayEvents[e].eventID; command.CommandText = Database_Versioning.text_for_stored_procedures.spUpdate_image_sensors_tables_with_new_event_id_after_target_time( userId, firstEventId, currentEvent, day); command.ExecuteNonQuery(); //now delete existing event id DeleteEvent(userId, currentEvent); } //update db event info (i.e. new start/end times, num images, etc.) UpdateDBEventInfo(userId, firstEventId); //there should only be 1 event for this day... Event_Rep firstEvent = Event_Rep.GetDayEvents(userId, day, false)[0]; //read list of boundary times from csv (i.e. episode start times) List <DateTime> boundaryList = new List <DateTime>(); List <string> annotationList = new List <string>(); Daily_Annotation_Summary.getBoundInfoFromCsv(csvFile, firstEvent.startTime, firstEvent.endTime, ref boundaryList, ref annotationList); //split into multiple events based on list of boundary times Event_Rep.SplitMultipleEvents(userId, firstEvent.eventID, boundaryList, annotationList); } con.Close(); } //close method split_event_into_two()...
} //close method btnAdd_New_EventType_Name_Click()... /// <summary> /// this method removes an item from the list of event types... /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnRemove_EventType_Name_Click(object sender, RoutedEventArgs e) { if (lst_Current_Event_Types.SelectedItem != null) { //1. get item selected in the list Annotation_Rep_Tree_Data_Model annotation_type_delete = (Annotation_Rep_Tree_Data_Model)lst_Current_Event_Types.SelectedItem; //2. convert it to the database storage type... string annotation_type_database_text_entry = Annotation_Rep_Tree_Data.convert_tree_node_to_delimited_string(annotation_type_delete); //3. then delete it from the database... Annotation_Rep.RmAnnotationType(annotation_type_database_text_entry); //4. finally update the display list to reflect this new change... update_list_on_display_with_latest_database_snapshot(); //let's log this interaction Record_User_Interactions.log_interaction_to_database("EditListofEventTypes_Remove_Typename", annotation_type_database_text_entry); } //close if (lst_Current_Event_Types.SelectedItem != null)... } //close method btnRemove_EventType_Name_Click()...
} //close method btnRemove_All_EventType_Names_Click()... /// <summary> /// this method updates the list on display with the latest database status... /// </summary> private void update_list_on_display_with_latest_database_snapshot() { lst_Current_Event_Types.ItemsSource = Annotation_Rep.GetAnnotationTypes().FirstGeneration[0].Children; } //close method update_list_on_display_with_latest_database_snapshot()...