Ejemplo n.º 1
0
        public void LoadData(KeyPairList lst)
        {
            obj             = lst;
            lblThisKey.Text = obj.thisKey;
            //
            tbl = new System.Data.DataTable("Keys");
            tbl.Columns.Add();
            tbl.Columns.Add();
            //
            tbl.Columns[0].Caption    = "First key";
            tbl.Columns[0].ColumnName = "FirstKey";
            tbl.Columns[0].DataType   = typeof(string);
            tbl.Columns[0].MaxLength  = 8;
            //
            tbl.Columns[1].Caption    = "Result keys";
            tbl.Columns[1].ColumnName = "ResultKeys";
            tbl.Columns[1].DataType   = typeof(string);
            tbl.Columns[1].MaxLength  = 8;
            //
            object[] v;
            int      n = obj.Count;

            for (int i = 0; i < n; i++)
            {
                v    = new object[2];
                v[0] = obj[i].PreviousKey;
                v[1] = obj[i].Value;
                tbl.Rows.Add(v);
            }
            //
            dataGrid1.DataSource = tbl;
        }
Ejemplo n.º 2
0
 protected void OnClick0(EventArgs e)
 {
     if (IsRunMode)
     {
         if (!string.IsNullOrEmpty(_keysToSend))
         {
             KeyPair kp = null;
             if (_keyPairList != null && _keyPairList.Count > 0)
             {
                 kp = _keyPairList.GetCombinedKey();                        //get key-pair based on keyboard recording
                 if (kp != null)
                 {
                     int len = kp.PreviousKey.Length;                             //key-companiation
                     //remove the key-combination and then send the result keys
                     string s = "{BS " + len.ToString(System.Globalization.CultureInfo.InvariantCulture) + "}" + kp.Value;
                     System.Windows.Forms.SendKeys.Send(s);
                     //replace used key-companiation with the result keys
                     KeyPairList.ReplaceKey(len, kp.Value);
                     KeyPairList.PushKeyBuffer(_keysToSend);
                 }
             }
             if (kp == null)
             {
                 System.Windows.Forms.SendKeys.Send(_keysToSend);
                 //record keyboard
                 if (string.Compare(_keysToSend, "{BACKSPACE}", StringComparison.OrdinalIgnoreCase) == 0 ||
                     string.Compare(_keysToSend, "{BS}", StringComparison.OrdinalIgnoreCase) == 0 ||
                     string.Compare(_keysToSend, "{BKSP}", StringComparison.OrdinalIgnoreCase) == 0)
                 {
                     KeyPairList.PopKeyBuffer();
                 }
                 else if (string.Compare(_keysToSend, "{DELETE}", StringComparison.OrdinalIgnoreCase) == 0 ||
                          string.Compare(_keysToSend, "{DEL}", StringComparison.OrdinalIgnoreCase) == 0)
                 {
                 }
                 else if (_keysToSend.StartsWith("{", StringComparison.OrdinalIgnoreCase))
                 {
                 }
                 else
                 {
                     KeyPairList.PushKey(_keysToSend);
                 }
             }
         }
     }
     base.OnClick(e);
 }
        public object Clone()
        {
            KeyPairList obj = new KeyPairList();

            obj.thisKey = thisKey;
            int n = Count;

            if (n > 0)
            {
                KeyPair[] a = new KeyPair[n];
                for (int i = 0; i < n; i++)
                {
                    a[i] = this[i];
                }
                obj.SetList(a);
            }
            return(obj);
        }
Ejemplo n.º 4
0
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            KeyPairList l = value as KeyPairList;

            if (l != null)
            {
                if (typeof(string).Equals(destinationType))
                {
                    bool          bFirst = true;
                    StringBuilder sb     = new StringBuilder();
                    for (int i = 0; i < l.Count; i++)
                    {
                        KeyPair kv = l[i];
                        if (!string.IsNullOrEmpty(kv.PreviousKey))
                        {
                            string val = kv.Value;
                            if (!string.IsNullOrEmpty(val))
                            {
                                val = val.Replace(S_COLUMN, "::");
                                val = val.Replace(S_PIPE, "||");
                            }
                            string key = kv.PreviousKey.Replace(S_PIPE, "||").Replace(S_COLUMN, "::");
                            if (bFirst)
                            {
                                bFirst = false;
                            }
                            else
                            {
                                sb.Append(S_PIPE);
                            }
                            sb.Append(key);
                            sb.Append(S_COLUMN);
                            sb.Append(val);
                        }
                    }
                    return(sb.ToString());
                }
            }
            return(base.ConvertTo(context, culture, value, destinationType));
        }
Ejemplo n.º 5
0
 public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     if (context != null && context.Instance != null && provider != null)
     {
         IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
         if (edSvc != null)
         {
             KeyMapsConverter kc = new KeyMapsConverter();
             KeyPairList      kl = value as KeyPairList;
             if (kl == null)
             {
                 ButtonKey bk = context.Instance as ButtonKey;
                 if (bk != null)
                 {
                     kl = bk.Keys;
                 }
                 else
                 {
                     if (value is string)
                     {
                         kl = (KeyPairList)kc.ConvertFromInvariantString((string)value);
                     }
                     else
                     {
                         kl = new KeyPairList();
                     }
                 }
             }
             KeyPairList        kl0 = (KeyPairList)kl.Clone();
             dlgPropKeyPairList dlg = new dlgPropKeyPairList();
             dlg.LoadData(kl0);
             if (edSvc.ShowDialog(dlg) == DialogResult.OK)
             {
                 value = kc.ConvertTo(kl0, typeof(string));
             }
         }
     }
     return(value);
 }
Ejemplo n.º 6
0
 public override object ConvertFrom(ITypeDescriptorContext context,
                                    CultureInfo culture, object value)
 {
     if (value is string)
     {
         string      s = value as string;
         KeyPairList l = new KeyPairList();
         while (!string.IsNullOrEmpty(s))
         {
             string keyVal = pop(ref s, PIPE);
             if (!string.IsNullOrEmpty(keyVal))
             {
                 string key = pop(ref keyVal, COLUMN);
                 if (!string.IsNullOrEmpty(key))
                 {
                     l.SetKeyPair(key, keyVal);
                 }
             }
         }
         return(l);
     }
     return(null);
 }