Class GDI2DView
- Namespace
- CADability
- Assembly
- CADability.dll
A 2d view of a Model that is painted with GDI (see PrintToGDI) instead of OpenGL, always looking from the top onto the x/y plane. It paints the objects in the order of the model, optionally sorted by the DisplayOrder of their layers (UseDisplayOrder), can show a paper of a given size with the area outside the paper in black (ShowPaper) and can print its contents as a single page (PrintSinglePage(PrintDocument)). Like the ModelView it handles actions, so the user can select and construct objects in it. Create it with GDI2DView(Project, Model, IFrame), add it to the frame (AddView(IView)) and make it the ActiveView; the menu command "MenuId.View.NewGDIView" does this. The view is saved with the project.
public class GDI2DView : IShowPropertyImpl, IShowProperty, IPropertyEntry, ICommandHandler, IView, ISerializable, IDeserializationCallback
- Inheritance
-
GDI2DView
- Implements
- Inherited Members
Constructors
GDI2DView()
Common initialization for the public constructor and the deserialization constructor: reads the drag and drop flags, the paper size and the mouse wheel zoom factor from the global settings. Project, model and projection are not set here.
protected GDI2DView()
GDI2DView(Project, Model, IFrame)
Creates a new AnimatedView object. In oder to display this view on the screen you need to add this view to a IFrame and set it as the ActiveView.
public GDI2DView(Project project, Model model, IFrame frame)
Parameters
projectProjectThe project that contains the lists of all schedules (if needed)
modelModelThe model that is displayed and contains the list of all drives
frameIFrameThe frame which is the context of this view
GDI2DView(SerializationInfo, StreamingContext)
Constructor for the legacy binary deserialization (ISerializable): restores project, model, name, projection, paper settings, display order flag and visible layers. Values missing in older files get their defaults. The remaining initialization happens in OnDeserialization(object).
protected GDI2DView(SerializationInfo info, StreamingContext context)
Parameters
infoSerializationInfoThe serialized data
contextStreamingContextThe source of the deserialization
Properties
AllowContextMenu
Whether a right click in this view opens the context menu of the current action; the initial value comes from the global setting "AllowContextMenu".
public bool AllowContextMenu { get; set; }
Property Value
AllowDrag
Whether objects may be dragged out of this view; the initial value comes from the global setting "AllowDrag".
public bool AllowDrag { get; set; }
Property Value
AllowDrop
Whether objects may be dropped on this view; the initial value comes from the global setting "AllowDrop".
public bool AllowDrop { get; set; }
Property Value
BackgroundColor
The color with which the canvas (or the paper, see ShowPaper) is cleared before the model is painted. Unless set explicitly, it is the color setting "Colors.Background" of the frame (or of the global settings), and it follows changes of that setting. Setting it does not repaint; call InvalidateAll().
public Color BackgroundColor { get; set; }
Property Value
ContextMenu
Implementation of ContextMenu: the default returns null. An entry whose LabelType contains ContextMenu must override it.
public override MenuWithHandler[] ContextMenu { get; }
Property Value
DeferRefresh
If set to true, any updates to the model will be ignored until set to false
public bool DeferRefresh { get; set; }
Property Value
EntryType
Overrides EntryType, returns GroupTitle.
public override ShowPropertyEntryType EntryType { get; }
Property Value
LabelText
Implementation of LabelText, returns either labelTextInternal (if not null) or GetString(string)(resourceId+".Label") Whe set, labelTextInternal is set.
public override string LabelText { get; set; }
Property Value
LabelType
How the label of this entry behaves (see ShowPropertyLabelFlags): whether it can be selected or edited, is bold or has a context menu. The default implementation returns Selectable.
public override ShowPropertyLabelFlags LabelType { get; }
Property Value
Model
The Model shown by this view. Setting it rebuilds the display list and repaints; the projection and the list of visible layers are kept.
public Model Model { get; set; }
Property Value
Name
The name of the view as shown in the property page and used by the frame to identify the view. Setting it does not refresh the property page.
public string Name { get; set; }
Property Value
PaperHeight
Height of the paper in model units (extent in y direction from the origin), see ShowPaper. The initial value comes from the global setting "GDI2DView.Paper.Height". Setting it repaints the view.
public double PaperHeight { get; set; }
Property Value
PaperWidth
Width of the paper in model units (extent in x direction from the origin), see ShowPaper. The initial value comes from the global setting "GDI2DView.Paper.Width". Setting it repaints the view.
public double PaperWidth { get; set; }
Property Value
ShowCoordCross
If true (the default), the coordinate cross with the axes of the world coordinate system (and of the drawing plane, when its origin differs) is painted in the background. Setting it does not repaint by itself.
public bool ShowCoordCross { get; set; }
Property Value
ShowPaper
If true, a paper of PaperWidth by PaperHeight with its lower left corner at the origin is shown in the BackgroundColor and the area outside the paper in black (as in the old CONDOR system); the paper is also included in the extent used for zoom total and for scrolling. Initially true when both paper dimensions are set in the global settings. Setting it repaints the view.
public bool ShowPaper { get; set; }
Property Value
SubEntries
The sub entries shown below this entry when it is opened in the property page. The default implementation has none and returns an empty array.
public override IShowProperty[] SubEntries { get; }
Property Value
SubEntriesCount
The number of SubEntries, 0 for an entry that cannot be opened. The default implementation returns 0.
public override int SubEntriesCount { get; }
Property Value
ThinLinesOnly
Use only thin lines for display
public bool ThinLinesOnly { get; set; }
Property Value
UseDisplayOrder
If true, the objects are painted sorted by the DisplayOrder of their layers (lowest first, objects without a layer at 0), so that objects on layers with a higher display order cover those on lower ones; if false (the default) they are painted in the order of the model. Setting it rebuilds the display list and repaints.
public bool UseDisplayOrder { get; set; }
Property Value
VisibleLayers
The layers that are shown in this view, as a checkable list for the property page. Objects on unchecked layers are neither painted nor picked. Change the visibility with Set(Layer, bool); the view repaints when the check state changes.
public CheckedLayerList VisibleLayers { get; }
Property Value
Methods
Added(IPropertyPage)
Implementation of Added(IPropertyPage): memorizes the property page in propertyPage. Unlike Added(IPropertyTreeView) it does not raise the state changed event. Override it to subscribe to events while the entry is displayed, and call the base implementation.
public override void Added(IPropertyPage propertyTreeView)
Parameters
propertyTreeViewIPropertyPage
DoDragDrop(GeoObjectList, DragDropEffects)
Not used: returns None without starting a drag and drop operation. The IView implementation of this view forwards to the canvas instead.
public DragDropEffects DoDragDrop(GeoObjectList dragList, DragDropEffects all)
Parameters
dragListGeoObjectListNot evaluated
allDragDropEffectsNot evaluated
Returns
Init()
Completes the initialization once project, model and frame are set: creates the list of visible layers with all layers of the project checked, reads the selection color and widths from the frame and creates a projection from the top with the grid settings of the global settings. Called by the public constructor.
protected void Init()
LabelChanged(string)
Implementation of LabelChanged(string). Override if LabelType is Editable.
public override void LabelChanged(string NewText)
Parameters
NewTextstringthe new text
PrintSinglePage(PrintDocument)
Prints the contents of this view on a single page via PrintToGDI. The paper (PaperWidth by PaperHeight) is fitted onto the page, so the paper size should be set. Exceptions of the printing system are swallowed.
public void PrintSinglePage(PrintDocument pd)
Parameters
pdPrintDocumentThe print document to print to, with the printer and page settings already set
Removed(IPropertyTreeView)
Implementation of Removed(IPropertyTreeView), raises the StateChangedEvent
public override void Removed(IPropertyTreeView propertyTreeView)
Parameters
propertyTreeViewIPropertyTreeViewremoved from this IPropertyTreeView
ZoomToModelExtent(double)
Zooms to the extend of the model. The projection direction is not changed.
public void ZoomToModelExtent(double factor)
Parameters
factordouble
ZoomTotal(double)
Zooms so that the whole model (for the LayoutView: the whole paper) is visible. The view direction is not changed.
public void ZoomTotal(double f)
Parameters
fdoubleFactor by which the extent is enlarged before it is fitted into the display rectangle: 1.1 leaves a small margin, 1.0 fits exactly
Events
MouseDoubleClick
Provide an event handler for the mouse double click message here if you want to manipulate the mouse input to this ModelView
public event MouseFilterDelegate MouseDoubleClick
Event Type
MouseDown
Provide an event handler for the mouse down message here if you want to manipulate the mouse input to this ModelView
public event MouseFilterDelegate MouseDown
Event Type
MouseMove
Provide an event handler for the mouse move message here if you want to manipulate the mouse input to this ModelView
public event MouseFilterDelegate MouseMove
Event Type
MouseUp
Provide an event handler for the mouse up message here if you want to manipulate the mouse input to this ModelView
public event MouseFilterDelegate MouseUp
Event Type
MouseWheel
Provide an event handler for the mouse wheel message here if you want to manipulate the mouse input to this ModelView
public event MouseFilterDelegate MouseWheel
Event Type
PaintActiveEvent
Raised during each paint cycle after the PaintSelectEvent handlers, so that the feedback of the running action (the active objects) is drawn last. Handlers are registered with SetPaintHandler(DrawingAspect, PaintView) for Active.
public event PaintView PaintActiveEvent
Event Type
PaintBackgroundEvent
Raised during each paint cycle directly after the model (and the grid and coordinate cross) has been painted and before the PaintSelectEvent and PaintActiveEvent handlers. Handlers are registered with SetPaintHandler(DrawingAspect, PaintView) for Background.
public event PaintView PaintBackgroundEvent
Event Type
PaintSelectEvent
Raised during each paint cycle after the model and the PaintBackgroundEvent handlers, so that the selection can be drawn on top of the model. Handlers are registered with SetPaintHandler(DrawingAspect, PaintView) for Select.
public event PaintView PaintSelectEvent
Event Type
ScrollPositionChangedEvent
Raised when the visible part of the display extent changes (zoom, scroll, resize), so that the host can update its scroll bars. See ScrollPositionChanged for the meaning of the parameters. Only the ModelView and the GDI2DView raise it; the LayoutView does not implement it.
public event ScrollPositionChanged ScrollPositionChangedEvent