view Chronosv2/source/Shell.xaml.cs @ 18:8049f7c58c2b

Login form 75% there
author stevenh7776 stevenhollidge@hotmail.com
date Wed, 14 Mar 2012 18:06:36 +0700
parents 741981715d94
children
line wrap: on
line source

using System;
using System.Windows;
using System.Windows.Input;
using Chronos.Interop;
using Chronos.ViewModel;
using WinInterop = System.Windows.Interop;

namespace Chronos
{
    /// <summary>
    /// Shell Window
    /// </summary>
    public partial class Shell 
        : Window
    {
        #region · Constructors ·

        /// <summary>
        /// Initializes a new instance of the <see cref="Shell"/> class.
        /// </summary>
        public Shell()
        {
            InitializeComponent();
        }

        #endregion

        #region · Event Handlers ·

        protected override void  OnPreviewKeyDown(KeyEventArgs e)
        {
            if (e.SystemKey == Key.Space && e.Key == Key.System)
            {
                // Disable Window's ControlBox Menu
                e.Handled = true;
            }

            base.OnPreviewKeyDown(e);
        }

        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);

            IntPtr handle = (new WinInterop.WindowInteropHelper(this)).Handle;
            WinInterop.HwndSource.FromHwnd(handle).AddHook(new WinInterop.HwndSourceHook(Win32Interop.WindowProc));

            ShellViewModel vm = new ShellViewModel();
            vm.WindowState = System.Windows.WindowState.Maximized;

            this.DataContext = vm;
        }

        #endregion
    }
}