private void OnPropertyDlgClose(object dialog)
        {
            _parentTemplate = null;

            AddPropertyDialog dlg = dialog as AddPropertyDialog;

            dlg.onAddClick -= OnAddPropertyClick;
            dlg.onClose    -= OnValueDlgClose;
        }
 public void AddPropertiesToXml(XmlDocument doc, XmlElement parent, BaseTemplate template)
 {
     foreach (string key in template.Properties.Keys)
     {
         foreach (PropertyTemplate p in template.Properties[key])
         {
             XmlElement n = doc.CreateElement(key);
             AddAttributesToXml(doc, n, p);
             AddPropertiesToXml(doc, n, p);
             parent.AppendChild(n);
         }
     }
 }
        public void AddAttributesToXml(XmlDocument doc, XmlElement parent, BaseTemplate template)
        {
            foreach (string key in template.Values.Keys)
            {
                string k = key;
                if (key.Contains("android:"))
                {
                    k = key.Replace("android:", "android___");
                }
                XmlAttribute attr = doc.CreateAttribute(k);
                attr.Value = template.Values[key];

                parent.Attributes.Append(attr);
            }
        }
        private void AddPropertyDialog(BaseTemplate parent)
        {
            _parentTemplate = parent;

            AddPropertyDialog dialog = EditorWindow.CreateInstance <AddPropertyDialog>();

            dialog.onAddClick += OnAddPropertyClick;
            dialog.onClose    += OnPropertyDlgClose;

#if UNITY_5 && !UNITY_5_0
            dialog.titleContent.text = "Add Property";
#else
            dialog.title = "Add Property";
#endif

            dialog.ShowAuxWindow();
        }
        private void DrawProperties(BaseTemplate parent)
        {
            foreach (string key in parent.Properties.Keys)
            {
                foreach (PropertyTemplate property in parent.Properties[key])
                {
                    if (parent is ActivityTemplate)
                    {
                        ActivityTemplate activity = parent as ActivityTemplate;
                        if (activity.IsLauncherProperty(property))
                        {
                            continue;
                        }
                    }

                    EditorGUILayout.Space();
                    EditorGUILayout.BeginVertical(GUI.skin.box, GUILayout.Height(27.0f));
                    EditorGUILayout.BeginHorizontal();

                    if (property.Values.ContainsKey("android:name"))
                    {
                        property.IsOpen = EditorGUILayout.Foldout(property.IsOpen, "[" + property.Tag + "] " + property.Values["android:name"]);
                    }
                    else
                    {
                        if (key.Equals("intent-filter"))
                        {
                            property.IsOpen = EditorGUILayout.Foldout(property.IsOpen, "[" + property.Tag + "] " + property.GetIntentFilterName(property));
                        }
                        else
                        {
                            property.IsOpen = EditorGUILayout.Foldout(property.IsOpen, "[" + property.Tag + "]");
                        }
                    }

                    if (GUILayout.Button("X", GUILayout.Width(20.0f)))
                    {
                        parent.RemoveProperty(property);
                        return;
                    }
                    EditorGUILayout.EndHorizontal();

                    if (property.IsOpen)
                    {
                        EditorGUILayout.BeginVertical();

                        foreach (string k in property.Values.Keys)
                        {
                            EditorGUILayout.Space();
                            EditorGUILayout.BeginHorizontal();

                            GUILayout.Label(k);
                            EditorGUILayout.Space();

                            string input = property.Values[k];
                            EditorGUI.BeginChangeCheck();
                            if (k.Equals("android:name"))
                            {
                                input = GUILayout.TextField(property.Values[k], GUILayout.Width(224.0f));
                            }
                            else
                            {
                                input = GUILayout.TextField(property.Values[k], GUILayout.Width(200.0f));
                            }
                            if (EditorGUI.EndChangeCheck())
                            {
                                property.SetValue(k, input);
                                return;
                            }

                            if (GUILayout.Button("X", GUILayout.Width(20.0f)))
                            {
                                property.RemoveValue(k);
                                return;
                            }

                            EditorGUILayout.EndHorizontal();
                        }

                        DrawProperties(property);
                        EditorGUILayout.Space();
                        EditorGUILayout.EndVertical();

                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.Space();
                        if (GUILayout.Button("Add Value", GUILayout.Width(100.0f)))
                        {
                            AddValueDialog(property);
                        }
                        if (GUILayout.Button("Add Property", GUILayout.Width(100.0f)))
                        {
                            AddPropertyDialog(property);
                        }
                        EditorGUILayout.Space();
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.Space();
                    }
                    EditorGUILayout.EndVertical();
                }
            }
        }