Click here to Skip to main content
15,940,246 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello everyone
I need help from someone
I am creating an application in this case I have encapsulated a wpf control (virtual keyboard) in a form and I would like it to open automatically hiding and moving the mouse, my problem is that the movement of the mouse control panel opens an indefinite number of times
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Threading;
using System.Windows.Threading;
using System.Windows.Interop;
using System.Runtime.InteropServices;
using System.ComponentModel;
using System.Windows.Forms;
using System.Windows.Markup;
using System.Diagnostics;
using System.Reflection;

namespace BensOSK
{
    /// <summary>
    /// Interaction logic for BensOnScreenKeyboardWindow.xaml
    /// </summary>
    public partial class BensOnScreenKeyboardWindow : Window
    {
        public EventHandler handler;
        /// <summary>
        /// Create a new BensOnScreenKeyboardWindow
        /// </summary>

        public BensOnScreenKeyboardWindow()
        {
            InitializeComponent();
            // add keyboard

            this.keyGrid.Children.Add(new BensOnScreenKeyboard(this));
             
             handler = delegate
                   {
                       DispatcherTimer timer = new DispatcherTimer();
                       timer.Interval = TimeSpan.FromSeconds(10);
                       timer.Tick += delegate
                       {
                           if (timer != null)
                           {
                               timer.Stop();
                               timer = null;
                               System.Windows.Interop.ComponentDispatcher.ThreadIdle -= handler;
                               this.Hide();
                               System.Windows.Interop.ComponentDispatcher.ThreadIdle += handler;
                           }
                       };
                       timer.Start();
                       Dispatcher.CurrentDispatcher.Hooks.OperationPosted += delegate
                       {
                           if (timer != null)
                               timer.Stop();
                           timer = null;
                       };
                   };
            ComponentDispatcher.ThreadIdle += handler;

        }
        

        /// <summary>
        /// Create a new BensOnScreenKeyboardWindow
        /// </summary>
        /// <param name="focusableElement">Specifies element to hold keyboards focus</param>
        public BensOnScreenKeyboardWindow(IInputElement focusableElement)
        {
            InitializeComponent();
            // add keyboard
            this.keyGrid.Children.Add(new BensOnScreenKeyboard(focusableElement));



        }

        /// <summary>
        /// Setup this window
        /// </summary>
        private void setupKeyboardWindow()
        {
            // set top
            this.Top = SystemParameters.PrimaryScreenHeight - this.Height;
            // set left
            this.Left = 150;

            // set width
            this.Width = SystemParameters.PrimaryScreenWidth;
        }

        /// <summary>
        /// Set the apps skin
        /// </summary>
        /// <param name="skinName"></param>
        private void setSkin(String skinName)
        {
            // create uri to skin
            Uri skinUri = new Uri(String.Format("/Skins/{0}.xaml", skinName), UriKind.Relative);
            // tell app to load skins
            App app = System.Windows.Application.Current as App;
            // load skins
            app.ApplySkin(skinUri);
        }

        private void Window_Initialized(object sender, EventArgs e)
        {
            // setup
            this.setupKeyboardWindow();



        }

        private void normalButton_Click(object sender, RoutedEventArgs e)
        {            // set skin
            this.setSkin(normalButton.CommandParameter.ToString());
        }

        private void blackButton_Click(object sender, RoutedEventArgs e)
        {
            // set skin
            this.setSkin(blackButton.CommandParameter.ToString());
        }

        private void blueButton_Click(object sender, RoutedEventArgs e)
        {
            // set skin
            this.setSkin(blueButton.CommandParameter.ToString());
        }

        

                


            }
        }


this is the code of the control
Posted

1 solution

this is the code of form
C#
<pre lang="c#">
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Windows.Interop;
using System.Windows.Threading;
using System.Windows;
namespace GEA
{
    public partial class Form2 : Form
    {
        public void DisableActiveFormControls()
        { Form currentform = Form.ActiveForm; }

        public Form2()
        {
            InitializeComponent();

        }

        private void cliForBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.cliForBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this.geaDataSet);

        }




        private void Form2_Load(object sender, EventArgs e)
        {
            // TODO: questa riga di codice carica i dati nella tabella 'geaDataSet.IdTipoCliFor'. È possibile spostarla o rimuoverla se necessario.
            this.idTipoCliForTableAdapter.Fill(this.geaDataSet.IdTipoCliFor);
            // TODO: questa riga di codice carica i dati nella tabella 'geaDataSet.CliFor'. È possibile spostarla o rimuoverla se necessario.
            this.cliForTableAdapter.Fill(this.geaDataSet.CliFor);

        }

        private void iDTextBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void nomeTextBox_TextChanged(object sender, EventArgs e)
        {


        }





        private void cognomeTextBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void ragione_SocialeTextBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void partita_IvaTextBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void codice_FiscaleTextBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void indirizzoTextBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void cittaTextBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void provinciaTextBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void capTextBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void bancaTextBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void Form2_MouseMove(object sender, MouseEventArgs e)
        {
            BensOSK.BensOnScreenKeyboardWindow benosk = new BensOSK.BensOnScreenKeyboardWindow();



            benosk.Show();
        }


        
        
    }
}


I tried searching but I could not solve the problem, I'm not a professional programmer, after a few attempts, I apologize for the English but I am Italian
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900