Carnac.Logic/PasswordModeService.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Carnac.Logic.Internal;
using Carnac.Logic.KeyMonitor;

namespace Carnac.Logic
{
    public class PasswordModeService : IPasswordModeService
    {
        private readonly FixedQueue<InterceptKeyEventArgs> log;
        private InterceptKeyEventArgs[] passwordKeyCombination;
        private readonly InterceptKeyEventArgsEqualityComparer comparer = new InterceptKeyEventArgsEqualityComparer();
        private bool currentMode;

        public PasswordModeService()
        {
            log = new FixedQueue<InterceptKeyEventArgs>(this.PasswordKeyCombination.Count());
        }

        public bool CheckPasswordMode(InterceptKeyEventArgs key)
        {
            log.Enqueue(key);
            var sortedLog = log.ToList();
            sortedLog.Sort();
            var isMatch = sortedLog.SequenceEqual(PasswordKeyCombination, comparer);
            if (isMatch)
            {
                currentMode = !currentMode;
                this.log.Clear();
                return true; //this way when the sequence is entered again to EXIT password mode, the key password keycombo doesn't show on screen
            }

            return currentMode;
        }

        public IEnumerable<InterceptKeyEventArgs> PasswordKeyCombination
        {
            get
            {
                if (passwordKeyCombination == null)
                {
                    passwordKeyCombination = new[]
                                                 {
                                                     new InterceptKeyEventArgs(Keys.P, KeyDirection.Down,true,true,false), 
                                                 };
                }

                return passwordKeyCombination;
            }
        }

        private class InterceptKeyEventArgsEqualityComparer : IEqualityComparer<InterceptKeyEventArgs>
        {
            public bool Equals(InterceptKeyEventArgs x, InterceptKeyEventArgs y)
            {
                if (x == null && y == null)
                {
                    return true;
                }
后面还有 20 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。