/// <summary> /// Searches for a given type of item among the childrens of this item. /// </summary> /// <param name="typeToSearch"></param> /// <returns></returns> public ISolutionItem SearchFirstItemByType(TypeOfSolutionItem typeToSearch) { if (Children != null) { for (int i = 0; i < Children.Count; i++) { if (Children[i].TypeOfItem == typeToSearch) { return(Children[i]); } var typedChild = Children[i].SearchFirstItemByType(typeToSearch); if (typedChild != null) { return(typedChild); } } } return(null); }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { // Check input parameter types if (values == null) { return(Binding.DoNothing); } if (values.Length != 2) { return(Binding.DoNothing); } TypeOfSolutionItem type = TypeOfSolutionItem.Unknown; bool typeIsAssigned = false; ItemExisits state = ItemExisits.Unknown; bool stateIsAssigned = false; for (int i = 0; i < values.Length; i++) { if (values[i] is TypeOfSolutionItem) { type = (TypeOfSolutionItem)values[i]; typeIsAssigned = true; } else { if (values[i] is ItemExisits) { state = (ItemExisits)values[i]; stateIsAssigned = true; } } } if (typeIsAssigned == false) { throw new ArgumentException(string.Format("Expected argument: '{0}' was not supplied.", type.GetType().ToString())); } if (stateIsAssigned == false) { throw new ArgumentException(string.Format("Expected argument: '{0}' was not supplied.", state.GetType().ToString())); } if (targetType != typeof(System.Windows.Media.ImageSource)) { throw new ArgumentException("Invalid return type. Expected return type: System.Windows.Media.ImageSource"); } string resourceUri = string.Empty; string stateExtension = string.Empty; switch (state) { case ItemExisits.Unknown: stateExtension = "Unknown"; break; case ItemExisits.DoesExist: stateExtension = string.Empty; break; case ItemExisits.DoesNotExist: stateExtension = "Problem"; break; default: throw new NotImplementedException(state.ToString()); } string typeURL = string.Empty; switch (type) { case TypeOfSolutionItem.Root: typeURL = "Icon_Solution"; break; case TypeOfSolutionItem.Project: typeURL = "Icon_Project"; break; case TypeOfSolutionItem.File: typeURL = "Icon_Documents"; break; case TypeOfSolutionItem.Unknown: default: throw new NotImplementedException(state.ToString()); } string resourceKey = string.Format("{0}{1}", typeURL, (string.IsNullOrEmpty(stateExtension) ? string.Empty : "_" + stateExtension)); return(Application.Current.FindResource(resourceKey)); }
/// <summary> /// Searches for a given type of item among the childrens of this item. /// </summary> /// <param name="typeToSearch"></param> /// <returns>Always null since this type of item does not have children.</returns> public ISolutionItem SearchFirstItemByType(TypeOfSolutionItem typeToSearch) { return(null); }