Exemplo n.º 1
0
        private void button5_Click(object sender, RibbonControlEventArgs e)
        {
            //fake p = new fake();

            //HITData p = new HITData();

            //ShortnData p = ShortnData.getCannedData();

            /*
             * TurKitSocKit.TurKitFindFixVerify tks = new TurKitSocKit.TurKitFindFixVerify();
             * //TurKitSocKit.TurKitFindFixVerifyOption tks = new TurKitSocKit.TurKitFindFixVerifyOption();
             * tks.job = 3;
             * tks.paragraph = 2;
             * tks.patches = new List<TurKitSocKit.TurKitFindFixVerifyPatch>();
             */
            //Sample tks = new Sample();

            //tks.list.Add(2);
            //tks.list.Add(3);

            HumanMacroData tks = new HumanMacroData();


            XmlSerializer x  = new XmlSerializer(tks.GetType());
            StringWriter  sw = new StringWriter();

            x.Serialize(sw, tks);
            string a = sw.ToString();

            Debug.Write(a);

            /*
             * CrowdproofData p = CrowdproofData.getCannedData();
             *
             * XmlSerializer x = new XmlSerializer(p.GetType());
             * StringWriter sw = new StringWriter();
             * x.Serialize(sw, p);
             * string a = sw.ToString();
             * Debug.Write(a);
             *
             * Microsoft.Office.Core.CustomXMLPart employeeXMLPart = Globals.Soylent.Application.ActiveDocument.CustomXMLParts.Add(a);
             */

            /*
             * string s = "";
             *
             * foreach (Microsoft.Office.Core.CustomXMLPart cus in Globals.Soylent.Application.ActiveDocument.CustomXMLParts)
             * {
             *  s = cus.XML;
             *
             * }
             *
             *
             * XmlSerializer y = new XmlSerializer(p.GetType());
             *
             * //StringReader sr = new StringReader(a);
             * StringReader sr = new StringReader(s);
             *
             * XmlReader z = XmlReader.Create(sr);
             * object obj = y.Deserialize(z);
             *
             * CrowdproofData q = obj as CrowdproofData;
             *
             * Word.Bookmark b = Globals.Soylent.Application.ActiveDocument.Bookmarks["Soylent" + q.job];
             * q.range = b.Range;
             */
        }
Exemplo n.º 2
0
        void Application_DocumentBeforeSave(Word.Document Doc, ref bool SaveAsUI, ref bool Cancel)
        {
            foreach (Microsoft.Office.Core.CustomXMLPart xmlPart in Globals.Soylent.Application.ActiveDocument.CustomXMLParts)
            {
                if (!(xmlPart.BuiltIn))
                {
                    xmlPart.Delete();
                }
            }
            foreach (object obj in soylentMap[Doc].sidebar.jobs.Children)
            {
                if (!(obj is StackPanel))
                {
                    continue;
                }
                StackPanel elem = obj as StackPanel;
                foreach (object elem2 in elem.Children)
                {
                    HITData raw;
                    if (elem2 is HITView)
                    {
                        raw = (elem2 as HITView).data;
                    }
                    else
                    {
                        raw = (elem2 as HITViewStub).data;
                    }

                    if (raw is ShortnData)
                    {
                        ShortnData hit = raw as ShortnData;

                        XmlSerializer x  = new XmlSerializer(hit.GetType());
                        StringWriter  sw = new StringWriter();
                        x.Serialize(sw, hit);
                        string xml = sw.ToString();
                        Microsoft.Office.Core.CustomXMLPart xmlPart = Globals.Soylent.Application.ActiveDocument.CustomXMLParts.Add(xml);
                    }
                    else if (raw is CrowdproofData)
                    {
                        CrowdproofData hit = raw as CrowdproofData;

                        XmlSerializer x  = new XmlSerializer(hit.GetType());
                        StringWriter  sw = new StringWriter();
                        x.Serialize(sw, hit);
                        string xml = sw.ToString();
                        Microsoft.Office.Core.CustomXMLPart xmlPart = Globals.Soylent.Application.ActiveDocument.CustomXMLParts.Add(xml);
                    }
                    else if (raw is HumanMacroData)
                    {
                        HumanMacroData hit = raw as HumanMacroData;

                        XmlSerializer x  = new XmlSerializer(hit.GetType());
                        StringWriter  sw = new StringWriter();
                        x.Serialize(sw, hit);
                        string xml = sw.ToString();
                        Microsoft.Office.Core.CustomXMLPart xmlPart = Globals.Soylent.Application.ActiveDocument.CustomXMLParts.Add(xml);
                    }
                }
            }
        }