天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

146 lines
4.5 KiB

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;
/// <summary>
/// 自动更新
/// </summary>
public static UpdateSetting UpdateSetting
{
get { return _updateSetting ?? (_updateSetting = GlobalConfig.GetConfigValues<UpdateSetting>(GlobalConfig.UpdateFileName)); }
set { _updateSetting = value; }
}
/// <summary>
/// 打开软键盘
/// </summary>
/// <param name="parentControl"></param>
/// <returns></returns>
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;
}
}
/// <summary>
/// 打开软键盘
/// </summary>
/// <param name="parentControl"></param>
/// <returns></returns>
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;
}
}
/// <summary>
/// 关闭软键盘
/// </summary>
/// <returns></returns>
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;
}
}
}