Horizon – Rev 8

Subversion Repositories:
Rev:
using System;
using System.Windows.Forms;
using Horizon.Utilities;

namespace Horizon.Snapshots
{
    public partial class SnapshotNoteForm : Form
    {
        #region Private Delegates, Events, Enums, Properties, Indexers and Fields

        private readonly SnapshotManagerForm _snapshotManagerForm;

        #endregion

        #region Public Events & Delegates

        public event EventHandler<SaveNoteEventArgs> SaveNote;

        #endregion

        #region Constructors, Destructors and Finalizers

        public SnapshotNoteForm()
        {
            InitializeComponent();
        }

        public SnapshotNoteForm(SnapshotManagerForm snapshotManagerForm, SnapshotPreview snapshotPreview) : this()
        {
            _snapshotManagerForm = snapshotManagerForm;
            _snapshotManagerForm.PreviewRetrieved += SnapshotManagerForm_PreviewRetrieved;

            richTextBox1.InvokeIfRequired(richTextBox => { richTextBox.Text = snapshotPreview.Note; });
        }

        /// <summary>
        ///     Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && components != null)
            {
                components.Dispose();
            }

            _snapshotManagerForm.PreviewRetrieved -= SnapshotManagerForm_PreviewRetrieved;

            base.Dispose(disposing);
        }

        #endregion

        #region Event Handlers
        private void SnapshotNoteForm_Load(object sender, EventArgs e)
        {
            Utilities.WindowState.FormTracker.Track(this);
        }
        private void SnapshotManagerForm_PreviewRetrieved(object sender, PreviewRetrievedEventArgs e)
        {
            richTextBox1.InvokeIfRequired(richTextBox => { richTextBox.Text = e.SnapshotPreview.Note; });
        }

        private void Button1_Click(object sender, EventArgs e)
        {
            richTextBox1.InvokeIfRequired(richTextBox =>
            {
                SaveNote?.Invoke(this, new SaveNoteEventArgs(richTextBox.Text));
            });
        }

        private void Button2_Click(object sender, EventArgs e)
        {
            Close();
        }

        #endregion


    }
}

Generated by GNU Enscript 1.6.5.90.