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);
        }
Ejemplo n.º 2
0
 public static void SendKey(EKey key)
 {
     if (directConn != null && bEnabled)
     {
         directConn.SendKey(key);
     }
 }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 4
0
    private static EKey AddStep(EKey _note, int _stepSize)
    {
        int note = (int)_note;

        note = (note + _stepSize) % 12;
        return((EKey)note);
    }
Ejemplo n.º 5
0
        private void SendValueToProcessAndFocusPrevious(EKey key)
        {
            var process = GetCurrentFocusedWindow();

            SendValueToForegroundWindow(key);
            Thread.Sleep(100);
            SetForegroundWindow(process.MainWindowHandle);
            CreatePostMessage(EKey.Escape, process);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 7
0
        public static ControlKey GetKey(EKey key)
        {
            if (key <= EKey.None || key >= EKey.Count)
            {
                return(null);
            }

            return(keys[(int)key]);
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 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);
    }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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));
    }
Ejemplo n.º 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());
        }
Ejemplo n.º 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("热键注册成功");
     }
 }
Ejemplo n.º 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();
                }
            }
        }
Ejemplo n.º 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
            });
        }
    }
Ejemplo n.º 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();
                }
            }
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 21
0
 private byte[] GetEncryptedString(string plainText, EKey ekey)
 {
     return(_eKeyService.Encrypt(plainText, ekey.Key, ekey.IV));
 }
Ejemplo n.º 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
                }));
            }
        }
Ejemplo n.º 23
0
 public static void SendKey(EKey key)
 {
     if (directConn != null && bEnabled)
     {
         directConn.SendKey(key);
     }
 }
Ejemplo n.º 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());
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 27
0
 public override string ToString() => EKey.ToString();
Ejemplo n.º 28
0
 public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint KeyModifiers, EKey vk);
Ejemplo n.º 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();
 }
Ejemplo n.º 30
0
 public static Stream OpenFile(EKey ekey)
 {
     return(DataTool.Program.Client.OpenEKey(ekey));
 }
Ejemplo n.º 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
            //将更新的快捷键输入文本框
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 34
0
 public static bool IsShiftKey(EKey key)
 {
     return(key == EKey.K_LeftShift || key == EKey.K_RightShift);
 }