Skip to main content

BingWallpaper

Namespace: Wisej.Web.Ext.BingWallpaper

Assembly: Wisej.Web.Ext.BingWallpaper (4.1.0.0)

Changes the background image of the Desktop or any target Control Bing's images of the day.

public class BingWallpaper : Component

The server downloads the list of the most recent Bing images of the day (up to MaxImages) when the component is rendered. The browser then shows the images as the background of the target Control, or of the current Desktop (or main page) when Control is null, and changes the image every RotationInterval milliseconds. If the images can't be downloaded, the error is written to the trace log and the background doesn't change.

Example:

The following example rotates five Bing images every 30 seconds as the background of the desktop:

public partial class MyDesktop : Desktop
{
private BingWallpaper bingWallpaper;

public MyDesktop()
{
InitializeComponent();

this.bingWallpaper = new BingWallpaper(this.components)
{
MaxImages = 5,
RotationInterval = 30000,
FadeTime = 2000
};
}
}

Constructors​

Instance member BingWallpaper()​

Initializes a new instance of the BingWallpaper class.

The new component rotates up to 10 images every 60 seconds, with a 1 second fade and the zoom animation enabled.

Example:

The following example uses Bing images as the background of a panel, without the zoom animation:

var wallpaper = new BingWallpaper();
wallpaper.Control = this.panelBackground;
wallpaper.EnableAnimation = false;

Instance member BingWallpaper(container)​

Initializes a new instance of the BingWallpaper class together with the specified container.

NameTypeDescription
containerIContainerA IContainer that represents the container for the component.

Adding the component to a container ensures that it's disposed together with the container, for example when the owning page, form or desktop is disposed.

Throws:

Example:

The following example shows a new Bing image every 10 minutes as the background of the main page:

// "components" is the container created by the designer for the page.
var wallpaper = new BingWallpaper(this.components)
{
Control = this,
RotationInterval = 600000
};

Properties​

Instance member Control​

Control: Returns or sets the control that will receive the background images. If left to null it will automatically use the current Desktop. (Default: null)

Value: The Control that shows the images, or null to use the current Desktop. The default is null.

When the value is null and the application doesn't have a Desktop, the images are shown on the MainPage. The images are scaled to cover the whole control. When the target control is disposed, the property is reset to null.

Example:

The following example shows the Bing images behind a login panel:

private void LoginPage_Load(object sender, EventArgs e)
{
this.bingWallpaper1.Control = this.panelLogin;
this.bingWallpaper1.RotationInterval = 15000;
}

Instance member EnableAnimation​

Boolean: Enables or disables a simple zoom animation when rotating images. (Default: True)

Value: true to zoom the new image while it fades in; otherwise false. The default is true.

When enabled, each new image slowly zooms to 105% of its size while it fades in. The zoom lasts five times the FadeTime, so with the default FadeTime of 1000 it takes 5 seconds. Disable it for a static background, for example when the images are behind content that should stay easy to read.

Example:

The following example turns off the zoom animation and only cross-fades the images:

var wallpaper = new BingWallpaper(this.components)
{
EnableAnimation = false,
FadeTime = 1500
};

Instance member FadeTime​

Int32: Returns or sets the duration, in milliseconds, of the cross-fade between two images. (Default: 1000)

Value: The duration of the cross-fade in milliseconds, from 0 to 10000 (10 seconds). The default is 1000.

When the image changes, the current image fades out while the next one fades in, and both transitions take FadeTime milliseconds. A value of 0 switches the images without fading. When EnableAnimation is true, the zoom animation lasts five times the FadeTime. Keep the FadeTime shorter than the RotationInterval, otherwise the next image starts fading in before the previous transition ends.

Throws:

Example:

The following example uses a slow 3 second cross-fade and a new image every 2 minutes:

var wallpaper = new BingWallpaper(this.components)
{
FadeTime = 3000,
RotationInterval = 120000
};

Instance member MaxImages​

Int32: Returns or sets the number of images to rotate. (Default: 10)

Value: The number of recent Bing images of the day to download, from 0 to 100. The default is 10.

The list of images is downloaded from bing.com by the server when the component is rendered, and it's reused until MaxImages changes. The server must be able to reach https://www.bing.com. A value of 0 downloads one image. Bing may return fewer images than requested; in that case all the returned images are rotated.

Throws:

Example:

The following example shows only today's image, without rotating:

var wallpaper = new BingWallpaper(this.components)
{
MaxImages = 1,
RotationInterval = 0
};

Instance member RotationInterval​

Int32: Returns or sets the rotation interval in milliseconds. (Default: 60000)

Value: The time in milliseconds between two images, from 0 to 36000000 (10 hours). The default is 60000 (1 minute).

The images are shown in order and start again from the first one after the last. The timer runs in the browser, so rotating the images doesn't cause any requests to the server. Set the value to 0 to show only the first image, without rotating.

Throws:

Example:

The following example lets the user choose how often the image changes, or stop the rotation:

private void comboBoxRotation_SelectedIndexChanged(object sender, EventArgs e)
{
switch (this.comboBoxRotation.Text)
{
case "Every minute":
this.bingWallpaper1.RotationInterval = 60 * 1000;
break;

case "Every hour":
this.bingWallpaper1.RotationInterval = 60 * 60 * 1000;
break;

case "Never":
this.bingWallpaper1.RotationInterval = 0;
break;
}
}

Methods​

Protected member Dispose(disposing)​

When the reference count goes down to zero, kill also the static timer.

ParameterTypeDescription
disposingBooleantrue when this method is called by the application rather than a finalizer.

Protected member OnAddReferences(list)​

Returns a collection of referenced components or collection of components.

ParameterTypeDescription
listIListList of referenced components or collection of components.

Protected member OnWebRender(config)​

Renders the client component.

ParameterTypeDescription
configObjectDynamic configuration object.

Implements​