Exemplo n.º 1
0
        /// <summary>
        /// set ChildrenActivity according current ModelItem
        /// </summary>
        private void SetChildrenActivityFromModelItemProperty()
        {
            Children = new ObservableCollection<WorkflowOutlineNode>();
            foreach (ModelProperty property in Model.Properties)
            {
                ModelItem value = property.Value;
                if (value == null)
                    continue;

                if (value.ItemType.IsSubclassOf(typeof(Activity)) || value.ItemType.IsSubclassOf(typeof(ActivityDelegate)))
                {
                    WorkflowOutlineNode newchild = new WorkflowOutlineNode(value);
                    Children.Add(newchild);
                    newchild.Parent = this;
                    continue;
                }

                ModelItemCollection items = value as ModelItemCollection;
                if (items != null)
                {
                    foreach (ModelItem i in items)
                    {
                        if (i.ItemType == typeof(FlowStep)
                            || i.ItemType.IsSubclassOf(typeof(Activity))
                            || i.ItemType.IsSubclassOf(typeof(ActivityDelegate))
                            || i.ItemType == typeof(PickBranch)
                            || i.ItemType == typeof(FlowDecision))
                        {
                            //Children.Add(new WorkflowOutlineNode(i));
                            WorkflowOutlineNode newchild = new WorkflowOutlineNode(i);
                            Children.Add(newchild);
                            newchild.Parent = this;
                        }
                    }
                    continue;
                }

                ModelItemDictionary dictionary = value as ModelItemDictionary;
                if (dictionary != null)
                {
                    foreach (KeyValuePair<ModelItem, ModelItem> pair in dictionary)
                    {
                        ModelItem candidateItem = pair.Value;
                        if (candidateItem == null)
                            continue;
                        if (candidateItem.ItemType.IsSubclassOf(typeof(Activity))
                            || candidateItem.ItemType.IsSubclassOf(typeof(FlowStep))
                            || candidateItem.ItemType.IsSubclassOf(typeof(ActivityDelegate)))
                        {
                            //Children.Add(new WorkflowOutlineNode(candidateItem));
                            WorkflowOutlineNode newchild = new WorkflowOutlineNode(candidateItem);
                            Children.Add(newchild);
                            newchild.Parent = this;
                        }
                    }
                    continue;
                }
            }
        }
Exemplo n.º 2
0
        private bool Filter(WorkflowOutlineNode act)
        {
            if (act == null)
                return false;
            if (act.Model != null)
            {
                var item = act.Model;

                if (IsSearchType)
                {
                    if (item.ItemType.Name.ToLower().Contains(this.SearchText.ToLower()))
                        return true;
                }

                if (IsSearchTitle && item.Properties[DisplayNamePropertyName] != null)
                {
                    if (act.NodeName.ToLower().Contains(this.SearchText.ToLower()))
                        return true;
                }

                if (IsSearchParameter)
                {
                    foreach (var property in item.Properties)
                    {
                        if (property.Value != null)
                        {
                            var value = property.Value.GetCurrentValue();
                            string strExpression = string.Empty;

                            if (property.PropertyType.Name == InArgumentTypeName
                                   || property.PropertyType.Name == OutArgumentTypeName
                                   || property.PropertyType.Name == InArgumentGenericTypeName
                                   || property.PropertyType.Name == OutArgumentGenericTypeName
                                   )
                            {
                                var argument = value as Argument;
                                if (argument != null)
                                    strExpression = ArgumentService.GetExpressionText(argument);
                            }

                            if (strExpression.ToLower().Contains(this.SearchText.ToLower()))
                                return true;
                        }
                    }
                }
            }
            return false;
        }
Exemplo n.º 3
0
 /// <summary>
 ///  Find with filter.
 /// </summary>
 /// <param name="startingItem"></param>
 /// <param name="filter"></param>
 private void SearchWorkflowOutlineNode(WorkflowOutlineNode startingItem, Predicate<WorkflowOutlineNode> filter)
 {
     if (startingItem != null)
     {
         if (filter(startingItem))
             this.searchResult.Add(startingItem);
         if (startingItem.Children != null && startingItem.Children.Any())
             foreach (var item in startingItem.Children)
             {
                 this.SearchWorkflowOutlineNode(item, filter);
             }
     }
 }
Exemplo n.º 4
0
 private bool CheckIsChild(WorkflowOutlineNode source, WorkflowOutlineNode target)
 {
     if (source.Children != null && source.Children.Any())
     {
         foreach (var c in source.Children)
         {
             if (c == target || CheckIsChild(c, target))
             {
                 return true;
             }
         }
     }
     return false;
 }