public void AddNewEntryValid() { //will determine if the add new entry is valid List <string> check_title_subtitle = new List <string> { Title_Add, Subtitle_Add }; List <string> exclude_lst = new List <string>(); Glo_ProjectData_Reference.IsNewTitleValid(check_title_subtitle, exclude_lst, out bool valid_entry, out bool is_duplicate, out bool is_title_exist); //this will only display if it's going to say it's invalid if (!valid_entry) { Debug.WriteLine("\nAddNewEntryValid"); Debug.WriteLine(string.Format(" {0,-15} = {1}", "Title", Title_Add)); Debug.WriteLine(string.Format(" {0,-15} = {1}", "Subtitle", Subtitle_Add)); Debug.WriteLine(string.Format(" {0,-15} = {1}", "is_duplicate", is_duplicate)); Debug.WriteLine(string.Format(" {0,-15} = {1}", "is_title_exist", is_title_exist)); Debug.WriteLine(string.Format(" {0,-15} = {1}", "valid_entry", valid_entry)); Debug.WriteLine(""); } Title_Valid = valid_entry; }
private void IsValidChangeTitleSubtitle() { List <string> check_title_subtitle = new List <string> { title_new_, subtitle_new_ }; List <string> exclude_lst = new List <string> { Title_Old, Subtitle_Old }; if (Glo_ProjectData_Reference == null) { return; } Glo_ProjectData_Reference.IsNewTitleValid(check_title_subtitle, exclude_lst, out bool valid_entry, out _, out _); Title_Valid = valid_entry; if (!Title_Valid) { Glo_MainPage_Reference.ShowPropertiesTitleInvalidTeachingTip(); } }
public void CreateNewEntryID(string given_title, out bool is_entryID_valid, out string entryID_created) { //will create a new entryID given an entry title Debug.WriteLine("CreateNewEntryID title='" + given_title + "'"); //the default return items is_entryID_valid = false; entryID_created = ""; //just to ensure that the given title is valid if (string.IsNullOrEmpty(given_title)) { Debug.WriteLine("ERROR: given_title not valid"); return; } //we want to turn something like title="Mech 2202" into entry_ID="mech†2202‡‡‡‡‡‡‡‖0001" //the title will be made lowercase, spaces converted to †, and truncated with ‡ trailing spaces //the second part will be a string number, in case the first section is a duplicate int truncated_title_length = 16; int designation_length = 4; int designation_start = 1; char space_replacement = '†'; //this is the "dagger" symbol char trailing_space = '‡'; //this is the "double dagger" symbol char title_des_sep = '‖'; //this is the "double vertical line" symbol string title_lower = given_title.ToLower(); string conv_spaces = title_lower.Replace(' ', space_replacement); int original_length = conv_spaces.Length; string trunc_title; if (original_length > truncated_title_length) { trunc_title = conv_spaces.Substring(0, truncated_title_length); //will convert "Mech 2202 New Class Blah" to "mech†2202†new†cl" } else //original_length <= truncated_title_length { trunc_title = conv_spaces.PadRight(truncated_title_length, trailing_space); //will convert "Mech 2202" to "mech†2202‡‡‡‡‡‡‡" } //this will be the number portion int designation_number; //now will check if this truncated title portion already exists bool trunc_title_exists = Glo_ProjectData_Reference.EntryIDs_Text_lst.Contains(trunc_title); //if it doesn't exist, then it's simple if (!trunc_title_exists) { designation_number = designation_start; } //otherwise we need to increase the counter else { designation_number = Glo_ProjectData_Reference.GetMaxDesignationForEntryIDTitle(trunc_title) + 1; } //this was the error number for designation if (designation_number == -1) { Debug.WriteLine("ERROR: designation_number = " + designation_number); return; } //will have made 34 into "0034" string designation_final = designation_number.ToString().PadLeft(designation_length, '0'); //should be the final format of entry_ID="mech†2202‡‡‡‡‡‡‡‖0001" entryID_created = trunc_title + title_des_sep + designation_final; is_entryID_valid = true; return; }