public bool Save(int enterpriseId)
        {
            var result = false;

            try
            {
                EKey ekey = new EKey();

                ekey.Active       = true;
                ekey.CreationTime = DateTime.UtcNow;

                ekey.EnterpriseId = enterpriseId;
                var generateKeyResult = generateKey();

                if (string.IsNullOrEmpty(generateKeyResult.Key) || string.IsNullOrEmpty(generateKeyResult.IV))
                {
                    return(false);
                }

                ekey.Key = generateKeyResult.Key;
                ekey.IV  = generateKeyResult.IV;

                _ekeyRepo.Insert(ekey);

                result = true;
            }

            catch (Exception ex)
            {
                throw;
            }

            return(result);
        }
示例#2
0
 public static void SendKey(EKey key)
 {
     if (directConn != null && bEnabled)
     {
         directConn.SendKey(key);
     }
 }
示例#3
0
        void CreatePostMessage(EKey key, Process process)
        {
            Thread.Sleep(100);
            switch (key)
            {
            case EKey.Default:
                PostMessage(process.MainWindowHandle, WM_KEYDOWN, VK_SPACE, 0);
                break;

            case EKey.Backward:
                PostMessage(process.MainWindowHandle, WM_KEYDOWN, VK_LEFT, 0);
                break;

            case EKey.Forward:
                PostMessage(process.MainWindowHandle, WM_KEYDOWN, VK_RIGHT, 0);
                break;

            case EKey.Escape:
                PostMessage(process.MainWindowHandle, WM_KEYDOWN, VK_ESC, 0);
                break;

            default:
                throw new Exception();
            }
        }
示例#4
0
    private static EKey AddStep(EKey _note, int _stepSize)
    {
        int note = (int)_note;

        note = (note + _stepSize) % 12;
        return((EKey)note);
    }
示例#5
0
        private void SendValueToProcessAndFocusPrevious(EKey key)
        {
            var process = GetCurrentFocusedWindow();

            SendValueToForegroundWindow(key);
            Thread.Sleep(100);
            SetForegroundWindow(process.MainWindowHandle);
            CreatePostMessage(EKey.Escape, process);
        }
示例#6
0
        private void SendValueToForegroundWindow(EKey key)
        {
            var processes = Process.GetProcessesByName("chrome");
            var process   = processes.Single(p => !string.IsNullOrWhiteSpace(p.MainWindowTitle));

            Thread.Sleep(100);
            SetForegroundWindow(process.MainWindowHandle);
            CreatePostMessage(key, process);
        }
示例#7
0
        public static ControlKey GetKey(EKey key)
        {
            if (key <= EKey.None || key >= EKey.Count)
            {
                return(null);
            }

            return(keys[(int)key]);
        }
示例#8
0
 public static AudioClip[] GetScaleAudio(EKey _key, EMode _mode, EInstrument _instrument)
 {
     AudioClip[] scaleTones = new AudioClip[7];
     scaleTones[0] = GetAudioClipInstrument(_key, _mode, _instrument, 1);
     for (int i = 1; i < 7; i++)
     {
         scaleTones[i] = GetAudioClipInstrument(_key, _mode, _instrument, i + 1);
     }
     return(scaleTones);
 }
示例#9
0
        /// <summary>
        /// Open a file from Encoding Key
        /// </summary>
        /// <param name="key">The Encoding Key</param>
        /// <returns>Loaded file</returns>
        public Stream OpenEKey(EKey key)    // ekey = value of ckey in encoding table
        {
            Stream stream = default;

            if (CreateArgs.Mode == ClientCreateArgs.InstallMode.CASC)
            {
                stream = ContainerHandler?.OpenEKey(key);
            }
            return(stream == null ? null : new BLTEStream(this, stream));
        }
示例#10
0
        private String GetKeyPayload(EKey key)
        {
            StringBuilder writer = new StringBuilder();

            writer.Append((char)0x00);
            writer.Append((char)0x00);
            writer.Append((char)0x00);
            WriteBase64Text(writer, key.ToString());
            return(writer.ToString());
        }
示例#11
0
    private static EKey GetNote(EKey _key, EMode _mode, int _step)
    {
        EKey note = _key;

        //1 is root
        for (int i = 2; i < _step; i++)
        {
            note = AddStep(note, GetStepsizeForMode(_step, _mode));
        }
        return(note);
    }
示例#12
0
        private void InternalSendKey(EKey key)
        {
            if (TvDirectSocket == null)
            {
                return;
            }

            StringBuilder writer = new StringBuilder();

            writer.Append((char)0x00);
            WriteText(writer, appName);
            WriteText(writer, GetKeyPayload(key));

            SendBytes(Encoding.UTF8.GetBytes(writer.ToString()), SendKeyResponse);
        }
示例#13
0
        public EKey GetKeyDown()
        {
            this.modifier = EKey.K_NULL;

            for (int i = 0; i < codes.Length; i++)
            {
                if (Input.GetKeyDown(codes[i]) || Input.GetKey(codes[i]))
                {
                    this.modifier = GetPressingModifierKey();
                    return(keys[i]);
                }
            }

            return(EKey.K_NULL);
        }
示例#14
0
    private static AudioClip GetAudioClipInstrument(EKey _key, EMode _mode, EInstrument _instrument, int _step)
    {
        string clipString = "";

        switch (_instrument)
        {
        case EInstrument.bassDrum:
            return(Resources.Load <AudioClip>("Audio/Music/Test/bassDrum"));

        case EInstrument.synthWarm:
            clipString += "synthWarm";
            break;
        }

        return(Resources.Load <AudioClip>("Audio/Music/Test/" + clipString));
    }
示例#15
0
        public void SendKey(EKey key)
        {
//          if (logger != null) logger.v(TAG, "Sending key " + key.getValue() + "...");
//          checkConnection();
            try
            {
                InternalSendKey(key);
            }
            catch
            {
//              if (logger != null) logger.v(TAG, "Could not send key because the server closed the connection. Reconnecting...");
//              initialize();
//              if (logger != null) logger.v(TAG, "Sending key " + key.getValue() + " again...");
//              internalSendKey(key);
            }
//		    if (logger != null) logger.v(TAG, "Successfully sent key " + key.getValue());
        }
示例#16
0
 /// <summary>
 /// 注册热键
 /// </summary>
 /// <param name="hwnd">窗口句柄</param>
 /// <param name="hotKey_id">热键ID</param>
 /// <param name="keyModifiers">组合键</param>
 /// <param name="key">热键</param>
 public static void RegHotKey(IntPtr hwnd, int hotKeyId, uint KeyModifiers, EKey key)
 {
     if (!RegisterHotKey(hwnd, hotKeyId, KeyModifiers, key))
     {
         int errorCode = Marshal.GetLastWin32Error();
         if (errorCode == 1409)
         {
             MessageBox.Show("热键被占用 !");
         }
         else
         {
             MessageBox.Show("热键注册失败!错误代码:" + errorCode);
         }
     }
     else
     {
         SendDanmakuMain.log("热键注册成功");
     }
 }
示例#17
0
        private void Window_KeyUp(object sender, KeyEventArgs e)
        {
            if (!loaded)
            {
                return;
            }

            EKey k = MapKey(e.Key);

            if (k == EKey.Count)
            {
                return;
            }

            if (ClearKey((byte)k))
            {
                if ((byte)k < repeatedKeysCount && --keyCount == 0)
                {
                    timer.Stop();
                }
            }
        }
示例#18
0
        public static HotKeyModel ReadKey()
        {
            var config = ColorPickerKey.OpenSubKey("Config");

            if (config == null)
            {
                return new HotKeyModel()
                       {
                           SelectType = EType.Ctrl, SelectKey = EKey.A
                       }
            }
            ;
            EType type = EType.Ctrl;
            EKey  eKey = EKey.A;

            Enum.TryParse <EType>(config.GetValue("Type").ToString(), true, out type);
            Enum.TryParse <EKey>(config.GetValue("Key").ToString(), true, out eKey);
            return(new HotKeyModel()
            {
                SelectKey = eKey, SelectType = type
            });
        }
    }
示例#19
0
        private void Window_KeyDown(object sender, KeyEventArgs e)
        {
            if (!loaded)
            {
                return;
            }

            EKey k = MapKey(e.Key);

            if (k == EKey.Count)
            {
                return;
            }

            if (!SetKey((byte)k))
            {
                keyActions[(byte)k]();

                if ((byte)k < repeatedKeysCount && keyCount++ == 0)
                {
                    timer.Start();
                }
            }
        }
示例#20
0
        /// <summary>
        /// Open a file from Encoding Key
        /// </summary>
        /// <param name="key">The Encoding Key</param>
        /// <returns>Loaded file</returns>
        public Stream OpenEKey(EKey key)    // ekey = value of ckey in encoding table
        {
            var stream = ContainerHandler?.OpenEKey(key);

            return(stream == null ? null : new BLTEStream(this, stream));
        }
示例#21
0
 private byte[] GetEncryptedString(string plainText, EKey ekey)
 {
     return(_eKeyService.Encrypt(plainText, ekey.Key, ekey.IV));
 }
示例#22
0
        public IActionResult Add([FromBody] dynamic value)
        {
            try
            {
                string svalue = Convert.ToString(value);

                dynamic UserJsonEntity = JsonConvert.DeserializeObject(svalue);

                string firstname    = UserJsonEntity["fn"];
                string lastname     = UserJsonEntity["ln"];
                string licencekey   = UserJsonEntity["lk"];
                var    seatkey      = UserJsonEntity["sk"];
                string optionaldata = UserJsonEntity["opt"];
                var    devicetype   = UserJsonEntity["dt"];
                var    devicemodel  = UserJsonEntity["dm"];


                //get the enterprise encryption key
                Subscription subscription = _subscriptionService.GetByLicenceKey(licencekey);
                if (subscription == null)
                {
                    return(Json(new
                    {
                        c = ResultCode.UserDataResultCodes.SubscriptionDoesntExist,
                        d = ""
                    }));
                }

                EKey eKey = _eKeyService.GetActive(subscription.EnterpriseClientId);

                if (eKey != null)
                {
                    _userDataService.Add(new Entity.Model.UserData()
                    {
                        FirstName    = GetEncryptedString(firstname, eKey),
                        LastName     = GetEncryptedString(lastname, eKey),
                        LicenceKey   = licencekey,
                        SeatKey      = seatkey,
                        OptionalData = string.IsNullOrEmpty(optionaldata)? null : GetEncryptedString(optionaldata, eKey),
                        DeviceType   = devicetype,
                        DeviceModel  = devicemodel
                    });

                    return(Json(new
                    {
                        c = ResultCode.Success,
                        d = true
                    }));
                }
                else
                {
                    return(Json(new
                    {
                        c = ResultCode.UserDataResultCodes.EkeyDoesntExist,
                        d = ""
                    }));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.GetLogText("userdataapi_adduserdata"));

                return(Json(new
                {
                    c = ResultCode.GenericException,
                    d = ex.Message
                }));
            }
        }
示例#23
0
 public static void SendKey(EKey key)
 {
     if (directConn != null && bEnabled)
     {
         directConn.SendKey(key);
     }
 }
示例#24
0
        public void SendKey(EKey key)
        {
// 		    if (logger != null) logger.v(TAG, "Sending key " + key.getValue() + "...");
// 		    checkConnection();
            try
            {
                InternalSendKey(key);
            }
            catch
            {
// 			    if (logger != null) logger.v(TAG, "Could not send key because the server closed the connection. Reconnecting...");
// 			    initialize();
// 			    if (logger != null) logger.v(TAG, "Sending key " + key.getValue() + " again...");
// 			    internalSendKey(key);
            }
//		    if (logger != null) logger.v(TAG, "Successfully sent key " + key.getValue());
        }
示例#25
0
        private void ShowAllShortCutChangedMethod(KeyEventArgs e)
        {
            if (e.Key == Key.LeftAlt || e.Key == Key.RightAlt)
            {
                return;
            }

            if (e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl)
            {
                return;
            }

            if (e.Key == Key.LeftShift || e.Key == Key.RightShift)
            {
                return;
            }

            bool useCtrl  = (e.KeyboardDevice.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;
            bool useAlt   = (e.KeyboardDevice.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt;
            bool useShift = (e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift;
            EKey useKey   = EKey.Q;

            foreach (int v in Enum.GetValues(typeof(EKey)))
            {
                string keyName = Enum.GetName(typeof(EKey), v);
                if (e.Key.ToString() == keyName)
                {
                    useKey = (EKey)v;
                }
            }

            var         OldHotKey = ShowAllHotKey;
            HotKeyModel newModel  = ShowAllHotKey;

            newModel.IsSelectAlt               = useAlt;
            newModel.IsSelectCtrl              = useCtrl;
            newModel.IsSelectShift             = useShift;
            newModel.SelectKey                 = useKey;
            ProgramData.Instance.ShowAllHotKey = ShowAllHotKey;
            var hotKeyList = new ObservableCollection <HotKeyModel>
            {
                ShowAllHotKey
            };

            if (!HotKeySettingsManager.Instance.RegisterGlobalHotKey(hotKeyList))
            {
                MessageBox.Show("快捷键注册失败,可能与其他软件存在冲突");
                ShowAllHotKey = OldHotKey;
            }


            //清楚当前快捷键
            //todo
            //检测输入的快捷键是否可用
            //todo
            //将更新的快捷键输入文本框



            IsTopMostChangedCommand           = new RelayCommand <bool>(IsTopMostChangedMethod);
            IsStartUpWithSystemChangedCommand = new RelayCommand <bool>(IsStartUpWithSystemChangedMethod);
            SelectionChangedCommand           = new RelayCommand <SelectionChangedEventArgs>(SelectionChangedMethod);
            ShowAllHotKeyChangedCommand       = new RelayCommand <KeyEventArgs>(ShowAllShortCutChangedMethod);
        }
示例#26
0
        public String GetKeyString(EKey k)
        {
            string s = "";

            switch (k)
            {
            case EKey.K_NULL:
                s = "NULL";
                break;

            case EKey.K_Escape:
                s = "Escape";
                break;

            case EKey.K_Return:
                s = "Return";
                break;

            case EKey.K_Backspace:
                s = "Backspace";
                break;

            case EKey.K_Space:
                s = "Space";
                break;

            case EKey.K_UpArrow:
                s = "UpArrow";
                break;

            case EKey.K_DownArrow:
                s = "DownArrow";
                break;

            case EKey.K_LeftArrow:
                s = "LeftArrow";
                break;

            case EKey.K_RightArrow:
                s = "RightArrow";
                break;

            case EKey.K_W:
                s = "W";
                break;

            case EKey.K_S:
                s = "S";
                break;

            case EKey.K_A:
                s = "A";
                break;

            case EKey.K_R:
                s = "R";
                break;

            case EKey.K_Menu:
                s = "Menu";
                break;

            case EKey.K_LeftControl:
                s = "LeftControl";
                break;

            case EKey.K_RightControl:
                s = "RightControl";
                break;

            case EKey.K_LeftAlt:
                s = "LeftAlt";
                break;

            case EKey.K_RightAlt:
                s = "RightAlt";
                break;

            case EKey.K_LeftShift:
                s = "LeftShift";
                break;

            case EKey.K_RightShift:
                s = "RightShift";
                break;

            case EKey.K_LeftApple:
                s = "LeftApple";
                break;

            case EKey.K_RightApple:
                s = "RightApple";
                break;
            }
            return(s);
        }
示例#27
0
 public override string ToString() => EKey.ToString();
示例#28
0
 public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint KeyModifiers, EKey vk);
示例#29
0
 private String GetKeyPayload(EKey key)
 {
     StringBuilder writer = new StringBuilder();
     writer.Append((char)0x00);
     writer.Append((char)0x00);
     writer.Append((char)0x00);
     WriteBase64Text(writer, key.ToString());
     return writer.ToString();
 }
示例#30
0
文件: IOHelper.cs 项目: ipud2/OWLib
 public static Stream OpenFile(EKey ekey)
 {
     return(DataTool.Program.Client.OpenEKey(ekey));
 }
示例#31
0
    // True if button is currently pressed
    public bool IsHeld(EKey Key)
    {
        KeyBind Bind = Bindings[(int)Key];

        return(Input.GetKey(Bind.Keyboard) || Input.GetKey(Bind.Gamepad));
    }
        private void ShowAllShortCutChangedMethod(KeyEventArgs e)
        {
            if (e.Key == Key.LeftAlt || e.Key == Key.RightAlt)
            {
                return;
            }

            if (e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl)
            {
                return;
            }

            if (e.Key == Key.LeftShift || e.Key == Key.RightShift)
            {
                return;
            }

            bool useCtrl  = (e.KeyboardDevice.Modifiers & ModifierKeys.Control) == ModifierKeys.Control;
            bool useAlt   = (e.KeyboardDevice.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt;
            bool useShift = (e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift;
            EKey useKey   = EKey.Q;

            foreach (int v in Enum.GetValues(typeof(EKey)))
            {
                string keyName = Enum.GetName(typeof(EKey), v);
                if (e.Key.ToString() == keyName)
                {
                    useKey = (EKey)v;
                }
            }

//            var OldHotKey = ShowAllHotKey;
            ShowAllHotKey.IsSelectAlt          = useAlt;
            ShowAllHotKey.IsSelectCtrl         = useCtrl;
            ShowAllHotKey.IsSelectShift        = useShift;
            ShowAllHotKey.SelectKey            = useKey;
            ProgramData.Instance.ShowAllHotKey = ShowAllHotKey;
            var hotKeyList = new ObservableCollection <HotKeyModel>
            {
                ShowAllHotKey
            };

            if (!HotKeySettingsManager.Instance.RegisterGlobalHotKey(hotKeyList))
            {
                MessageBox.Show("快捷键注册失败,可能与其他软件存在冲突");
//                ShowAllHotKey = OldHotKey;
            }

            if (SettingWin.ShowAllTB.Text.ToString() != ShowAllHotKey.ToString())
            {
                BindingExpression b = SettingWin.ShowAllTB.GetBindingExpression(TextBox.TextProperty);
                b.UpdateTarget();
            }
            //暂时不用这个,先解决bug
            //            SettingWin.ShowAllTB.Text = ShowAllHotKey.ToString();

            //清楚当前快捷键
            //todo
            //检测输入的快捷键是否可用
            //todo
            //将更新的快捷键输入文本框
        }
示例#33
0
        private void InternalSendKey(EKey key)
        {
            if (TvDirectSocket == null)
            {
                return;
            }

            StringBuilder writer = new StringBuilder();
            writer.Append((char)0x00);
            WriteText(writer, appName);
            WriteText(writer, GetKeyPayload(key));

            SendBytes(Encoding.UTF8.GetBytes(writer.ToString()), SendKeyResponse);
        }
示例#34
0
 public static bool IsShiftKey(EKey key)
 {
     return(key == EKey.K_LeftShift || key == EKey.K_RightShift);
 }