public override void DropImage(string imageFile, bool isSvg) { Visio.Page vPag = vApp.ActivePage; double magicScale = isSvg ? 1 : 96 / (double)LatexData.DPI; if (vPag != null) { var shpNew = vPag.Import(imageFile); if (selectedShape != null) { shpNew.CellsU["PinX"].FormulaU = selectedShape.CellsU["PinX"].FormulaU; shpNew.CellsU["PinY"].FormulaU = selectedShape.CellsU["PinY"].FormulaU; } //Set size string oldWidth_s = shpNew.CellsU["Width"].FormulaU; double oldWidth_d = double.Parse(oldWidth_s.Replace(" mm", ""), CultureInfo.InvariantCulture); shpNew.CellsU["Width"].FormulaU = String.Format("{0:f} mm", oldWidth_d * magicScale * LatexData.fontSize / 10); string oldHeight_s = shpNew.CellsU["Height"].FormulaU; double oldHeight_d = double.Parse(oldHeight_s.Replace(" mm", ""), CultureInfo.InvariantCulture); shpNew.CellsU["Height"].FormulaU = String.Format("{0:f} mm", oldHeight_d * magicScale * LatexData.fontSize / 10); shpNew.AddNamedRow((short)Visio.VisSectionIndices.visSectionAction, "RightClick", 0); shpNew.CellsU["Actions.RightClick"].FormulaU = "\"Edit LaTeX image\""; shpNew.CellsU["Actions.RightClick.Action"].FormulaU = "RUNADDONWARGS(\"QueueMarkerEvent\", \"/app=VisioTex\")"; using (var ms = new MemoryStream()) { var ser = new DataContractJsonSerializer(typeof(LatexData)); ser.WriteObject(ms, LatexData); byte[] json = ms.ToArray(); shpNew.Data1 = Encoding.UTF8.GetString(json, 0, json.Length); } selectedShape?.Delete(); } }