示例#1
0
        /// <summary>
        /// Try and get the KeyInput which corresponds to the given Key and modifiers
        /// TODO: really think about this method
        /// </summary>
        internal bool TryGetKeyInput(Key key, ModifierKeys modifierKeys, out KeyInput keyInput)
        {
            // First just check and see if there is a direct mapping
            var keyType = new KeyType(key, modifierKeys);
            if (_cache.TryGetValue(keyType, out keyInput))
            {
                return true;
            }

            // Next consider only the shift key part of the requested modifier.  We can
            // re-apply the original modifiers later
            keyType = new KeyType(key, modifierKeys & ModifierKeys.Shift);
            if (_cache.TryGetValue(keyType, out keyInput))
            {
                // Reapply the modifiers
                keyInput = KeyInputUtil.ChangeKeyModifiers(keyInput, ConvertToKeyModifiers(modifierKeys));
                return true;
            }

            // Last consider it without any modifiers and reapply
            keyType = new KeyType(key, ModifierKeys.None);
            if (_cache.TryGetValue(keyType, out keyInput))
            {
                // Reapply the modifiers
                keyInput = KeyInputUtil.ChangeKeyModifiers(keyInput, ConvertToKeyModifiers(modifierKeys));
                return true;
            }

            return false;
        }
示例#2
0
    public KeySequence(string name, KeyType[] keys, Element prim, Element sec) {
    	this.name = name;
        _keys = keys;
        Primary = prim;
        Secondary = sec;

    }
 //---------------------------------------------------------------------
 // Ctors
 //---------------------------------------------------------------------
 public RainbowFolder(RainbowFolder value)
 {
     Type = value.Type;
     Key = value.Key;
     SmallIcon = value.SmallIcon;
     LargeIcon = value.LargeIcon;
 }
    public void AddIconByKeyType(KeyType keyType)
    {
        GameObject prefab = null;

        switch (keyType)
        {
            case KeyType.A:
                prefab = plantIcon;
                break;
            case KeyType.B:
                prefab = boneIcon;
                break;
            case KeyType.C:
                prefab = mineralIcon;
                break;
            case KeyType.D:
                prefab = fluidIcon;
                break;
        }

        if (prefab != null)
        {
            // set prefab position
            prefab.transform.position = new Vector3
            (
                transform.position.x + (_icons.Count - 1),
                transform.position.y,
                transform.position.z + (_icons.Count - 1)
            );
            
            GameObject newIcon = Instantiate(prefab);
            _icons.Add(newIcon);
        }
    }
 //---------------------------------------------------------------------
 // Public
 //---------------------------------------------------------------------
 public void CopyFrom(RainbowFolder target)
 {
     Type = target.Type;
     Key = target.Key;
     SmallIcon = target.SmallIcon;
     LargeIcon = target.LargeIcon;
 }
 public RainbowFolder(KeyType type, string key, Texture2D smallIcon, Texture2D largeIcon)
 {
     Type = type;
     Key = key;
     SmallIcon = smallIcon;
     LargeIcon = largeIcon;
 }
		public static byte[] Retrieve (KeyType kt)
		{
			string key = null;
			
			switch (kt) {
				case KeyType.Validation:
					key = keyValidation;
					break;

				case KeyType.Encryption:
					key = keyEncryption;
					break;

				default:
					throw new ArgumentException ("Unknown key type.");
			}

			if (key == null)
				return null;
			
			object o = null;

			try {
				RegistryKey v = OpenRegistryKey (key, false);
				o = v.GetValue ("AutoGenKey", null);
			} catch (Exception) {
				return null;
			}

			if (o == null || o.GetType () != typeof (byte[]))
				return null;
			return (byte[]) o;
		}
示例#8
0
 public KeyEventArgs(int scanCode, KeyType type, int value, int timeStamp)
 {
     ScanCode = scanCode;
     Type = type;
     Value = value;
     TimeStamp = timeStamp;
 }
示例#9
0
 /// <inheritdoc/>>
 public bool OnKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey)
 {
     bool result = false;
     Debug.WriteLine(String.Format("OnKeyEvent: KeyType: {0} 0x{1:X} Modifiers: {2}", type, windowsKeyCode, modifiers));
     // TODO: Handle MessageNeeded cases here somehow.
     return result;
 }
示例#10
0
 public Key(double time, double value, KeyType inFunction, BaseTweenType baseTweenType)
 {
     Time = time;
     Value = value;
     InFunction = inFunction;
     BaseTweenType = baseTweenType;
 }
示例#11
0
 public EntityKey(string value, KeyType type)
 {
     if (value == null) throw new ArgumentNullException("key");
     _value = value;
     _hashedValue = EntityBuilder.Fnv1Hash(_value);
     _type = type;
 }
示例#12
0
 public ArrowComponent(GameObject parent)
     : base(parent)
 {
     arrowKey = ArrowType.None;
     keyTimer = 0;
     keyPressed = KeyType.None;
 }
	public KeyActionConfig(KeyType type, int order, Action down, Action up)
	{
		Category = type;
        Order = order;
		KeyDownAction = down;
		KeyUpAction = up;
	}
 public ProtocolKeyAttribute(string name, string defaultValue, KeyUsagePhase phase, KeySender sender, KeyType type)
 {
     _name = name;
     _default = defaultValue;
     _phase = phase;
     _sender = sender;
     _type = type;
 }
 static int GetKey(KeyType keyType, ushort length, byte dec)
 {
     var result = 0;
     result |= (int)keyType << 24;
     result |= (int)dec << 16;
     result |= length;
     return result;
 }
示例#16
0
        public bool OnPreKeyEvent(IWebBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, bool isKeyboardShortcut)
        {
            bool block = false;
            if (KeyCommand != null)
                block = KeyCommand(this, windowsKeyCode);

            return block;
        }
示例#17
0
文件: Key.cs 项目: hj1980/Mosa
 /// <summary>
 /// Initializes a new instance of the <see cref="Key"/> class.
 /// </summary>
 public Key(char key)
 {
     keyType = KeyType.RegularKey;
     character = key;
     control = false;
     alt = false;
     shift = char.IsUpper(key);
 }
示例#18
0
		public KeyInfo( Key key )
		{
			m_KeyVal = key.KeyValue;
			m_Description = key.Description;
			m_MaxRange = key.MaxRange;
			m_Link = key.Link;
			m_Type = (KeyType)key.ItemID;
		}
示例#19
0
文件: Key.cs 项目: 54616E6E6572/Mosa
 /// <summary>
 /// Initializes a new instance of the <see cref="Key"/> class.
 /// </summary>
 public Key()
 {
     keyType = KeyType.NoKey;
     character = (char)0x00;
     control = false;
     alt = false;
     shift = false;
 }
示例#20
0
 public bool OnPreKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode,
     CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut)
 {
     if (windowsKeyCode == (int)Keys.F12)
     {
         Program.Form.ChromiumBrowser.ShowDevTools();
     }
     return false;
 }
 public ConverterSet this[KeyType keyType, ushort length = 0, byte dec = 0]
 {
     get {
         return _dictionary[ConverterSetDictionary.GetKey(keyType, length, dec)];
     }
     set {
         _dictionary[ConverterSetDictionary.GetKey(keyType, length, dec)] = value;
     }
 }
示例#22
0
 private static void waiting(KeyType type)
 {
     keySemaphore = KeyType.NOTHING;
     do
     {
             Thread.Sleep(200);
     } while(keySemaphore != type);
     keySemaphore = KeyType.NOTHING;
 }
示例#23
0
        public Key( KeyType type, uint LockVal, Item link )
            : base((int)type)
        {
            Weight = 1.0;

            m_MaxRange = 3;
            m_KeyVal = LockVal;
            m_Link = link;
        }
 /// <summary>
 /// Constructs a command to create a mobile service
 /// </summary>
 internal RegenerateMobileServiceKeyCommand(string serviceName, KeyType type = KeyType.Application)
 {
     OperationId = "mobileservices";
     ServiceType = "services";
     Name = serviceName;
     HttpVerb = HttpVerbPost;
     KeyType = type;
     HttpCommand = String.Format("mobileservices/{0}/regenerateKey?type={1}", serviceName.ToLower(), type.ToString().ToLower());
 }
 public BasicOAuthStoreConsumerKeyAndSecret(String key, String secret,
                                            KeyType type, String name, String pass)
 {
     consumerKey = key;
     consumerSecret = secret;
     keyType = type;
     certName = name;
     certPass = pass;
 }
示例#26
0
 private void ShowKeyType(KeyType type)
 {
     selectedType = type;
     labelTypeTitle.Text = "Key Type: " + type.Name;
     listBoxKeys.DataSource = new BindingList<Key>(selectedType.keys);
     listBoxKeys.DisplayMember = "Serial";
     listBoxKeys.SelectedIndex = -1;
     PopulateDoors();
 }
示例#27
0
 /// <summary>
 /// 删除注册表中的指定项
 /// </summary>
 /// <param name="keytype">注册表基项枚举</param>
 /// <param name="key">注册表中的项,不包括基项</param>
 /// <returns>返回布尔值,指定操作是否成功</returns>
 public void DeleteSubKey(KeyType keytype, string key)
 {
     RegistryKey rk = (RegistryKey)GetRegistryKey(keytype);
     RegistryKey software = rk.OpenSubKey(baseKey, true);
     if (software != null)
     {
         software.DeleteSubKeyTree(key);
     }
 }
示例#28
0
        internal KeySetForm()
        {
            this.result = Result.CANCEL;
            this.keyType = KeyType.SINGLE;
            KeyPreview = true;
            InitializeComponent();

            this._keyboardHook = new KeyboardHook();
            this._keyboardHook.KeyboardHooked += KeyHookEvent;
        }
示例#29
0
		public KeyInfo( GenericReader reader )
		{
			int version = reader.ReadInt();

			m_KeyVal = reader.ReadUInt();
			m_Description = reader.ReadString();
			m_MaxRange = reader.ReadInt();
			m_Link = reader.ReadItem();
			m_Type = (KeyType)reader.ReadInt();
		}
示例#30
0
 internal ColumnDef(
     int aColumnIndex,
     string aColumnName)
 {
     _ColumnIndex = aColumnIndex;
     _ColumnName = aColumnName;
     _DBType = "DBType.Int";
     _SystemType = "System.Int32";
     _KeyType = KeyType.NoKey;
 }
示例#31
0
 internal override Type GetPocoType(TypeDescription existing = null)
 {
     return(typeof(IDictionary <,>).MakeGenericType(KeyType.GetPocoType(existing), ValueType.GetPocoType(existing)));
 }
示例#32
0
 internal override void Seal(TypeDescription existing = null)
 {
     KeyType.Seal(existing);
     ValueType.Seal(existing);
 }
示例#33
0
 public static void SetKeyframeData(IBaseKeyframe keyframe, IKeyframeGroup group, KeyType keyType, SkyProfile profile)
 {
     KeyframeInspectorWindow.keyframe = keyframe;
     KeyframeInspectorWindow.@group   = group;
     KeyframeInspectorWindow.keyType  = keyType;
     KeyframeInspectorWindow.profile  = profile;
 }
示例#34
0
 public bool ContainsKey(KeyType id)
 {
     return(_items.ContainsKey(id));
 }
示例#35
0
        private async Task ChangePsw(KeyType keyType)
        {
            if (txtSelCard.Text == "")
            {
                MessageBox.Show("请先进行选卡操作!", "提示信息", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            if (txtOldKey.Text == "" || txtNewKey.Text == "")
            {
                MessageBox.Show("请在密码A编辑框和新密码编辑框输入相应密码!", "提示信息", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            byte[] keyA;
            if (txtOldKey.Text == "默认")
            {
                keyA = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
            }
            else
            {
                keyA = new byte[6];
                byte[] b = Encoding.ASCII.GetBytes(txtOldKey.Text);
                if (b.Length > 6)
                {
                    MessageBox.Show("密码A编辑框输入的密码超出长度!", "错误信息", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                b.CopyTo(keyA, 0);
            }

            var info = await i14443a.AuthKeyAsync(KeyType.KeyA, 15, keyA);

            this.Dispatcher.Invoke(new Action(() =>
            {
                txtMsg.Text = "发送的字节:" + info.GetSendByteStr();
                txtMsg.AppendText("\r\n接收的字节:" + info.GetRecvByteStr());
                txtMsg.AppendText("\r\n" + info.GetStatusStr());
            }));
            if (info.ReturnValue != ReturnMessage.Success)
            {
                return;
            }

            var info1 = await i14443a.ReadAsync(63);

            this.Dispatcher.Invoke(new Action(() =>
            {
                txtMsg.AppendText("\r\n\r\n发送的字节:" + info1.GetSendByteStr());
                txtMsg.AppendText("\r\n接收的字节:" + info1.GetRecvByteStr());
                txtMsg.AppendText("\r\n读取结果:" + info1.GetBlockDataStr());
                txtMsg.AppendText("\r\n" + info1.GetStatusStr());
            }));
            if (info1.ReturnValue != ReturnMessage.Success)
            {
                return;
            }

            byte[] newKey = new byte[6];
            byte[] b1     = Encoding.ASCII.GetBytes(txtNewKey.Text);
            if (b1.Length > 6)
            {
                MessageBox.Show("新密码超出长度!", "错误信息", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            b1.CopyTo(newKey, 0);

            byte[] newData = info1.BlockData;
            if (keyType == KeyType.KeyA)
            {
                newKey.CopyTo(newData, 0);
            }
            else
            {
                keyA.CopyTo(newData, 0);
                newKey.CopyTo(newData, 10);
            }

            var info2 = await i14443a.WriteAsync(63, newData);

            this.Dispatcher.Invoke(new Action(() =>
            {
                txtMsg.AppendText("\r\n\r\n发送的字节:" + info2.GetSendByteStr());
                txtMsg.AppendText("\r\n接收的字节:" + info2.GetRecvByteStr());
                txtMsg.AppendText("\r\n" + info2.GetStatusStr());
            }));
            if (info2.ReturnValue == ReturnMessage.Success)
            {
                if (keyType == KeyType.KeyA)
                {
                    txtOldKey.Text = txtNewKey.Text;
                }
            }
        }
示例#36
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MissingKeyException"/> class with serialized data.
 /// </summary>
 /// <param name="info">The <see cref="SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
 /// <param name="context">The <see cref="StreamingContext"/>  that contains contextual information about the source or destination.</param>
 protected MissingKeyException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     Name = info.GetString(nameof(Name));
     Type = (KeyType)info.GetValue(nameof(Type), Type.GetType());
 }
示例#37
0
 public CallbackList()
 {
     _nextId = 1;
     _items  = new Dictionary <KeyType, CallbackItem>();
     _index  = new Dictionary <CallbackType, KeyType>();
 }
示例#38
0
 public Result()
 {
     keyType = KeyType.Uninitialized;
     errNo   = 0;
     errInfo = new ErrInfo();
 }
示例#39
0
 internal override IEnumerable <string> Dependencies() => KeyType.Dependencies().Concat(ValueType.Dependencies());
示例#40
0
 public override string ToSql()
 {
     return($"map<{KeyType.ToSql()}, {ValueType.ToSql()}>");
 }
示例#41
0
 public KeyPressingWaitDescriptor(KeyType key)
     : this(new[] { key }, false)
 {
 }
示例#42
0
        /// <summary>
        /// 判断页面注入true或false
        /// </summary>
        /// <param name="server">服务器响应对象ServerInfo</param>
        /// <param name="isUseCode">是否使用状态码判断</param>
        /// <param name="key">关键字</param>
        /// <returns></returns>
        public static Boolean isTrue(ServerInfo server, String key, Boolean reverKey, KeyType keyType, int trueHTTPCode)
        {
            switch (keyType)
            {
            case KeyType.Key:

                //用关键字判断
                if (server.body.Length > 0 && server.body.IndexOf(key) != -1)
                {
                    if (reverKey)
                    {
                        return(false);
                    }
                    else
                    {
                        //判断httpcode是否一致
                        if (trueHTTPCode != 0 && server.code == trueHTTPCode)
                        {
                            return(true);
                        }
                        return(false);
                    }
                }
                else
                {
                    if (reverKey)
                    {
                        //判断httpcode是否一致
                        if (trueHTTPCode != 0 && server.code == trueHTTPCode)
                        {
                            return(true);
                        }
                        return(true);
                    }
                    return(false);
                }

            case KeyType.Reg:

                //用正则判断
                if (server.body.Length > 0 && Regex.IsMatch(server.body, key))
                {
                    if (reverKey)
                    {
                        return(false);
                    }
                    return(true);
                }
                else
                {
                    if (reverKey)
                    {
                        return(true);
                    }
                    return(false);
                }

            case KeyType.Code:
                //用状态码判断
                if (server.code > 0 && key.Equals(server.code + ""))
                {
                    if (reverKey)
                    {
                        return(false);
                    }
                    return(true);
                }
                else
                {
                    if (reverKey)
                    {
                        return(true);
                    }
                    return(false);
                }


            case KeyType.Time:
                //由于计数器有误差(可能客户端计数小于服务端,,如果页面正常响应时间非常快,可能导致返回时间可能提前,所以考虑设置一个误差值)
                int time = Tools.convertToInt(key);
                if (server.runTime > (time * 1000 - (time * deviation)))
                {
                    if (reverKey)
                    {
                        return(false);
                    }
                    return(true);
                }
                else
                {
                    if (reverKey)
                    {
                        return(true);
                    }
                    return(false);
                }

            case KeyType.EQLen:
                //用长度判断
                if (key.Equals(server.length.ToString()))
                {
                    if (reverKey)
                    {
                        return(false);
                    }
                    return(true);
                }
                else
                {
                    if (reverKey)
                    {
                        return(true);
                    }
                    return(false);
                }

            case KeyType.MaxLen:
                //用长度判断
                if (server.length > Tools.convertToInt(key))
                {
                    if (reverKey)
                    {
                        return(false);
                    }
                    return(true);
                }
                else
                {
                    if (reverKey)
                    {
                        return(true);
                    }
                    return(false);
                }

            case KeyType.MinLen:
                //用长度判断
                if (server.length < Tools.convertToInt(key))
                {
                    if (reverKey)
                    {
                        return(false);
                    }
                    return(true);
                }
                else
                {
                    if (reverKey)
                    {
                        return(true);
                    }
                    return(false);
                }
            }
            return(false);
        }
示例#43
0
        /// <summary>
        /// Calls DPAPI CryptProtectData function to encrypt an array of
        /// plaintext bytes.
        /// </summary>
        /// <param name="keyType">
        /// Defines type of encryption key to use. When user key is
        /// specified, any application running under the same user account
        /// as the one making this call, will be able to decrypt data.
        /// Machine key will allow any application running on the same
        /// computer where data were encrypted to perform decryption.
        /// Note: If optional entropy is specifed, it will be required
        /// for decryption.
        /// </param>
        /// <param name="plainTextBytes">
        /// Plaintext data to be encrypted.
        /// </param>
        /// <param name="entropyBytes">
        /// Optional entropy which - if specified - will be required to
        /// perform decryption.
        /// </param>
        /// <param name="description">
        /// Optional description of data to be encrypted. If this value is
        /// specified, it will be stored along with encrypted data and
        /// returned as a separate value during decryption.
        /// </param>
        /// <returns>
        /// Encrypted value.
        /// </returns>
        public static byte[] Encrypt(KeyType keyType,
                                     byte[] plainTextBytes,
                                     byte[] entropyBytes,
                                     string description)
        {
            // Make sure that parameters are valid.
            if (plainTextBytes == null)
            {
                plainTextBytes = new byte[0];
            }
            if (entropyBytes == null)
            {
                entropyBytes = new byte[0];
            }
            if (description == null)
            {
                description = String.Empty;
            }

            // Create BLOBs to hold data.
            DATA_BLOB plainTextBlob  = new DATA_BLOB();
            DATA_BLOB cipherTextBlob = new DATA_BLOB();
            DATA_BLOB entropyBlob    = new DATA_BLOB();

            // We only need prompt structure because it is a required
            // parameter.
            CRYPTPROTECT_PROMPTSTRUCT prompt =
                new CRYPTPROTECT_PROMPTSTRUCT();

            InitPrompt(ref prompt);

            try
            {
                // Convert plaintext bytes into a BLOB structure.
                try
                {
                    InitBLOB(plainTextBytes, ref plainTextBlob);
                }
                catch (Exception ex)
                {
                    throw new Exception(
                              "Cannot initialize plaintext BLOB.", ex);
                }

                // Convert entropy bytes into a BLOB structure.
                try
                {
                    InitBLOB(entropyBytes, ref entropyBlob);
                }
                catch (Exception ex)
                {
                    throw new Exception(
                              "Cannot initialize entropy BLOB.", ex);
                }

                // Disable any types of UI.
                int flags = CRYPTPROTECT_UI_FORBIDDEN;

                // When using machine-specific key, set up machine flag.
                if (keyType == KeyType.MachineKey)
                {
                    flags |= CRYPTPROTECT_LOCAL_MACHINE;
                }

                // Call DPAPI to encrypt data.
                bool success = CryptProtectData(ref plainTextBlob,
                                                description,
                                                ref entropyBlob,
                                                IntPtr.Zero,
                                                ref prompt,
                                                flags,
                                                ref cipherTextBlob);
                // Check the result.
                if (!success)
                {
                    // If operation failed, retrieve last Win32 error.
                    int errCode = Marshal.GetLastWin32Error();

                    // Win32Exception will contain error message corresponding
                    // to the Windows error code.
                    throw new Exception(
                              "CryptProtectData failed.", new Win32Exception(errCode));
                }

                // Allocate memory to hold ciphertext.
                byte[] cipherTextBytes = new byte[cipherTextBlob.cbData];

                // Copy ciphertext from the BLOB to a byte array.
                Marshal.Copy(cipherTextBlob.pbData,
                             cipherTextBytes,
                             0,
                             cipherTextBlob.cbData);

                // Return the result.
                return(cipherTextBytes);
            }
            catch (Exception ex)
            {
                throw new Exception("DPAPI was unable to encrypt data.", ex);
            }
            // Free all memory allocated for BLOBs.
            finally
            {
                if (plainTextBlob.pbData != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(plainTextBlob.pbData);
                }

                if (cipherTextBlob.pbData != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(cipherTextBlob.pbData);
                }

                if (entropyBlob.pbData != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(entropyBlob.pbData);
                }
            }
        }
示例#44
0
 public CallbackItem(CallbackType callback, KeyType callbackId)
 {
     Callback   = callback;
     CallbackId = callbackId;
 }
示例#45
0
 /// <summary>
 /// Calls DPAPI CryptProtectData function to encrypt a plaintext
 /// string value. This function does not specify data description.
 /// </summary>
 /// <param name="keyType">
 /// Defines type of encryption key to use. When user key is
 /// specified, any application running under the same user account
 /// as the one making this call, will be able to decrypt data.
 /// Machine key will allow any application running on the same
 /// computer where data were encrypted to perform decryption.
 /// Note: If optional entropy is specifed, it will be required
 /// for decryption.
 /// </param>
 /// <param name="plainText">
 /// Plaintext data to be encrypted.
 /// </param>
 /// <param name="entropy">
 /// Optional entropy which - if specified - will be required to
 /// perform decryption.
 /// </param>
 /// <returns>
 /// Encrypted value in a base64-encoded format.
 /// </returns>
 public static string Encrypt(KeyType keyType,
                              string plainText,
                              string entropy)
 {
     return(Encrypt(keyType, plainText, entropy, String.Empty));
 }
示例#46
0
 /// <summary>
 ///  Initializes a new instance of the <see cref="MissingKeyException"/> class with a specified error message,
 ///  information about the missing key and a reference to the inner exception that is the cause of this exception.
 /// </summary>
 /// <param name="message">The error message that explains the reason for the exception.</param>
 /// <param name="name">The name of the key that is missing, or the rights ID of the missing key if <paramref name="keyType"/> is <see cref="KeyType.Title"/></param>
 /// <param name="keyType">The <see cref="KeyType"/> of the key that is missing.</param>
 public MissingKeyException(string message, string name, KeyType keyType)
     : base(message)
 {
     Name = name;
     Type = keyType;
 }
示例#47
0
        /// <inheritdoc/>>
        public bool OnPreKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut)
        {
            const int WM_SYSKEYDOWN = 0x104;
            const int WM_KEYDOWN    = 0x100;
            const int WM_KEYUP      = 0x101;
            const int WM_SYSKEYUP   = 0x105;
            const int WM_CHAR       = 0x102;
            const int WM_SYSCHAR    = 0x106;
            const int VK_TAB        = 0x9;
            const int VK_LEFT       = 0x25;
            const int VK_UP         = 0x26;
            const int VK_RIGHT      = 0x27;
            const int VK_DOWN       = 0x28;

            isKeyboardShortcut = false;

            // Don't deal with TABs by default:
            // TODO: Are there any additional ones we need to be careful of?
            // i.e. Escape, Return, etc...?
            if (windowsKeyCode == VK_TAB || windowsKeyCode == VK_LEFT || windowsKeyCode == VK_UP || windowsKeyCode == VK_DOWN || windowsKeyCode == VK_RIGHT)
            {
                return(false);
            }

            var result = false;

            var control = browserControl as Control;
            var msgType = 0;

            switch (type)
            {
            case KeyType.RawKeyDown:
                if (isSystemKey)
                {
                    msgType = WM_SYSKEYDOWN;
                }
                else
                {
                    msgType = WM_KEYDOWN;
                }
                break;

            case KeyType.KeyUp:
                if (isSystemKey)
                {
                    msgType = WM_SYSKEYUP;
                }
                else
                {
                    msgType = WM_KEYUP;
                }
                break;

            case KeyType.Char:
                if (isSystemKey)
                {
                    msgType = WM_SYSCHAR;
                }
                else
                {
                    msgType = WM_CHAR;
                }
                break;

            default:
                Trace.Assert(false);
                break;
            }
            // We have to adapt from CEF's UI thread message loop to our fronting WinForm control here.
            // So, we have to make some calls that Application.Run usually ends up handling for us:
            var state = PreProcessControlState.MessageNotNeeded;

            // We can't use BeginInvoke here, because we need the results for the return value
            // and isKeyboardShortcut. In theory this shouldn't deadlock, because
            // atm this is the only synchronous operation between the two threads.
            control.Invoke(new Action(() =>
            {
                var msg = new Message
                {
                    HWnd   = control.Handle,
                    Msg    = msgType,
                    WParam = new IntPtr(windowsKeyCode),
                    LParam = new IntPtr(nativeKeyCode)
                };

                // First comes Application.AddMessageFilter related processing:
                // 99.9% of the time in WinForms this doesn't do anything interesting.
                var processed = Application.FilterMessage(ref msg);
                if (processed)
                {
                    state = PreProcessControlState.MessageProcessed;
                }
                else
                {
                    // Next we see if our control (or one of its parents)
                    // wants first crack at the message via several possible Control methods.
                    // This includes things like Mnemonics/Accelerators/Menu Shortcuts/etc...
                    state = control.PreProcessControlMessage(ref msg);
                }
            }));

            if (state == PreProcessControlState.MessageNeeded)
            {
                // TODO: Determine how to track MessageNeeded for OnKeyEvent.
                isKeyboardShortcut = true;
            }
            else if (state == PreProcessControlState.MessageProcessed)
            {
                // Most of the interesting cases get processed by PreProcessControlMessage.
                result = true;
            }

            Debug.WriteLine("OnPreKeyEvent: KeyType: {0} 0x{1:X} Modifiers: {2}", type, windowsKeyCode, modifiers);
            Debug.WriteLine("OnPreKeyEvent PreProcessControlState: {0}", state);

            return(result);
        }
        bool IKeyboardHandler.OnPreKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut)
        {
            //    browserControl.Copy();

            /* double change = 0.1;
             *  Task<double> task = browser.GetZoomLevelAsync();
             *  task.ContinueWith(previous =>
             *  {
             *      if (previous.IsCompleted)
             *      {
             *          double currentLevel = previous.Result;
             *          browser.SetZoomLevel(currentLevel + change);
             *      }
             *      else
             *      {
             *          throw new InvalidOperationException("Unexpected failure of calling CEF->GetZoomLevelAsync", previous.Exception);
             *      }
             *  }, TaskContinuationOptions.ExecuteSynchronously);
             *  return true;*/

            //Debug.WriteLine("KeyType= {0} ,windowsKeyCode = {1} , modifiers={2}", type, windowsKeyCode, modifiers);
            if (modifiers.HasFlag(CefEventFlags.ControlDown) && windowsKeyCode == (int)Keys.Add)
            {
                _ctrlBrowser.tsZoomPlus_Click(this, EventArgs.Empty);
                return(true);
            }
            if (modifiers.HasFlag(CefEventFlags.ControlDown) && windowsKeyCode == (int)Keys.Subtract)
            {
                _ctrlBrowser.tsZoomMinus_Click(this, EventArgs.Empty);
                return(true);
            }
            if (modifiers == CefEventFlags.ControlDown && windowsKeyCode == (int)Keys.C)
            {
                _frmMain.last_command           = ContextMenuCommand.CMD_COPY;
                _frmMain.isCopyWithoutTranslate = false;
                browserControl.Copy();
                return(true);
            }
            else if (windowsKeyCode == (int)Keys.F2 && type != KeyType.Char)
            {
                _frmMain.last_command           = ContextMenuCommand.CMD_MY_COPY;
                _frmMain.isCopyWithoutTranslate = true;
                browserControl.Copy();
                return(true);
            }
            else
            {
                if (type != KeyType.Char)
                {
                    string kkey = string.Empty;
                    if (windowsKeyCode == (int)Keys.F1)
                    {
                        kkey = "f1";
                    }
                    //else if (windowsKeyCode == (int)Keys.F2) kkey = "f2";
                    else if (windowsKeyCode == (int)Keys.F3)
                    {
                        kkey = "f3";
                    }
                    else if (windowsKeyCode == (int)Keys.F4)
                    {
                        kkey = "f4";
                    }
                    else if (windowsKeyCode == (int)Keys.F5)
                    {
                        kkey = "f5";
                    }
                    else if (windowsKeyCode == (int)Keys.F6)
                    {
                        kkey = "f6";
                    }
                    else if (windowsKeyCode == (int)Keys.F7)
                    {
                        kkey = "f7";
                    }
                    else if (windowsKeyCode == (int)Keys.F8)
                    {
                        kkey = "f8";
                    }
                    else if (windowsKeyCode == (int)Keys.F9)
                    {
                        kkey = "f9";
                    }
                    else if (windowsKeyCode == (int)Keys.F10)
                    {
                        kkey = "f10";
                    }
                    else if (windowsKeyCode == (int)Keys.F11)
                    {
                        kkey = "f11";
                    }
                    else if (windowsKeyCode == (int)Keys.F12)
                    {
                        kkey = "f12";
                    }
                    MenuBrowser mb = GetMenuBrowserForShortcut(kkey);
                    if (mb != null)
                    {
                        _frmMain.last_command           = mb.Command;
                        _frmMain.isCopyWithoutTranslate = true;
                        browserControl.Copy();
                        return(true);
                    }
                }
            }
            isKeyboardShortcut = false;
            //true: Event is handeld
            return(false);
        }
示例#49
0
        public static GameObject CreateKnown(KnownGameObject type)
        {
            GameObject go = new GameObject();

            switch (type)
            {
            case KnownGameObject.Owliver:
            {
                go = new Owliver();
            }
            break;

            case KnownGameObject.Shop:
            {
                go = new Shop();
            }
            break;

            case KnownGameObject.Slurp:
            {
                go = new Slurp();
            }
            break;

            case KnownGameObject.Tankton:
            {
                go = new Tankton();
            }
            break;

            case KnownGameObject.DeathConfetti:
            {
                go = new DeathConfetti();
            }
            break;

            case KnownGameObject.Projectile:
            {
                go = new Projectile();
            }
            break;

            case KnownGameObject.BackgroundScreen:
            {
                go = new BackgroundScreen();
            }
            break;

            case KnownGameObject.Gate:
            {
                go = new Gate();
            }
            break;

            case KnownGameObject.Flora_Fir:
            case KnownGameObject.Flora_FirAlt:
            case KnownGameObject.Flora_Conifer:
            case KnownGameObject.Flora_ConiferAlt:
            case KnownGameObject.Flora_Oak:
            case KnownGameObject.Flora_Orange:
            case KnownGameObject.Flora_Bush:
            {
                FloraType floraType = (FloraType)(type - KnownGameObject.Flora_Fir);
                go = new Flora()
                {
                    TreeType = floraType,
                };
            }
            break;

            case KnownGameObject.Bonbon_Gold:
            case KnownGameObject.Bonbon_Red:
            {
                BonbonType bonbonType = (BonbonType)(type - KnownGameObject.Bonbon_Gold);
                go = new BonbonPickup()
                {
                    BonbonType = bonbonType,
                };
            }
            break;

            case KnownGameObject.Key_Gold:
            {
                KeyType keyType = (KeyType)(type - KnownGameObject.Key_Gold);
                go = new KeyPickup()
                {
                    KeyType = keyType,
                };
            }
            break;

            case KnownGameObject.ShopItem_FruitBowl:
            case KnownGameObject.ShopItem_FishingRod:
            case KnownGameObject.ShopItem_Stick:
            {
                ShopItemType itemType = (ShopItemType)(type - KnownGameObject.ShopItem_FruitBowl);
                go = new ShopItem()
                {
                    ItemType = itemType
                };
            }
            break;

            case KnownGameObject.Random_FirTree:
            {
                FloraType floraType = _random.Choose(FloraType.Fir, FloraType.Conifer);
                go = new Flora()
                {
                    TreeType = floraType,
                };
            }
            break;

            case KnownGameObject.Random_FirTreeAlt:
            {
                FloraType floraType = _random.Choose(FloraType.FirAlt, FloraType.ConiferAlt);
                go = new Flora()
                {
                    TreeType = floraType,
                };
            }
            break;

            case KnownGameObject.Random_OakTree:
            {
                FloraType floraType = _random.Choose(FloraType.Oak, FloraType.Orange);
                go = new Flora()
                {
                    TreeType = floraType,
                };
            }
            break;

            default:
                throw new ArgumentException("Unknown game object type.");
            }

            int instanceID = _knownCreationCount[(int)type]++;

            go.Name = $"{type}_{instanceID}";

            return(go);
        }
        //bool OnKeyEventww(IWebBrowser browser, KeyType type, int code, int modifiers, bool isSystemKey,
        //                       bool isAfterJavaScript)
        //{
        //    //var routedEvent = UIElement.KeyDownEvent;
        //    switch (type)
        //    {
        //        case KeyType.RawKeyDown:
        //        case KeyType.KeyDown:
        //            //routedEvent = isAfterJavaScript ? Keyboard.KeyDownEvent : Keyboard.PreviewKeyDownEvent;
        //            break;
        //        case KeyType.KeyUp:
        //            //routedEvent = isAfterJavaScript ? Keyboard.KeyUpEvent : Keyboard.PreviewKeyUpEvent;
        //            break;
        //        case KeyType.Char:
        //            // perhaps TextInputEvent ?
        //            break;
        //        default:
        //            /*Debug.Fail*/
        //            Trace.TraceWarning("Unsupported key event type: " + type);
        //            return false;
        //    }

        //    //if (type == KeyType.KeyUp)
        //    //host.Dispatcher.InvokeAsync(CommandManager.InvalidateRequerySuggested,
        //    //                            DispatcherPriority.ApplicationIdle);

        //    //return host.Dispatcher.Invoke(() =>
        //    //{
        //    //    var kb = Keyboard.PrimaryDevice;
        //    //    var ps = PresentationSource.FromDependencyObject(host);
        //    //    var ts = 0;
        //    //    var key = KeyInterop.KeyFromVirtualKey(code);

        //    //    var e = new KeyEventArgs(kb, ps, ts, key);
        //    //    e.RoutedEvent = routedEvent;

        //    //    Debug.WriteLine("Raising {0} {1}+{{{2}}}", routedEvent, key, Keyboard.Modifiers);
        //    //    host.RaiseEvent(e);

        //    //    return e.Handled;
        //    //});
        //    return true;
        //}

        bool IKeyboardHandler.OnKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey)
        {
            return(false);
        }
 internal bool TryReadString(OperationArguments operationArguments, KeyType key, out string value)
 => _tryReadString(this, operationArguments, key, out value);
示例#52
0
 public CallbackItem this[KeyType key] {
     get { return(_items[key]); }
 }
示例#53
0
 /// <summary>
 /// Gets the key code for the given type.
 /// </summary>
 /// <returns>The mathcing KeyCode or keyCode.None if there is no match.</returns>
 /// <param name="type">Key type.</param>
 /// <param name="keyNumber">Key number if this is an action key (ignored otherwise).</param>
 override public KeyCode GetKeyForType(KeyType type, int keyNumber)
 {
     return(input.GetKeyForType(type, keyNumber));
 }
 public override string ToString()
 {
     return(Principal + "@" + Realm + "," + KeyType.ToString());
 }
示例#55
0
 /// <summary>
 /// Sets the joystick axis that corresponds to a Platform PRO input axis.
 /// </summary>
 /// <returns>true</returns>
 /// <c>false</c>
 /// <param name="type">Type of key being set.</param>
 /// <param name="axis">Unity axis name.</param>
 /// <param name="reverseAxis">Should axis values be reversed.</param>
 override public bool SetAxis(KeyType type, string axis, bool reverseAxis)
 {
     Debug.LogWarning("BufferedInput should not be updated directly, update the underlying input implementation.");
     return(false);
 }
示例#56
0
 public bool OnPreKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut)
 {
     return(false);
 }
示例#57
0
 /// <summary>
 /// Sets the keyboayrd key that corresponds to a Platform PRO input key.
 /// </summary>
 /// <returns>true</returns>
 /// <c>false</c>
 /// <param name="type">Type of key being set.</param>
 /// <param name="keyNumber">The action key number or ignored if not setting an action key</param>
 /// <param name="keyCode">Key code.</param>
 override public bool SetKey(KeyType type, KeyCode keyCode, int keyNumber)
 {
     Debug.LogWarning("BufferedInput should not be updated directly, update the underlying input implementation.");
     return(false);
 }
 internal bool TryReadBoolean(OperationArguments operationArguments, KeyType key, out bool?value)
 => _tryReadBoolean(this, operationArguments, key, out value);
示例#59
0
 public Key(KeyType type) : this(type, 0)
 {
 }
示例#60
0
 public Key(KeyType type, uint LockVal) : this(type, LockVal, null)
 {
     m_KeyVal = LockVal;
 }