Table of Contents

Class FrameImpl

Namespace
CADability
Assembly
CADability.dll

A standard implementation of the IFrame interface, used by CadFrame and the old SingleDocumentFrame

public abstract class FrameImpl : IFrame, ICommandHandler
Inheritance
FrameImpl
Implements
Inherited Members

Constructors

FrameImpl()

Creates a frame without project, control center and canvas: creates the action stack, loads the global settings and the list of most recently used files and registers the frame as MainFrame. The derived class sets the ControlCenter, the Project and the views afterwards.

public FrameImpl()

FrameImpl(ICanvas)

Creates a frame that displays its views on the given canvas but has no control center, so no property pages are shown. A project has to be set afterwards.

public FrameImpl(ICanvas canvas)

Parameters

canvas ICanvas

The canvas on which the views are displayed

FrameImpl(Project, ModelView, IControlCenter)

Creates a frame with the given control center, opens the given project in it and makes the given model view the active view. No canvas is involved in this configuration.

public FrameImpl(Project pr, ModelView modelView, IControlCenter cc)

Parameters

pr Project

The project to open in the frame

modelView ModelView

The view that becomes the active view

cc IControlCenter

The control center (properties explorer) of the application

FrameImpl(IControlCenter, ICanvas)

Creates a frame that displays its views on the given canvas and its properties in the given control center. The control center is connected to the frame and its standard property pages are created. A project has to be set afterwards.

public FrameImpl(IControlCenter cc, ICanvas canvas)

Parameters

cc IControlCenter

The control center (properties explorer) of the application

canvas ICanvas

The canvas on which the views are displayed

Fields

MainFrame

The frame that was created last; there is usually only one frame in an application. Objects that have no access to a frame but need its services, e.g. the active view or the UIService, use it. May be null when no frame exists (e.g. in tests); it is reset by Dispose().

public static IFrame MainFrame

Field Value

IFrame

Properties

ActionStack

The stack of running actions. The views forward their mouse events to it and it distributes menu commands to the actions. For starting and terminating actions SetAction(Action), RemoveActiveAction() and ActiveAction are usually sufficient.

public ActionStack ActionStack { get; }

Property Value

ActionStack

ActiveAction

Returns the currently active action. Call GetID() to find out more about that action.

public Action ActiveAction { get; }

Property Value

Action

ActiveView

The view that currently has the focus and receives the commands and the mouse input. Setting it shows the view on the canvas and updates the "View" page of the control center.

public IView ActiveView { get; set; }

Property Value

IView

AllViews

All views currently open in the frame: the model views, followed by the layout views, the GDI views and the animated views (layout and GDI views do not exist in the WebAssembly build). The array is a snapshot; adding or removing views does not change it.

public IView[] AllViews { get; }

Property Value

IView[]

CommandHandler

Returns the CommandHandler of this frame. All menu and toolbar commands are routed through this command handler. If the tollbars and menus of CADability are used no action has to be taken. If you use your own menues or toolbars call OnCommand(string) and OnUpdateCommand(string, CommandState) for all commands concerning CADability.

public ICommandHandler CommandHandler { get; }

Property Value

ICommandHandler

ControlCenter

The control center (properties explorer) of the application. Setting it raises ControlCenterCreatedEvent, creates the standard property pages "Action", "Project", "Global" and "View", fills the global settings into the "Global" page and the current project into the "Project" page, and brings the "Action" page to front.

public IControlCenter ControlCenter { get; set; }

Property Value

IControlCenter

CurrentMenuId

The menu id of the command that is currently being executed by OnCommand(string). An action started by that command reads it in OnSetAction() to remember the menu id it was started with.

public string CurrentMenuId { get; set; }

Property Value

string

DesignMode

Not implemented, throws a NotImplementedException. Remnant of the Windows Forms based implementation.

public bool DesignMode { get; }

Property Value

bool

GlobalSettings

Gets or set the GlobalSettings object (Settings). The global settings are saved in the file CADability.GlobalSettings.bin. If you set a different settings object you are responsible for saving the content.

public Settings GlobalSettings { get; set; }

Property Value

Settings

Project

Gets or sets the project handles in this farme

public Project Project { get; set; }

Property Value

Project

SelectedObjects

The objects currently selected by the SelectObjectsAction. Getting the value returns null when another action is active. Setting the value changes the selection of the select action, even when it is not the active action (e.g. while a context menu action runs on top of it); when there is no select action on the stack, nothing happens.

public GeoObjectList SelectedObjects { get; set; }

Property Value

GeoObjectList

SnapMode

The snapping mode for mouse movements when interactively constructing objects

public SnapPointFinder.SnapModes SnapMode { get; set; }

Property Value

SnapPointFinder.SnapModes

SolidModellingMode

When Solid objects get inserted into a model, this is how it will be handeled

public Make3D.SolidModellingMode SolidModellingMode { get; set; }

Property Value

Make3D.SolidModellingMode

UIService

The user interface services (see UIService). Must be provided by the derived class, which usually implements IUIService itself and returns this.

public abstract IUIService UIService { get; }

Property Value

IUIService

Methods

AddView(IView)

Adds a view to the frame and to the project: a ModelView is registered under its name, an AnimatedView, a GDI view or a layout view in the corresponding list of the project. The "View" page of the control center is updated. Views of other types are ignored. The view does not become the active view; set ActiveView for that.

public void AddView(IView toAdd)

Parameters

toAdd IView

The view to add

AssureModelView()

Not implemented in this class, throws a NotImplementedException (see AssureModelView()).

public void AssureModelView()

Dispose()

Shuts the frame down: removes all actions from the action stack, saves and releases the global settings, disconnects from the project and clears MainFrame if it refers to this frame. Call it when the application closes.

public void Dispose()

FindView(string)

Find a View with the provided name.

public IView FindView(string name)

Parameters

name string

name of the View

Returns

IView

The View, if found, null otherwise

FocusChanged(IPropertyTreeView, IShowProperty, bool)

Not implemented, throws a NotImplementedException. Remnant of the focus handling of the old property tree view.

public void FocusChanged(IPropertyTreeView inThisView, IShowProperty thisItem, bool gotFocus)

Parameters

inThisView IPropertyTreeView

The property tree view in which the focus changed

thisItem IShowProperty

The entry that got or lost the focus

gotFocus bool

true if the entry got the focus, false if it lost it

GenerateNewProject()

Generates a new project, saves the current project if necessary and sets the new project as the current project.

public bool GenerateNewProject()

Returns

bool

GetActivePropertyDisplay()

Returns the name of the currently selected property page of the control center. This implementation always returns "Action".

public string GetActivePropertyDisplay()

Returns

string

The name of the active property page

GetBooleanSetting(string, bool)

Gets the boolen setting for the Name. If not found Default will be returned. GetSetting(string)

public bool GetBooleanSetting(string Name, bool Default)

Parameters

Name string
Default bool

Returns

bool

GetColorSetting(string, Color)

Gets the color setting for the Name. If not found Default will be returned. GetSetting(string)

public Color GetColorSetting(string Name, Color Default)

Parameters

Name string
Default Color

Returns

Color

GetDoubleSetting(string, double)

Gets the double setting for the Name. If not found Default will be returned. GetSetting(string)

public double GetDoubleSetting(string Name, double Default)

Parameters

Name string
Default double

Returns

double

GetIntSetting(string, int)

Gets the integer setting for the Name. If not found Default will be returned. GetSetting(string)

public int GetIntSetting(string Name, int Default)

Parameters

Name string
Default int

Returns

int

GetSetting(string)

Gets the value of the setting with the given name. This implementation reads the global settings only (GlobalSettings); project specific settings are not consulted.

public object GetSetting(string Name)

Parameters

Name string

The name of the setting, e.g. "Approximate.Precision"

Returns

object

The value of the setting, or null if there is no such setting

GetStringSetting(string, string)

Gets the string setting for the Name. If not found Default will be returned. GetSetting(string)

public string GetStringSetting(string Name, string Default)

Parameters

Name string
Default string

Returns

string

OnCommand(string)

Executes a menu command. The command is offered in this order to the ProcessCommandEvent handlers, the commands handled by the frame itself (file, view, snap mode and similar commands), the Project, the actions on the action stack (topmost first) and finally the active view. CurrentMenuId is set to the command before it is executed. Override it to handle additional commands of the application.

public virtual bool OnCommand(string MenuId)

Parameters

MenuId string

The id of the menu command (see MenuResource.xml)

Returns

bool

true if the command was handled, false otherwise

OnSnapCenter()

Toggles SnapToObjectCenter in the SnapMode and stores the new snap mode in the global settings. Called by the corresponding menu command.

public void OnSnapCenter()

OnSnapDropPoint()

Toggles SnapToDropPoint in the SnapMode and stores the new snap mode in the global settings. Called by the corresponding menu command.

public void OnSnapDropPoint()

OnSnapGrid()

Toggles SnapToGridPoint in the SnapMode and stores the new snap mode in the global settings. Called by the corresponding menu command.

public void OnSnapGrid()

OnSnapIntersections()

Toggles SnapToIntersectionPoint in the SnapMode and stores the new snap mode in the global settings. Called by the corresponding menu command.

public void OnSnapIntersections()

OnSnapObjectPoint()

Toggles SnapToObjectPoint in the SnapMode and stores the new snap mode in the global settings. Called by the corresponding menu command.

public void OnSnapObjectPoint()

OnSnapOrtho()

Toggles AdjustOrtho in the SnapMode and stores the new snap mode in the global settings. Called by the corresponding menu command.

public void OnSnapOrtho()

OnSnapSnapPoint()

Toggles SnapToObjectSnapPoint in the SnapMode and stores the new snap mode in the global settings. Called by the corresponding menu command.

public void OnSnapSnapPoint()

OnSnapSurface()

Toggles SnapToFaceSurface in the SnapMode and stores the new snap mode in the global settings. Called by the corresponding menu command.

public void OnSnapSurface()

OnSnapTangentPoint()

Toggles SnapToTangentPoint in the SnapMode and stores the new snap mode in the global settings. Called by the corresponding menu command.

public void OnSnapTangentPoint()

OnUpdateCommand(string, CommandState)

Determines the state (enabled, checked) of a menu item or toolbar button. The request is offered in the same order as in OnCommand(string): the UpdateCommandEvent handlers, the frame itself, the project, the actions on the action stack and finally the active view.

public virtual bool OnUpdateCommand(string MenuId, CommandState CommandState)

Parameters

MenuId string

The id of the menu command (see MenuResource.xml)

CommandState CommandState

The state to fill in

Returns

bool

true if the state was determined, false otherwise

PreProcessKeyDown(KeyEventArgs)

Gives the active action the first chance to process a key before the control center sees it: Escape, Delete, Enter and Tab are forwarded to OnEscape(object), OnDelete(object), OnEnter(object) and OnTab(object) (Ctrl+Tab is left to the control center for switching between property pages). When the action does not handle the key, it is passed on to PreProcessKeyDown(KeyEventArgs). The application calls this from the key down event of its main window.

public virtual void PreProcessKeyDown(KeyEventArgs e)

Parameters

e KeyEventArgs

The key event arguments; Handled is set when the key has been processed

PreProcessMouseWheel(MouseEventArgs)

Not implemented, throws a NotImplementedException. Mouse wheel events are handled by the views and the action stack.

public bool PreProcessMouseWheel(MouseEventArgs e)

Parameters

e MouseEventArgs

The mouse event arguments

Returns

bool

Does not return

RemoveActiveAction()

Removes the active action froom the action stack. Usually actions terminate themselves by calling RemoveThisAction().

public void RemoveActiveAction()

RemoveView(IView)

Removes a view from the frame and from the project, the counterpart of AddView(IView). The "View" page of the control center is updated. Views of unknown types are ignored. If the removed view was the active view, the caller has to set another ActiveView.

public void RemoveView(IView toRemove)

Parameters

toRemove IView

The view to remove

SetAction(Action)

Starts the provided action. The currently active action will either be aborted or pushed down on the action stack until the provided action terminates.

public void SetAction(Action Action)

Parameters

Action Action

SetControlCenterFocus(string, string, bool, bool)

Selects the property page with the given name in the control center. Selecting an entry, opening it and showing its context menu are not implemented in this class, so resourceId, openEntry and popupCOntextMenu have no effect and the method always returns false (see SetControlCenterFocus(string, string, bool, bool)).

public bool SetControlCenterFocus(string tabPageName, string resourceId, bool openEntry, bool popupCOntextMenu)

Parameters

tabPageName string

Name of the property page: "Action", "Project", "Global" or "View"

resourceId string

Resource id of an entry, ignored

openEntry bool

Ignored

popupCOntextMenu bool

Ignored

Returns

bool

Always false

SetProjectProperties()

Refreshes the properties in the propertypage

public void SetProjectProperties()

ShowPropertyDisplay(string)

Brings the property page with the Name to front (in the tab control)

public void ShowPropertyDisplay(string Name)

Parameters

Name string

UpdateMRUMenu(string[])

Updates the list of most recently used files in the file menu (see UpdateMRUMenu(string[])). Does nothing in this class; the application overrides it to fill its menu.

public virtual void UpdateMRUMenu(string[] mruFiles)

Parameters

mruFiles string[]

The full names of the most recently used files

Events

ActionStartedEvent

Notification that a Action started

public event ActionStartedDelegate ActionStartedEvent

Event Type

ActionStartedDelegate

ActionTerminatedEvent

Notification that a Action terminated

public event ActionTerminatedDelegate ActionTerminatedEvent

Event Type

ActionTerminatedDelegate

ControlCenterCreatedEvent

This event will raised when the ControlCenter has been created. You can use the method ControlCenter.HideEntry to suppress entries in the ControlCenter

public event ControlCenterCreatedDelegate ControlCenterCreatedEvent

Event Type

ControlCenterCreatedDelegate

FileNameChangedEvent

Raised when the file name of the project changes: when a project is opened or created, or when it is saved under a new name. The application uses it to update the title of its window.

public event FrameImpl.FileNameChangedDelegate FileNameChangedEvent

Event Type

FrameImpl.FileNameChangedDelegate

ProcessCommandEvent

Provide a event handler if you want to be notified on command routed through this frame or to execute command handlers for some routed commands-

public event ProcessCommandDelegate ProcessCommandEvent

Event Type

ProcessCommandDelegate

ProcessContextMenuEvent

Provide a event handler if you want to be notified on contex menue commands routed through this frame or to execute command handlers for some routed commands-

public event ProcessContextMenuDelegate ProcessContextMenuEvent

Event Type

ProcessContextMenuDelegate

ProjectClosedEvent

Provide a event handler if you want to be notified when a project is beeing closed.

public event ProjectClosedDelegate ProjectClosedEvent

Event Type

ProjectClosedDelegate

ProjectOpenedEvent

Provide a event handler if you want to be notified when a project is opened.

public event ProjectOpenedDelegate ProjectOpenedEvent

Event Type

ProjectOpenedDelegate

SettingChangedEvent

Register here to get notified when a setting has changed

public event SettingChangedDelegate SettingChangedEvent

Event Type

SettingChangedDelegate

UpdateCommandEvent

Provide a event handler if you want to control the appearnce of commands in the menu or toolbar (set the enabled and check flags).

public event UpdateCommandDelegate UpdateCommandEvent

Event Type

UpdateCommandDelegate

UpdateContextMenuEvent

Provide a event handler if you want to control the appearance of commands in a context the menu (set the enabled and check flags).

public event UpdateContextMenuDelegate UpdateContextMenuEvent

Event Type

UpdateContextMenuDelegate

ViewsChangedEvent

Provide a event handler if you want to be notified when new views are created or views are closed.

public event ViewsChangedDelegate ViewsChangedEvent

Event Type

ViewsChangedDelegate