} //close method btnClose_App_Click()... /// <summary> /// this method is called whenever the user wants to export annotations... /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnExport_Click(object sender, RoutedEventArgs e) { int userId = User_Object.OVERALL_userID; string userName = User_Object.OVERALL_USER_NAME; //will suggest saving output to participant's most recent data folder //todo for some reason, calling User_Object below causes a problem //on some computers (try testing this more thoroughly) string suggestedPath = ""; // User_Object.get_likely_PC_destination_root( //userId, userName); //prompt researcher on where to store annotations SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = suggestedPath; saveFileDialog.FileName = userName + ".csv"; saveFileDialog.ShowDialog(); if (!saveFileDialog.FileName.Equals("")) { //save annotations for this day to file string fileName = saveFileDialog.FileName; Daily_Annotation_Summary.writeAllAnnotationsToCsv(userId, fileName); Record_User_Interactions.log_interaction_to_database( "Window1_btnExport_Click", fileName); } } //close method btnExport_Click()...
/// <summary> /// this method is responsible for highlighting all events belonging to a certain activity... /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lstDailyActivitySummary_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (lstDailyActivitySummary.SelectedItem != null) //firstly check whether a valid item has been selected... { //firstly get the type of activity we want to highlight... Daily_Annotation_Summary selected_activity = (Daily_Annotation_Summary)lstDailyActivitySummary.SelectedItem; //then find the event ids displayed today which are part of the given activity type List <int> eventIDs_to_highlight = Daily_Annotation_Summary.ActivityEventIds(Window1.OVERALL_userID, current_day_on_display, selected_activity.annType); foreach (Event_Rep displayed_event in LstDisplayEvents.Items) { //by defaut reset the border colour for this event... displayed_event.borderColour = Event_Rep.DefaultKeyframeBorderColour; //then we try to see if this event is in our list of target event ids to highlight foreach (int target_id in eventIDs_to_highlight) { if (displayed_event.eventID == target_id) { displayed_event.borderColour = "red"; //if this is the target event, let's highlight it's border colour... } } //close foreach(int target_id in eventIDs_to_highlight)... } //close foreach (Event_Rep displayed_event in LstDisplayEvents.Items)... //finally refresh the list of events on display to highlight the target events... LstDisplayEvents.Items.Refresh(); //let's record this user interaction for later analysis... Record_User_Interactions.log_interaction_to_database("Window1_lstDailyActivitySummary_SelectionChanged", selected_activity.annType); } //close if (lstDailyActivitySummary.SelectedItem != null) //firstly check whether a valid item has been selected... } //close method lstDailyActivitySummary_SelectionChanged()...
} //close method update_display_page_events()... /// <summary> /// this method is used to update the main screen of the interface to show the event/image information associated with this day /// </summary> /// <param name="day_to_display"></param> private void update_interface_with_information_on_day(DateTime day_to_display) { //firstly let's update the overall interface variable on what day it is... current_day_on_display = day_to_display; //let's update the UI with what day and day this data is relating to txtDayDisplay.Text = day_to_display.DayOfWeek.ToString(); txtDateDisplay.Text = day_to_display.ToLongDateString(); //now display the time span of the events of this day DateTime day_startTime = new DateTime(); DateTime day_endTime = day_startTime; Image_Rep.GetDayStartEndTime(Window1.OVERALL_userID, day_to_display, ref day_startTime, ref day_endTime); //firstly we get start/end time data directly from the database if (day_startTime != day_endTime) //if the start time isn't equal to the end time, it means that we've successfully retrieved information from the database... { txtTimeFrame.Text = "(" + day_startTime.ToString("HH:mm tt") + " - "; txtTimeFrame.Text += day_endTime.ToString("HH:mm tt") + ")"; } //close if(day_startTime != day_endTime)... else { txtTimeFrame.Text = " - "; //if no data has been retrieved, well then we've no information to show... } //and also let's display the number of images associated with this day... txtImageNumber.Text = Image_Rep.GetNumImagesInDay(Window1.OVERALL_userID, day_to_display).ToString() + " Photos"; //finally give a breakdown of the amount of time spent on various activities... lstDailyActivitySummary.ItemsSource = Daily_Annotation_Summary.getDayAnnotationSummary(Window1.OVERALL_userID, day_to_display); //and also a breakdown of the individual annotated events... lstIndividual_Journeys.ItemsSource = Interface_Code.Event_Activity_Annotation.getAnnotatedEventsDay(Window1.OVERALL_userID, day_to_display); } //end method display_days_events_on_interface()
public Event_Rep( int eventID, DateTime startTime, DateTime endTime, string keyframePath, string comment, bool loadImage) { this.eventID = eventID; this.startTime = startTime; this.endTime = endTime; this.eventDuration = endTime - startTime; this.comment = comment; this.shortComment = GetStringStart(comment, 15); this.keyframePath = keyframePath; this.borderColour = DefaultKeyframeBorderColour; //format time string for UI if (startTime.Hour < 12) { this.strTime = startTime.ToShortTimeString() + " am"; } else { this.strTime = startTime.ToShortTimeString() + " pm"; } this.eventLength = Daily_Annotation_Summary.SecondsToString( (int)eventDuration.TotalSeconds); if (loadImage) { this.keyframeSource = Image_Rep.GetImgBitmap(keyframePath, false); } }
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()...
private void btnExport_Click(object sender, RoutedEventArgs e) { //todo for some reason, calling User_Object below causes a problem //on some computers (try testing this more thoroughly) string suggestedPath = "";// User_Object.get_likely_PC_destination_root( //userId, userName); //prompt researcher on where to store annotations SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.InitialDirectory = suggestedPath; saveFileDialog.FileName = "myAnnotationSchema.csv"; if (saveFileDialog.ShowDialog() == true) { //save annotations for this day to file string fileName = saveFileDialog.FileName; Daily_Annotation_Summary.writeAnnotationSchemaToCsv(fileName); Record_User_Interactions.log_interaction_to_database( "EditListOfEventTypes_btnExportClick", fileName); } }
private void btnImport_Click(object sender, RoutedEventArgs e) { //todo for some reason, calling User_Object below causes a problem //on some computers (try testing this more thoroughly) string suggestedPath = "";// User_Object.get_likely_PC_destination_root( //userId, userName); //prompt researcher on where to store annotations OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = suggestedPath; if (openFileDialog.ShowDialog() == true) { //save annotations for this day to file string fileName = openFileDialog.FileName; Daily_Annotation_Summary.readAnnotationSchemaCsv(fileName); Record_User_Interactions.log_interaction_to_database( "EditListOfEventTypes_btnImportClick", fileName); update_list_on_display_with_latest_database_snapshot(); } }