Пример #1
0
 private void frmHotkeyEdit_Load(object sender, System.EventArgs e)
 {
     btnOk.Image          = Z.IconLibrary.Silk.Icon.Accept.GetImage();
     btnOk.ImageAlign     = ContentAlignment.MiddleLeft;
     btnCancel.Image      = Z.IconLibrary.Silk.Icon.Cancel.GetImage();
     btnCancel.ImageAlign = ContentAlignment.MiddleLeft;
     if (this.Hotkey == null)
     {
         this.Hotkey = new HotkeyKeys();
     }
     UcHotkeyMain.HotKey = this.Hotkey;
 }
 private void BindControls()
 {
     if (this.HotKey == null)
     {
         this.HotKey = new HotkeyKeys();
     }
     chkAlt.Checked           = this.HotKey.Alt;
     chkCtrl.Checked          = this.HotKey.Ctrl;
     chkDisableNative.Checked = this.HotKey.NativeBlock;
     chkInstallHook.Checked   = this.HotKey.InstallHook;
     chkLeftMod.Checked       = this.HotKey.Left;
     chkRightMod.Checked      = this.HotKey.Right;
     chkShift.Checked         = this.HotKey.Shift;
     chkUp.Checked            = this.HotKey.UP;
     chkWildcard.Checked      = this.HotKey.WildCard;
     chkWin.Checked           = this.HotKey.Win;
     ddlKeys1.SelectedItem    = this.HotKey.Key1.ToString();
     ddlKeys2.SelectedItem    = this.HotKey.Key2.ToString();
 }
        /// <summary>
        /// Method to Validate <see cref="command.hotkey"/> Value
        /// </summary>
        /// <returns>
        /// Returns true if Validation passes; Otherwise, false.
        /// </returns>
        protected string ValidateHotkey()
        {
            if (string.IsNullOrWhiteSpace(this.hotkey))
            {
                return(Properties.Resources.ErrorValueMutNotBeNull);
            }

            HotkeyKeys hks;

            if (HotkeyKeys.TryParse(this.hotkey, out hks))
            {
                if (Parent != null && Parent.Any(
                        x => string.Equals(x.hotkey, this.hotkey, StringComparison.CurrentCultureIgnoreCase) && !ReferenceEquals(x, this)))
                {
                    return(Properties.Resources.ErrorDuplicateNotAllowed);
                }
                return(string.Empty);
            }
            return(Properties.Resources.ErrorInvalidFormat);
        }
        /// <summary>
        /// Gets error Text of any Property error
        /// </summary>
        /// <param name="pName">The Property</param>
        /// <param name="hasError">True if the property has an error; Otherwise, false</param>
        /// <returns>
        /// String containing error message if the property has an error; Otherwise, Empty string.
        /// </returns>
        private string GetResult(PropertyNames pName, out bool hasError)
        {
            hasError = false;
            if (pName == PropertyNames.hotkey)
            {
                if (string.IsNullOrWhiteSpace(this.hotkey))
                {
                    hasError = true;
                    return(Properties.Resources.ErrorValueMutNotBeNull);
                }


                HotkeyKeys hks;
                if (HotkeyKeys.TryParse(this.hotkey, out hks))
                {
                    if (Parent != null && Parent.Any(
                            x => string.Equals(x.hotkey, this.hotkey, StringComparison.CurrentCultureIgnoreCase) && !ReferenceEquals(x, this)))
                    {
                        hasError = true;
                        return(Properties.Resources.ErrorDuplicateNotAllowed);
                    }
                    return(string.Empty);
                }
                hasError = true;
                return(Properties.Resources.ErrorInvalidFormat);
            }
            else if (pName == PropertyNames.name)
            {
                if (string.IsNullOrWhiteSpace(this.name))
                {
                    hasError = true;
                    return(Properties.Resources.ErrorValueMutNotBeNull);
                }
            }

            return(string.Empty);
        }