/// <summary>
 /// Either create and show, or else re-attach to (if it's already up) the virtual keyboard.
 /// To be called from the desired target-Window that wants to use it.
 /// </summary>
 /// <param name="targetWindow">The Window that wants to be the owner of the virtual-keyboard Window and the target of it's output</param>
 public static void ShowOrAttachTo(IVirtualKeyboardInjectable targetWindow)
 {
     try
     {
         _desiredTargetWindow = targetWindow;
         // Evidently, for modal Windows I can't share user-focus with another Window unless I first close and then recreate it.
         // A shame. Seems like a waste of time. But I don't know of a work-around to it (yet).
         if (IsUp)
         {
             Console.WriteLine("VirtualKeyboard: re-attaching to a different Window.");
             VirtualKeyboard.The.Closed += new EventHandler(OnTheKeyboardClosed);
             VirtualKeyboard.The.Close();
             targetWindow.TheVirtualKeyboard = null;
         }
         else
         {
             VirtualKeyboard virtualKeyboard = ShowIt(targetWindow);
             targetWindow.TheVirtualKeyboard = virtualKeyboard;
         }
     }
     catch (Exception x)
     {
         Console.WriteLine("in VirtualKeyboard.ShowOrAttachTo: " + x.Message);
         IInterlocution inter = Application.Current as IInterlocution;
         if (inter != null)
         {
             inter.NotifyUserOfError("Well, now this is embarrassing.", "in VirtualKeyboard.ShowOrAttachTo.", x);
         }
     }
 }
        public static void ShowKeyboard(IVirtualKeyboardInjectable targetWindow, ref virtual_numpad myPointerToIt)
        {
            if (myPointerToIt != null)
            {

            }
            else
            {
                myPointerToIt = new virtual_numpad();
                myPointerToIt.ShowIt(targetWindow);
            }
        }
 /// <summary>
 /// Create (and return) the VirtualKeyboard, and Show it.
 /// This is the factory-method for instantiating and showing the virtual keyboard.
 /// </summary>
 /// <param name="parentWindow">The window that will accept input from the keyboard</param>
 /// <returns>a reference to the VirtualKeyboard</returns>
 private static VirtualKeyboard ShowIt(IVirtualKeyboardInjectable targetWindow)
 {
     if (_theVirtualKeyboard == null)
     {
         _theVirtualKeyboard = new VirtualKeyboard();
     }
     _theVirtualKeyboard.Owner         = (Window)targetWindow;
     _theVirtualKeyboard.ShowActivated = false;
     if (!_theVirtualKeyboard.IsLoaded)
     {
         _theVirtualKeyboard.Show();
     }
     _theVirtualKeyboard.TargetWindow = targetWindow;
     if (targetWindow.ControlToInjectInto != null)
     {
         targetWindow.ControlToInjectInto.Focus();
     }
     return(_theVirtualKeyboard);
 }
 private void ShowIt(IVirtualKeyboardInjectable targetWindow)
 {
     this.target_window = targetWindow;
     if (target_window != null)
         target_window.ControlToInjectInto.Focus();
 }
 /// <summary>
 /// Create (and return) the VirtualKeyboard, and Show it.
 /// This is the factory-method for instantiating and showing the virtual keyboard.
 /// </summary>
 /// <param name="parentWindow">The window that will accept input from the keyboard</param>
 /// <returns>a reference to the VirtualKeyboard</returns>
 private static VirtualKeyboard ShowIt(IVirtualKeyboardInjectable targetWindow)
 {
     if (_theVirtualKeyboard == null)
     {
         _theVirtualKeyboard = new VirtualKeyboard();
     }
     _theVirtualKeyboard.Owner = (Window)targetWindow;
     _theVirtualKeyboard.ShowActivated = false;
     if (!_theVirtualKeyboard.IsLoaded)
     {
         _theVirtualKeyboard.Show();
     }
     _theVirtualKeyboard.TargetWindow = targetWindow;
     if (targetWindow.ControlToInjectInto != null)
     {
         targetWindow.ControlToInjectInto.Focus();
     }
     return _theVirtualKeyboard;
 }
 /// <summary>
 /// Either create and show, or else re-attach to (if it's already up) the virtual keyboard.
 /// To be called from the desired target-Window that wants to use it.
 /// </summary>
 /// <param name="targetWindow">The Window that wants to be the owner of the virtual-keyboard Window and the target of it's output</param>
 public static void ShowOrAttachTo(IVirtualKeyboardInjectable targetWindow)
 {
     try
     {
         _desiredTargetWindow = targetWindow;
         // Evidently, for modal Windows I can't share user-focus with another Window unless I first close and then recreate it.
         // A shame. Seems like a waste of time. But I don't know of a work-around to it (yet).
         if (IsUp)
         {
             Console.WriteLine("VirtualKeyboard: re-attaching to a different Window.");
             VirtualKeyboard.The.Closed += new EventHandler(OnTheKeyboardClosed);
             VirtualKeyboard.The.Close();
             targetWindow.TheVirtualKeyboard = null;
         }
         else
         {
             VirtualKeyboard virtualKeyboard = ShowIt(targetWindow);
             targetWindow.TheVirtualKeyboard = virtualKeyboard;
         }
     }
     catch (Exception x)
     {
         Console.WriteLine("in VirtualKeyboard.ShowOrAttachTo: " + x.Message);
         IInterlocution inter = Application.Current as IInterlocution;
         if (inter != null)
         {
             inter.NotifyUserOfError("Well, now this is embarrassing.", "in VirtualKeyboard.ShowOrAttachTo.", x);
         }
     }
 }