分享

02控制AutoCAD环境(二) 控制图形窗口(1)设置文档窗口的位置和大小

 Jcstone 2012-09-09

02-02 控制AutoCAD环境(二) 控制图形窗口(1)设置文档窗口的位置和大小

分类: AutoCAD .NET API开发 373人阅读 评论(0) 收藏 举报

Control the Drawing Windows

控制图形窗口

(译者注:AutoCAD应用程序是多文档界面软件,英文为Multiple Document Interface,简称MDI。在AutoCAD主窗口内可以打开多个图形文档,而每个图形文档都拥有一个窗口。

Like the AutoCAD Application window, you can minimize, maximize, reposition, resize, and check the state of any Document window. But you can also change the way the drawing is displayed within a window by using views, viewports, and zooming methods.

AutoCAD应用程序窗口一样,我们同样可以对任一图形文档窗口进行最小化、最大化、改变位置、改变大小以及检查状态等操作。我们还可以通过使用视图、视口及缩放方法改变图形在窗口内的显示方式。

The AutoCAD .NET API provides many ways to display your drawing. You can control the drawing display to move quickly to different areas of your drawing while you track the overall effect of your changes. You can zoom to change magnification or pan to reposition the view in the graphics area, save a named view and then restore it when you need to plot or refer to specific details, or display several views at one time by splitting the screen into several tiled viewports.

AutoCAD .NET API编程接口提供了许多显示图形的手段。当追踪所绘图形的整体效果时,我们可以控制图形显示快速移动到图形的不同区域,我们可以缩放或平移视图,保存命名视图并在需要打印或引用特定细节时恢复命名视图,或者通过将屏幕分割为多个平铺视口的方式来一次显示多个视图。

 

Topics in this section

本节主题

l  Position and Size the Document Window 设置文档窗口的位置和大小

l  Zoom and Pan the Current View 缩放和平移当前视图

l  Use Named Views 使用命名视图

l  Use Tiled Viewports 使用平铺视口

l  Update the Geometry in the Document Window 更新文档窗口的几何信息

 

1Position and Size the Document Window 设置文档窗口的位置和大小

Use the Document object to modify the position and size of any document window. The Document window can be minimized or maximized by using the WindowState property, and you can find the current state of the Document window by using the WindowState property.

使用Document对象来调整文档窗口的位置和大小。可以用WindowState属性最大化和最小化文档窗口,还可以用WindowState属性获取文档窗口当前状态

Size the active Document window 设置当前文档窗口大小

This example uses the Location and Size properties to set the placement and size of Document window to 400 pixels wide by 400 pixels high.

本例使用Location属性和Size属性设置文档窗口位置并将窗口大小设置为400像素宽400像素高。

VB.NET

Imports Autodesk.AutoCAD.Runtime

Imports Autodesk.AutoCAD.ApplicationServices

Imports Autodesk.AutoCAD.Windows

 

<CommandMethod("SizeDocumentWindow")> _

Public Sub SizeDocumentWindow()

  '' Size the Document window

  Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument

  acDoc.Window.WindowState = Window.State.Normal

 

  '' Set the position of the Document window

  Dim ptDoc As Point = New Point(0, 0)

  acDoc.Window.Location = ptDoc

 

  '' Set the size of the Document window

  Dim szDoc As Size = New Size(400, 400)

  acDoc.Window.Size = szDoc

End Sub

C#

using Autodesk.AutoCAD.Runtime;

using Autodesk.AutoCAD.ApplicationServices;

using Autodesk.AutoCAD.Windows;

 

[CommandMethod("SizeDocumentWindow")]

public static void SizeDocumentWindow()

{

  // Get the Document window获取当前文档窗口

  Document acDoc = Application.DocumentManager.MdiActiveDocument;

  acDoc.Window.WindowState = Window.State.Normal;

 

  // Set the position of the Document window设置文档窗口位置

  Point ptDoc  = new Point(0, 0);

  acDoc.Window.Location = ptDoc;

 

  // Set the size of the Document window设置文档窗口大小

  Size szDoc = new Size(400, 400);

  acDoc.Window.Size = szDoc;

}

VBA/ActiveX Code Reference

Sub SizeDocumentWindow()

    ThisDrawing.Width = 400

    ThisDrawing.Height = 400

End Sub

Minimize and maximize the active Document window 最小化和最大化活动文档窗口

VB.NET

Imports Autodesk.AutoCAD.Runtime

Imports Autodesk.AutoCAD.ApplicationServices

Imports Autodesk.AutoCAD.Windows

 

<CommandMethod("MinMaxDocumentWindow")> _

Public Sub MinMaxDocumentWindow()

  Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument

 

  '' Minimize the Document window

  acDoc.Window.WindowState = Window.State.Minimized

  MsgBox("Minimized", MsgBoxStyle.SystemModal, "MinMax")

 

  '' Maximize the Document window

  acDoc.Window.WindowState = Window.State.Maximized

  MsgBox("Maximized", MsgBoxStyle.SystemModal, "MinMax")

End Sub

C#

using Autodesk.AutoCAD.Runtime;

using Autodesk.AutoCAD.ApplicationServices;

using Autodesk.AutoCAD.Windows;

 

[CommandMethod("MinMaxDocumentWindow")]

public static void MinMaxDocumentWindow()

{

  Document acDoc = Application.DocumentManager.MdiActiveDocument;

 

  // Minimize the Document window最小化文档窗口

  acDoc.Window.WindowState = Window.State.Minimized;

  System.Windows.Forms.MessageBox.Show("Minimized" , "MinMax");

 

  // Maximize the Document window最大化文档窗口

  acDoc.Window.WindowState = Window.State.Maximized;

  System.Windows.Forms.MessageBox.Show("Maximized" , "MinMax");

}

VBA/ActiveX Code Reference

Sub MinMaxDocumentWindow()

    '' Minimize the Document window

    ThisDrawing.WindowState = acMin

    MsgBox "Minimized"

 

    '' Minimize the Document window

    ThisDrawing.WindowState = acMax

    MsgBox "Maximized"

End Sub

Find the current state of the active Document window 获取活动文档窗口的当前状态

VB.NET

Imports Autodesk.AutoCAD.Runtime

Imports Autodesk.AutoCAD.ApplicationServices

Imports Autodesk.AutoCAD.Windows

 

<CommandMethod("CurrentDocWindowState")> _

Public Sub CurrentDocWindowState()

  Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument

 

  System.Windows.Forms.MessageBox.Show("The document window is " & _

  acDoc.Window.WindowState.ToString(), "Window State")

End Sub

C#

using Autodesk.AutoCAD.Runtime;

using Autodesk.AutoCAD.ApplicationServices;

using Autodesk.AutoCAD.Windows;

 

[CommandMethod("CurrentDocWindowState")]

public static void CurrentDocWindowState()

{

  Document acDoc = Application.DocumentManager.MdiActiveDocument;

 

  System.Windows.Forms.MessageBox.Show("The document window is " +

  acDoc.Window.WindowState.ToString(), "Window State");

}

VBA/ActiveX Code Reference

Sub CurrentDocWindowState()

    Dim CurrWindowState As Integer

    Dim msg As String

    CurrWindowState = ThisDrawing.WindowState

    msg = Choose(CurrWindowState, "Normal", _

                 "Minimized", "Maximized")

    MsgBox "The document window is " + msg

End Sub

 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多