using System;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing;
using System.IO;
using Wxv.Wml;
using Wxv.Wml.Serialization;
using Wxv.Wml.Transactions;
namespace Wxv.WmlDemo
{
public class MainForm : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu;
private System.Windows.Forms.MenuItem editMenuItem;
private System.Windows.Forms.MenuItem fileMenuItem;
private System.Windows.Forms.MenuItem exitMenuItem;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem undoMenuItem;
private Wxv.WmlDemo.MenuImage menuImages;
private System.Windows.Forms.ImageList menuImageList;
private System.Windows.Forms.MenuItem menuItem10;
private System.Windows.Forms.MenuItem redoMenuItem;
private System.Windows.Forms.MenuItem helpMenuItem;
private System.Windows.Forms.MenuItem aboutMenuItem;
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.Panel dataPanel;
private System.Windows.Forms.Panel undoRedoPanel;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Panel dataEditPanel;
private System.Windows.Forms.Panel redoPanel;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.RichTextBox dataTextBox;
private System.Windows.Forms.RichTextBox redoTextBox;
private System.Windows.Forms.Button modifyButton;
private System.Windows.Forms.Button undoButton;
private System.Windows.Forms.Button redoButton;
private System.Windows.Forms.Splitter horSplitter;
private System.Windows.Forms.Splitter verSplitter;
private System.Windows.Forms.MenuItem modifyMenuItem;
private System.Windows.Forms.RichTextBox undoTextBox;
private System.Windows.Forms.MenuItem newMenuItem;
private System.Windows.Forms.MenuItem openMenuItem;
private System.Windows.Forms.MenuItem saveAsMenuItem;
private System.Windows.Forms.OpenFileDialog openFileDialog;
private System.Windows.Forms.SaveFileDialog saveFileDialog;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem showTypeInformationMenuItem;
private System.ComponentModel.IContainer components;
public MainForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
this.menuImageList = new System.Windows.Forms.ImageList(this.components);
this.mainMenu = new System.Windows.Forms.MainMenu();
this.fileMenuItem = new System.Windows.Forms.MenuItem();
this.newMenuItem = new System.Windows.Forms.MenuItem();
this.openMenuItem = new System.Windows.Forms.MenuItem();
this.saveAsMenuItem = new System.Windows.Forms.MenuItem();
this.menuItem10 = new System.Windows.Forms.MenuItem();
this.exitMenuItem = new System.Windows.Forms.MenuItem();
this.editMenuItem = new System.Windows.Forms.MenuItem();
this.modifyMenuItem = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.undoMenuItem = new System.Windows.Forms.MenuItem();
this.redoMenuItem = new System.Windows.Forms.MenuItem();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.showTypeInformationMenuItem = new System.Windows.Forms.MenuItem();
this.helpMenuItem = new System.Windows.Forms.MenuItem();
this.aboutMenuItem = new System.Windows.Forms.MenuItem();
this.menuImages = new Wxv.WmlDemo.MenuImage(this.components);
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.dataPanel = new System.Windows.Forms.Panel();
this.dataTextBox = new System.Windows.Forms.RichTextBox();
this.dataEditPanel = new System.Windows.Forms.Panel();
this.redoButton = new System.Windows.Forms.Button();
this.undoButton = new System.Windows.Forms.Button();
this.modifyButton = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.undoRedoPanel = new System.Windows.Forms.Panel();
this.undoTextBox = new System.Windows.Forms.RichTextBox();
this.horSplitter = new System.Windows.Forms.Splitter();
this.redoPanel = new System.Windows.Forms.Panel();
this.redoTextBox = new System.Windows.Forms.RichTextBox();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.verSplitter = new System.Windows.Forms.Splitter();
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
this.dataPanel.SuspendLayout();
this.dataEditPanel.SuspendLayout();
this.undoRedoPanel.SuspendLayout();
this.redoPanel.SuspendLayout();
this.SuspendLayout();
//
// menuImageList
//
this.menuImageList.ImageSize = new System.Drawing.Size(16, 16);
this.menuImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("menuImageList.ImageStream")));
this.menuImageList.TransparentColor = System.Drawing.Color.Transparent;
//
// mainMenu
//
this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.fileMenuItem,
this.editMenuItem,
this.helpMenuItem});
//
// fileMenuItem
//
this.fileMenuItem.Index = 0;
this.fileMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.newMenuItem,
this.openMenuItem,
this.saveAsMenuItem,
this.menuItem10,
this.exitMenuItem});
this.fileMenuItem.Text = "&File";
//
// newMenuItem
//
this.newMenuItem.Index = 0;
this.menuImages.SetMenuImage(this.newMenuItem, "4");
this.newMenuItem.OwnerDraw = true;
this.newMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
this.newMenuItem.Text = "&New";
this.newMenuItem.Click += new System.EventHandler(this.newMenuItem_Click);
//
// openMenuItem
//
this.openMenuItem.Index = 1;
this.menuImages.SetMenuImage(this.openMenuItem, "5");
this.openMenuItem.OwnerDraw = true;
this.openMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlO;
this.openMenuItem.Text = "&Open...";
this.openMenuItem.Click += new System.EventHandler(this.openMenuItem_Click);
//
// saveAsMenuItem
//
this.saveAsMenuItem.Index = 2;
this.menuImages.SetMenuImage(this.saveAsMenuItem, "6");
this.saveAsMenuItem.OwnerDraw = true;
this.saveAsMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
this.saveAsMenuItem.Text = "Save &As...";
this.saveAsMenuItem.Click += new System.EventHandler(this.saveAsMenuItem_Click);
//
// menuItem10
//
this.menuItem10.Index = 3;
this.menuImages.SetMenuImage(this.menuItem10, null);
this.menuItem10.OwnerDraw = true;
this.menuItem10.Text = "-";
//
// exitMenuItem
//
this.exitMenuItem.Index = 4;
this.menuImages.SetMenuImage(this.exitMenuItem, "2");
this.exitMenuItem.OwnerDraw = true;
this.exitMenuItem.Text = "E&xit";
this.exitMenuItem.Click += new System.EventHandler(this.exitMenuItem_Click);
//
// editMenuItem
//
this.editMenuItem.Index = 1;
this.editMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.modifyMenuItem,
this.menuItem2,
this.undoMenuItem,
this.redoMenuItem,
this.menuItem1,
this.showTypeInformationMenuItem});
this.editMenuItem.Text = "&Edit";
//
// modifyMenuItem
//
this.modifyMenuItem.Index = 0;
this.menuImages.SetMenuImage(this.modifyMenuItem, "7");
this.modifyMenuItem.OwnerDraw = true;
this.modifyMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlM;
this.modifyMenuItem.Text = "&Modify";
this.modifyMenuItem.Click += new System.EventHandler(this.modifyMenuItem_Click);
//
// menuItem2
//
this.menuItem2.Index = 1;
this.menuImages.SetMenuImage(this.menuItem2, null);
this.menuItem2.OwnerDraw = true;
this.menuItem2.Text = "-";
//
// undoMenuItem
//
this.undoMenuItem.Index = 2;
this.menuImages.SetMenuImage(this.undoMenuItem, "0");
this.undoMenuItem.OwnerDraw = true;
this.undoMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlZ;
this.undoMenuItem.Text = "&Undo";
this.undoMenuItem.Click += new System.EventHandler(this.undoMenuItem_Click);
//
// redoMenuItem
//
this.redoMenuItem.Index = 3;
this.menuImages.SetMenuImage(this.redoMenuItem, "1");
this.redoMenuItem.OwnerDraw = true;
this.redoMenuItem.Shortcut = System.Windows.Forms.Shortcut.CtrlY;
this.redoMenuItem.Text = "&Redo";
this.redoMenuItem.Click += new System.EventHandler(this.redoMenuItem_Click);
//
// menuItem1
//
this.menuItem1.Index = 4;
this.menuImages.SetMenuImage(this.menuItem1, null);
this.menuItem1.OwnerDraw = true;
this.menuItem1.Text = "-";
//
// showTypeInformationMenuItem
//
this.showTypeInformationMenuItem.Index = 5;
this.menuImages.SetMenuImage(this.showTypeInformationMenuItem, null);
this.showTypeInformationMenuItem.OwnerDraw = true;
this.showTypeInformationMenuItem.Text = "&Show Type Information";
this.showTypeInformationMenuItem.Click += new System.EventHandler(this.showTypeInformationMenuItem_Click);
//
// helpMenuItem
//
this.helpMenuItem.Index = 2;
this.helpMenuItem.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.aboutMenuItem});
this.helpMenuItem.Text = "&Help";
//
// aboutMenuItem
//
this.aboutMenuItem.Index = 0;
this.menuImages.SetMenuImage(this.aboutMenuItem, "3");
this.aboutMenuItem.OwnerDraw = true;
this.aboutMenuItem.Text = "&About";
this.aboutMenuItem.Click += new System.EventHandler(this.aboutMenuItem_Click);
//
// menuImages
//
this.menuImages.ImageList = this.menuImageList;
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 391);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Size = new System.Drawing.Size(744, 18);
this.statusBar1.TabIndex = 0;
//
// dataPanel
//
this.dataPanel.Controls.Add(this.dataTextBox);
this.dataPanel.Controls.Add(this.dataEditPanel);
this.dataPanel.Controls.Add(this.label1);
this.dataPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataPanel.Location = new System.Drawing.Point(0, 0);
this.dataPanel.Name = "dataPanel";
this.dataPanel.Size = new System.Drawing.Size(397, 391);
this.dataPanel.TabIndex = 1;
//
// dataTextBox
//
this.dataTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataTextBox.Font = new System.Drawing.Font("Lucida Console", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.dataTextBox.Location = new System.Drawing.Point(0, 18);
this.dataTextBox.Name = "dataTextBox";
this.dataTextBox.ReadOnly = true;
this.dataTextBox.Size = new System.Drawing.Size(397, 333);
this.dataTextBox.TabIndex = 2;
this.dataTextBox.Text = "dataTextBox";
//
// dataEditPanel
//
this.dataEditPanel.Controls.Add(this.redoButton);
this.dataEditPanel.Controls.Add(this.undoButton);
this.dataEditPanel.Controls.Add(this.modifyButton);
this.dataEditPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.dataEditPanel.Location = new System.Drawing.Point(0, 351);
this.dataEditPanel.Name = "dataEditPanel";
this.dataEditPanel.Size = new System.Drawing.Size(397, 40);
this.dataEditPanel.TabIndex = 1;
//
// redoButton
//
this.redoButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.redoButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.redoButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.redoButton.ImageIndex = 0;
this.redoButton.ImageList = this.menuImageList;
this.redoButton.Location = new System.Drawing.Point(271, 8);
this.redoButton.Name = "redoButton";
this.redoButton.Size = new System.Drawing.Size(120, 23);
this.redoButton.TabIndex = 2;
this.redoButton.Text = "&Redo";
this.redoButton.Click += new System.EventHandler(this.redoMenuItem_Click);
//
// undoButton
//
this.undoButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.undoButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.undoButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.undoButton.ImageIndex = 0;
this.undoButton.Location = new System.Drawing.Point(143, 8);
this.undoButton.Name = "undoButton";
this.undoButton.Size = new System.Drawing.Size(120, 23);
this.undoButton.TabIndex = 1;
this.undoButton.Text = "&Undo";
this.undoButton.Click += new System.EventHandler(this.undoMenuItem_Click);
//
// modifyButton
//
this.modifyButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.modifyButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.modifyButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.modifyButton.ImageIndex = 0;
this.modifyButton.Location = new System.Drawing.Point(15, 8);
this.modifyButton.Name = "modifyButton";
this.modifyButton.Size = new System.Drawing.Size(120, 23);
this.modifyButton.TabIndex = 0;
this.modifyButton.Text = "&Modify";
this.modifyButton.Click += new System.EventHandler(this.modifyMenuItem_Click);
//
// label1
//
this.label1.Dock = System.Windows.Forms.DockStyle.Top;
this.label1.Location = new System.Drawing.Point(0, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(397, 18);
this.label1.TabIndex = 0;
this.label1.Text = "data: ";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// undoRedoPanel
//
this.undoRedoPanel.Controls.Add(this.undoTextBox);
this.undoRedoPanel.Controls.Add(this.horSplitter);
this.undoRedoPanel.Controls.Add(this.redoPanel);
this.undoRedoPanel.Controls.Add(this.label2);
this.undoRedoPanel.Dock = System.Windows.Forms.DockStyle.Right;
this.undoRedoPanel.Location = new System.Drawing.Point(400, 0);
this.undoRedoPanel.Name = "undoRedoPanel";
this.undoRedoPanel.Size = new System.Drawing.Size(344, 391);
this.undoRedoPanel.TabIndex = 2;
//
// undoTextBox
//
this.undoTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.undoTextBox.Font = new System.Drawing.Font("Lucida Console", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.undoTextBox.Location = new System.Drawing.Point(0, 18);
this.undoTextBox.Name = "undoTextBox";
this.undoTextBox.ReadOnly = true;
this.undoTextBox.Size = new System.Drawing.Size(344, 178);
this.undoTextBox.TabIndex = 2;
this.undoTextBox.Text = "undoTextBox";
//
// horSplitter
//
this.horSplitter.Dock = System.Windows.Forms.DockStyle.Bottom;
this.horSplitter.Location = new System.Drawing.Point(0, 196);
this.horSplitter.Name = "horSplitter";
this.horSplitter.Size = new System.Drawing.Size(344, 3);
this.horSplitter.TabIndex = 11;
this.horSplitter.TabStop = false;
//
// redoPanel
//
this.redoPanel.Controls.Add(this.redoTextBox);
this.redoPanel.Controls.Add(this.label3);
this.redoPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.redoPanel.Location = new System.Drawing.Point(0, 199);
this.redoPanel.Name = "redoPanel";
this.redoPanel.Size = new System.Drawing.Size(344, 192);
this.redoPanel.TabIndex = 10;
//
// redoTextBox
//
this.redoTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.redoTextBox.Font = new System.Drawing.Font("Lucida Console", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.redoTextBox.Location = new System.Drawing.Point(0, 18);
this.redoTextBox.Name = "redoTextBox";
this.redoTextBox.ReadOnly = true;
this.redoTextBox.Size = new System.Drawing.Size(344, 174);
this.redoTextBox.TabIndex = 10;
this.redoTextBox.Text = "redoTextBox";
//
// label3
//
this.label3.Dock = System.Windows.Forms.DockStyle.Top;
this.label3.Location = new System.Drawing.Point(0, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(344, 18);
this.label3.TabIndex = 9;
this.label3.Text = " redo differences: ";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label2
//
this.label2.Dock = System.Windows.Forms.DockStyle.Top;
this.label2.Location = new System.Drawing.Point(0, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(344, 18);
this.label2.TabIndex = 1;
this.label2.Text = " undo differences: ";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// verSplitter
//
this.verSplitter.Dock = System.Windows.Forms.DockStyle.Right;
this.verSplitter.Location = new System.Drawing.Point(397, 0);
this.verSplitter.Name = "verSplitter";
this.verSplitter.Size = new System.Drawing.Size(3, 391);
this.verSplitter.TabIndex = 3;
this.verSplitter.TabStop = false;
//
// openFileDialog
//
this.openFileDialog.Filter = "Xml files|*.xml";
this.openFileDialog.RestoreDirectory = true;
//
// saveFileDialog
//
this.saveFileDialog.Filter = "Xml files|*.xml";
this.saveFileDialog.RestoreDirectory = true;
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.AutoScroll = true;
this.ClientSize = new System.Drawing.Size(744, 409);
this.Controls.Add(this.dataPanel);
this.Controls.Add(this.verSplitter);
this.Controls.Add(this.undoRedoPanel);
this.Controls.Add(this.statusBar1);
this.KeyPreview = true;
this.Menu = this.mainMenu;
this.Name = "MainForm";
this.Text = "Wml Demo";
this.Load += new System.EventHandler(this.MainForm_Load);
this.dataPanel.ResumeLayout(false);
this.dataEditPanel.ResumeLayout(false);
this.undoRedoPanel.ResumeLayout(false);
this.redoPanel.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new MainForm());
}
private WmlTransactionLog transactionLog = new WmlTransactionLog();
private JobPosition topJobPosition;
private int modifyCount;
#region Form Events
private void MainForm_Load(object sender, System.EventArgs e)
{
topJobPosition = new JobPosition();
topJobPosition.Randomize();
modifyCount = 1;
transactionLog.OnStateModified += new WmlTransactionLogNotification (OnModified);
transactionLog.CurrentState = topJobPosition;
}
#endregion
#region Menu & Button Events
private void exitMenuItem_Click(object sender, System.EventArgs e)
{
Close();
}
private void newMenuItem_Click(object sender, System.EventArgs e)
{
topJobPosition = new JobPosition();
topJobPosition.Randomize();
modifyCount = 1;
transactionLog.CurrentState = topJobPosition;
}
private void openMenuItem_Click(object sender, System.EventArgs e)
{
if (openFileDialog.ShowDialog() != DialogResult.OK)
return;
JobPosition topJobPosition0;
try
{
topJobPosition0 = (JobPosition) WmlSerializer.Deserialize (openFileDialog.FileName, typeof (JobPosition));
}
catch (Exception ex)
{
MessageBox.Show (this, "Error opening file: \r\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
topJobPosition = topJobPosition0;
modifyCount = 1;
transactionLog.CurrentState = topJobPosition;
}
private void saveAsMenuItem_Click(object sender, System.EventArgs e)
{
if (saveFileDialog.ShowDialog() != DialogResult.OK)
return;
try
{
WmlSerializer.Serialize (topJobPosition, saveFileDialog.FileName);
}
catch (Exception ex)
{
MessageBox.Show (this, "Error saving file: \r\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void modifyMenuItem_Click(object sender, System.EventArgs e)
{
WmlTransaction transaction = transactionLog.BeginTransaction("Modify " + modifyCount);
try
{
// keep on looping until we have made a random change
do
{
topJobPosition.Randomize();
}
while (WmlSerializer.Equals (transaction.PreviousState, topJobPosition));
modifyCount++;
transaction.Commit();
}
catch (Exception ex)
{
transaction.RollBack();
// show any validation errors (none in this demo)
MessageBox.Show (this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void undoMenuItem_Click(object sender, System.EventArgs e)
{
transactionLog.RollBack();
}
private void redoMenuItem_Click(object sender, System.EventArgs e)
{
transactionLog.RollForward();
}
private void showTypeInformationMenuItem_Click(object sender, System.EventArgs e)
{
showTypeInformationMenuItem.Checked = !showTypeInformationMenuItem.Checked;
if (showTypeInformationMenuItem.Checked)
dataTextBox.Text = WmlSerializeTypeInfo.Types_ToString();
else
RefreshView();
}
private void aboutMenuItem_Click(object sender, System.EventArgs e)
{
MessageBox.Show (this, "Wml Demo", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
#endregion
private void RefreshView()
{
dataTextBox.Text = WmlSerializer.ToString (topJobPosition);
modifyButton.Text = "&Modify " + modifyCount;
modifyMenuItem.Text = "&Modify " + modifyCount;
showTypeInformationMenuItem.Checked = false;
if (transactionLog.CanRollBack)
{
undoTextBox.Text = WmlSerializer.ToString (transactionLog.RollBackTransaction.Difference);
undoButton.Text = "&Undo " + transactionLog.RollBackTransaction.Name;
undoButton.Enabled = true;
undoMenuItem.Text = "&Undo " + transactionLog.RollBackTransaction.Name;
undoMenuItem.Enabled = true;
undoMenuItem.Visible = false;
undoMenuItem.Visible = true; // HACK: toggling visible forces the menuItem to remeasure itself
}
else
{
undoTextBox.Text = "";
undoButton.Text = "&Undo";
undoButton.Enabled = false;
undoMenuItem.Text = "&Undo";
undoMenuItem.Enabled = false;
}
if (transactionLog.CanRollForward)
{
redoTextBox.Text = WmlSerializer.ToString (transactionLog.RollForwardTransaction.Difference);
redoButton.Text = "&Redo " + transactionLog.RollForwardTransaction.Name;
redoButton.Enabled = true;
redoMenuItem.Text = "&Redo " + transactionLog.RollForwardTransaction.Name;
redoMenuItem.Enabled = true;
redoMenuItem.Visible = false;
redoMenuItem.Visible = true; // HACK: toggling visible forces the menuItem to remeasure itself
}
else
{
redoTextBox.Text = "";
redoButton.Text = "&Redo";
redoButton.Enabled = false;
redoMenuItem.Text = "&Redo";
redoMenuItem.Enabled = false;
}
}
/// <summary>
/// Called when WmlTransactionLog detects a change to our data that its tracking.
/// Show the data and update the UI
/// </summary>
private void OnModified (WmlTransactionLog transactionLog)
{
RefreshView();
}
}
}