/// <summary>
        /// Mains the window initialized.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        /// <exception cref="ArgumentNullException">main Window WorkArea is <c>null</c>.</exception>
        private void MainWindowInitialized(object sender, EventArgs e)
        {
            if (this.mainWindow.WorkArea == null)
            {
                throw new ArgumentNullException("mainWindow", "No Designer!");
            }

            var workArea = this.mainWindow.WorkArea;

            // the global ApplicationCommands adding.
            // this.designerCanvas.CommandBindings.Add(new CommandBinding(ApplicationCommands.New, New_Executed));
            workArea.AddCommandBinding(ApplicationCommands.New, this.NewExecuted);
            workArea.AddCommandBinding(ApplicationCommands.Open, this.OpenExecuted);
            workArea.AddCommandBinding(ApplicationCommands.Save, this.SaveExecuted, this.SaveEnabled);
            workArea.AddCommandBinding(ApplicationCommands.Print, this.PrintExecuted);

            // this.designerCanvas.CommandBindings.Add(new CommandBinding(this.PasteCommand, this.Paste_Executed, Paste_Enabled));
            workArea.AddCommandBinding(ApplicationCommands.Cut, this.CutExecuted, this.CutEnabled);
            workArea.AddCommandBinding(ApplicationCommands.Copy, this.CopyExecuted, this.CopyEnabled);
            workArea.AddCommandBinding(ApplicationCommands.Paste, this.PasteExecuted, this.Paste_Enabled);
            workArea.AddCommandBinding(ApplicationCommands.Delete, this.DeleteExecuted, this.DeleteEnabled);

            // this.designerCanvas.CommandBindings.Add(new CommandBinding(SelectAllCommand, SelectAll_Executed));
            // SelectAllCommand.InputGestures.Add(new KeyGesture(Key.A, ModifierKeys.Control));
            // System.Windows.Input.KeyBinding f = new KeyBinding(
            // mainWindow.InputBindings.Add(new KeyBinding(this.SelectAllCommand, new KeyGesture(Key.A, ModifierKeys.Control)));
            this.mainWindow.InputBindings.Add(new KeyBinding(this.CancelCommand, new KeyGesture(Key.Escape)));

            // Apply KeyGestures from Attributes.
            CommandKeyGestureAttribute.ApplyKeyGestures(GetType(), this.mainWindow, this);

            // and finally detach from the Initialized event.
            this.mainWindow.Initialized -= this.MainWindowInitialized;
        }
        public void ApplyKeyGesturesTest()
        {
            var       instance     = new MyClass();
            Type      type         = instance.GetType();
            UIElement inputBinder  = instance.mainWindow;
            UIElement inputBinder2 = instance.subWindow;

            Assert.IsEmpty(inputBinder.InputBindings);
            Assert.IsEmpty(((RelayCommand)instance.FirstCommand).InputGestures);
            Assert.IsEmpty(inputBinder2.InputBindings);
            Assert.IsEmpty(((RelayCommand)instance.SecondCommand).InputGestures);

            // Apply gestures from "mainWindow"-targets to the mainWindow field.
            CommandKeyGestureAttribute.ApplyKeyGestures(type, inputBinder, instance);

            Assert.IsNotEmpty(inputBinder.InputBindings);
            Assert.AreEqual(1, inputBinder.InputBindings.Count);
            var inpBinding = inputBinder.InputBindings[0];

            Assert.AreSame(instance.FirstCommand, inpBinding.Command);
            var gesture = (KeyGesture)inpBinding.Gesture;

            Assert.AreEqual(Key.A, gesture.Key);
            Assert.AreEqual(ModifierKeys.Control, gesture.Modifiers);

            var rlay = (RelayCommand)instance.FirstCommand;

            Assert.IsNotEmpty(rlay.InputGestures);
            Assert.AreEqual(1, rlay.InputGestures.Count);
            var inpGesture = rlay.InputGestures[0];

            gesture = (KeyGesture)inpGesture;
            Assert.AreEqual(Key.A, gesture.Key);
            Assert.AreEqual(ModifierKeys.Control, gesture.Modifiers);

            Assert.IsEmpty(inputBinder2.InputBindings);
            Assert.IsEmpty(((RelayCommand)instance.SecondCommand).InputGestures);

            // Apply gestures from "subWindow"-targets to the subWindow field.
            CommandKeyGestureAttribute.ApplyKeyGestures(type, inputBinder2, instance);

            Assert.IsNotEmpty(inputBinder2.InputBindings);
            Assert.AreEqual(1, inputBinder2.InputBindings.Count);
            inpBinding = inputBinder2.InputBindings[0];
            Assert.AreSame(instance.SecondCommand, inpBinding.Command);
            gesture = (KeyGesture)inpBinding.Gesture;
            Assert.AreEqual(Key.B, gesture.Key);
            Assert.AreEqual(ModifierKeys.Alt, gesture.Modifiers);

            rlay = (RelayCommand)instance.SecondCommand;
            Assert.IsNotEmpty(rlay.InputGestures);
            Assert.AreEqual(1, rlay.InputGestures.Count);
            inpGesture = rlay.InputGestures[0];
            gesture    = (KeyGesture)inpGesture;
            Assert.AreEqual(Key.B, gesture.Key);
            Assert.AreEqual(ModifierKeys.Alt, gesture.Modifiers);
        }
        public void ApplyKeyGesturesTest1()
        {
            // Todo: MockMe
            Type          type        = null; // TODO: Initialize to an appropriate value
            ICanInputBind inputBinder = null; // TODO: Initialize to an appropriate value
            object        instance    = null; // TODO: Initialize to an appropriate value

            CommandKeyGestureAttribute.ApplyKeyGestures(type, inputBinder, instance);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }