| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 | using MECF.Framework.Common.DataCenter;using MECF.Framework.UI.Client.CenterViews.Dialogs;using MECF.Framework.UI.Client.ClientViews.Dialogs;using OpenSEMI.ClientBase;using OpenSEMI.Ctrlib.Controls;using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Input;using TextBox2 = OpenSEMI.Ctrlib.Controls.TextBoxEx;namespace MECF.Framework.UI.Client.Themes.OceanBlue{    public partial class TextBoxEx3 : ResourceDictionary    {        public bool EnablePopupKeyboard { get; set; } = true;        public void OnClick(object sender, MouseButtonEventArgs e)        {            if (e.StylusDevice != null)            {                e.Handled = true;                return;            }            e.Handled = true;            if (sender is TextBox2)            {                TextBox2 textBox = sender as TextBox2;                string strRet = Show(sender, textBox.Text);                if (string.IsNullOrEmpty(strRet)) return;                if (strRet != textBox.Text)                {                    if (!textBox.AllowIsOutOfRangeSaveChange && textBox.IsOutOfRange(double.Parse(strRet)))                    {                        DialogBox.ShowInfo($"Out Of Range{textBox.MinValue}-{textBox.MaxValue}");                        return;                    }                    textBox.TextSaved = false;                    textBox.Text = strRet;                }            }            else if (sender is PasswordBox)            {                PasswordBox passwordBox = sender as PasswordBox;                string strRet = Show(sender, passwordBox.Password);                if (string.IsNullOrEmpty(strRet)) return;                passwordBox.Password = strRet;            }        }        public void TextBox_PreviewTouchDown(object sender, TouchEventArgs e)        {            if (sender is TextBox2)            {                TextBox2 textBox = sender as TextBox2;                string strRet = Show(sender, textBox.Text);                if (string.IsNullOrEmpty(strRet)) return;                if (strRet != textBox.Text)                {                    if (!textBox.AllowIsOutOfRangeSaveChange && textBox.IsOutOfRange(double.Parse(strRet)))                    {                        DialogBox.ShowInfo($"Out Of Range{textBox.MinValue}-{textBox.MaxValue}");                        return;                    }                    textBox.TextSaved = false;                    textBox.Text = strRet;                }            }            else if (sender is PasswordBox)            {                PasswordBox passwordBox = sender as PasswordBox;                string strRet = Show(sender, passwordBox.Password);                if (string.IsNullOrEmpty(strRet)) return;                passwordBox.Password = strRet;            }        }        public void OnLoaded(object sender, RoutedEventArgs e)        {            if (sender is TextBox2)            {                TextBox2 textBox = sender as TextBox2;                if (QueryDataClient.Instance.Service.GetConfig($"System.EnablePopupKeyboard") != null)                    EnablePopupKeyboard = (bool)QueryDataClient.Instance.Service.GetConfig($"System.EnablePopupKeyboard");                textBox.IsReadOnly = EnablePopupKeyboard;            }        }        private string Show(object sender, string strDefaultValue)        {            TextBox2 control = sender as TextBox2;            string strRet = string.Empty;            if (QueryDataClient.Instance.Service.GetConfig($"System.EnablePopupKeyboard") != null)                EnablePopupKeyboard = (bool)QueryDataClient.Instance.Service.GetConfig($"System.EnablePopupKeyboard");            if (!EnablePopupKeyboard) { return string.Empty; }            if (control.Tag != null && control.Tag.ToString().Contains("Number"))            {                NumberKeyboard numberKeyboard = new NumberKeyboard("", strDefaultValue);                numberKeyboard.KeepDecimals = control.KeepDecimals;                var point = control.PointFromScreen(new Point(0, 0));                double x = SystemParameters.WorkArea.Width;                double y = SystemParameters.WorkArea.Height;                if (-point.Y + control.ActualHeight + 5 + numberKeyboard.Height < y)                {                    numberKeyboard.Top = -point.Y + control.ActualHeight + 5;                }                else                {                    numberKeyboard.Top = -point.Y - numberKeyboard.Height - 5;                }                if (-point.X + numberKeyboard.Width < x)                {                    numberKeyboard.Left = -point.X;                }                else                {                    numberKeyboard.Left = -point.X - (numberKeyboard.Width - control.ActualWidth);                }                if ((bool)numberKeyboard.ShowDialog())                {                    strRet = numberKeyboard.ValueString;                }            }            //if (control.Tag != null && control.Tag.ToString().Equals("Number"))            //{            //    var point = control.PointFromScreen(new Point(0, 0));            //    double x = SystemParameters.WorkArea.Width;            //    double y = SystemParameters.WorkArea.Height;            //    NumberKeyborardNoMinus numberKeyboard = new NumberKeyborardNoMinus("", strDefaultValue,true,control.MaxValue,control.MinValue);            //    if (-point.Y + control.ActualHeight + 5 + numberKeyboard.Height < y)            //    {            //        numberKeyboard.Top = -point.Y + control.ActualHeight + 5;            //    }            //    else            //    {            //        numberKeyboard.Top = -point.Y - numberKeyboard.Height - 5;            //    }            //    if (-point.X + numberKeyboard.Width < x)            //    {            //        numberKeyboard.Left = -point.X;            //    }            //    else            //    {            //        numberKeyboard.Left = -point.X - (numberKeyboard.Width - control.ActualWidth);            //    }            //    if ((bool)numberKeyboard.ShowDialog()) strRet = numberKeyboard.ValueString;            //}            else if (control.Tag != null && control.Tag.ToString().Contains("None"))            {                return string.Empty;            }            else            {                FullKeyboard fullKeyboard = new FullKeyboard("", strDefaultValue);                var point = control.PointFromScreen(new Point(0, 0));                double x = SystemParameters.WorkArea.Width;                double y = SystemParameters.WorkArea.Height;                if (-point.Y + control.ActualHeight + 5 + fullKeyboard.Height < y)                {                    fullKeyboard.Top = -point.Y + control.ActualHeight + 5;                }                else                {                    fullKeyboard.Top = -point.Y - fullKeyboard.Height - 5;                }                if (-point.X + fullKeyboard.Width < x)                {                    fullKeyboard.Left = -point.X;                }                else                {                    fullKeyboard.Left = -point.X - (fullKeyboard.Width - control.ActualWidth);                }                if ((bool)fullKeyboard.ShowDialog()) strRet = fullKeyboard.ValueString;            }            return strRet;        }    }}
 |