예제 #1
0
        internal void Load(BinaryReader reader)
        {
            ClearBindings();

            var bindingCount = reader.ReadInt32();

            for (int i = 0; i < bindingCount; i++)
            {
                var bindingSourceType = (BindingSourceType)reader.ReadInt32();

                if (bindingSourceType == BindingSourceType.DeviceBindingSource)
                {
                    var binding = new DeviceBindingSource();
                    binding.Load(reader);
                    AddBinding(binding);
                }

                if (bindingSourceType == BindingSourceType.KeyBindingSource)
                {
                    var binding = new KeyBindingSource();
                    binding.Load(reader);
                    AddBinding(binding);
                }

                if (bindingSourceType == BindingSourceType.MouseBindingSource)
                {
                    var binding = new MouseBindingSource();
                    binding.Load(reader);
                    AddBinding(binding);
                }
            }
        }
 Mouse ListenForControl()
 {
     for (var control = Mouse.None; control <= Mouse.Button9; control++)
     {
         if (MouseBindingSource.ButtonIsPressed(control))
         {
             return(control);
         }
     }
     return(Mouse.None);
 }
        public override bool Equals(object other)
        {
            if (other == null)
            {
                return(false);
            }
            MouseBindingSource mouseBindingSource = other as MouseBindingSource;

            if (mouseBindingSource != null)
            {
                return(Control == mouseBindingSource.Control);
            }
            return(false);
        }
        public BindingSource Listen(BindingListenOptions listenOptions, InputDevice device)
        {
            if (!listenOptions.IncludeMouseButtons)
            {
                return(null);
            }

            if (detectFound != Mouse.None)
            {
                if (!IsPressed(detectFound))
                {
                    if (detectPhase == 2)
                    {
                        var bindingSource = new MouseBindingSource(detectFound);
                        Reset();
                        return(bindingSource);
                    }
                }
            }

            var control = ListenForControl();

            if (control != Mouse.None)
            {
                if (detectPhase == 1)
                {
                    detectFound = control;
                    detectPhase = 2;                     // Wait for release.
                }
            }
            else
            {
                if (detectPhase == 0)
                {
                    detectPhase = 1;                     // Wait for press.
                }
            }

            return(null);
        }
예제 #5
0
        internal void Load(BinaryReader reader)
        {
            ClearBindings();

            var bindingCount = reader.ReadInt32();

            for (var i = 0; i < bindingCount; i++)
            {
                var           bindingSourceType = (BindingSourceType)reader.ReadInt32();
                BindingSource bindingSource;

                switch (bindingSourceType)
                {
                case BindingSourceType.None:
                    continue;

                case BindingSourceType.DeviceBindingSource:
                    bindingSource = new DeviceBindingSource();
                    break;

                case BindingSourceType.KeyBindingSource:
                    bindingSource = new KeyBindingSource();
                    break;

                case BindingSourceType.MouseBindingSource:
                    bindingSource = new MouseBindingSource();
                    break;

                case BindingSourceType.UnknownDeviceBindingSource:
                    bindingSource = new UnknownDeviceBindingSource();
                    break;

                default:
                    throw new InControlException("Don't know how to load BindingSourceType: " + bindingSourceType);
                }

                bindingSource.Load(reader);
                AddBinding(bindingSource);
            }
        }
		public BindingSource Listen( BindingListenOptions listenOptions, InputDevice device )
		{
			if (!listenOptions.IncludeMouseButtons)
			{
				return null;
			}

			if (detectFound != Mouse.None)
			{
				if (!MouseBindingSource.ButtonIsPressed( detectFound ))
				{
					if (detectPhase == 2)
					{
						var bindingSource = new MouseBindingSource( detectFound );
						Reset();
						return bindingSource;
					}
				}
			}

			var control = ListenForControl();
			if (control != Mouse.None)
			{
				if (detectPhase == 1)
				{
					detectFound = control;
					detectPhase = 2; // Wait for release.
				}
			}
			else
			{
				if (detectPhase == 0)
				{
					detectPhase = 1; // Wait for press.
				}
			}

			return null;
		}
예제 #7
0
        internal void Load(BinaryReader reader, ushort dataFormatVersion)
        {
            ClearBindings();
            int num = reader.ReadInt32();

            for (int i = 0; i < num; i++)
            {
                BindingSourceType bindingSourceType = (BindingSourceType)reader.ReadInt32();
                BindingSource     bindingSource;
                switch (bindingSourceType)
                {
                case BindingSourceType.DeviceBindingSource:
                    bindingSource = new DeviceBindingSource();
                    break;

                case BindingSourceType.KeyBindingSource:
                    bindingSource = new KeyBindingSource();
                    break;

                case BindingSourceType.MouseBindingSource:
                    bindingSource = new MouseBindingSource();
                    break;

                case BindingSourceType.UnknownDeviceBindingSource:
                    bindingSource = new UnknownDeviceBindingSource();
                    break;

                default:
                    throw new InControlException("Don't know how to load BindingSourceType: " + bindingSourceType);

                case BindingSourceType.None:
                    continue;
                }
                bindingSource.Load(reader, dataFormatVersion);
                AddBinding(bindingSource);
            }
        }
예제 #8
0
		internal void Load( BinaryReader reader )
		{
			ClearBindings();

			var bindingCount = reader.ReadInt32();
			for (int i = 0; i < bindingCount; i++)
			{
				var bindingSourceType = (BindingSourceType) reader.ReadInt32();

				if (bindingSourceType == BindingSourceType.DeviceBindingSource)
				{
					var binding = new DeviceBindingSource();
					binding.Load( reader );
					AddBinding( binding );
				}

				if (bindingSourceType == BindingSourceType.KeyBindingSource)
				{
					var binding = new KeyBindingSource();
					binding.Load( reader );
					AddBinding( binding );
				}

				if (bindingSourceType == BindingSourceType.MouseBindingSource)
				{
					var binding = new MouseBindingSource();
					binding.Load( reader );
					AddBinding( binding );
				}
			}
		}
예제 #9
0
		internal void Load( BinaryReader reader )
		{
			ClearBindings();

			var bindingCount = reader.ReadInt32();
			for (int i = 0; i < bindingCount; i++)
			{
				var bindingSourceType = (BindingSourceType) reader.ReadInt32();
				BindingSource bindingSource;

				switch (bindingSourceType)
				{
					case BindingSourceType.DeviceBindingSource:
						bindingSource = new DeviceBindingSource();
						break;

					case BindingSourceType.KeyBindingSource:
						bindingSource = new KeyBindingSource();
						break;

					case BindingSourceType.MouseBindingSource:
						bindingSource = new MouseBindingSource();
						break;
					
					case BindingSourceType.UnknownDeviceBindingSource:
						bindingSource = new UnknownDeviceBindingSource();
						break;

					default:
						throw new InControlException( "Don't know how to load BindingSourceType: " + bindingSourceType );
				}

				bindingSource.Load( reader );
				AddBinding( bindingSource );
			}
		}