public override void onObjectAdded(MMEventArgs aArgs) // only for new topics { Topic _t = aArgs.target as Topic; Relationship _r = aArgs.target as Relationship; Boundary _b = aArgs.target as Boundary; string rootfolder = aArgs.aMapFolderPath + "share\\"; string _path = rootfolder + SUtils.modtime + "&" + SUtils.currentUserName + ".txt"; string _what = "add:"; string pGuid = ""; string offset = ""; int a = 0; if (_r != null) // add relationship { SUtils.ProcessRelationship(_r, _path, "relationship:add"); _r = null; return; } if (_b != null) // add boundary { SUtils.ProcessBoundary(_b, _path, "boundary:add"); System.Threading.Thread.Sleep(100); // иначе выноска границы может вперед прийти по облачному хранилищу _b = null; return; } if (_t == null) { return; // TODO case? } if (_t.IsFloatingTopic) { _what = "add:floating"; } if (_t.IsCalloutTopic || _t.IsSummaryTopic) { _what = "add:callout"; if (_t.ParentRelationship != null) // add callout to relationship { _what = "add:relcallout"; Relationship rel = _t.ParentRelationship; pGuid = rel.get_Attributes(SUtils.SYNERGYNAMESPACE).GetAttributeValue(SUtils.OGUID); } if (_t.ParentBoundary != null) // add callout to boundary { _what = "add:bndcallout"; Boundary bnd = _t.ParentBoundary; pGuid = bnd.get_Attributes(SUtils.SYNERGYNAMESPACE).GetAttributeValue(SUtils.OGUID); } } if (_t.IsFloatingTopic || _t.IsMainTopic || _t.IsCalloutTopic) { float x, y; _t.GetOffset(out x, out y); offset = x.ToString() + ";" + y.ToString(); if (_t.IsMainTopic) { a = -1; } } if (!_t.IsFloatingTopic && _what != "add:relcallout" && _what != "add:bndcallout") { pGuid = _t.ParentTopic.get_Attributes(SUtils.SYNERGYNAMESPACE).GetAttributeValue(SUtils.OGUID); a = MMUtils.SubtopicIndex(_t); } if (!_t.IsCalloutTopic && !_t.IsFloatingTopic && !_t.IsSummaryTopic) { _what = _what + a.ToString(); } string _shorttext = MMUtils.TShortText(_t.Text); TransactionsWrapper.SetAttributes(_t); string _tGuid = _t.Guid; string _topicdata = ""; if (_t.IsDefaultTopicText) { _topicdata = "newtopic"; } else { _topicdata = _t.Xml; } _t = null; try { StreamWriter sw = new StreamWriter(File.Create(_path)); sw.WriteLine(_what); sw.WriteLine(pGuid); // parent topic's guid - to which add topic(s) sw.WriteLine(_shorttext); // topic text or what added - for chat sw.WriteLine(_tGuid); sw.WriteLine(SUtils.TimeStamp + ";" + SUtils.currentUserName + ";" + SUtils.currentUserEmail); sw.WriteLine(offset); // for main, floating or callout topic sw.WriteLine(_topicdata); sw.Close(); } catch (Exception e) { System.Windows.Forms.MessageBox.Show("Exception: " + e.Message, "SaveChanges:onObjectAdded"); } }