public void AnnotateResult(ReturnType type) { if (type == ReturnType.SmartTag) { string tag = NAMESPACE + "#soylent" + DateTime.Now.Ticks; SmartTag resultTag = Globals.Factory.CreateSmartTag(tag, "Soylent Results: " + text.Text.Substring(0, 10) + "..."); Regex pattern = new Regex(text.Text.Trim().Replace(" ", "\\s"), RegexOptions.IgnorePatternWhitespace); resultTag.Expressions.Add(pattern); List <VSTO.Action> actions = new List <Microsoft.Office.Tools.Word.Action>(); foreach (string result in results) { VSTO.Action action = Globals.Factory.CreateAction(result); action.Click += new ActionClickEventHandler(replaceText); actions.Add(action); } resultTag.Actions = actions.ToArray(); Globals.Soylent.VstoSmartTags.Add(resultTag); } else if (type == ReturnType.Comment) { foreach (string result in results) { object commentText = result; Globals.Soylent.jobToDoc[this.job].Comments.Add(text, ref commentText); foreach (Microsoft.Office.Interop.Word.Comment c in Globals.Soylent.jobToDoc[this.job].Comments) { c.Author = "Turker"; c.Initial = "Turker"; } } } }
public TemperatureSmartTag() { this.smartTagDemo = Globals.Factory.CreateSmartTag( "http://www.microsoft.com#TemperatureSmartTag", "Temperature", this); // Add a regular expression for the Temperature SmartTag recognition. smartTagDemo.Expressions.Add(new Regex( "\\s*(?'number'[-+]?[0-9]+)°?\\s?(?'temperature'(F|C|f|c))\\s*")); // Create an instance of the temperature action. temperatureAction = Globals.Factory.CreateAction("Convert"); // Add the action to the Actions array for the smart tag. smartTagDemo.Actions = new Word.Action[] { temperatureAction }; temperatureAction.BeforeCaptionShow += TemperatureAction_BeforeCaptionShow; temperatureAction.Click += TemperatureAction_Click; }
public void AnnotateResult() { Word.Range text = range; foreach (CrowdproofPatch pp in patches) { string tag = HumanMacroData.NAMESPACE + "#soylent" + DateTime.Now.Ticks; SmartTag resultTag = Globals.Factory.CreateSmartTag(tag, pp.reasons[0]); Regex pattern = new Regex(pp.range.Text.Trim().Replace(" ", "\\s"), RegexOptions.IgnorePatternWhitespace); resultTag.Expressions.Add(pattern); List <VSTO.Action> actions = new List <Microsoft.Office.Tools.Word.Action>(); foreach (string result in pp.replacements) { VSTO.Action action = Globals.Factory.CreateAction(result); action.Click += new ActionClickEventHandler(HumanMacroData.replaceText); actions.Add(action); } /* this doesn't work in Word 2010 */ if (WordVersion.currentVersion < WordVersion.OFFICE_2010) { foreach (string reason in pp.reasons) { VSTO.Action action = Globals.Factory.CreateAction("Error Descriptions///" + reason); action.Click += new ActionClickEventHandler(HumanMacroData.replaceText); actions.Add(action); } } resultTag.Actions = actions.ToArray(); Globals.Soylent.VstoSmartTags.Add(resultTag); if (WordVersion.currentVersion >= WordVersion.OFFICE_2010) { pp.range.Underline = Word.WdUnderline.wdUnderlineWavy; pp.range.Font.UnderlineColor = Word.WdColor.wdColorLavender; } } }
public WB4SmartTag() : base("http://www.semanticwb.org/smarttags#demo", "Smart tags for SWB4") { //Terms.Add("Empresa"); Microsoft.Office.Tools.Word.Action action1 = new Microsoft.Office.Tools.Word.Action("Objetos encontrados"); action1.Click += new ActionClickEventHandler(showInfo_click); Actions = new Microsoft.Office.Tools.Word.Action[] { action1 }; List <String> values = new List <string>(); ResourceManager rs = new ResourceManager(typeof(Resource)); String data = (String)rs.GetObject("nonrelevant_es"); StringReader sr = new StringReader(data); String word = sr.ReadLine(); while (word != null) { word = word.Trim(); if (!word.StartsWith("#")) { values.Add(word); } word = sr.ReadLine(); } norelevant = values.ToArray(); }