Exemplo n.º 1
0
        private void InvestigateAssemblies()
        {
            foreach (Assembly assembly in _partsToInvestigate)
            {
                string moduleName = assembly.FullName.Substring(0,assembly.FullName.IndexOf(','));
                ElementPo module = new ElementPo { IsChecked = false, FullName = assembly.FullName, Name  = moduleName,Type = 1 };

                foreach (Type type in assembly.GetTypes().Where(x => x.IsSubclassOf(typeof(Screen))))
                {
                    Type viewType = assembly.GetTypes().Where(x => type.Name.Contains(x.Name) && x.IsSubclassOf(typeof(UIElement))).FirstOrDefault();
                    ElementPo viewElement = GetViewElement(viewType);
                    if (viewElement != null)
                    {
                        viewElement.Parrent = module;
                        module.Childs.Add(viewElement);
                    }
                }
                Elements.Add(module);
            }
            if(CompletedLoading!=null)
            {
               CompletedLoading(Elements);
            }
        }
Exemplo n.º 2
0
        //public List<Element> GetAllElements()
        //{
        //    List<Element> elements = new List<Element>();

        //    foreach (AssemblyPart ap in Deployment.Current.Parts)
        //    {

        //        StreamResourceInfo sri = Application.GetResourceStream(new Uri(ap.Source, UriKind.Relative));
        //        Assembly a = new AssemblyPart().Load(sri.Stream);
        //        if (a.FullName.Contains("Module") && !(a.FullName.Contains("Interfaces") || a.FullName.Contains("Services")))
        //        {
        //            Element module = new Element{FullName = a.FullName, Type = 1};

        //            foreach (Type type in a.GetTypes().Where(x => x.IsSubclassOf(typeof(Screen))))
        //            {
        //                Type viewType = a.GetTypes().Where(x => type.Name.Contains(x.Name) && x.IsSubclassOf(typeof(UIElement))).FirstOrDefault();
        //                Element viewElement= GetViewElement(viewType);
        //                if(viewElement!=null)
        //                {
        //                    module.Childs.Add(viewElement);
        //                }
        //            }
        //            elements.Add(module);
        //        }
        //    }
        //    return elements;
        //}

        private ElementPo GetViewElement(Type viewType)
        {
            ElementPo viewElement = null;
            if (viewType != null)
            {
                viewElement = new ElementPo { IsChecked = false, FullName = viewType.FullName, Name = viewType.Name,Type = 2};
                foreach (ElementPo element in GetControlElement(viewType))
                {
                    element.Parrent = viewElement;
                    viewElement.Childs.Add(element);
                }
            }
            return viewElement;
        }
Exemplo n.º 3
0
 private IEnumerable<ElementPo> GetControlElement(Type viewType)
 {
     foreach (FrameworkElement element in ((DependencyObject)Activator.CreateInstance(viewType)).GetVisuals().OfType<FrameworkElement>().Where(x => x.Name != string.Empty).ToList())
     {
         ElementPo controlElement = new ElementPo{Name = element.Name,Type = 3,IsChecked = false,ElementType = element.GetType().Name};
         yield return controlElement;
     }        
 }
        /// <summary>
        /// Selects the node.
        /// </summary>
        /// <param name="elementPo">The element po.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        public void SelectNode(ElementPo elementPo, RoutedEventArgs e)
        {
            if (((CheckBox)e.OriginalSource).IsChecked.HasValue && ((CheckBox)e.OriginalSource).IsChecked.Value && elementPo.Parrent != null)
            {
                elementPo.Parrent.IsChecked = true;
                if (elementPo.Parrent.Parrent != null)
                    elementPo.Parrent.Parrent.IsChecked = true;
            }

            foreach (ElementPo element in TraverseElements(elementPo.Childs))
            {
                element.IsChecked = ((CheckBox)e.OriginalSource).IsChecked ?? false;
            }
        }