示例#1
0
        public static void GetChanges(Document _doc, string _filepath) // _filepath to .txt file in share folder
        {
            //string[] files = Directory.GetFiles(mapFolderPath, "*.txt");

            float  x = 0, y = 0; // callouts, main and floating topics
            int    index  = 1;   // subtopic index in a branch
            string line   = "";
            string _case  = "";
            string _what  = ""; // case details
            string rollup = SUtils.rollupuri;
            //string numbering = SUtils.numberinguri;

            string mapfolderpath = Path.GetDirectoryName(_filepath) + "\\";

            //foreach (string file in files)
            {
                System.IO.StreamReader _file = null;
                try
                {
                    _file = new System.IO.StreamReader(_filepath);
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show("Exception: " + e.Message, "ReceiveChanges:StreamReader");
                    return;
                }

                line  = _file.ReadLine(); // line 1: case
                _case = line;
                int colon = line.IndexOf(":");

                if (colon != -1)
                {
                    _case = line.Substring(0, colon); // before colon
                    _what = line.Substring(++colon);  // after colon
                    if (!int.TryParse(_what, out index))
                    {
                        index = 1;
                    }
                }

                MapCompanion.received = true; // to repulse event handlers

                switch (_case)
                {
                ///////////////////////// MODIFY TOPIC ///////////////////////
                case "modify":

                    // line 2: topic Guid
                    _t = SUtils.FindTopicByAttrGuid(_doc, _file.ReadLine());
                    if (_t == null)
                    {
                        System.Windows.Forms.MessageBox.Show("ReceiveChanges.CaseModify.TopicNotFound");
                        break;     //TODO
                    }

                    if (_what == "rollup")     // set or remove rollup
                    {
                        if (_t.HasAttributesNamespace[rollup])
                        {
                            _t.IsTaskRollupTopic = false;
                        }
                        else
                        {
                            _t.IsTaskRollupTopic = true;
                        }
                        break;
                    }

                    // line 3: topic text (for chat)
                    forchat = _file.ReadLine();

                    // line 4: timestamp (to attributes)
                    TransactionsWrapper.SetATTR(_t, SUtils.TMODIFIED, _file.ReadLine());

                    // line 5: offset
                    line = _file.ReadLine();
                    if (line != "")
                    {
                        if (_t.IsFloatingTopic || _t.IsMainTopic || _t.IsCalloutTopic)
                        {
                            int w = line.IndexOf(";");
                            float.TryParse(line.Substring(0, w), out x);
                            float.TryParse(line.Substring(w + 1), out y);
                        }
                    }

                    // line 6 to end: value
                    line = _file.ReadLine();
                    string _value = line;

                    while (line != null)
                    {
                        line = _file.ReadLine();
                        if (line != null)
                        {
                            _value = _value + Environment.NewLine + line;
                        }
                    }

                    if (_what != "offset")
                    {
                        PortraitSet.TopicPortrait(_t, _what, _value, mapfolderpath);
                    }

                    if (_t.IsFloatingTopic || _t.IsMainTopic || _t.IsCalloutTopic)
                    {
                        _t.SetOffset(x, y);     //restore topic position
                    }
                    break;
                ////////////////// MODIFY case ends ///////////////////

                /////////////////////////// ADD TOPIC ////////////////////////
                case "add":

                    Topic        _parent  = null;
                    Boundary     _bparent = null;
                    Relationship _rparent = null;

                    // line 2: parent guid
                    line = _file.ReadLine();
                    if (line != "")     // empty if floating topic
                    {
                        if (_what == "relcallout")
                        {
                            _rparent = SUtils.FindRelationshipByAttrGuid(_doc, line);
                        }
                        else if (_what == "bndcallout")
                        {
                            _bparent = SUtils.FindBoundaryByAttrGuid(_doc, line);
                        }
                        else
                        {
                            _parent = SUtils.FindTopicByAttrGuid(_doc, line);
                        }
                        if (_parent == null && _rparent == null && _bparent == null)
                        {
                            System.Windows.Forms.MessageBox.Show("ReceiveChanges.CaseAdd.ObjectNotFound");
                            break;     // TODO обнаружить ошибку - сообщить пользователю?
                        }
                    }

                    // line 3: topic text - for chat
                    forchat = _file.ReadLine();

                    // line 4: added topic guid : add topic
                    line = _file.ReadLine();
                    if (_what == "floating")
                    {
                        _t = _doc.AllFloatingTopics.Add();
                    }
                    else if (_what == "callout")
                    {
                        _t = _parent.AllCalloutTopics.Add();
                    }
                    else if (_what == "relcallout")
                    {
                        _t = _rparent.AllCalloutTopics.Add();
                    }
                    else if (_what == "bndcallout")
                    {
                        _t = _bparent.CreateSummaryTopic(MMUtils.GetString("callout.text"));
                    }
                    else
                    {
                        _t = _parent.AllSubTopics.Add();
                        _parent.AllSubTopics.Insert(_t, index); // EventDocumentClipboardPaste fires!
                        MapCompanion.paste = false;             // so, neutralize it...
                    }

                    TransactionsWrapper.SetATTR(_t, SUtils.OGUID, line);

                    // line 5: timestamp
                    line = _file.ReadLine();
                    TransactionsWrapper.SetATTR(_t, SUtils.TADDED, line);
                    TransactionsWrapper.SetATTR(_t, SUtils.TMODIFIED, line);

                    // line 6: offset
                    line = _file.ReadLine();
                    if (line != "")     // skip standart topics
                    {
                        int w = line.IndexOf(";");
                        float.TryParse(line.Substring(0, w), out x);
                        float.TryParse(line.Substring(w + 1), out y);
                    }
                    if (_t.IsFloatingTopic || _t.IsMainTopic || _t.IsCalloutTopic)
                    {
                        _t.SetOffset(x, y);
                    }

                    // line 7: skip if new topic added, otherwise (topic was pasted) replace whole topic xml
                    line = _file.ReadLine();     // <?xml version="1.0" standalone="no"?>
                    if (line != "newtopic")
                    {
                        _t.Xml = line + _file.ReadLine();     // topic XML
                        if (_t.IsFloatingTopic || _t.IsMainTopic || _t.IsCalloutTopic)
                        {
                            _t.SetOffset(x, y);
                        }
                    }

                    _parent = null; _rparent = null; _bparent = null;
                    break;
                ///////////////////// ADD TOPIC case ends ////////////////////////

                //////////// DELETE TOPIC OR RELATIONSHIP OR BOUNDARY ////////////
                case "delete":

                    // line 2: guid of object to delete
                    line = _file.ReadLine();

                    DocumentObject m_objtodelete = null;
                    m_objtodelete = SUtils.FindObjectByAttrGuid(_doc, line);

                    if (m_objtodelete == null)
                    {
                        System.Windows.Forms.MessageBox.Show("ReceiveChanges.CaseDelete.ObjectNotFound");
                        break;     // TODO map synchro failure, do something
                    }

                    m_objtodelete.Delete();
                    m_objtodelete = null;

                    // line 3: for chat: topic text or "relationship" or "boundary"
                    forchat = _file.ReadLine();

                    // line 4: for chat: name of user who deleted object
                    username = _file.ReadLine();

                    break;
                //////////////////// DELETE case ends ////////////////////

                //////////////////// RELATIONSHIP ADD, MODIFY //////////////////
                case "relationship":
                    Relationship rel = null;

                    // line 2: relationship guid
                    line = _file.ReadLine();
                    if (_what == "modify")
                    {
                        rel = SUtils.FindRelationshipByAttrGuid(_doc, line);
                        if (rel == null)
                        {
                            System.Windows.Forms.MessageBox.Show("ReceiveChanges.CaseRelationships.RelNotFound");
                            break;
                        }
                    }

                    // line 3: Guid of connection 1st object
                    string Guid1 = _file.ReadLine();
                    Topic  t1 = null, t2 = null;

                    Boundary b1 = SUtils.FindBoundaryByAttrGuid(_doc, Guid1);
                    if (b1 == null)
                    {
                        t1 = SUtils.FindTopicByAttrGuid(_doc, Guid1);
                    }

                    if (b1 == null && t1 == null)
                    {
                        System.Windows.Forms.MessageBox.Show("ReceiveChanges.CaseRelationships.Object1NotFound");
                        break;     // TODO
                    }

                    // line 4:
                    string Guid2 = _file.ReadLine();

                    Boundary b2 = SUtils.FindBoundaryByAttrGuid(_doc, Guid2);
                    if (b2 == null)
                    {
                        t2 = SUtils.FindTopicByAttrGuid(_doc, Guid2);
                    }

                    if (b2 == null && t2 == null)
                    {
                        System.Windows.Forms.MessageBox.Show("ReceiveChanges.CaseRelationships.Object2NotFound");
                        break;     // TODO
                    }

                    if (b1 == null)
                    {
                        if (b2 == null)
                        {
                            if (_what == "modify")
                            {
                                rel.SetConnection1ToTopic(t1);
                                rel.SetConnection2ToTopic(t2);
                            }
                            else
                            {
                                rel = t1.AllRelationships.AddToTopic(t2);
                                TransactionsWrapper.SetAttributes(rel, line);
                            }
                        }
                        else
                        if (_what == "modify")
                        {
                            rel.SetConnection1ToTopic(t1);
                            rel.SetConnection2ToBoundary(b2);
                        }
                        else
                        {
                            rel = t1.AllRelationships.AddToBoundary(b2);
                            TransactionsWrapper.SetAttributes(rel, line);
                        }
                    }
                    else
                    {
                        if (b2 == null)
                        {
                            if (_what == "modify")
                            {
                                rel.SetConnection1ToBoundary(b1);
                                rel.SetConnection2ToTopic(t2);
                            }
                            else
                            {
                                rel = b1.AllRelationships.AddToTopic(t2);
                                TransactionsWrapper.SetAttributes(rel, line);
                            }
                        }
                        else
                        if (_what == "modify")
                        {
                            rel.SetConnection1ToBoundary(b1);
                            rel.SetConnection2ToBoundary(b2);
                        }
                        else
                        {
                            rel = b1.AllRelationships.AddToBoundary(b2);
                            TransactionsWrapper.SetAttributes(rel, line);
                        }
                    }

                    // line 5-8: control points
                    if ((line = _file.ReadLine()) == null)     //new rel added, go out
                    {
                        break;
                    }
                    rel.SetControlPoints(
                        Convert.ToSingle(line),
                        Convert.ToSingle(_file.ReadLine()),
                        Convert.ToSingle(_file.ReadLine()),
                        Convert.ToSingle(_file.ReadLine())
                        );

                    // line 9-10:

                    rel.Shape1 = RelationshipShape(_file.ReadLine());
                    rel.Shape2 = RelationshipShape(_file.ReadLine());

                    // line 11:
                    rel.LineColor.Value = Convert.ToInt32(_file.ReadLine());

                    // line 12:
                    rel.LineDashStyle = LineDashStyle(_file.ReadLine());

                    // line 13:
                    rel.LineShape = LineShape(_file.ReadLine());

                    // line 14:
                    rel.LineWidth = Convert.ToSingle(_file.ReadLine());

                    // line 15:
                    rel.AutoRouting = Convert.ToBoolean(_file.ReadLine());

                    rel = null; t1 = null; t2 = null; b1 = null; b2 = null;

                    break;
                /////////////// RELATIONSHIP case ends //////////

                /////////////////// ADD OR MODIFY BOUNDARY ////////////////
                case "boundary":
                    // line 2: topic guid
                    _t = SUtils.FindTopicByAttrGuid(_doc, _file.ReadLine());
                    Boundary b = null;

                    // line 3: boundary shape or portrait
                    if (_what == "add")
                    {
                        b       = _t.CreateBoundary();
                        b.Shape = BoundaryShape(_file.ReadLine());
                    }
                    else     // modify boundary
                    {
                        b = _t.Boundary;
                        string[] bvalues = _file.ReadLine().Split(';');

                        b.Shape           = MMEnums.BoundaryShape(bvalues[0]);
                        b.FillColor.Value = Convert.ToInt32(bvalues[1]);
                        b.LineColor.Value = Convert.ToInt32(bvalues[2]);
                        b.LineDashStyle   = MMEnums.LineDashStyle(bvalues[3]);
                        b.LineWidth       = Convert.ToInt32(bvalues[4]);
                    }

                    // line 4: boundary guid
                    TransactionsWrapper.SetAttributes(b, _file.ReadLine());

                    b = null;
                    break;
                    ////////////// BOUNDARY case ends ////////////////
                }

                MapCompanion.received = false;
                _file.Close();
                _t = null; // TODO dooble-check! very important!!
                //File.Delete(file);
            } // foreach files

            //MMBase.SendMessage("received"); // TODO nedeed?
        }
示例#2
0
        public static void TopicPortrait(Topic t, string what, string _value, string mapFolderPath)
        {
            int    newline = _value.IndexOf(Environment.NewLine);
            string rootfolder = mapFolderPath;
            string firstline = "", nextline = "";

            if (newline == -1)
            {
                firstline = _value;
            }
            else
            {
                firstline = _value.Substring(0, _value.IndexOf("\r\n"));
                nextline  = _value.Substring(_value.IndexOf("\r\n") + 2);
            }
///TEXT
            if (what == "text")
            {
                t.Text = _value;
            }
            else if (what == "rtf")
            {
                t.Title.TextRTF = _value;
            }
            else if (what == "font")
            {
                string[] _fontvalues = firstline.Split(';');

                t.Text = nextline;

                if (t.TextColor.Value.ToString() != _fontvalues[0])
                {
                    t.TextColor.Value = Convert.ToInt32(_fontvalues[0]);
                }
                if (t.Font.Bold.ToString() != _fontvalues[1])
                {
                    t.Font.Bold = Convert.ToBoolean(_fontvalues[1]);
                }
                if (t.Font.Italic.ToString() != _fontvalues[2])
                {
                    t.Font.Italic = Convert.ToBoolean(_fontvalues[2]);
                }
                if (t.Font.Strikethrough.ToString() != _fontvalues[3])
                {
                    t.Font.Strikethrough = Convert.ToBoolean(_fontvalues[3]);
                }
                if (t.Font.Underline.ToString() != _fontvalues[4])
                {
                    t.Font.Underline = Convert.ToBoolean(_fontvalues[4]);
                }
                if (t.Font.Size.ToString() != _fontvalues[5])
                {
                    t.Font.Size = Convert.ToSingle(_fontvalues[5]);
                }
                if (t.Font.Name != _fontvalues[6])
                {
                    t.Font.Name = _fontvalues[6];
                }
            }
///TASK
            else if (what == "task")
            {
                if (firstline == "empty")
                {
                    if (t.Task.HasEffort)
                    {
                        t.Task.SetEffort(MmDurationUnit.mmDurationUnitDay, 0);
                    }
                    t.Task.Complete  = -1;
                    t.Task.Priority  = MmTaskPriority.mmTaskPriorityNone;
                    t.Task.Resources = "";
                    t.Task.StartDate = MMUtils.NULLDATE;
                    t.Task.DueDate   = MMUtils.NULLDATE;
                    t.Task.Milestone = false;
                }
                else
                {
                    string[] _taskvalues = firstline.Split(';');
                    t.Task.Complete     = Convert.ToInt32(_taskvalues[0]);
                    t.Task.Priority     = MMEnums.Priority(_taskvalues[1]);
                    t.Task.Resources    = _taskvalues[2];
                    t.Task.StartDate    = Convert.ToDateTime(_taskvalues[3]);
                    t.Task.DueDate      = Convert.ToDateTime(_taskvalues[4]);
                    t.Task.DurationUnit = MMEnums.DurationUnit(_taskvalues[5]);
                    t.Task.Milestone    = Convert.ToBoolean(_taskvalues[6]);
                    if (_taskvalues[7] == "0")
                    {
                        if (t.Task.HasEffort)
                        {
                            t.Task.SetEffort(MmDurationUnit.mmDurationUnitDay, 0);
                        }
                    }
                    else
                    {
                        t.Task.EffortUnit = MMEnums.DurationUnit(_taskvalues[7]);
                        t.Task.SetEffort(t.Task.EffortUnit, Convert.ToInt32(_taskvalues[8]));
                    }
                }
            }
///NOTES
            else if (what == "notes")
            {
                string _notesText = firstline;

                if (_notesText == "empty")
                {
                    t.Notes.Text = "";
                }
                else
                {
                    try
                    {
                        t.Notes.TextXHTML = _notesText;
                        t.Notes.Commit();
                    }
                    catch (Exception e)
                    {
                        System.Windows.Forms.MessageBox.Show("Exception: " + e.Message, "Receiving Notes");
                    }
                }
            }
///LINKS
            else if (what == "link")
            {
                foreach (Hyperlink _h in t.Hyperlinks)
                {
                    t.Hyperlinks.Remove(1);
                }

                if (firstline == "empty")
                {
                    return;
                }

                string[] _links;

                if (nextline == "")
                {
                    _links = new string[] { firstline };
                }
                else
                {
                    firstline = firstline + "\r\n" + nextline;
                    nextline  = firstline.Replace("\r", "");
                    _links    = nextline.Split('\n');
                }

                foreach (string _link in _links)
                {
                    string _what  = _link.Substring(0, firstline.IndexOf(":"));
                    string _hlink = _link.Substring(firstline.IndexOf(":") + 1);

                    if (_what == "web" || _what == "file")
                    {
                        t.Hyperlinks.AddHyperlink(_hlink);
                    }
                    else
                    {
                        if (_what == "localtopic")
                        {
                            string _guid = SUtils.FindTopicByAttrGuid(t.Document, _hlink).Guid;
                            t.Hyperlinks.AddHyperlinkToTopicByGuid(_guid);
                        }

                        if (_what == "remotetopic")
                        {
                            string _address = _hlink.Substring(0, _hlink.LastIndexOf(":"));
                            string _guid    = _hlink.Substring(_hlink.LastIndexOf(":") + 1);
                            t.Hyperlinks.AddHyperlinkToTopicByGuid(_guid, _address);
                        }
                    }
                }
            }
///NUMBERING
            else if (what == "numbering")
            {
                string ss        = t.Text;
                string numbering = SUtils.numberinguri;
                //System.Windows.Forms.Clipboard.SetText(t.Xml);
                if (firstline == "empty")
                {
                    t.get_Attributes(numbering).DeleteAll();
                }
                else
                {
                    string   rr      = "";
                    string[] nvalues = firstline.Split(';');
                    if (t.ContainsAttributesNamespace(numbering))
                    {
                        rr = t.get_Attributes(numbering).GetAttributeValue("Depth");
                    }
                    t.get_Attributes(numbering).SetAttributeValue("Depth", nvalues[0].ToString());
                    t.get_Attributes(numbering).SetAttributeValue("Level1Text", nvalues[1].ToString());
                    t.get_Attributes(numbering).SetAttributeValue("Level2Text", nvalues[2].ToString());
                    t.get_Attributes(numbering).SetAttributeValue("Level3Text", nvalues[3].ToString());
                    t.get_Attributes(numbering).SetAttributeValue("Level4Text", nvalues[4].ToString());
                    t.get_Attributes(numbering).SetAttributeValue("Level5Text", nvalues[5].ToString());
                    t.get_Attributes(numbering).SetAttributeValue("Numbering", nvalues[6].ToString());
                    t.get_Attributes(numbering).SetAttributeValue("Separators", nvalues[7].ToString());
                    t.get_Attributes(numbering).SetAttributeValue("Repeat", nvalues[8].ToString());
                }
            }
///IMAGE
            else if (what == "oneimage")
            {
                if (t.HasImage)
                {
                    t.Image.Delete();
                }

                if (firstline != "empty")
                {
                    string[] imgvalues = firstline.Split(';');
                    string   _filename = imgvalues[0];
                    string   _path     = rootfolder + _filename;

                    if (t.HasImage)
                    {
                        t.Image.Load(_path);
                    }
                    else
                    {
                        t.CreateImage(_path);
                    }

                    t.Image.Height = Convert.ToSingle(imgvalues[1]);
                    t.Image.Width  = Convert.ToSingle(imgvalues[2]);
                }
            }
//ICONS
            else if (what == "icons")
            {
                //renove all user icons
                if (t.UserIcons.Count > 0)
                {
                    t.UserIcons.RemoveAll();
                }

                if (firstline == "emptyall")
                {
                    t.Task.Complete = -1;
                    t.Task.Priority = MmTaskPriority.mmTaskPriorityNone;
                }

                if (firstline == "empty" || firstline == "emptyall")
                {
                    return;
                }

                AddIcon(t, firstline, mapFolderPath);

                if (nextline != "")
                {
                    nextline = nextline.Replace("\r", "");
                    string[] _usericons = nextline.Split('\n');

                    foreach (string _iconname in _usericons)
                    {
                        AddIcon(t, _iconname, mapFolderPath);
                    }

                    _usericons = null;
                }
            }

            else if (what == "color")
            {
                string[] _colorvalues = firstline.Split(';');

                if (_colorvalues[0] == "isautomatic")
                {
                    t.FillColor.SetAutomatic();
                }
                else
                {
                    t.FillColor.Value = Convert.ToInt32(_colorvalues[0]);
                }

                if (_colorvalues[1] == "isautomatic")
                {
                    t.LineColor.SetAutomatic();
                }
                else
                {
                    t.LineColor.Value = Convert.ToInt32(_colorvalues[1]);
                }
            }

            else if (what == "subtopicshape")
            {
                if (firstline == "isautomatic")
                {
                    t.Shape.SetAutomatic();
                }
                else
                {
                    string[] _shapevalues = firstline.Split(';');

                    MmStandardTopicShape x = StandardTopicShape(_shapevalues[0]);
                    MmFloatingTopicShape y = FloatingTopicShape(_shapevalues[1]);
                    MmCalloutTopicShape  z = CalloutTopicShape(_shapevalues[1]);

                    t.Shape.SetTypes(x, y, z);
                }
            }
        }
示例#3
0
        public static string TopicPortrait(Topic t, ref string what, string extra, string mapFolderPath)
        {
            if (what == "numbering" || what == "notesdata" || what == "businessdata")
            {
                return("queue");
            }

            string _return    = "";
            string s          = "";
            string rootfolder = mapFolderPath + "share\\";

//TEXT
            if (what == "text")
            {
                xRoot(t.Xml);
                XmlNode _nodeFont      = m_root.SelectSingleNode("ap:Text/ap:Font", NSManager);
                XmlNode _nodeFontRange = m_root.SelectSingleNode("ap:Text/ap:FontRange", NSManager);

                if (_nodeFontRange != null && _nodeFontRange.Attributes.Count > 0) // rtf
                {
                    what    = "rtf";
                    _return = t.Title.TextRTF;
                }
                else if (_nodeFont != null && _nodeFont.Attributes.Count > 0) // font
                {
                    s       = MMEnums.GetFont(t);
                    what    = "font";
                    _return = s + "\r\n" + t.Text;
                }
                else // plain text
                {
                    _return = t.Text;
                }

                _nodeFont = null; _nodeFontRange = null; m_manager = null; m_root = null; xDoc = null;
                return(_return);
            }
//TASK
            if (what == "task")
            {
                if (t.Task.IsEmpty)
                {
                    return("empty");
                }

                s = t.Task.Complete.ToString() + ";" +
                    t.Task.Priority.ToString() + ";" +
                    t.Task.Resources + ";" +
                    t.Task.StartDate.ToString() + ";" +
                    t.Task.DueDate.ToString() + ";" +
                    t.Task.DurationUnit.ToString() + ";" +
                    t.Task.Milestone.ToString() + ";";

                if (!t.Task.HasEffort)
                {
                    s = s + "0;0";
                }
                else
                {
                    s = s + t.Task.EffortUnit.ToString() + ";" + t.Task.GetEffort(t.Task.EffortUnit).ToString();
                }

                return(s);
            }
//NOTES
            if (what == "notesxhtmldata")
            {
                what = "notes";

                if (t.Notes.IsEmpty)
                {
                    return("empty");
                }

                string cleanXML   = MMUtils.getCleanTopicXML(t.Xml);
                int    _start     = cleanXML.IndexOf("<html xmlns");
                int    _finish    = cleanXML.IndexOf("</ap:NotesXhtmlData>");
                string _noteshtml = cleanXML.Substring(_start, _finish - _start);
                string _head      = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"          " +
                                    "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
                _noteshtml = _head + _noteshtml;

                return(_noteshtml);
            }
//LINKS
            if (what == "hyperlink" || what == "indexedhyperlink")
            {
                what = "link";

                if (!t.HasHyperlink)
                {
                    return("empty");
                }

                foreach (Hyperlink _h in t.Hyperlinks)
                {
                    string _address = _h.Address;
                    string _guid    = _h.TopicLabelGuid;

                    if (_guid == "")                            //ссылка на файл или web-страницу
                    {
                        if (_address.Substring(0, 4) == "http") //на web-страницу
                        {
                            s = s + "web:" + _address + "\r\n";
                        }
                        else //TODO local file
                        {
                            s = s + "file:" + _address + "\r\n";

                            //int a = _address.LastIndexOf("\\") + 1; // filename only
                            //s = s + "file:" + _address.Substring(a) + "\r\n";
                            // TODO File.Copy(_address, rootfolder + _address.Substring(a)); // copy to share folder in Place

                            if (_address.Substring(_address.Length - 5) == ".mmap") //ссылка на карту
                            {
                                // TODO

                                //Document _doc = MMUtils.MindManager.AllDocuments.Open(_address, "", false);

                                //if (!_doc.ContainsAttributesNamespace(SYNERGYNAMESPACE)) //publish this map if it is not published
                                //{
                                //    PublishMap(
                                //        _doc, _doc.Guid,
                                //        GetRegistry("", "CurrentUserName"),
                                //        GetRegistry("", "CurrentUserEmail"),
                                //        false  // TODO single map or project!
                                //        );

                                //    _doc.SaveAs(rootfolder + _doc.Name);
                                //    _h.Address = _doc.Name;

                                //    if (!_doc.Window.IsVisible)
                                //        _doc.Close();
                                //}
                            }
                        }
                    }
                    else //ссылка на топик
                    {
                        if (_address == "") //в этой же карте
                        {
                            Topic _t = MMUtils.FindTopicByGuid(MMUtils.ActiveDocument, _guid);
                            s  = s + "localtopic:" + _t.get_Attributes(SUtils.SYNERGYNAMESPACE).GetAttributeValue(SUtils.OGUID) + "\r\n";
                            _t = null;
                        }
                        else //в другой карте
                        {
                            s = s + "remotetopic:" + _address + ":" + _guid + "\r\n"; //TODO remote topic OGUID?
                        }
                    }
                }

                return(s.Remove(s.LastIndexOf("\r\n"), 2));
            }
//NUMBERING
            if (what == "numbering")
            {
                if (!t.HasAttributesNamespace[SUtils.numberinguri])
                {
                    return("empty");
                }
                return(MMEnums.GetNumbering(t));
            }
//IMAGE
            if (what == "oneimage")
            {
                if (!t.HasImage)
                {
                    return("empty");
                }

                string _filename = SUtils.modtime + ".png";
                string _path     = rootfolder + _filename;
                t.Image.Save(_path, MmGraphicType.mmGraphicTypePng);
                return(_filename + ";" + t.Image.Height.ToString() + ";" + t.Image.Width.ToString());
            }

//ICONS
            if (what == "icons" || what == "customiconimagedata")
            {
                what = "icons";

                if (t.UserIcons.Count == 0)
                {
                    if (t.Task.Complete == -1 && t.Task.Priority == MmTaskPriority.mmTaskPriorityNone)
                    {
                        return("emptyall");
                    }
                    return("empty");
                }

                foreach (Icon _ico in t.UserIcons)
                {
                    if (_ico.Type == MmIconType.mmIconTypeAutomaticTaskComplete ||
                        _ico.Type == MmIconType.mmIconTypeAutomaticTaskPriority)
                    {
                        continue;
                    }
                    if (_ico.Type == MmIconType.mmIconTypeStock)
                    {
                        s = s + _ico.StockIcon.ToString() + "\r\n";
                    }
                    if (_ico.Type == MmIconType.mmIconTypeCustom)
                    {
                        string _filename = SUtils.modtime + "&" + SUtils.currentUserName + ".ico";
                        string _path     = rootfolder + _filename;

                        _ico.Save(_path, MmGraphicType.mmGraphicTypeGif);
                        s = s + _filename + "\r\n";
                    }
                }

                return(s.Remove(s.LastIndexOf("\r\n"), 2));
            }

            if (what == "color")
            {
                if (t.FillColor.IsAutomatic)
                {
                    s = "isautomatic;";
                }
                else
                {
                    s = t.FillColor.Value.ToString() + ";";
                }

                if (t.LineColor.IsAutomatic)
                {
                    return(s + "isautomatic");
                }
                else
                {
                    return(s + t.LineColor.Value.ToString());
                }
            }

            if (what == "subtopicshape")
            {
                t.Shape.GetAutomatic(out bool xx, out bool yy, out bool zz);
                if (xx && yy && zz)
                {
                    return("isautomatic");
                }

                t.Shape.GetTypes(out MmStandardTopicShape x, out MmFloatingTopicShape y, out MmCalloutTopicShape z);
                return(x.ToString() + ";" + y.ToString() + ";" + z.ToString());
            }

            if (what == "offset")
            {
                return("offset");
            }

            return("queue");
        }