public Session() { this.activityLists = new ConcurrentActivityLists(); this.annotations = new AnnotationList(); //check this part //this.output_file = FILEINFO_ELEMENT +"_copy"+ ".xml"; //this.output_csv_file = FILEINFO_ELEMENT + "_copy" + ".csv"; }
//--- This colors assigned to the annotation bar in the viewer are protocol specific ---- //Check how I can make it more general private static void SaveLabelsColorsToFile(string aDataDirectory, int number_of_categories, ConcurrentActivityLists list_of_activities) { TextWriter labels_colors_csv; string label = ""; string csv = ""; string color = ""; string argb = ""; string category_name = ""; //Load the list according the number of activity categories for (int i = 0; i < number_of_categories; i++) { #region create a csv file for each category //if (i == 0) //{ // //Category 1 // if (File.Exists(aDataDirectory + "\\" + ANNOTATION_SUBDIRECTORY + "\\ActivityLabelsColors_1.csv")) // { File.Delete(aDataDirectory + "\\" + ANNOTATION_SUBDIRECTORY + "\\ActivityLabelsColors_1.csv"); } // labels_colors_csv = new StreamWriter(aDataDirectory + "\\" + ANNOTATION_SUBDIRECTORY + "\\ActivityLabelsColors_1.csv"); // //Write headers // labels_colors_csv.WriteLine("Category,Label,Color,ARGB"); //} //else //{ // //Category 2 // if (File.Exists(aDataDirectory + "\\" + ANNOTATION_SUBDIRECTORY + "\\ActivityLabelsColors_2.csv")) // { File.Delete(aDataDirectory + "\\" + ANNOTATION_SUBDIRECTORY + "\\ActivityLabelsColors_2.csv"); } // labels_colors_csv = new StreamWriter(aDataDirectory + "\\" + ANNOTATION_SUBDIRECTORY + "\\ActivityLabelsColors_2.csv"); // //Write headers // labels_colors_csv.WriteLine("Category,Label,Color,ARGB"); //} if (File.Exists(aDataDirectory + "\\" + ANNOTATION_SUBDIRECTORY + "\\ActivityLabelsColors_" + (i + 1) + ".csv")) { File.Delete(aDataDirectory + "\\" + ANNOTATION_SUBDIRECTORY + "\\ActivityLabelsColors_" + (i + 1) + ".csv"); } labels_colors_csv = new StreamWriter(aDataDirectory + "\\" + ANNOTATION_SUBDIRECTORY + "\\ActivityLabelsColors_" + (i + 1) + ".csv"); //Write Headers labels_colors_csv.WriteLine("Category,Label,Color,ARGB"); #endregion #region assign color to each label if (list_of_activities.Count > i) { category_name = list_of_activities[i]._Name; //load labels for each category for (int j = 0; j < list_of_activities[i].Count; j++) { label = list_of_activities[i][j]._Name; csv = ""; color = ""; argb = ""; Color[,] labelcolors; int[,] labelrgb; AssignLabelColors(out labelcolors, out labelrgb); if (label.Trim().CompareTo("") != 0) { csv = category_name + "," + label + ","; if (label.CompareTo("unknown") == 0) { color = Color.Gainsboro.Name; argb = Color.Gainsboro.ToArgb().ToString(); } else { int color_id = 0; Math.DivRem(j, NumberColorCategories, out color_id); color = labelcolors[i, color_id].Name; argb = labelrgb[i, color_id].ToString(); } //save to file labels_colors_csv.WriteLine(csv + color + "," + argb); }//ends if }//ends for } #endregion #region close csv files labels_colors_csv.Flush(); labels_colors_csv.Close(); #endregion } //ends if for overlapping activity lists }