示例#1
0
        public void m_command_Click() // open map
        {
            string aMapGuid      = m_command.ToolTip;
            string _mapName      = m_command.Caption;
            string _mapPlacePath = "";
            string aStorage      = "";
            string _mapLocalPath = "";
            bool   mapnotfound   = true;

            using (MapsDB _db = new MapsDB())
            {
                System.Data.DataTable _dt = _db.ExecuteQuery("select * from MAPS where MAPGUID=`" + aMapGuid + "`");
                if (_dt.Rows.Count != 0)
                {
                    mapnotfound   = false;
                    _mapLocalPath = _dt.Rows[0]["LOCALPATH"].ToString();
                    _mapPlacePath = _dt.Rows[0]["PATHTOPLACE"].ToString();
                    aStorage      = _dt.Rows[0]["STORAGE"].ToString();
                }
            }

            if (mapnotfound)
            {
                System.Windows.Forms.MessageBox.Show(String.Format(MMUtils.GetString("maps.mapnoexists.message"), _mapName),
                                                     MMUtils.GetString("maps.mapnoexists.caption"));
                return; // TODO нужно предложить удалить ее - из БД и из меню
            }

            // if map is opened already
            foreach (Document _map in MMUtils.MindManager.AllDocuments)
            {
                if (SUtils.SynergyMapGuid(_map) == aMapGuid)
                {
                    _map.Activate();
                    return;
                }
            }

            if (Directory.Exists(_mapPlacePath)) // TODO если по причине неподключенного сетевого диска -
            {
                string _latestfile        = Directory.GetFiles(_mapPlacePath, "*.mmap").Last().ToString();
                long   localmap_lastwrite = Convert.ToInt64(File.GetLastWriteTimeUtc(_mapLocalPath).ToString("yyyyMMddHHmmssfff"));
                long   placemap_time      = Convert.ToInt64(Path.GetFileNameWithoutExtension(_latestfile));

                // Check if map in Place is newer than local map, if yes - replace local map
                if (placemap_time > localmap_lastwrite)
                {
                    try
                    {
                        File.Copy(_latestfile, _mapLocalPath, true); // copy (overwrite) map from its Place to local Synergy
                    }
                    catch { } // TODO
                }
            }

            DocumentStorage.reopenmap = false;
            System.IO.File.SetAttributes(_mapLocalPath, System.IO.FileAttributes.Normal);
            MMUtils.MindManager.AllDocuments.Open(_mapLocalPath);
        }
示例#2
0
        void m_cmdShareMap_Click()
        {
            string mapGuid = SUtils.SynergyMapGuid(MMUtils.ActiveDocument);

            foreach (Timers item in TIMERS)
            {
                if (item.m_Guid == mapGuid)
                {
                    using (ShareMapDlg _dlg = new ShareMapDlg(MMUtils.ActiveDocument.Name, item.m_PlacePath))
                        _dlg.ShowDialog(new WindowWrapper((IntPtr)MMUtils.MindManager.hWnd));
                    break;
                }
            }
        }