public ItemNodePresenter([NotNull] INodePresenterFactoryInternal factory, IPropertyProviderViewModel propertyProvider, [NotNull] INodePresenter parent, [NotNull] IObjectNode container, NodeIndex index) : base(factory, propertyProvider, parent) { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } if (parent == null) { throw new ArgumentNullException(nameof(parent)); } Container = container ?? throw new ArgumentNullException(nameof(container)); Descriptor = TypeDescriptorFactory.Default.Find(container.Descriptor.GetInnerCollectionType()); OwnerCollection = parent; Type = (container.Descriptor as CollectionDescriptor)?.ElementType ?? (container.Descriptor as DictionaryDescriptor)?.ValueType; Index = index; Name = index.ToString(); Order = index.IsInt ? (int?)index.Int : null; // So items are sorted by index instead of string CombineKey = Name; DisplayName = Index.IsInt ? "Item " + Index : Index.ToString(); container.ItemChanging += OnItemChanging; container.ItemChanged += OnItemChanged; AttachCommands(); }
/// <summary> /// Each of the query words must be found in at least one field ∀w ∃f /// </summary> public SearchResult IsMatch(BaseNode node) { SearchResult result = null; if (node == null) { return(null); } if (NodeIndex > -1) { if (node is TimedNode timedNode && timedNode.Index == NodeIndex) { result = new SearchResult(node); var prefix = "Node id: "; result.AddMatch(prefix + NodeIndex.ToString(), NodeIndex.ToString()); return(result); } } var searchFields = PopulateSearchFields(node); if (TypeKeyword != null) { // zeroth field is always the type if (string.Equals(TypeKeyword, searchFields[0], StringComparison.OrdinalIgnoreCase) || // special case for types derived from Task, $task should still work (TypeKeyword == "task" && searchFields.Count > 1 && searchFields[1] == "Task")) { // this node is of the type that we need, search other fields if (result == null) { result = new SearchResult(node, IncludeDuration, IncludeStart, IncludeEnd); } result.AddMatchByNodeType(); } else { return(null); } } bool nameMatched = false; bool valueMatched = false; for (int i = 0; i < Words.Count; i++) { bool anyFieldMatched = false; var word = Words[i]; for (int j = 0; j < searchFields.Count; j++) { var field = searchFields[j]; if (!MatchesInStrings[i].Contains(field)) { // no point looking here, we know this string doesn't match anything continue; } if (result == null) { result = new SearchResult(node, IncludeDuration, IncludeStart, IncludeEnd); } // if matched on the type of the node (always field 0), special case it if (j == 0) { result.AddMatchByNodeType(); } else { string fullText = field; var named = node as NameValueNode; // NameValueNode is special case have to check in which field to search if (named != null && (nameToSearch != null || valueToSearch != null)) { if (j == 1 && word == nameToSearch) { result.AddMatch(fullText, word, addAtBeginning: true); nameMatched = true; anyFieldMatched = true; break; } if (j == 2 && word == valueToSearch) { result.AddMatch(fullText, word); valueMatched = true; anyFieldMatched = true; break; } } else { result.AddMatch(fullText, word); anyFieldMatched = true; break; } } } if (!anyFieldMatched) { return(null); } } if (result == null) { return(null); } if (nameToSearch != null && valueToSearch != null && (!nameMatched || !valueMatched)) { return(null); } bool showResult = IncludeMatchers.Count == 0; foreach (NodeQueryMatcher matcher in IncludeMatchers) { if (!showResult) { showResult = IsUnder(matcher, result); } } if (!showResult) { return(null); } foreach (NodeQueryMatcher matcher in ExcludeMatchers) { if (IsUnder(matcher, result)) { return(null); } } return(result); }
/// <summary>新規インスタンスを初期化する。</summary> /// <param name="ni">このインスタンスが示す NodeIndex</param> public NodeIndexCode(NodeIndex ni) { _code = ni.ToString(); }
/// <summary> /// Each of the query words must be found in at least one field ∀w ∃f /// </summary> public SearchResult IsMatch(BaseNode node) { SearchResult result = null; if (node == null) { return(null); } if (NodeIndex > -1) { if (node is TimedNode timedNode && timedNode.Index == NodeIndex) { result = new SearchResult(node); var prefix = "Node id: "; result.AddMatch(prefix + NodeIndex.ToString(), NodeIndex.ToString()); return(result); } } var searchFields = PopulateSearchFields(node); if (TypeKeyword != null) { // zeroth field is always the type if (string.Equals(TypeKeyword, searchFields[0], StringComparison.OrdinalIgnoreCase) || // special case for types derived from Task, $task should still work (TypeKeyword == "task" && searchFields.Count > 1 && searchFields[1] == "Task")) { // this node is of the type that we need, search other fields if (result == null) { result = new SearchResult(node, IncludeDuration); } result.AddMatchByNodeType(); } else { return(null); } } for (int i = 0; i < Words.Count; i++) { bool anyFieldMatched = false; var word = Words[i]; for (int j = 0; j < searchFields.Count; j++) { var field = searchFields[j]; if (!MatchesInStrings[i].Contains(field)) { // no point looking here, we know this string doesn't match anything continue; } if (result == null) { result = new SearchResult(node, IncludeDuration); } // if matched on the type of the node (always field 0), special case it if (j == 0) { result.AddMatchByNodeType(); } else { string fullText = field; if (node is NameValueNode named && fullText == named.Name) { // if we matched a property in the name, show value as well since it's useful fullText = named.ToString(); } result.AddMatch(fullText, word); } anyFieldMatched = true; break; } if (!anyFieldMatched) { return(null); } } if (result == null) { return(null); } if (UnderMatcher != null && !IsUnder(UnderMatcher, result)) { return(null); } return(result); }
public override string ToString() { return(CenterX.ToString() + ", " + CenterY.ToString() + ", " + SizeX.ToString() + ", " + SizeY.ToString() + ", " + NodeIndex.ToString() + ", " + NodeCount.ToString() + ", " + Short7.ToString() + ", " + Short8.ToString() + ", " + FloatUtil.ToString(Float1) + ", " + Byte1.ToString() + ", " + Byte2.ToString() + ", " + Byte3.ToString() + ", " + Byte4.ToString()); }