public EditPatternForm(FilterRule rule, string property, FilterTarget target) : this(property, target) { Pattern = rule; searchTextBox.Text = rule.SearchString; negateCheckBox.Checked = rule.Negate; typeSelection.ChangeSelection((PatternSelectionType)rule.FilterType); }
public void Main() { object eval; if (PropertyName == "$item") { eval = FilterTarget; } else { var evalProp = FilterTarget.GetType().GetProperty(PropertyName); if (evalProp == null) { return; } if (evalProp.GetGetMethod() == null) { return; } eval = evalProp.GetValue(FilterTarget, null); if (eval == null) { return; } } if (eval is string == false && (Operator == FilterOperators.Contains || Operator == FilterOperators.NotContains)) { throw new ArgException("The Contains and NotContains operators can only be applied to properties of type string"); } object comparison = Value; try { if (eval.GetType() != typeof(string)) { if (ArgRevivers.CanRevive(eval.GetType())) { comparison = ArgRevivers.Revive(eval.GetType(), "", comparison + ""); } } } catch (Exception ex) { PowerLogger.LogLine("Unable to convert a string to:" + eval.GetType().FullName); return; } if (FilterLogic.FilterAcceptsObject(eval, Operator, comparison)) { ArgPipeline.Push(FilterTarget); } }
public EditPatternForm(string property, FilterTarget target) { Eto.Serialization.Xaml.XamlReader.Load(this); propertyLabel.Text = property; typeSelection = new SelectionUI <PatternSelectionType>(null, typeSelectionStack); if (target == FilterTarget.Train) { typeSelection.DisableOption(PatternSelectionType.StationType); } }
/// <summary> /// 通过filter以及param, 将container中不满足的对象删除. /// </summary> public static void FilterTargetsBy(ArrayList container, FilterTarget filter, params object[] param) { int firstUnmatched = 0; // firstUnmatched及之后的所有battleunit都无效. for (int i = 0; i < container.Count; ++i) { BattleUnit target = (BattleUnit)container[i]; if (filter(target, param)) { container[firstUnmatched++] = container[i]; } } // 移除该位置及之后的所有battleunit. container.RemoveRange(firstUnmatched, container.Count - firstUnmatched); }
public void ExecuteOutFilter(IFilter filter, Action <Entity> callback, FilterTarget target) { switch (target) { case FilterTarget.All: for (int i = 0; i < this.Components.Count; i++) { if (this.Components[i] is Entity && !filter.Contains(this.Components[i] as Entity)) { callback(this.Components[i] as Entity); } } break; case FilterTarget.AlwaysUpdate: for (int i = 0; i < this.AlwaysUpdate.Count; i++) { if (this.AlwaysUpdate[i] is Entity && !filter.Contains(this.AlwaysUpdate[i] as Entity)) { callback(this.AlwaysUpdate[i] as Entity); } } break; case FilterTarget.OnScreen: EntityRenderer r = this.renderer as EntityRenderer; if (r != null) { foreach (Entity e in this.integrator.GetEntitiesInRect(r.TopLeft, r.BottomRight, true)) { if (!filter.Contains(e)) { callback(e); } } } break; } }
public IEnumerable <Entity> GetEntitiesByFilter(IFilter filter, FilterTarget target) { switch (target) { case FilterTarget.All: for (int i = 0; i < this.Components.Count; i++) { if (this.Components[i] is Entity && filter.Contains(this.Components[i] as Entity)) { yield return(this.Components[i] as Entity); } } break; case FilterTarget.AlwaysUpdate: for (int i = 0; i < this.AlwaysUpdate.Count; i++) { if (this.AlwaysUpdate[i] is Entity && filter.Contains(this.AlwaysUpdate[i] as Entity)) { yield return(this.Components[i] as Entity); } } break; case FilterTarget.OnScreen: EntityRenderer r = this.renderer as EntityRenderer; if (r != null) { foreach (Entity e in this.integrator.GetEntitiesInRect(r.TopLeft, r.BottomRight, true)) { if (filter.Contains(e)) { yield return(e); } } } break; } }