using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HZH_Controls.Controls;
using HZH_Controls.Forms;
namespace QMAPP.WinForm.Common
{
static class global
{
private static FrmAnchor m_frmAnchor;
public static int enterTime = 0;
private static int m_intSelectionStart;
private static int m_intSelectionLength;
private static MainForm.InvokeViewCloseHandler _invokeViewCloseHandler;
static global()
{
}
private static UpdateSetting _updateSetting;
///
/// 自动更新
///
public static UpdateSetting UpdateSetting
{
get { return _updateSetting ?? (_updateSetting = GlobalConfig.GetConfigValues(GlobalConfig.UpdateFileName)); }
set { _updateSetting = value; }
}
///
/// 打开软键盘
///
///
///
public static bool ShowKey(UCCombox parentControl)
{
try
{
m_intSelectionStart = parentControl.txtInput.SelectionStart;
m_intSelectionLength = parentControl.txtInput.SelectionLength;
parentControl.FindForm().ActiveControl = parentControl;
parentControl.FindForm().ActiveControl = parentControl.txtInput;
UCKeyBorderAll key = new UCKeyBorderAll();
key.CharType = KeyBorderCharType.CHAR;
key.RetractClike += (a, b) => { m_frmAnchor.Hide(); };
m_frmAnchor = new FrmAnchor(parentControl, key);
m_frmAnchor.VisibleChanged += (a, b) =>
{
if (m_frmAnchor.Visible)
{
parentControl.txtInput.SelectionStart = m_intSelectionStart;
parentControl.txtInput.SelectionLength = m_intSelectionLength;
}
};
if (!m_frmAnchor.Visible) m_frmAnchor.Show(parentControl.FindForm());
return true;
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
///
/// 打开软键盘
///
///
///
public static bool ShowKey(TextBoxBase parentControl)
{
try
{
m_intSelectionStart = parentControl.SelectionStart;
m_intSelectionLength = parentControl.SelectionLength;
parentControl.FindForm().ActiveControl = parentControl;
//parentControl.FindForm().ActiveControl = parentControl;
UCKeyBorderAll key = new UCKeyBorderAll();
key.CharType = KeyBorderCharType.CHAR;
key.RetractClike += (a, b) => { m_frmAnchor.Hide(); };
m_frmAnchor = new FrmAnchor(parentControl, key);
m_frmAnchor.VisibleChanged += (a, b) =>
{
if (m_frmAnchor.Visible)
{
parentControl.SelectionStart = m_intSelectionStart;
parentControl.SelectionLength = m_intSelectionLength;
}
};
if (!m_frmAnchor.Visible) m_frmAnchor.Show(parentControl.FindForm());
return true;
}
catch (Exception e)
{
Console.WriteLine(e);
return false;
}
}
///
/// 关闭软键盘
///
///
public static bool HideKey()
{
try
{
if (m_frmAnchor != null)
{
if (m_frmAnchor.Visible) m_frmAnchor.Hide();
}
return true;
}
catch (Exception e)
{
Console.WriteLine(e);
return false;
}
}
public static MainForm.InvokeViewCloseHandler GetInvokeViewCloseHandler()
{
return _invokeViewCloseHandler;
}
public static void SetInvokeViewCloseHandler(MainForm.InvokeViewCloseHandler pHandler)
{
_invokeViewCloseHandler = pHandler;
}
}
}