示例#1
0
    public static bool LoadEditorLayout(EditorRoot root)
    {
        bool bRet = false;

        EditorLayoutInfo editorLayout = new EditorLayoutInfo();

        editorLayout.ReadEditorLayoutInfo(LayoutInfoBaseDir, root, ref editorLayout);

        if (CheckLayoutInfoValid(root, editorLayout))
        {
            //root.position = new Rect(editorLayout.XPox, editorLayout.YPox, editorLayout.Width, editorLayout.Height);
            //EditorUtility.SetDirty(root);
            //root.position = new Rect(editorLayout.XPox, editorLayout.YPox, editorLayout.Width, editorLayout.Height);
            List <EditorControl> spliterTbl = root.GetSpliterCtrl(root.RootCtrl);

            foreach (var item in spliterTbl)
            {
                foreach (var info in editorLayout.DivisionInfo)
                {
                    if (item.CtrlID == info.SpliterID)
                    {
                        item.layoutConstraint.spliterOffset    = info.SplitOffset;
                        item.layoutConstraint.spliterOffsetInv = info.SpliterOffsetInv;
                        break;
                    }
                }
            }
        }

        return(bRet);
    }
示例#2
0
    public static bool SaveEditorLayout(EditorRoot root)
    {
        bool bRet = false;

        if (null == root)
        {
            return(false);
        }

        EditorLayoutInfo editorLayout = new EditorLayoutInfo();

        editorLayout.WirteEditorLayoutInfo(LayoutInfoBaseDir, root);

        return(bRet);
    }
示例#3
0
    public object GetSerializeObject(EditorRoot root)
    {
        if (null == root)
        {
            return(null);
        }

        EditorLayoutInfo newInfo = new EditorLayoutInfo();

        newInfo.XPox   = root.position.x;
        newInfo.YPox   = root.position.y;
        newInfo.Width  = root.position.width;
        newInfo.Height = root.position.height;

        newInfo.DivisionInfo = GetDivisionInfo(root.RootCtrl);

        return(newInfo);
    }
示例#4
0
    private static bool CheckLayoutInfoValid(EditorRoot root, EditorLayoutInfo layoutInfo)
    {
        bool bRet = true;

        if (
            (null == root) ||
            (null == layoutInfo)
            )
        {
            return(false);
        }

        do
        {
            List <string> spliterTbl = root.GetSpliterCtrlID(root.RootCtrl);

            if (spliterTbl.Count != layoutInfo.DivisionInfo.Count)
            {
                bRet = false;
                break;
            }

            foreach (var item in layoutInfo.DivisionInfo)
            {
                if (!spliterTbl.Contains(item.SpliterID))
                {
                    bRet = false;
                    break;
                }
            }
            if (!bRet)
            {
                break;
            }
        } while (false);

        return(bRet);
    }
示例#5
0
    public void ReadEditorLayoutInfo(string baseDir, EditorRoot root, ref EditorLayoutInfo info)
    {
        if (
            (null == root) ||
            string.IsNullOrEmpty(baseDir)
            )
        {
            return;
        }

        string eidtorLayoutInfoPath = baseDir + root.editorName + "/" + "EditorLayoutInfo.layout";

        if (!File.Exists(eidtorLayoutInfoPath))
        {
            return;
        }
        StreamReader yamlReader       = File.OpenText(eidtorLayoutInfoPath);
        Deserializer yamlDeserializer = new Deserializer();

        //读取持久化对象
        info = yamlDeserializer.Deserialize <EditorLayoutInfo>(yamlReader);

        yamlReader.Close();
    }