예제 #1
0
        public override void onAfterPaste(MMEventArgs aArgs)
        {
            Document _doc = aArgs.Document;

            // if boundary selected
            if (_doc.Selection.HasBoundary && !_doc.Selection.HasTopic) //if any topic in selection, any boundaries are ignored
            {
                Boundary bnd = null;
                foreach (Boundary b in _doc.Selection)
                {
                    bnd = b; // take the first one
                    break;
                }
                aArgs.target = bnd.Topic;
                aArgs.what   = "boundary";
                onObjectChanged(aArgs);
                _doc = null;
                bnd  = null;
                return;
            }

            MapCompanion.publishpaste = true;
            Topic _t = null;

            foreach (DocumentObject obj in _doc.Selection) // находим "верхний" топик в выборе
            {
                _t = obj as Topic;
                if (_t == null)
                {
                    continue;
                }

                aArgs.target = _t;
                ProcessBranch(_t);
                onObjectAdded(aArgs);
            }
            _t   = null;
            _doc = null;

            string rootfolder = aArgs.aMapFolderPath + "share\\";
            string _path;

            // Process relationships if any
            if (!restrict)
            {
                foreach (Relationship r in BranchRelationships) // list of branch relationships
                {
                    _path = rootfolder + SUtils.modtime + "&" + SUtils.currentUserName + ".txt";

                    SUtils.ProcessRelationship(r, _path, "relationship:paste");

                    foreach (Topic callout in r.AllCalloutTopics)
                    {
                        RelationshipTopics(callout, aArgs);
                    }
                }
            }

            for (int i = 0; i <= BranchRelationships.Count; i++)
            {
                BranchRelationships[i] = null; // TODO needed?
            }
            BranchRelationships.Clear();
        }
예제 #2
0
        /// <summary>
        /// Set Synergy attributes to all objects in the branch of given topic and collect all relationships
        /// </summary>
        void ProcessBranch(Topic _topic)
        {
            TransactionsWrapper.SetAttributes(_topic);

            if (_topic.HasBoundary)
            {
                TransactionsWrapper.SetAttributes(_topic.Boundary, _topic.Boundary.Guid);

                foreach (Relationship _r in _topic.Boundary.AllRelationships)
                {
                    if (BranchRelationships.Contains(_r))
                    {
                        continue;
                    }

                    TransactionsWrapper.SetAttributes(_r, _r.Guid);
                    BranchRelationships.Add(_r); // list of relationships to process further

                    foreach (Topic _t in _r.AllCalloutTopics)
                    {
                        TransactionsWrapper.SetAttributes(_t);
                        foreach (Topic _subtopic in _t.AllSubTopics)
                        {
                            ProcessBranch(_subtopic);
                        }
                    }
                }

                if (_topic.Boundary.HasSummaryTopic)
                {
                    Topic _st = _topic.Boundary.SummaryTopic;
                    TransactionsWrapper.SetAttributes(_st);

                    foreach (Topic _subtopic in _st.AllSubTopics)
                    {
                        ProcessBranch(_subtopic);
                    }
                    _st = null;
                }
            }

            foreach (Relationship _r in _topic.AllRelationships)
            {
                if (BranchRelationships.Contains(_r))
                {
                    continue;
                }

                TransactionsWrapper.SetAttributes(_r, _r.Guid);
                BranchRelationships.Add(_r); // list of relationships to process further

                foreach (Topic _t in _r.AllCalloutTopics)
                {
                    TransactionsWrapper.SetAttributes(_t);
                    foreach (Topic _subtopic in _t.AllSubTopics)
                    {
                        ProcessBranch(_subtopic);
                    }
                }
            }

            foreach (Topic _subtopic in _topic.AllSubTopics)
            {
                ProcessBranch(_subtopic);
            }

            foreach (Topic _subtopic in _topic.AllCalloutTopics)
            {
                ProcessBranch(_subtopic);
            }
        }