Table of Contents

Interface IUIService

Namespace
CADability.UserInterface
Assembly
CADability.dll

The services of the user interface framework which the kernel needs but cannot provide itself: dialogs (file, color, message box, page setup, print), the clipboard, the state of the mouse and the modifier keys, bitmaps, a progress bar and an offscreen paint interface. CADability.Forms implements it with Windows Forms; the kernel reaches it through UIService. The dialog methods use the substitutes of the Windows Forms types in the namespace CADability.Substitutes, so the kernel does not depend on Windows Forms.

public interface IUIService

Properties

CurrentMousePosition

The current position of the mouse cursor in screen coordinates (pixels); a view converts it to its client coordinates.

Point CurrentMousePosition { get; }

Property Value

Point

ModifierKeys

The modifier keys (Shift, Control, Alt) that are currently pressed. Actions and views use it to decide e.g. whether an object is copied instead of moved, or added to the selection instead of replacing it.

Keys ModifierKeys { get; }

Property Value

Keys

Methods

CreatePaintInterface(Bitmap, double)

Creates a paint interface that renders into the given bitmap instead of a window, e.g. to print a view or to produce an image of a model.

IPaintTo3D CreatePaintInterface(Bitmap paintToBitmap, double precision)

Parameters

paintToBitmap Bitmap

the bitmap to render into

precision double

the precision for the tessellation of curves and surfaces, in model units

Returns

IPaintTo3D

the paint interface, initialized for the bitmap

GetBitmap(string)

Returns a bitmap from a bitmap strip, name has the format filename:index(, where filename should be part of the resources?)

Bitmap GetBitmap(string name)

Parameters

name string

Returns

Bitmap

GetClipboardData()

Returns the objects that SetClipboardData(GeoObjectList, bool) put on the clipboard.

GeoObjectList GetClipboardData()

Returns

GeoObjectList

a new list with the objects, or null when the clipboard holds no CADability objects

GetDataPresent(object)

Extracts the CADability objects from the data of a drag and drop operation. The views use it to accept objects dropped onto the canvas.

GeoObjectList GetDataPresent(object data)

Parameters

data object

the data object of the drag and drop operation (a System.Windows.Forms.IDataObject in CADability.Forms)

Returns

GeoObjectList

the objects, or null when the data contains no CADability objects

HasClipboardData()

Tells whether the clipboard holds data that GetClipboardData() can read; used to enable the paste command.

bool HasClipboardData()

Returns

bool

true when there are CADability objects on the clipboard

SetClipboardData(GeoObjectList, bool)

Puts the objects on the clipboard, serialized in CADability's own format, so that they can be pasted with GetClipboardData(), also into another CADability application. An empty list is ignored.

void SetClipboardData(GeoObjectList objects, bool copy)

Parameters

objects GeoObjectList

the objects to copy

copy bool

true: the data stays on the clipboard after the application exits, false: it is removed then

ShowColorDialog(ref Color)

Shows a color selection dialog, initialized with color.

DialogResult ShowColorDialog(ref Color color)

Parameters

color Color

in: the initial color, out: the selected color when the dialog was confirmed

Returns

DialogResult

OK when the user confirmed, Cancel otherwise

ShowMessageBox(string, string, MessageBoxButtons)

Shows a modal message box with the given text, caption and buttons.

DialogResult ShowMessageBox(string text, string caption, MessageBoxButtons buttons)

Parameters

text string

the message

caption string

the title of the message box

buttons MessageBoxButtons

the buttons to offer

Returns

DialogResult

the button the user pressed, e.g. Yes or OK

ShowOpenFileDlg(string, string, string, ref int, out string)

Shows an open file dialog. The id is used to cache the last directory, so with different ids you get different start directories. The filter is a windows OpenFileDialog filter, filterIndex specifies, which of the filters should be used as default, fileName returns the name of the selected file.

DialogResult ShowOpenFileDlg(string id, string title, string filter, ref int filterIndex, out string fileName)

Parameters

id string

to keep default directories of different usages apart

title string

title of the dialog, or simply open file, when title is null

filter string
filterIndex int
fileName string

the filename

Returns

DialogResult

ShowPageSetupDlg(ref PrintDocument, PageSettings, out int, out int, out bool)

Shows the page setup dialog for printing and returns the chosen paper size and orientation.

DialogResult ShowPageSetupDlg(ref PrintDocument printDocument1, PageSettings pageSettings, out int width, out int height, out bool landscape)

Parameters

printDocument1 PrintDocument

in: the document to set up, out: the document with the chosen settings

pageSettings PageSettings

the current page settings

width int

the width of the paper in hundredths of an inch, 0 when the dialog was cancelled

height int

the height of the paper in hundredths of an inch, 0 when the dialog was cancelled

landscape bool

true when landscape orientation was chosen, false otherwise or when the dialog was cancelled

Returns

DialogResult

OK when the user confirmed, Cancel otherwise

ShowPrintDlg(ref PrintDocument)

Shows the print dialog (printer selection) for the document.

DialogResult ShowPrintDlg(ref PrintDocument printDocument)

Parameters

printDocument PrintDocument

in: the document to print, out: the document with the chosen printer settings

Returns

DialogResult

OK when the user confirmed and the document may be printed, Cancel otherwise

ShowProgressBar(bool, double, string)

Shows or hides a progress bar.

void ShowProgressBar(bool show, double percent = 0, string title = null)

Parameters

show bool

true: show, false: hide

percent double

progress percentage (0..100)

title string

title of the progress bar, null: don't change the current title

ShowSaveFileDlg(string, string, string, ref int, ref string)

Shows a save file dialog. As with ShowOpenFileDlg(string, string, string, ref int, out string), id keys the last used directory, filter and filterIndex select the file types, and fileName receives the chosen name when the user confirms.

DialogResult ShowSaveFileDlg(string id, string title, string filter, ref int filterIndex, ref string fileName)

Parameters

id string

to keep default directories of different usages apart

title string

title of the dialog, or null for the default title

filter string

the filter string in the format of the Windows Forms file dialogs

filterIndex int

in: the index of the initially selected filter, out: the index of the filter the user selected

fileName string

out: the selected file name; unchanged when the dialog was cancelled

Returns

DialogResult

OK when the user confirmed, Cancel otherwise

Events

ApplicationIdle

Raised when the message loop of the application has no messages to process (Application.Idle in Windows Forms). The AnimatedView subscribes to it to advance its animation.

event EventHandler ApplicationIdle

Event Type

EventHandler