Method UpdateSimpleDialogDisplay
UpdateSimpleDialogDisplay(CopyBufOption)
Updates the dialog in simple dialog mode.
Declaration
Error UpdateSimpleDialogDisplay(CopyBufOption copyBufOption)
Parameters
Type | Name | Description |
---|---|---|
CopyBufOption | copyBufOption | Whether to overwrite the shadow buffer. |
Returns
Type | Description |
---|---|
Error | Error |
Remarks
Apart from the visible buffer, the simple dialog mode also has a shadow buffer.
This shadow buffer can be used to prepare several graphical elements and then render all of them in one step with an update.
When the display is to be updated one can either overwrite the shadow buffer with the contents in the currently visible buffer or not.
Used in conjunction with
CreateSimpleDialogText(String, Int32, Int32, Color, Color),
SetSimpleDialogResourceImage(Bitmap, Int32, Int32, SelectBuf) and
SetSimpleDialogResourceImage(String, Int32, Int32, SelectBuf, SimpleDialogFileLoadOptions).
Examples
The following example demonstrates the difference of the visible and the shadow buffer.
C#
Error error = driver.SetSimpleDialogMode();
int max = 14;
int height = 40;
for (int k = 0; k < 100; k++)
{
Bitmap bitmap = GetNumberedTile(k, height, height,
new Pen(0 == k % 2 ? Brushes.Blue : Brushes.Red, 4f));
int column = (k % max + k / max) * height;
int row = (k % max) * height;
SelectBuf whichBuffer = 0 == k % 2 ? SelectBuf.CurrentBuffer : SelectBuf.ShadowBuffer;
error = driver.SetSimpleDialogResourceImage(bitmap, column, row, whichBuffer);
}
// The even numbered tiles are in the currently visible buffer.
// The odd numbered tiles are in the shadow buffer.
error = driver.UpdateSimpleDialogDisplay(CopyBufOption.DoNotCopyCurrentToShadowBeforeSwitching);
// The odd numbered tiles are visible.
// The even numbered tiles were visible, if CopyBufOption.CopyCurrentToShadowBeforeSwitching would have been used.
for (int k = 0; k < 10; k++)
{
Bitmap bitmap1 = GetNumberedTile(-1 - k, height, height, new Pen(Brushes.Yellow, 4f));
int column = k * height;
int row = ((k + 1) % max) * height;
error = driver.SetSimpleDialogResourceImage(bitmap1, column, row, SelectBuf.ShadowBuffer);
}
error = driver.UpdateSimpleDialogDisplay(CopyBufOption.DoNotCopyCurrentToShadowBeforeSwitching);
// The previously visible tiles and the negative numbered tiles are visible.
//driver.SetSimpleDialogClearDisplay(SelectBufClearOption.CurrentBuffer);
Bitmap GetNumberedTile(int number, int width, int height, Pen boxPen)
{
float emSize = 16.0f;
Rectangle box = new Rectangle(0, 0, width, height);
Bitmap bitmap = new Bitmap(box.Width, box.Height);
using Graphics g = Graphics.FromImage(bitmap);
g.Clear(Color.Transparent);
g.DrawString($"{number}.", new Font(FontFamily.GenericSansSerif, emSize, FontStyle.Regular),
Brushes.White, new PointF(width / 2 - emSize, height / 2 - emSize));
g.DrawRectangle(boxPen, box);
return bitmap;
}
VB.NET
Private Sub ShadowBufferDemo()
Dim [error] As [Error] = driver.SetSimpleDialogMode()
Dim max = 14
Dim height = 40
For k = 0 To 100 - 1
Dim bitmap As Bitmap = GetNumberedTile(k, height, height,
New Pen(If(0 = k Mod 2, Brushes.Blue, Brushes.Red), 4.0F))
Dim column As Integer = (k Mod max + k / max) * height
Dim row = (k Mod max) * height
Dim whichBuffer = If(0 = k Mod 2, SelectBuf.CurrentBuffer, SelectBuf.ShadowBuffer)
[error] = driver.SetSimpleDialogResourceImage(bitmap, column, row, whichBuffer)
Next
' The even numbered tiles are in the currently visible buffer.
' The odd numbered tiles are in the shadow buffer.
[error] = driver.UpdateSimpleDialogDisplay(CopyBufOption.DoNotCopyCurrentToShadowBeforeSwitching)
' The odd numbered tiles are visible.
' The even numbered tiles were visible, if CopyBufOption.CopyCurrentToShadowBeforeSwitching would have been used.
For k = 0 To 10 - 1
Dim bitmap1 As Bitmap = GetNumberedTile(-1 - k, height, height,
New Pen(Brushes.Yellow, 4.0F))
Dim column = k * height
Dim row = ((k + 1) Mod max) * height
[error] = driver.SetSimpleDialogResourceImage(bitmap1,
column, row, SelectBuf.ShadowBuffer)
Next
[error] = driver.UpdateSimpleDialogDisplay(
CopyBufOption.DoNotCopyCurrentToShadowBeforeSwitching)
' The previously visible tiles and the negative numbered tiles are visible.
'driver.SetSimpleDialogClearDisplay(SelectBufClearOption.CurrentBuffer);
End Sub
Private Function GetNumberedTile(ByVal number As Integer, ByVal width As Integer, ByVal height As Integer, ByVal boxPen As Pen) As Bitmap
Dim emSize = 16.0F
Dim box As Rectangle = New Rectangle(0, 0, width, height)
Dim bitmap As Bitmap = New Bitmap(box.Width, box.Height)
Dim g = Graphics.FromImage(bitmap)
g.Clear(Color.Transparent)
g.DrawString($"{number}.",
New Font(FontFamily.GenericSansSerif, emSize, FontStyle.Regular),
Brushes.White, New PointF(width / 2 - emSize, height / 2 - emSize))
g.DrawRectangle(boxPen, box)
Return bitmap
End Function