- dataobjectbase_2.1.0.zip
- doc
- lib
- CatenaLogic.BlogArticles.dll
- output
- Release
- CatenaLogic.BlogArticles.dll
- CatenaLogic.Examples.exe
- Data
- Example 01 - Simple object
- Example 02 - Error validation
- Example 03 - Serialization
- Example 04 - Nested objects
- Example 05 - Backward compatibility
- Example 06 - Revert and apply
- screenshots
- Example 02 - Error validation.png
- snippets
- dataobject.snippet
- propdata.snippet
- src
- CatenaLogic.Examples
- App.xaml
- App.xaml.cs
- CatenaLogic.Examples.csproj
- Data
- Example 01 - Simple object
- Example 02 - Error validation
- Example 03 - Serialization
- Example 04 - Nested objects
- Example 05 - Backward compatibility
- Example 06 - Revert and apply
- Properties
- UI
- Input
- Windows
- Example 02 - Error validation
- Example 03 - Serialization
- Example 05 - Backward compatibility
- Example 06 - Revert and apply
- CatenaLogic.Test
- CatenaLogic
- DataObjectBase.sln
- DataObjectBase.vsmdi
- LocalTestRun.testrunconfig
- dataobjectbase.zip
|
using System.Windows;
using System.Windows.Input;
using CatenaLogic.Examples.Data;
using CatenaLogic.Examples.UI.Input;
using CatenaLogic.Windows;
namespace CatenaLogic.Examples.UI.Windows
{
/// <summary>
/// Interaction logic for RevertAndApplyWindow.xaml
/// </summary>
public partial class RevertAndApplyWindow : DataWindow
{
#region Variable
private bool _hasState = false;
#endregion
#region Constructor & destructor
/// <summary>
/// Initializes a new instance of the <see cref="RevertAndApplyWindow"/> class.
/// </summary>
public RevertAndApplyWindow()
: base(DataWindowMode.Close)
{
// Initialize component
InitializeComponent();
// Add command bindings
CommandBindings.Add(new CommandBinding(RevertAndApplyCommands.CreateState, CreateState_Executed, CreateState_CanExecute));
CommandBindings.Add(new CommandBinding(RevertAndApplyCommands.Revert, Revert_Executed, Revert_CanExecute));
CommandBindings.Add(new CommandBinding(RevertAndApplyCommands.Apply, Apply_Executed, Apply_CanExecute));
}
#endregion
#region Properties
/// <summary>
/// Gets or sets RevertAndApplyObject.
/// </summary>
/// <remarks>
/// Wrapper for the RevertAndApplyObject dependency property.
/// </remarks>
public RevertAndApplyObject RevertAndApplyObject
{
get { return (RevertAndApplyObject)GetValue(RevertAndApplyObjectProperty); }
set { SetValue(RevertAndApplyObjectProperty, value); }
}
/// <summary>
/// DependencyProperty definition as the backing store for RevertAndApplyObject.
/// </summary>
public static readonly DependencyProperty RevertAndApplyObjectProperty =
DependencyProperty.Register("RevertAndApplyObject", typeof(RevertAndApplyObject), typeof(RevertAndApplyWindow), new UIPropertyMetadata(new RevertAndApplyObject()));
#endregion
#region Command bindings
/// <summary>
/// Determines whether the user can execute the CreateState command.
/// </summary>
/// <param name="sender">Sender.</param>
/// <param name="e">The event data.</param>
private void CreateState_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
// Only allow when there is no state
e.CanExecute = !_hasState;
}
/// <summary>
/// Handled when the user invokes the CreateState command.
/// </summary>
/// <param name="sender">Sender.</param>
/// <param name="e">Event Arguments.</param>
private void CreateState_Executed(object sender, ExecutedRoutedEventArgs e)
{
// Create state
RevertAndApplyObject.BeginEdit();
// State
_hasState = true;
}
/// <summary>
/// Determines whether the user can execute the Revert command.
/// </summary>
/// <param name="sender">Sender.</param>
/// <param name="e">The event data.</param>
private void Revert_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
// Only allow when there is a state
e.CanExecute = _hasState;
}
/// <summary>
/// Handled when the user invokes the Revert command.
/// </summary>
/// <param name="sender">Sender.</param>
/// <param name="e">Event Arguments.</param>
private void Revert_Executed(object sender, ExecutedRoutedEventArgs e)
{
// Cancel edit
RevertAndApplyObject.CancelEdit();
// No state
_hasState = false;
}
/// <summary>
/// Determines whether the user can execute the Apply command.
/// </summary>
/// <param name="sender">Sender.</param>
/// <param name="e">The event data.</param>
private void Apply_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
// Only allow when there is a state
e.CanExecute = _hasState;
}
/// <summary>
/// Handled when the user invokes the Apply command.
/// </summary>
/// <param name="sender">Sender.</param>
/// <param name="e">Event Arguments.</param>
private void Apply_Executed(object sender, ExecutedRoutedEventArgs e)
{
// End edit
RevertAndApplyObject.EndEdit();
// No state
_hasState = false;
}
#endregion
#region Methods
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.