private bool ShouldFilterNode(CLVBaseNode node, string filter)
        {
            bool             shouldFilter  = false;
            CLVTagNode       tagNode       = node as CLVTagNode;
            CLVComponentNode componentNode = node as CLVComponentNode;

            if (tagNode != null)
            {
                if (FilterBy == FilterType.Component)
                {
                    tagNode.Children.Filter = ApplyFilter;
                    if (tagNode.Children.IsEmpty)
                    {
                        shouldFilter = true;
                    }
                }
                else
                {
                    shouldFilter = !MatchLabel(tagNode, filter);
                }
            }
            else if (componentNode != null)
            {
                if (FilterBy == FilterType.Component)
                {
                    shouldFilter = !MatchLabel(componentNode, filter);
                }
            }

            return(shouldFilter);
        }
        /// <summary>
        /// The method checks if node should be filtered based on io spec filter. It is used in ApplyFilter.
        /// If node does not have matching input/outputs it should be filtered out.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <returns>true, if node should be filtered out, false, otherwise</returns>
        private bool ShouldFilterNodeBasedOnIoSpecFilter(CLVBaseNode node)
        {
            bool shouldFilter = false;

            //apply only to component nodes (not tag nodes)
            CLVComponentNode componentNode = node as CLVComponentNode;

            if (componentNode != null)
            {
                //if there are any io spec filters
                if (IoSpecFilters.Count > 0)
                {
                    //get component or composite component definition
                    IMetadataWithIOSpecDefinition compDef = componentNode.Component as IMetadataWithIOSpecDefinition;

                    // check each io spec filter
                    foreach (IOSpecFilter filter in IoSpecFilters)
                    {
                        //that is not empty
                        if (filter.IsEmpty == false)
                        {
                            if (compDef != null)
                            {
                                //proceed with filtering
                                if (filter.RequiresInput)
                                {
                                    //compare the full type (not friendly name)
                                    bool match = compDef.IOSpecDefinition.Input.Any(item => item.Value.Type.Equals(filter.FilterByDataType.Value));
                                    if (match == false)
                                    {
                                        shouldFilter = true;
                                        break;
                                    }
                                }
                                if (filter.RequiresOutput)
                                {
                                    //compare the full type (not friendly name)
                                    bool match = compDef.IOSpecDefinition.Output.Any(item => item.Value.Type.Equals(filter.FilterByDataType.Value));
                                    if (match == false)
                                    {
                                        shouldFilter = true;
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                //if it was not component metadefinition automatically filter it out (since it has not any input, output)
                                //we check it at this stage, to not exclude it, when the filters are empty
                                shouldFilter = true;
                                break; //just return
                            }
                        } //filter.IsEmpty
                    } // foreach loop
                }     // count > 0
            }         // component != null

            return(shouldFilter);
        }
Exemplo n.º 3
0
 private void BuildTagsHierarchy()
 {
     foreach (var component in m_componentsLibraryViewModel.ComponentsCollection)
     {
         var node = new CLVComponentNode(component, this);
         m_componentNodeCollection.Add(node);
         node.AddTag("All Components");
         //if (component.Tags != null)
         //{
         //    component.Tags.TagAdded += new EventHandler<Core.Components.TagChangedEventArgs>(Tags_TagAdded);
         //    component.Tags.TagRemoved += new EventHandler<Core.Components.TagChangedEventArgs>(Tags_TagRemoved);
         //}
         node.PropertyChanged += new PropertyChangedEventHandler(ComponentNodePropertyChanged);
     }
 }
Exemplo n.º 4
0
        private bool FilterComponents(object item)
        {
            bool             show = false;
            CLVComponentNode node = item as CLVComponentNode;

            if (node != null)
            {
                show = true;
                if (!string.IsNullOrWhiteSpace(m_lowercaseComponentFilter))
                {
                    show = node.Label.ToLower().Contains(m_lowercaseComponentFilter);
                }

                if (show == false)
                {
                    node.IsSelected = false;
                }
            }

            return(show);
        }
 private void BuildTagsHierarchy()
 {
     foreach (var component in m_componentsLibraryViewModel.ComponentsCollection)
     {
         var node = new CLVComponentNode(component, this);
         m_componentNodeCollection.Add(node);
         node.AddTag("All Components");
         //if (component.Tags != null)
         //{
         //    component.Tags.TagAdded += new EventHandler<Core.Components.TagChangedEventArgs>(Tags_TagAdded);
         //    component.Tags.TagRemoved += new EventHandler<Core.Components.TagChangedEventArgs>(Tags_TagRemoved);
         //}
         node.PropertyChanged += new PropertyChangedEventHandler(ComponentNodePropertyChanged);
     }
 }
 private void AddNodeTag(MetadataDefinition component)
 {
     var node = new CLVComponentNode(component, this);
     node.AddTag("All Components");
 }
        private void AddNodeTag(MetadataDefinition component)
        {
            var node = new CLVComponentNode(component, this);

            node.AddTag("All Components");
        }