/// <summary> /// Create a TextFilter that finds the given string using the given comparison /// </summary> /// <param name="olv"></param> /// <param name="text"></param> /// <param name="comparison"></param> public TextMatchFilter(ObjectListView olv, string text, StringComparison comparison) { this.ListView = olv; //++Added by KhoiVV isUseNoneVietNamese = olv.isUseNoneVietNamese; //if (olv.isUseNoneVietNamese) //{ // this.ContainsStrings = new string[] { SanitaUtility.RemoveSign4VN(text) }; //} //else //{ // this.ContainsStrings = new string[] { text }; //} if (olv.isUseNoneVietNamese) { this.ContainsStrings = SanitaUtility.RemoveSign4VN(text).Split(';'); } else { this.ContainsStrings = text.Split(';'); } //--Added by KhoiVV this.StringComparison = comparison; }
/// <summary> /// Do the actual work of filtering /// </summary> /// <param name="modelObject"></param> /// <returns></returns> public override bool Filter(object modelObject) { if (this.ListView == null || !this.HasComponents) { return(true); } //++Update by KhoiVV foreach (TextMatchingStrategy filter in this.MatchingStrategies) { bool ret = false; foreach (OLVColumn column in this.IterateColumns()) { if (column.IsVisible && column.Searchable) { string cellText = column.GetStringValue(modelObject); if (isUseNoneVietNamese) { cellText = SanitaUtility.RemoveSign4VN(cellText); } if (String.IsNullOrEmpty(filter.Text) || filter.MatchesText(cellText)) { ret = true; } } } if (ret == false) { return(false); } } return(true); //--Update by KhoiVV }
public static String RemoveVietNamSign(this String data_control) { return(SanitaUtility.RemoveSign4VN(data_control)); }
public override CompareResult Compare(string fragmentText) { if (Parent.SearchTinhHuyenXa) { if (fragmentText.Length == 2 || fragmentText.Length == 3) { if (lowercaseKey.ToUpper().StartsWith(fragmentText + "KX", StringComparison.InvariantCultureIgnoreCase)) { return(CompareResult.VisibleAndSelected); } } else { if (lowercaseKey.ToUpper().StartsWith(fragmentText, StringComparison.InvariantCultureIgnoreCase)) { return(CompareResult.VisibleAndSelected); } } } else { if (ignoreCase) { #if true //if (!String.IsNullOrEmpty(fragmentText.Trim())) //{ // String[] list_data = fragmentText.TrimSpace().Trim().Split(' '); // foreach (String data in list_data) // { // if (!String.IsNullOrEmpty(data)) // { // if (!SanitaUtility.RemoveSign4VN(lowercaseText).Contains(SanitaUtility.RemoveSign4VN(data.ToLower()))) // { // return CompareResult.Hidden; // } // } // } // return CompareResult.Visible; //} if (lowercaseText.ToLower() == fragmentText.ToLower()) { return(CompareResult.VisibleAndSelected); } if (lowercaseText != null && SanitaUtility.RemoveSign4VN(lowercaseText).Contains(SanitaUtility.RemoveSign4VN(fragmentText.ToLower()))) { return(CompareResult.Visible); } if (lowercaseKey != null && lowercaseKey.Contains(fragmentText.ToLower())) { return(CompareResult.Visible); } if (lowercaseData != null && lowercaseData.Contains(fragmentText.ToLower())) { return(CompareResult.Visible); } #else if (lowercaseText.Contains(fragmentText.ToLower())) { return(CompareResult.Visible); } #endif } else { if (!String.IsNullOrEmpty(Text) && Text.Contains(fragmentText)) { return(CompareResult.Visible); } if (!String.IsNullOrEmpty(Key) && Key.Contains(fragmentText)) { return(CompareResult.Visible); } if (!String.IsNullOrEmpty(Data) && Data.Contains(fragmentText)) { return(CompareResult.Visible); } } } return(CompareResult.Hidden); }