马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
[C#] 纯文本查看 复制代码
//
[CommandMethod("GetActiveDocumentScreenShot")]
public void GetActiveDocumentScreenShot()
{
dynamic acad = Application.AcadApplication;
Document doc = Application.DocumentManager.MdiActiveDocument; //当前活动文档
acad.ZoomExtents(); //窗口缩放
Editor ed = doc.Editor; //当前活动文档的命令行
Size size = doc.Window.DeviceIndependentSize; //当前CAD活动窗口的尺寸
ed.WriteMessage("\n 初始尺寸尺寸<Size>:" + size.ToString() + "\n");//截屏初始尺寸
//输入图片放大倍数
int value = 1;//指定一个初始值
PromptIntegerOptions options = new PromptIntegerOptions("\n 请输入放大倍数<5>: ");;
options.AllowNone = true;
options.DefaultValue = 5;//默认值
options.LowerLimit = 1;//最小值
options.UpperLimit = 10;//最大值,太大内存受不了啊~
PromptIntegerResult result = doc.Editor.GetInteger(options);
switch (result.Status)
{
case PromptStatus.OK:
value = result.Value;
break;
case PromptStatus.None:// 空输入
value = options.DefaultValue;
break;
case PromptStatus.Cancel:
doc.Editor.WriteMessage("\n用户取消了输入");
break;
default:
break;
}
//end 输入图片放大倍数
Bitmap image = doc.CapturePreviewImage((uint) (size.Width * value), (uint) (size.Height * value)); //捕获屏幕预览
string fn = doc.Database.Filename + ".Png"; //保存位置
ed.WriteMessage("\n 保存位置<Filename>:" + fn + "\n");//提示输出文件
image.Save(fn, ImageFormat.Png); //保存图像
/*利用Explorer.exe定位文件.
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo("Explorer.exe");
info.Arguments = "/select," + fn ;
System.Diagnostics.Process.Start(info);
*/
}
|