The post is devoted to the application that is complete screen saver. Sure, screen saver is quite old technology, and there is no necessity to use it on modern displays. But from my point of view moving objects on display until computer fall to sleep looks better than stable background picture.
The application bases on the idea of mathematical objects modelling application, as it could provide interesting visual patterns. This version uses 2D closed cellular automaton, and it could be iterated in natural way. These automata are quite interesting, and you can read more about it in Wikipedia: Cellular automaton, Conway’s Game of Life.
The application provides settings that controls size and colors of cells and current automaton algorithm. Statistics views could be shown on the main window. There are line chart with series of born, died and total amount of cells; and column chart with distribution of cells per their age. As the application is a screen saver, it exits at any key or left mouse click, but user may use context menu to show/hide statistics and restart automaton.
The code of the application and its features is described in additional posts that are listed below. This post describes to user features of application.
There is an application archive automata_screen_saver_app. Full code is accessible on GitHub Apps repository.
The gallery shows the application window with various colors, cell sizes and different modes.
Application demonstrates the following features:
- adapt to the current size of displays;
- support many displays;
- visual look of automaton, i.e. colors, borders, could be tuned;
- automaton has been uploaded in the background;
- context menu allows to change settings and to show/hide statistics without interrupting screen saver;
- user may restart automaton on the fly;
- for installation it is necessary copy files and install screen saver;
- new automaton types could be easily added as Prism modules;
- features are implemented in NuGet packages;
- use Unity as dependency container;
- use log4net for logging;
- save settings in xml.
Zip archive contains
Automata Screen Saver.scr file that should be installed like a screen saver. It is necessary to call context menu for
Automata Screen Saver.scr file in File Explorer, and then click on
Screen Saver Window could be used to set timeout, settings of screen saver, and preview it. Images below show these steps.
The main window
By default, the main window demonstrates current automaton, mouse cursor is hided. If user moves mouse, cursor shows and again hides in one second. User may right click and calls context menu.
- Statistics – checked item, show/hide statistics for automaton at the current screen;
- Restart – init all automata (on all screens) with initial set of points, that depending on the settings;
- Settings – show settings window and allow user to change settings without interrupting automaton iteration;
- About – show about dialog.
Statistics is presented by two float semi-transparent windows in the left part of screen. Each automaton window has its own statistics window. The application uses OxyPlot library for chart controls, as it is lightweight and easy to use. The top statistics window shows column chart with distribution of cells per their age. There exist life algorithms such that cells could live many iterations, and chart summarizes count of all cells with age more than 50.
Second statistics window show line chart with series of born, died and total amount of cells.
When user restart automaton, all statistics values are reset to zero, and then automaton is recreated. All cells in the initial automaton are one iteration old, and born and died lines has empty values and intersects X-axis.
Settings contains life algorithm, colors, cell sizes. Let us consider it in details.
- Automaton type – type of the automaton; currently only one value that is equal to “cellular automaton”;
- Secondary displays – which window is shown on secondary displays. There are the following options:
- Empty window – empty, black window is shown on secondary displays;
- Automaton – the same window as the main window is shown on secondary displays. Each of them contains own automaton, but all they share the same color and size settings;
- Background type – type of background; currently only one value that is equal to “solid color”;
- Color – background color of the main window and empty window.
- Life model | Type – used life algorithm. It defines how many neighbors dead cell should has to born again (for example, “B3” – it will born if there is exactly 3 neighbors), and how many neighbors living cell should has to survive (for example, “S23” – living cell survives if it has 2 or 3 neighbors). There are the following options:
- Conway’s Game of Life (B3/S23) – Conway’s Game of Life, highly complex behavior;
- Edward Fredkin’s replicaton (B1357/S1357) – replicator Edward Fredkin’s replicating automaton: every pattern is eventually replaced by multiple copies of itself;
- Seeds (B2/S) – all patterns are phoenixes, meaning that every live cell immediately dies, and many patterns lead to explosive chaotic growth. However, some engineered patterns with complex behavior are known;
- Pseudorandom (B25/S4) – this rule supports a small self-replicating pattern which, when combined with a small glider pattern, causes the glider to bounce back and forth in a pseudorandom walk;
- Life without death(B3/S012345678) – also known as Inkspot or Flakes. Cells that become alive never die. It combines chaotic growth with more structured ladder-like patterns that can be used to simulate arbitrary Boolean circuits;
- Life 34 (B34/S34) – was initially thought to be a stable alternative to Life, until computer simulation found that larger patterns tend to explode. Has many small oscillators and spaceships;
- Diamoeba (B35678/S5678) – forms large diamonds with chaotically fluctuating boundaries. First studied by Dean Hickerson, who in 1993 offered a $50 prize to find a pattern that fills space with live cells; the prize was won in 1999 by David Bell;
- Pattern 2×2 (B36/S125) – if a pattern is composed of 2×2 blocks, it will continue to evolve in the same form; grouping these blocks into larger powers of two leads to the same behavior, but slower. Has complex oscillators of high periods as well as a small glider;
- High life (B36/S23) – similar to Life but with a small self-replicating pattern;
- Day and night (B3678/S34678) – symmetric under on-off reversal. Has engineered patterns with highly complex behavior;
- Stephen Morley’s Move (B368/S245) – named after Stephen Morley; also called Move. Supports very high-period and slow spaceships;
- Twisted majority rule (B4678/S35678) – symmetric under on-off reversal. Approximates the curve-shortening flow on the boundaries between live and dead cells;
- Automaton | Iteration – delay in ms between two automaton iterations;
- Automaton | Initial – type of initial automaton. There are the following values:
- Previous state – automaton saves the last state, and at next launch continue with saved set of points;
- Date & Time – initial automaton starts with set of points that looks like current date and time;
- UTC Date & Time – initial automaton starts with set of points that looks like current UTC date and time;
- Random – automaton starts from random set of points.
- Cell size | Width – width in pixels of a cell;
- Cell size | Height – height in pixels of a cell;
- Cell animation | Type – visual type of how cells are died/born. There are the following values:
- No automation – cell is hided and shown immediately;
- Fade – cell changes opacity from 0 to 1 or backward.
- Cell animation | Delay – delay in ms for animation with “Fade” type.
- Cell colors | Start – start color for gradient for the inside of the circle; could be darker than Finish in order to make cells looks “negative”;
- Cell colors | Finish – finish color for gradient for the inside of the circle;
- Cell colors | Inner – color of the inside of square;
- Cell colors | Age – Boolean value that defines additional “age” colorization of cells when depends on its age circle become darker;
- Border | Color – color of borders around squares;
- Border | Show – Boolean value that defines show or hide cell border.
Solution uses C#6, .Net 4.5.1, Wpf with Prism pattern, OxyPlot chart control, and Ikc5.* NuGet packages. Features are described in the following posts:
- Grid with dynamic number of rows and columns, part 2 (also published at codeproject site) is devoted to the Wpf datagrid with cells that has defined fixed size but number of rows and columns is updated dynamically in order to fill all available space;
- Wpf application with real-time data in OxyPlot charts (also published at codeproject site) is devoted to the Wpf application that shows (emulated) real-time data in charts;
- Wpf windows on two screens (also published at codeproject site) shows how to position Wpf window on secondary monitor or show two windows on two monitors. The post contains complete code and we discuss how to address several scenarios;
- Extendable screen saver with Prism (also published at codeproject site) is devoted to screen saver application written in Wpf with Prism pattern. Provided code is the complete application with two different animation patterns that are implemented in two modules. The application is modular and could be easily extended by adding new modules.
The application uses the following software and NuGet packages:
- Prism is a fully open source version of the Prism guidance originally produced by Microsoft Patterns & Practices. Prism provides an implementation of a collection of design patterns that are helpful in writing well structured and maintainable XAML applications, including MVVM, dependency injection, commanding, event aggregation, and more. There are related links:
- Unity (the Unity Application Block) is a lightweight extensible dependency injection container with support for constructor, property, and method call injection. There are related links:
- Extended WPF Toolkit is the collection of WPF controls, components and utilities for creating next generation Windows applications. There are related links:
- OxyPlot is a cross-platform plotting library for .NET. There are related links:
- NuGet Gallery: OxyPlot core library (PCL) 1.0.0 and OxyPlot for WPF 1.0.0;
- project site;
- log4net is a tool to help the programmer output log statements to a variety of output targets. There are related links:
- Ikc5.TypeLibrary – the library contains the extension class with methods that manipulate properties with
DefaultValueattribute and copy values of properties between objects, the service that provides lite object with public properties from parent object, base class for
INotifyPropertyChangedinterface, logging interfaces and extensions methods. There are related links:
- Ikc5.Prism.Common – the library contains classes for Prism applications. Now it contains logging extensions. There are related links:
- Ikc5.Prism.Settings – there are three NuGet packages under the common title
Ikc5.Prism.Settings. These packages allow manipulate user settings in Prism applications and serialize/deserialize them in xml files. All package contains the same library and last two packages add models, view models and views to the project. There are links for these packages:
- Ikc5.Math.CellularAutomata – the library contains classes to create and investigate 2D cellular automata. There are cellular automaton classes, life algorithms and neighbors’ algorithms, cells, different interfaces’ implementation. There are links for these packages:
Solution has the following structure:
- Common class libraries –
Common.Modelscontains enumerations, common classes and interfaces.
Common.ViewModelscontains attached properties, hierarchy of converters, and common styles;
- Life module –
Life.Modelsrefers to NuGet package
Ikc5.Math.CellularAutomataand contains additional models.
Life.Viewsimplements views for cellular automaton.
- ScreenSaver – the main Wpf application.
It has the similar structure and it is described in the post Extendable screen saver with Prism mentioned above.
Add modules with Mealy and Moore automata.
1. All used IP-addresses, names of servers, workstations, domains, are fictional and are used exclusively as a demonstration only.
2. Information is provided «AS IS».