public WpfContainer(string xamlPath)
        {
            Context = new ParserContext();
            Context.XmlnsDictionary.Add("", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
            Context.XmlnsDictionary.Add("x", "http://schemas.microsoft.com/winfx/2006/xaml");

            XamlFile = new FrameworkElementWrapper((FrameworkElement)XamlReader.Load(new FileStream(xamlPath, FileMode.Open), Context));
        }
 public FrameworkElementWrapper(FrameworkElement element, HereString hereString, FrameworkElementWrapper parent = null)
 {
     Element = element;
     XamlDeclaration = hereString;
     Icon = IconMappings.ContainsKey(element.GetType().Name)
         ? IconMappings[element.GetType().Name]
         : IconMappings["Element"];
     GenerateChildren();
     Parent = parent;
     EventMappings = new Dictionary<string, PsEventHandler>();
     var events = element.GetType().GetEvents();
     foreach (var eventInfo in events)
     {
         EventMappings.Add(eventInfo.Name, null);
     }
 }
        public static FrameworkElementWrapper TopLevelContainer(FrameworkElementWrapper elementWrapper)
        {
            FrameworkElementWrapper topLevelContainer = null;
            while (topLevelContainer == null)
            {
                if (elementWrapper.Parent == null)
                {
                    topLevelContainer = elementWrapper;
                    break;
                }

                elementWrapper = elementWrapper.Parent;
                topLevelContainer = elementWrapper;
            }

            return topLevelContainer;
        }
        public static string GenerateItemVariables(FrameworkElementWrapper elementWrapper, string vars = "")
        {
            vars += elementWrapper.VarDeclaration != null ? elementWrapper.VarDeclaration + "\r\n" : "" ;
            foreach (var child in elementWrapper.Children)
            {
                vars += GenerateItemVariables(child);
            }

            return vars;
        }
 public List<StringWrapper> GenerateElementDeclarations(HereString hereString)
 {
     //potential placeholder value
     var xaml = new FrameworkElementWrapper((Window) XamlReader.Parse(hereString.Value), hereString);
     return CreateDeclarationsHelper($"{hereString.Name}_Form", xaml);
 }
 private static List<StringWrapper> CreateDeclarationsHelper(string root, FrameworkElementWrapper frameworkElement)
 {
     var declarations = new List<StringWrapper>();
     if (frameworkElement.Element.Name != "")
         declarations.Add(
             new StringWrapper(
                 $"${frameworkElement.Element.Name}=${root}.Content.FindName(\"{frameworkElement.Name}\")"));
     foreach (var child in frameworkElement.Children)
     {
         declarations.AddRange(CreateDeclarationsHelper(root, child));
     }
     return declarations;
 }