Skip to content

Commit

Permalink
Merge 971ca2c into bce2462
Browse files Browse the repository at this point in the history
  • Loading branch information
natsnudasoft committed Feb 25, 2019
2 parents bce2462 + 971ca2c commit 63f64c8
Show file tree
Hide file tree
Showing 92 changed files with 12,241 additions and 492 deletions.
65 changes: 60 additions & 5 deletions README.md
Expand Up @@ -3,10 +3,12 @@
[![AppVeyor master][AppVeyorImage]][AppVeyorUrl]
[![license][LicenceImage]][LicenceUrl]

A configurable Windows screensaver allowing user specified images to float around the desktop.
A configurable Windows screensaver allowing user specified images to float around the desktop with
composable behaviours and effects.

Multiple images may be specified and the screensaver will select from these images at random.

[<img src="./resources/EgamiFlowScreensaver.jpg" alt="Egami Flow Screensaver Screenshot" width="468px" style="width: 468px;"/>](./resources/EgamiFlowScreensaver.jpg?raw=true)
[<img src="./resources/EgamiFlowScreensaver.jpg" alt="Egami Flow Screensaver Screenshot" width="840px" style="width: 840px;"/>](./resources/EgamiFlowScreensaver.jpg?raw=true)

See the [configuration](#configuration) section for more details on the available features.

Expand All @@ -29,14 +31,48 @@ settings window. The configuration window looks like the image below.
On this page you can manage the images that will be randomly selected to float around the screen by
the screensaver while it is running, as well as configure a few other settings as follows:

### Contents
- [Images Settings](#images-settings)
* [Add Image](#add-image)
* [Remove Image](#remove-image)
* [Image Emit Rate](#image-emit-rate)
* [Max Image Emit Count](#max-image-emit-count)
* [Image Emit Lifetime](#image-emit-lifetime)
* [Infinite Emit Mode](#infinite-emit-mode)
* [Image Emit Location](#image-emit-location)
- [Manage Emit Behaviours](#manage-emit-behaviours)
* [Configure Behaviour](#configure-behaviour)
- [Background Settings](#background-settings)
* [Desktop](#desktop)
* [Solid Colour](#solid-colour)
* [Image](#image)
+ [Image Position](#image-position)

### Images Settings
#### Add Image
Allows you to select a new image file to add to the list of images that will be randomly selected
when images are created.

#### Remove Image
Removes the selected image file from the list of images that will be randomly selected when images
are created.

#### Image Emit Rate
The number of new images that will be created by the screensaver per second.

#### Max Image Emit Count
The maximum number of images that will be created by the screensaver; when this number of images
are floating around the screen, the screensaver will stop creating new images.

#### Image Emit Lifetime
The time that emitted images will stay on the screen for (in milliseconds) if *Infinite Emit Mode*
is enabled. Behaviour transitions may extend this lifetime.

#### Infinite Emit Mode
Whether or not images will be emitted infinitely. In this mode, images will be destroyed after the
time set by *Image Emit Lifetime*, and may have transitioning effects while they are being destroyed
if any behaviours that allow this are enabled and configured to do so.

#### Image Emit Location
The location that images will be emitted at on the screensaver; possible values are described
in the following table:
Expand All @@ -50,16 +86,35 @@ in the following table:
| Bottom Right | Images should be emitted from the bottom right of the primary screen. |
| Centre | Images should be emitted from the centre of the primary screen. |
| Random | Images should be emitted from random locations on the primary screen. |
| Custom... | Images should be emitted from a selected location on the screensaver. This location can be selected with the *Choose Location* button. |

#### Manage Emit Behaviours

Displays a window allowing you to manage various effects and behaviours that can be applied to any
images emitted by the screensaver. This window contains a list of available behaviours that you can
enable by ticking the relevant checkbox; a description of the selected behaviour is shown underneath
the list.

[<img src="./resources/EgamiFlowApplyBehaviorsConfiguration.png" alt="Egami Flow Apply Behaviours Configuration Screenshot" />](./resources/EgamiFlowApplyBehaviorsConfiguration.png?raw=true)

##### Configure Behaviour
Configure the selected behaviour in the behaviours list, if it has any configuration options; the
behaviour must be enabled before you are able to configure it.

### Background Settings
#### Desktop
The screensaver will take a screenshot of the current desktop and use that as the background.
<sub>*(This setting does not currently work on Windows 8 and up; preview mode works fine, however
when the screensaver actually runs, a grey background shows instead.)*</sub>

#### Solid Color
The screensaver will display a chosen colour as the background.
#### Solid Colour
The screensaver will display a chosen colour as the background. The colour to be displayed can be
selected by clicking the *Choose Colour* button.

#### Image
The screensaver will display a chosen image as the background.
The screensaver will display a chosen image as the background. The image to be displayed can be
selected by clicking the *Choose Image* button. You may also specify the colour to be displayed
behind this image by clicking the *Choose Colour* button.

##### Image Position
How the screensaver will position the chosen background image; possible values are described
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Expand Up @@ -48,7 +48,7 @@
release: 'EgamiFlowScreensaver $(APPVEYOR_REPO_TAG_NAME)'
description: ''
auth_token:
secure: Btb4eq03u8e4+k4WUyv4mWf0kfmzuxSCRo6u1nfOCtxlr4hrdpB5af5tVpt5q+1q
secure: winth2ckr0q/1fONK0Nz7MixzIikq4sYbi/uKfJ97WYgL6rKwI/TT9PNHXcX2pFF
artifact: EgamiFlowScreensaver_Release_Any_CPU
draft: false
prerelease: false
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/EgamiFlowScreensaver.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/EgamiFlowScreensaverConfiguration.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/ScreensaverSettings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 100 additions & 0 deletions src/EgamiFlowScreensaver/AlphaChangeScreensaverImageItemBehavior.cs
@@ -0,0 +1,100 @@
// <copyright file="AlphaChangeScreensaverImageItemBehavior.cs" company="natsnudasoft">
// Copyright (c) Adrian John Dunstan. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

namespace Natsnudasoft.EgamiFlowScreensaver
{
using System;
using Microsoft.Xna.Framework;

/// <summary>
/// Provides a behaviour to apply to an image item that causes the image item to transition from
/// one alpha value to another over a specified time frame.
/// </summary>
/// <seealso cref="TransitionScreensaverImageItemBehavior"/>
public sealed class AlphaChangeScreensaverImageItemBehavior :
TransitionScreensaverImageItemBehavior
{
/// <summary>
/// Initializes a new instance of the <see cref="AlphaChangeScreensaverImageItemBehavior"/>
/// class.
/// </summary>
/// <param name="screensaverArea">The description of the area of the screensaver.</param>
/// <param name="startAlpha">The alpha value that the image item this behaviour is applied
/// to will start at. This value can be out of range to delay the start of the transition.
/// </param>
/// <param name="endAlpha">The alpha value that the image item this behaviour is applied to
/// will finish at. This value can be out of range to advance to the end of the transition
/// faster.</param>
/// <param name="transitionTime">The time the image item this behaviour is applied to will
/// take to transition between the specified alpha values.</param>
/// <exception cref="ArgumentNullException"><paramref name="screensaverArea"/> is
/// <see langword="null"/>.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="transitionTime"/> is less
/// than a zero time.</exception>
public AlphaChangeScreensaverImageItemBehavior(
ScreensaverArea screensaverArea,
float startAlpha,
float endAlpha,
TimeSpan transitionTime)
: base(
screensaverArea,
transitionTime,
(s, p) => s.Alpha =
MathHelper.Clamp(MathHelper.Lerp(startAlpha, endAlpha, p), 0f, 1f))
{
}

/// <summary>
/// Initializes a new instance of the <see cref="AlphaChangeScreensaverImageItemBehavior"/>
/// class.
/// </summary>
/// <param name="screensaverArea">The description of the area of the screensaver.</param>
/// <param name="startAlpha">The alpha value that the image item this behaviour is applied
/// to will start at. This value can be out of range to delay the start of the transition.
/// </param>
/// <param name="endAlpha">The alpha value that the image item this behaviour is applied to
/// will finish at. This value can be out of range to advance to the end of the transition
/// faster.</param>
/// <param name="transitionTime">The time the image item this behaviour is applied to will
/// take to transition between the specified alpha values.</param>
/// <param name="endTransitionAlpha">The alpha value that the image item this behaviour is
/// applied to will finish at when it is being destroyed (starting from
/// <paramref name="endAlpha"/>).</param>
/// <param name="endTransitionTime">The time the image item this behaviour is applied to
/// will take to transition when it is being destroyed.</param>
/// <exception cref="ArgumentNullException"><paramref name="screensaverArea"/> is
/// <see langword="null"/>.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="transitionTime"/>, or
/// <paramref name="endTransitionTime"/> is less than a zero time.</exception>
public AlphaChangeScreensaverImageItemBehavior(
ScreensaverArea screensaverArea,
float startAlpha,
float endAlpha,
TimeSpan transitionTime,
float endTransitionAlpha,
TimeSpan endTransitionTime)
: base(
screensaverArea,
transitionTime,
(s, p) => s.Alpha =
MathHelper.Clamp(MathHelper.Lerp(startAlpha, endAlpha, p), 0f, 1f),
endTransitionTime,
(s, p) => s.Alpha =
MathHelper.Clamp(MathHelper.Lerp(endAlpha, endTransitionAlpha, p), 0f, 1f))
{
}
}
}
119 changes: 119 additions & 0 deletions src/EgamiFlowScreensaver/BottomLeftImageEmitDetails.cs
@@ -0,0 +1,119 @@
// <copyright file="BottomLeftImageEmitDetails.cs" company="natsnudasoft">
// Copyright (c) Adrian John Dunstan. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

namespace Natsnudasoft.EgamiFlowScreensaver
{
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Natsnudasoft.EgamiFlowScreensaver.Config;
using Natsnudasoft.NatsnudaLibrary;

/// <summary>
/// Provides a class capable of creating locations at the bottom left of a screen for a
/// <see cref="ScreensaverImageEmitter" />.
/// </summary>
public sealed class BottomLeftImageEmitDetails : ImageEmitDetails
{
/// <summary>
/// Initializes a new instance of the <see cref="BottomLeftImageEmitDetails"/> class.
/// </summary>
/// <param name="screensaverArea">The description of the area of the screensaver.</param>
/// <param name="screensaverConfiguration">The <see cref="ScreensaverConfiguration"/>
/// representing the configured state of the screensaver.</param>
/// <param name="behaviorFactories">A collection of factories that define how to create
/// behaviours that will be attached to any images emitted by a
/// <see cref="ScreensaverImageEmitter"/>.</param>
/// <exception cref="ArgumentNullException"><paramref name="screensaverArea"/>,
/// <paramref name="screensaverConfiguration"/>, or <paramref name="behaviorFactories"/>
/// is <see langword="null"/>.</exception>
public BottomLeftImageEmitDetails(
ScreensaverArea screensaverArea,
ScreensaverConfiguration screensaverConfiguration,
IEnumerable<Func<IScreensaverImageItemBehavior>> behaviorFactories)
: base(screensaverArea, screensaverConfiguration, behaviorFactories)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="BottomLeftImageEmitDetails"/> class.
/// </summary>
/// <param name="screensaverArea">The description of the area of the screensaver.</param>
/// <param name="screensaverConfiguration">The <see cref="ScreensaverConfiguration"/>
/// representing the configured state of the screensaver.</param>
/// <param name="behaviorFactories">A collection of factories that define how to create
/// behaviours that will be attached to any images emitted by a
/// <see cref="ScreensaverImageEmitter"/>.</param>
/// <param name="random">A pseudo-random number generator that can be used to generate
/// randomness in the <see cref="BottomLeftImageEmitDetails"/>.</param>
/// <exception cref="ArgumentNullException"><paramref name="screensaverArea"/>,
/// <paramref name="screensaverConfiguration"/>, <paramref name="behaviorFactories"/>, or
/// <paramref name="random"/> is <see langword="null"/>.</exception>
public BottomLeftImageEmitDetails(
ScreensaverArea screensaverArea,
ScreensaverConfiguration screensaverConfiguration,
IEnumerable<Func<IScreensaverImageItemBehavior>> behaviorFactories,
Random random)
: base(screensaverArea, screensaverConfiguration, behaviorFactories, random)
{
}

/// <inheritdoc/>
/// <exception cref="ArgumentNullException"><paramref name="texture"/> is
/// <see langword="null"/>.</exception>
public override ScreensaverImageItem CreateScreensaverImageItem(Texture2D texture)
{
ParameterValidation.IsNotNull(texture, nameof(texture));

var origin = new Vector2(texture.Width, texture.Height) / 2f;
var bottomLeftPrimary = new Point(
this.ScreensaverArea.PrimaryGameBounds.Left,
this.ScreensaverArea.PrimaryGameBounds.Bottom);
var maxX = bottomLeftPrimary.X - texture.Width + origin.X;
var minX = maxX - TwoPositionDistribution;
var minY = bottomLeftPrimary.Y + origin.Y;
var maxY = minY + TwoPositionDistribution;
var position = new Vector2(
this.Random.NextFloat(minX, maxX),
this.Random.NextFloat(minY, maxY));
return new ScreensaverImageItem(
texture,
this.BehaviorFactories.Select(f => f?.Invoke()))
{
Position = position,
Origin = origin
};
}

/// <inheritdoc/>
protected override Func<IScreensaverImageItemBehavior> CreateDefaultMovingBehaviorFactory()
{
IScreensaverImageItemBehavior CreateDefaultMovingBehavior()
{
const float minSpeed = MovingScreensaverImageItemBehavior.DefaultMinSpeed;
const float maxSpeed = MovingScreensaverImageItemBehavior.DefaultMaxSpeed;
var speed = new Vector2(
this.Random.NextFloat(minSpeed, maxSpeed),
-this.Random.NextFloat(minSpeed, maxSpeed));
return new MovingScreensaverImageItemBehavior(this.ScreensaverArea, speed);
}

return CreateDefaultMovingBehavior;
}
}
}

0 comments on commit 63f64c8

Please sign in to comment.