public static void Destroy() { m_timer200.Stop(); m_timer200.Tick -= m_timer200_Tick; m_timer200 = null; closeMap_timer.Stop(); closeMap_timer.Tick -= MapClose_timer_Tick; closeMap_timer = null; openMap_timer.Stop(); openMap_timer.Tick -= MapOpen_timer_Tick; openMap_timer = null; m_documentEventBefore.Fire -= m_documentEventBefore_Fire; System.Runtime.InteropServices.Marshal.ReleaseComObject(m_documentEventBefore); m_documentEventBefore = null; m_documentEventAfter.Fire -= m_documentEventAfter_Fire; System.Runtime.InteropServices.Marshal.ReleaseComObject(m_documentEventAfter); foreach (DocumentStorage item in SDocs) { item.Sdoc = null; item._mc.Dispose(); } SDocs.Clear(); }
static void m_documentEventBefore_Fire(int eventFlag, MmEventTime time, object pSource, ref object pExtra) { Document _doc = pSource as Document; bool _notsynergy = true; if (_doc == null || !_doc.HasAttributesNamespace[SUtils.SYNERGYNAMESPACE]) { return; } string mapGuid = SUtils.SynergyMapGuid(_doc); foreach (DocumentStorage item in SDocs) { if (mapGuid == item.MGuid) { _notsynergy = false; break; } } if (_notsynergy) { _doc = null; return; } if (eventFlag == EventDocumentClosed) { if (closeMap) { closeMap = false; _doc = null; return; } File.SetAttributes(_doc.FullName, FileAttributes.Normal); Sync(_doc, false); // Unsubscribe this map foreach (Watchers _item in Maps.MapsGroup.WATCHERS) { if (_item.aMapGuid == mapGuid) { _item.Dispose(); Maps.MapsGroup.WATCHERS.Remove(_item); break; } } string m_PlacePath = ""; bool _isonline = true; foreach (Timers _item in MapsGroup.TIMERS) { if (_item.m_Guid == mapGuid) { _isonline = (_item.m_Status == "online"); m_PlacePath = _item.m_PlacePath; string _folder = _item.m_PlacePath; _folder = Path.GetDirectoryName(_folder) + "\\"; try { string _file = _folder + "info.locker"; if (File.Exists(_file)) { File.Delete(_file); } _file = _folder + SUtils.currentUserName + ".online"; if (File.Exists(_file)) { File.Delete(_file); } } catch { } _item.Destroy(); MapsGroup.TIMERS.Remove(_item); break; } } if (MMUtils.MindManager.VisibleDocuments.Count == 1) // this map is the only document, so - it is last { MapsGroup.dlgUsersOnline.Visible = false; if (DocumentStorage.SDocs.Count > 0) { MessageBox.Show("All documents closed, but SDocs is not empty...", "Possible bug"); } foreach (DocumentStorage item in SDocs) { item.Sdoc = null; item._mc.Dispose(); } SDocs.Clear(); } if (_isonline) { try { _doc.Save(); // Prepare last file for save in Place string _path = m_PlacePath + File.GetLastWriteTimeUtc(_doc.FullName).ToString("yyyyMMddHHmmssfff") + ".mmap"; File.Copy(_doc.FullName, _path, true); } catch (Exception e) { MessageBox.Show("Exception: " + e.Message, "onBeforeClosed"); } finally { _doc = null; } } _doc = null; } if (eventFlag == EventDocumentSaved) { _doc = null; } if (eventFlag == EventDocumentClipboardDrag) // TODO needed? { //foreach (MMBase _parent in m_parent) // _parent.onBeforeDocumentClipboardDragBase(new MMEventArgs(m_documentEventBefore, _doc)); _doc = null; } if (eventFlag == EventDocumentClipboardDrop) { MapCompanion.paste = true; _doc = null; } if (eventFlag == EventDocumentClipboardCopy) // TODO needed? { //foreach (MMBase _parent in m_parent) // _parent.onBeforeDocumentClipboardCopyBase(new MMEventArgs(m_documentEventBefore, _doc)); _doc = null; } if (eventFlag == EventDocumentClipboardPaste) { MapCompanion.paste = true; _doc = null; } _doc = null; }