private void RefreshSourcesList(string filter) { //cmbSource.BeginUpdate(); try { cmbSource.Items.Clear(); string flt = "*" + filter + "*"; int num = fSourcesList.Count; for (int i = 0; i < num; i++) { string st = fSourcesList[i]; if (filter == "" || SysUtils.MatchesMask(st, flt)) { cmbSource.Items.Add(new GKComboItem(st, fSourcesList.GetObject(i))); } } } finally { //cmbSource.EndUpdate(); } }
public void Test_Matches() { bool res = SysUtils.MatchesMask("abrakadabra", "*kad*"); Assert.IsTrue(res); res = SysUtils.MatchesMask("abrakadabra", "*test*"); Assert.IsFalse(res); }
protected static bool IsMatchesMask(string str, string mask) { bool result = false; if (string.IsNullOrEmpty(str) || string.IsNullOrEmpty(mask)) { return(result); } string stx = str.ToLower(); string[] masks = mask.ToLower().Split('|'); int num = masks.Length; for (int i = 0; i < num; i++) { result = result || SysUtils.MatchesMask(stx, masks[i]); } return(result); }
private bool CheckCondition(FilterCondition fcond) { bool res = true; try { object dataval = GetColumnValueEx(fcond.ColumnIndex, -1, false); if (dataval == null) { return(true); } int compRes = 0; if (fcond.Condition != ConditionKind.ck_Contains) { compRes = ((IComparable)dataval).CompareTo(fcond.Value); } switch (fcond.Condition) { case ConditionKind.ck_NotEq: res = compRes != 0; break; case ConditionKind.ck_LT: res = compRes < 0; break; case ConditionKind.ck_LET: res = compRes <= 0; break; case ConditionKind.ck_Eq: res = compRes == 0; break; case ConditionKind.ck_GET: res = compRes >= 0; break; case ConditionKind.ck_GT: res = compRes > 0; break; case ConditionKind.ck_Contains: res = SysUtils.MatchesMask(dataval.ToString(), "*" + fcond.Value + "*"); break; case ConditionKind.ck_NotContains: res = !SysUtils.MatchesMask(dataval.ToString(), "*" + fcond.Value + "*"); break; } } catch (Exception ex) { Logger.LogWrite("ListManager.CheckCondition(): " + ex.Message); res = true; } return(res); }