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
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
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
paintToBitmapBitmapthe bitmap to render into
precisiondoublethe 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
namestring
Returns
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
dataobjectthe 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
objectsGeoObjectListthe objects to copy
copybooltrue: 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
colorColorin: the initial color, out: the selected color when the dialog was confirmed
Returns
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
textstringthe message
captionstringthe title of the message box
buttonsMessageBoxButtonsthe buttons to offer
Returns
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
idstringto keep default directories of different usages apart
titlestringtitle of the dialog, or simply open file, when title is null
filterstringfilterIndexintfileNamestringthe filename
Returns
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
printDocument1PrintDocumentin: the document to set up, out: the document with the chosen settings
pageSettingsPageSettingsthe current page settings
widthintthe width of the paper in hundredths of an inch, 0 when the dialog was cancelled
heightintthe height of the paper in hundredths of an inch, 0 when the dialog was cancelled
landscapebooltrue when landscape orientation was chosen, false otherwise or when the dialog was cancelled
Returns
ShowPrintDlg(ref PrintDocument)
Shows the print dialog (printer selection) for the document.
DialogResult ShowPrintDlg(ref PrintDocument printDocument)
Parameters
printDocumentPrintDocumentin: 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
showbooltrue: show, false: hide
percentdoubleprogress percentage (0..100)
titlestringtitle 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
idstringto keep default directories of different usages apart
titlestringtitle of the dialog, or null for the default title
filterstringthe filter string in the format of the Windows Forms file dialogs
filterIndexintin: the index of the initially selected filter, out: the index of the filter the user selected
fileNamestringout: the selected file name; unchanged when the dialog was cancelled
Returns
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