Пример #1
0
        public static void Diagnostics(Word.Document doc, string when)
        {
            Debug.WriteLine("----- Diagnostics " + when + " -----");

            int counter = 0;

            // List all of our ContentControl(s)
            foreach (Word.ContentControl ccc in doc.ContentControls)
            {
                if (ccc.Title.Equals(Constants.ContentControlTitle))
                {
                    counter++;
                    Debug.WriteLine("ContentControl: " + ccc.ID);
                    Debug.WriteLine("   Range.Start: " + ccc.Range.Start);
                    Debug.WriteLine("           Tag: " + ccc?.Tag);
                }
            }

            Debug.WriteLine("  Found " + counter + " ContentControl(s)");

            // List all of our CustomXMLPart(s)
            counter = 0;
            foreach (CustomXMLPart x in doc.CustomXMLParts.SelectByNamespace("http://www.xml-cml.org/schema"))
            {
                counter++;
                Debug.WriteLine("CustomXMLPart: " + x.Id);
                string molId = CustomXmlPartHelper.GetCmlId(x);
                Debug.WriteLine("   MoleculeId: " + molId);
            }

            Debug.WriteLine("  Found " + counter + " CustomXMLPart(s)");
        }
Пример #2
0
        public static void RefreshAllStructures(Word.Document doc)
        {
            string module = $"{Product}.{Class}.{MethodBase.GetCurrentMethod().Name}()";

            if (Globals.Chem4WordV3.SystemOptions == null)
            {
                Globals.Chem4WordV3.LoadOptions();
            }

            IChem4WordRenderer renderer =
                Globals.Chem4WordV3.GetRendererPlugIn(
                    Globals.Chem4WordV3.SystemOptions.SelectedRendererPlugIn);

            if (renderer != null)
            {
                foreach (CustomXMLPart xmlPart in doc.CustomXMLParts)
                {
                    var cml = xmlPart.XML;

                    var          cxmlId = CustomXmlPartHelper.GetCmlId(xmlPart);
                    CMLConverter cc     = new CMLConverter();
                    var          model  = cc.Import(cml);

                    renderer.Properties = new Dictionary <string, string>();
                    renderer.Properties.Add("Guid", cxmlId);
                    renderer.Cml = cml;

                    string tempfileName = renderer.Render();
                    if (File.Exists(tempfileName))
                    {
                        UpdateThisStructure(doc, model, cxmlId, tempfileName);
                    }
                }
            }
        }