view Chronosv2/source/Shell.xaml.cs @ 30:8d574f2d4174

Cleaned up client
author adminsh@apollo
date Wed, 21 Mar 2012 22:26:48 +0000
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
    }
}