Beispiel #1
0
        protected override void OnDisable()
        {
            base.OnDisable();

            UFProject.ExportXml(TempXmlPath);
            UFSelection.OnSelectionChange = null;
            UFSelection.ActiveControl     = null;
        }
Beispiel #2
0
 public static void CreateNewProject()
 {
     current = new UFProject();
     UFCanvas canvas1 = new UFCanvas();
     canvas1.Text = "canvas1";
     canvas1.Name = "canvas1";
     current.Controls.Add(canvas1);
 }
Beispiel #3
0
        void OnGUI()
        {
            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("New Form", UIOP.Button))
                {
                    UFProject.CreateNewProject();
                    RepaintAll();
                }

                if (GUILayout.Button("Import Code", UIOP.Button))
                {
                    UFSelector.OpenWindow((t) =>
                    {
                        UFProject.ImportCode(t);
                        UFSelection.ActiveControl = null;
                        RepaintAll();
                    });
                }

                if (GUILayout.Button("Export Code", UIOP.Button))
                {
                    string path = EditorUtility.SaveFilePanel("Select the path to export", "Assets/Editor", UFProject.Current.ClassName, "cs");
                    if (!string.IsNullOrEmpty(path) && path.Contains("/Editor/"))
                    {
                        UFProject.ExportCode(path);
                    }
                }

                if (GUILayout.Button("Export Native Code", UIOP.Button))
                {
                    string path = EditorUtility.SaveFilePanel("Select the path to export", "Assets/Editor", UFProject.Current.ClassName, "cs");
                    if (!string.IsNullOrEmpty(path) && path.Contains("/Editor/"))
                    {
                        UFProject.ExportNativeCode(path);
                    }
                }

                if (GUILayout.Button("Import Xml", UIOP.Button))
                {
                    string path = EditorUtility.OpenFilePanel("Select the path to import", "", "xml");
                    if (!string.IsNullOrEmpty(path) && File.Exists(path))
                    {
                        UFProject.ImportXml(path);
                        RepaintAll();
                    }
                }

                if (GUILayout.Button("Export Xml", UIOP.Button))
                {
                    string path = EditorUtility.SaveFilePanel("Select the path to export", "", UFProject.Current.ClassName, "xml");
                    if (!string.IsNullOrEmpty(path))
                    {
                        UFProject.ExportXml(path);
                    }
                }
            }
        }
Beispiel #4
0
        public static void CreateNewProject()
        {
            current = new UFProject();
            UFCanvas canvas1 = new UFCanvas();

            canvas1.Text = "canvas1";
            canvas1.Name = "canvas1";
            current.Controls.Add(canvas1);
        }
Beispiel #5
0
        public static void ImportCode(Type t)
        {
            if (t.BaseType != typeof(UFWindow))
            {
                throw new Exception("Specified type is not derived from 'UFWindow'! - " + t.Name);
            }

            current           = new UFProject();
            current.Namespace = t.Namespace;
            current.ClassName = t.Name;

            var window = EditorWindow.CreateInstance(t) as UFWindow;

            current.Controls.AddRange(window.Controls);
            current.Controls.ForEach(child => child.RefleshHierarchy());
            EditorWindow.DestroyImmediate(window);
        }
Beispiel #6
0
        protected override void OnEnable()
        {
            base.OnEnable();

            UFSelection.OnSelectionChange += (control) =>
            {
                RepaintAll();
            };

            if (File.Exists(TempXmlPath))
            {
                UFProject.ImportXml(TempXmlPath);
            }
            else
            {
                UFProject.CreateNewProject();
            }
        }
Beispiel #7
0
        public static void ImportXml(string xmlPath)
        {
            var assembly = Assembly.GetAssembly(typeof(UFControl));

            var list = assembly.GetTypes()
                       .Where(t => t.BaseType == typeof(UFControl))
                       .ToList();

            list.Add(typeof(UFControl));
            list = list.Distinct().ToList();

            var attributes = new XmlAttributes();

            list.ForEach(t => attributes.XmlArrayItems.Add(new XmlArrayItemAttribute(t)));

            var attrOverride = new XmlAttributeOverrides();

            attrOverride.Add(typeof(UFControl), "childList", attributes);
            attrOverride.Add(typeof(UFProject), "Controls", attributes);

            current = UFUtility.ImportXml <UFProject>(xmlPath, attrOverride: attrOverride);
            current.Controls.ForEach(child => child.RefleshHierarchy());
        }
Beispiel #8
0
        public static void ImportXml(string xmlPath)
        {
            var assembly = Assembly.GetAssembly(typeof(UFControl));

            var list = assembly.GetTypes()
                .Where(t => t.BaseType == typeof(UFControl))
                .ToList();
            list.Add(typeof(UFControl));
            list = list.Distinct().ToList();

            var attributes = new XmlAttributes();
            list.ForEach(t => attributes.XmlArrayItems.Add(new XmlArrayItemAttribute(t)));

            var attrOverride = new XmlAttributeOverrides();
            attrOverride.Add(typeof(UFControl), "childList", attributes);
            attrOverride.Add(typeof(UFProject), "Controls", attributes);

            current = UFUtility.ImportXml<UFProject>(xmlPath, attrOverride: attrOverride);
            current.Controls.ForEach(child => child.RefleshHierarchy());
        }
Beispiel #9
0
        public static void ImportCode(Type t)
        {
            if(t.BaseType != typeof(UFWindow))
            {
                throw new Exception("Specified type is not derived from 'UFWindow'! - " + t.Name);
            }

            current = new UFProject();
            current.Namespace = t.Namespace;
            current.ClassName = t.Name;

            var window = EditorWindow.CreateInstance(t) as UFWindow;
            current.Controls.AddRange(window.Controls);
            current.Controls.ForEach(child => child.RefleshHierarchy());
            EditorWindow.DestroyImmediate(window);
        }