using System.Diagnostics; using System.IO; using System; using System.Windows.Forms; using Eplan.EplApi.ApplicationFramework; using Eplan.EplApi.Base; using Eplan.EplApi.Gui; using Eplan.EplApi.Scripting; using System.Drawing; //This script is provided free of charge by CD-S (Competence Development and Solutions e.U). class CDS_ClipBoard_Extension { string pathImages = PathMap.SubstitutePath("$(IMG)"); [DeclareRegister] public void Register() { MessageBox.Show("CD-S hopes you enjoy inserting images with our EPLAN script.\r\n\r\nIf you need assistance with standardization and automation, please visit my homepage.\r\n\r\nwww.cd-s.at\r\n\r\nBest regards,\r\n\r\nChris"); } [DeclareUnregister] public void UnRegister() { MessageBox.Show("Insert Image from ClipBoard Script removed"); } [DeclareAction("ClipboardImage")] public void ConClipboardImage() { string PictureName = pathImages + @"\xXx_" //Please Enter your Company Name or Letters instead of the xXx on the Left + DateTime.Now.ToString("yyyyMMdd") + "_" + DateTime.Now.ToString("HHmm") + ".png"; if (Clipboard.ContainsImage()) { Image img = Clipboard.GetImage(); img.Save(PictureName, System.Drawing.Imaging.ImageFormat.Png); ActionCallingContext oACC = new ActionCallingContext(); oACC.AddParameter("Name", "XGedIaInsertImage"); oACC.AddParameter("Filename", PictureName); CommandLineInterpreter oCLI = new CommandLineInterpreter(); oCLI.Execute("XGedStartInteractionAction2D", oACC); } else { MessageBox.Show("There is no image in your clipboard yet!!"); } } [DeclareAction("IMGFolder")] public void OpenIMGFolder() { string sImg = PathMap.SubstitutePath("$(IMG)"); if (Directory.Exists(sImg)) { Process.Start("explorer.exe", sImg); } else { MessageBox.Show("There is no image directory in the project."); } } [DeclareMenu] public void Function() { Eplan.EplApi.Gui.ContextMenu oCTXMnu = new Eplan.EplApi.Gui.ContextMenu(); ContextMenuLocation oCtxLoc = new ContextMenuLocation(); oCtxLoc.DialogName = "Editor"; oCtxLoc.ContextMenuName = "Ged"; oCTXMnu.AddMenuItem(oCtxLoc, "Insert Image from Clipboard" , "ClipboardImage", false, false); oCtxLoc.DialogName = "PmPageObjectTreeDialog"; oCtxLoc.ContextMenuName = "1007"; oCTXMnu.AddMenuItem(oCtxLoc, "Open IMG Directory", "IMGFolder", false, false); } }