示例#1
0
        string BuildFranceMap(string _name)
        {
            if (TaxonUtils.Locations == null || _Current == null)
            {
                return("");
            }
            TaxonTreeNode original = _Current.GetOriginal();

            if (original == null || !TaxonUtils.Locations.LocationByTaxon.TryGetValue(original, out string Ids))
            {
                return("");
            }
            France.Map map = new France.Map();
            foreach (string id in Ids.Split("|".ToCharArray()))
            {
                map.SetTheme(id, "on");
            }

            _MapFileCount = (_MapFileCount + 1) % 100;
            string file = "comment_france_map" + _MapFileCount.ToString("D3") + ".jpg";
            string path = Path.Combine(TaxonUtils.GetTempPath(), file);

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            map.CreateTexture(path, 0.6f);

            int count = 0;

            while (!File.Exists(path) && ++count < 4)
            {
                System.Threading.Thread.Sleep(500);
            }

            string result = "";

            result += "<p><img src=\"" + path + "\" xmlns = \"\" /></p>";
            return(result);
        }
示例#2
0
        //---------------------------------------------------------------------------------
        void BuildHtml()
        {
            HtmlDocument  = "<html>\n";
            HtmlDocument += TaxonComments.Manager.HtmlHeader;

            HtmlDocument += "  <body>\n";

            if (_HtmlDivs.Count == 0)
            {
                HtmlDocument += "    <h2>Loading ...</h2>\n";
            }
            else
            {
                int index = HtmlDocument.LastIndexOf("</script>");
                HtmlDocument = HtmlDocument.Insert(index, _HtmlDivs.ShowAllFunction());
                HtmlDocument = HtmlDocument.Insert(index, _HtmlDivs.HideAllFunction());

                bool first = true;
                for (int i = 0; i < _HtmlDivs.Count; i++)
                {
                    HtmlDiv div = _HtmlDivs[i];

                    string calltitle = " ondblclick =\"callcsharp('" + div.Name + "', " + i.ToString() + ")\"";
                    if (div.Content == null)
                    {
                        if ((first && AddTitleForFirstEmpty) || AddTitleForEmpty || (first && AddFranceMap))
                        {
                            HtmlDocument += "    <h2 class=\"taxonTitle\"" + calltitle + ">\n";
                            HtmlDocument += "      " + div.DisplayName + "\n";
                            HtmlDocument += "    </h2>\n";
                            if (AddFranceMap)
                            {
                                HtmlDocument += BuildFranceMap(div.Name);
                            }
                        }
                    }
                    else
                    {
                        HtmlDocument += "    <h2 class=\"taxonTitle\"" + calltitle + ">\n";
                        HtmlDocument += "      <button id=\"" + div.Name + "Hide\" onClick=\"hide('" + div.Name + "')\" class=\"buttonCollapse\" >-</button>\n";
                        HtmlDocument += "      <button id=\"" + div.Name + "Show\" onClick=\"show('" + div.Name + "')\" class=\"buttonExpand\" >+</button>\n";
                        HtmlDocument += "      " + div.DisplayName + "\n";
                        HtmlDocument += "    </h2>\n";

                        if (first && AddFranceMap)
                        {
                            HtmlDocument += BuildFranceMap(div.Name);
                        }

                        HtmlDocument += "    <div id=\"" + div.Name + "\" class=\"taxon\" >\n";
                        HtmlDocument += "\n\n" + div.Content + "\n\n\n";
                        HtmlDocument += "    </div>\n";
                    }
                    first = false;
                }
            }
            HtmlDocument += "  </body>\n";
            HtmlDocument += "</html>";

            HasCollapsibleDivs = _HtmlDivs.CanCollapseExpand();

            string path = Path.Combine(TaxonUtils.GetTempPath(), "HtmlDocument.html");

            VinceToolbox.fileFunctions.saveTextFile(path, HtmlDocument);
        }