public bool isSaved(int snapshotCount, eProfilerMode profilerMode, string ip = null)
    {
        DirectoryInfo TheFolder = new DirectoryInfo(combineBasepath(profilerMode, ip));

        if (!TheFolder.Exists)
        {
            return(false);
        }
        if (TheFolder.GetFiles().Length != snapshotCount)
        {
            return(false);
        }
        return(true);
    }
    public string combineBasepath(eProfilerMode profilerMode, string ip = null)
    {
        string mode = "";

        if (profilerMode == eProfilerMode.Remote)
        {
            if (ip == null)
            {
                ip = "";
            }
            mode = "-Remote-" + ip;
        }
        else if (profilerMode == eProfilerMode.Editor)
        {
            mode = "-Editor";
        }
        return(Path.Combine(MemUtil.SnapshotsDir, _now + mode));
    }
    public bool saveAllSnapshot(List <MemSnapshotInfo> snapshotInfos, eProfilerMode profilerMode, string ip = null)
    {
        if (snapshotInfos.Count <= 0)
        {
            return(false);
        }

        try
        {
            _basePath = combineBasepath(profilerMode, ip);

            if (!Directory.Exists(_basePath))
            {
                Directory.CreateDirectory(_basePath);
            }

            for (int index = 0; index < snapshotInfos.Count; index++)
            {
                var    packed   = snapshotInfos[index];
                string fileName = Path.Combine(_basePath, string.Format("{0}.memsnap", index));
                if (!File.Exists(fileName))
                {
                    saveSnapshotJson(index, packed);
                    System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    using (Stream stream = File.Open(fileName, FileMode.Create))
                    {
                        bf.Serialize(stream, packed);
                    }
                }
            }
            return(true);
        }
        catch (Exception ex)
        {
            Debug.LogError(string.Format("save snapshot error ! msg ={0}", ex.Message));
            Debug.LogException(ex);
            return(false);
        }
    }
        void OnGUI()
        {
            handleCommandEvent();
            // main bar
            GUILayout.BeginHorizontal();
            int connectedIndex = GUI.SelectionGrid(new Rect(0, 0, 180, 20), (int)_selectedProfilerMode, _ConnectedOptions, _ConnectedOptions.Length, MemStyles.ToolbarButton);

            if (connectedIndex != (int)_selectedProfilerMode)
            {
                _isRemoteConnected = false;

                if (_SnapshotChunks.Count > 0 &&
                    !_snapshotIOperator.isSaved(_SnapshotChunks.Count, _selectedProfilerMode, lastLoginIP) &&
                    !switchProfilerModeDialog())
                {
                }
                else
                {
                    clearSnapshotChunk();
                    _selectedProfilerMode = (eProfilerMode)connectedIndex;

                    if (_selectedProfilerMode == (int)eProfilerMode.Editor)
                    {
                        connectEditor();
                    }
                }
            }

            GUILayout.Space(200);
            drawProfilerModeGUI();
            if (GUILayout.Button("Open Dir", GUILayout.MaxWidth(100)))
            {
                EditorUtility.RevealInFinder(MemUtil.SnapshotsDir);
            }
            GUILayout.EndHorizontal();

            // view bar
            GUILayout.BeginArea(new Rect(0, MemConst.TopBarHeight, position.width - MemConst.InspectorWidth, 30));
            GUILayout.BeginHorizontal(MemStyles.Toolbar);
            int selected = GUILayout.SelectionGrid((int)m_selectedView, MemConst.ShowTypes, MemConst.ShowTypes.Length, MemStyles.ToolbarButton);

            if (m_selectedView != (eShowType)selected)
            {
                m_selectedView = (eShowType)selected;
                RefreshCurrentView();
            }

            GUILayout.EndHorizontal();
            GUILayout.EndArea();

            // selected views
            float TabHeight = 30;
            float yoffset   = MemConst.TopBarHeight + TabHeight;
            Rect  view      = new Rect(0f, yoffset, position.width - MemConst.InspectorWidth, position.height - yoffset);

            switch (m_selectedView)
            {
            case eShowType.InTable:
                if (_tableBrowser != null)
                {
                    _tableBrowser.Draw(view);
                }
                break;

            case eShowType.InTreemap:
                if (_treeMapView != null)
                {
                    _treeMapView.Draw(view);
                }
                break;

            default:
                break;
            }

            if (_inspector != null)
            {
                _inspector.Draw();
            }
        }