/// <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()...
IEnumerable<Annotation_Rep_Tree_Data_Model> FindMatches(string searchText, Annotation_Rep_Tree_Data_Model annotation) { if (annotation.NameContainsText(searchText)) yield return annotation; foreach (Annotation_Rep_Tree_Data_Model child in annotation.Children) foreach (Annotation_Rep_Tree_Data_Model match in this.FindMatches(searchText, child)) yield return match; }
} //close constructor method Annotation_Rep_Tree_Data_Model... private Annotation_Rep_Tree_Data_Model(Annotation_Rep_Tree_Data annotation, Annotation_Rep_Tree_Data_Model parent) { _annotation = annotation; _parent = parent; _children = new ReadOnlyCollection <Annotation_Rep_Tree_Data_Model>( (from child in _annotation.Children select new Annotation_Rep_Tree_Data_Model(child, this)) .ToList <Annotation_Rep_Tree_Data_Model>()); }
public AnnotationTreeViewModel(Annotation_Rep_Tree_Data rootAnnotation) { _rootAnnotation = new Annotation_Rep_Tree_Data_Model(rootAnnotation); _firstGeneration = new ReadOnlyCollection <Annotation_Rep_Tree_Data_Model>( new Annotation_Rep_Tree_Data_Model[] { _rootAnnotation }); _searchCommand = new SearchAnnotationTreeCommand(this); }
public AnnotationTreeViewModel(Annotation_Rep_Tree_Data rootAnnotation) { _rootAnnotation = new Annotation_Rep_Tree_Data_Model(rootAnnotation); _firstGeneration = new ReadOnlyCollection<Annotation_Rep_Tree_Data_Model>( new Annotation_Rep_Tree_Data_Model[] { _rootAnnotation }); _searchCommand = new SearchAnnotationTreeCommand(this); }
IEnumerable <Annotation_Rep_Tree_Data_Model> FindMatches(string searchText, Annotation_Rep_Tree_Data_Model annotation) { if (annotation.NameContainsText(searchText)) { yield return(annotation); } foreach (Annotation_Rep_Tree_Data_Model child in annotation.Children) { foreach (Annotation_Rep_Tree_Data_Model match in this.FindMatches(searchText, child)) { yield return(match); } } }
} //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 add_element_to_appropriate_child_node_which_is_returned()... public static string convert_tree_node_to_delimited_string(Annotation_Rep_Tree_Data_Model individual_node) { if (!individual_node.Name.Equals(ROOT_NAME)) { string final_output = individual_node.Name; Annotation_Rep_Tree_Data_Model parent = individual_node.Parent; if (parent != null) { if (!parent.Name.Equals(ROOT_NAME)) { final_output = convert_tree_node_to_delimited_string(parent) + ";" + final_output; } } return(final_output); } else { return(""); } } //close method convert_tree_node_to_delimited_string()...
private Annotation_Rep_Tree_Data_Model(Annotation_Rep_Tree_Data annotation, Annotation_Rep_Tree_Data_Model parent) { _annotation = annotation; _parent = parent; _children = new ReadOnlyCollection<Annotation_Rep_Tree_Data_Model>( (from child in _annotation.Children select new Annotation_Rep_Tree_Data_Model(child, this)) .ToList<Annotation_Rep_Tree_Data_Model>()); }
public static string convert_tree_node_to_delimited_string(Annotation_Rep_Tree_Data_Model individual_node) { if (!individual_node.Name.Equals(ROOT_NAME)) { string final_output = individual_node.Name; Annotation_Rep_Tree_Data_Model parent = individual_node.Parent; if (parent != null) { if (!parent.Name.Equals(ROOT_NAME)) final_output = convert_tree_node_to_delimited_string(parent) + ";" + final_output; } return final_output; } else return ""; }