private void AddOprationAction(object sender, RoutedEventArgs e)
        {
            if (_oprationList == null)
                _oprationList = new List<Business.UserOperation>();
            OprationSetting setting = new OprationSetting();
            if (setting.ShowDialog() == true)
            {
                string name = setting.OprationName;
                Business.OprationType opType = Business.OprationType.Com;
                //  Console.Write(opType);
                if (setting.OprationType.ToLower() == "tcp") opType = Business.OprationType.TCP;
                else if (setting.OprationType.ToLower() == "udp") opType = Business.OprationType.UDP;
                else if (setting.OprationType.ToLower() == "串口") opType = Business.OprationType.Com;

                Business.DataType dType = Business.DataType.Character;
                if (setting.DataType.ToLower() == "十六进制") dType = Business.DataType.Hex;
                else if (setting.DataType.ToLower() == "字符串") dType = Business.DataType.Character;

                string daTa = setting.Data;
                int time = setting.Time;
                Object a = setting.Setting;
                Business.UserOperation temp = new Business.UserOperation(name, opType, dType, a, daTa, time);
                _oprationList.Add(temp);
                Refresh();

            }

        }
        private void opration_OnEditThis(object sender, EventArgs e)
        {
            Business.UserOperation oprationToEdit = (sender as UserOpration).MyOperation;
            Console.Write(_CurrentOperation);
            if (_CurrentOperation != null)
            {
                OprationSetting setting = new OprationSetting();
                setting.OprationName = (sender as UserOpration).MyOperation.Name;
                // Console.Write(setting.OprationName);
                setting.OprationType = GetOperationTypeString((sender as UserOpration).MyOperation.OpreationType);
                // Console.Write(setting.OprationType);
                setting.DataType = GetDataTypeString((sender as UserOpration).MyOperation.DataType);
                setting.Data     = (sender as UserOpration).MyOperation.Data;
                setting.Time     = (sender as UserOpration).MyOperation.Time;
                setting.Setting  = _CurrentOperation.Setting;

                if (setting.ShowDialog() == true)
                {
                    oprationToEdit.Name = setting.OprationName;
                    //  oprationToEdit.OpreationType=(Business.OprationType)Enum.Parse(typeof(Business.OprationType), setting.OprationType);
                    // oprationToEdit.DataType =(Business.DataType)Enum.Parse(typeof(Business.DataType),setting.DataType);
                    Business.OprationType opType = Business.OprationType.Com;
                    if (setting.OprationType.ToLower() == "tcp")
                    {
                        opType = Business.OprationType.TCP;
                    }
                    else if (setting.OprationType.ToLower() == "udp")
                    {
                        opType = Business.OprationType.UDP;
                    }
                    else if (setting.OprationType.ToLower() == "串口")
                    {
                        opType = Business.OprationType.Com;
                    }

                    Business.DataType dType = Business.DataType.Character;
                    if (setting.DataType.ToLower() == "十六进制")
                    {
                        dType = Business.DataType.Hex;
                    }
                    else if (setting.DataType.ToLower() == "字符串")
                    {
                        dType = Business.DataType.Character;
                    }

                    //oprationToEdit.Data = setting.Data;
                    //oprationToEdit.Time = setting.Time;
                    _CurrentOperation.Name          = setting.OprationName;
                    _CurrentOperation.OpreationType = opType;
                    _CurrentOperation.DataType      = dType;
                    _CurrentOperation.Setting       = setting.Setting;
                    _CurrentOperation.Data          = setting.Data;
                    _CurrentOperation.Time          = setting.Time;
                    Refresh();
                }
            }
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddOprationAction(object sender, RoutedEventArgs e)
        {
            if (_oprationList == null)
            {
                _oprationList = new List <Business.UserOperation>();
            }
            OprationSetting setting = new OprationSetting();

            if (setting.ShowDialog() == true)
            {
                string name = setting.OprationName;//名称
                Business.OprationType opType = Business.OprationType.Com;
                //  Console.Write(opType);
                if (setting.OprationType.ToLower() == "tcp")
                {
                    opType = Business.OprationType.TCP;
                }
                else if (setting.OprationType.ToLower() == "udp")
                {
                    opType = Business.OprationType.UDP;
                }
                else if (setting.OprationType.ToLower() == "串口")
                {
                    opType = Business.OprationType.Com;
                }

                Business.DataType dType = Business.DataType.Character;
                if (setting.DataType.ToLower() == "十六进制")
                {
                    dType = Business.DataType.Hex;
                }
                else if (setting.DataType.ToLower() == "字符串")
                {
                    dType = Business.DataType.Character;
                }

                string daTa = setting.Data;
                int    time = setting.Time;
                Object a    = setting.Setting;
                Business.UserOperation temp = new Business.UserOperation(name, opType, dType, a, daTa, time);
                _oprationList.Add(temp);

                /*
                 * _CurrentOperation.Name = setting.OprationName;
                 * _CurrentOperation.OpreationType = opType;
                 * _CurrentOperation.DataType = dType;
                 * _CurrentOperation.Setting = setting.Setting;
                 * _CurrentOperation.Data = daTa;
                 * _CurrentOperation.Time = time;
                 */
                Refresh();
            }
        }
        private void opration_OnEditThis(object sender, EventArgs e)
        {
            Business.UserOperation oprationToEdit = (sender as UserOpration).MyOperation;
            OprationSetting setting = new OprationSetting();
            setting.OprationName = (sender as UserOpration).MyOperation.Name;
            Console.Write(setting.OprationName);
            setting.OprationType = GetOperationTypeString((sender as UserOpration).MyOperation.OpreationType);
            Console.Write(setting.OprationType);
            setting.DataType = GetDataTypeString((sender as UserOpration).MyOperation.DataType);
            setting.Data = (sender as UserOpration).MyOperation.Data;
            setting.Time = (sender as UserOpration).MyOperation.Time;

            if (setting.ShowDialog() == true)
            {
                oprationToEdit.Name = setting.OprationName;
                //  oprationToEdit.OpreationType=(Business.OprationType)Enum.Parse(typeof(Business.OprationType), setting.OprationType);
                // oprationToEdit.DataType =(Business.DataType)Enum.Parse(typeof(Business.DataType),setting.DataType);
                Business.OprationType opType = Business.OprationType.Com;
                if (setting.OprationType.ToLower() == "tcp") opType = Business.OprationType.TCP;
                else if (setting.OprationType.ToLower() == "udp") opType = Business.OprationType.UDP;
                else if (setting.OprationType.ToLower() == "串口") opType = Business.OprationType.Com;

                Business.DataType dType = Business.DataType.Character;
                if (setting.DataType.ToLower() == "十六进制") dType = Business.DataType.Hex;
                else if (setting.DataType.ToLower() == "字符串") dType = Business.DataType.Character;
                oprationToEdit.Data = setting.Data;
                oprationToEdit.Time = setting.Time;
                Refresh();
            }
        }