VisualStateManager

You can use Visual State Manager to create layer between user interface and application logic. The main reason this project was created is the lack of such mechanism in Windows Forms libraries.

Example

using Action = VisualStateManager.Action;

public partial class Form1 : Form { private Condition canRunAction; private Action helloWorldAction; private void InitializeActions() {
// Conditions regulate availability, visibility and
// checked-state of controls attached to actions canRunAction = new Condition(false);

// You can attach action to one or more controls.
// VSM will maintain its Enabled, Visible and
// Checked states for you basing on chosen Conditions. helloWorldAction = new Action(DoHelloWorld, canRunAction, button1); } public void DoHelloWorld() { MessageBox.Show("Hello, world!"); } public Form1() { InitializeComponent(); InitializeActions(); } private void checkBox1_CheckedChanged(object sender, EventArgs e) {
// Set Value of condition to affect all controls
// which are being controlled by it.
canRunAction.Value = checkBox1.Checked; } }

Last edited Jun 10, 2015 at 12:09 PM by spook, version 3