wpf控件auto\show hide [英] wpf control auto\show hide
本文介绍了wpf控件auto\show hide的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好。
我需要某人的帮助
我正在创建一个应用程序,在这种情况下,我已经在一个表单中封装了一个wpf控件(虚拟键盘),我会喜欢打开自动隐藏和移动鼠标,我的问题是鼠标控制面板的移动无限次打开
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
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
推荐答案
这是表格代码
this is the code of form
<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
这篇关于wpf控件auto\show hide的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文