Exemplo n.º 1
0
 private void ClearTextBoxes()
 {
     NewPersonName.Clear();
     NewCompanyName.Clear();
     NewCatalogName.Clear();
     KeyBox.Clear();
     SearchResult.Text = "";
 }
Exemplo n.º 2
0
    private void HandleKeyTick(Box box, int ticks)
    {
        KeyBox keyBox = box as KeyBox;

        bool isNameAtMaxLength = (slot.player.name.Length >= Config.MAX_CHARS_PER_NAME);
        bool isNameEmpty       = (slot.player.name.Length == 0);

        if (keyBox.index == SPACE_KEY)
        {
            if (!isNameAtMaxLength)
            {
                slot.player.name += " ";
            }
        }
        else if (keyBox.index == BACKSPACE_KEY)
        {
            if (!isNameEmpty)
            {
                slot.player.name = slot.player.name.Substring(0, slot.player.name.Length - 1);
            }
        }
        else         //normal letters
        {
            if (!isNameAtMaxLength)
            {
                slot.player.name += THE_KEYBOARD[keyBox.index];
            }
        }

        string name = slot.player.name;

        if
        (
            (!isNameAtMaxLength && (name.Length >= Config.MAX_CHARS_PER_NAME)) ||               // if it's now too long
            (isNameAtMaxLength && !(name.Length >= Config.MAX_CHARS_PER_NAME)) ||               //it just stopped being too long
            (!isNameEmpty && (name.Length == 0)) ||                                             //it just became empty
            (isNameEmpty && !(name.Length == 0))                                                //it just stopped being empty
        )
        {
            isNameAtMaxLength = (name.Length >= Config.MAX_CHARS_PER_NAME);
            isNameEmpty       = (name.Length == 0);

            okBox.isEnabled = !isNameEmpty;

            for (int k = 0; k < 28; k++)
            {
                if ((k == BACKSPACE_KEY && !isNameEmpty) || (k != BACKSPACE_KEY && !isNameAtMaxLength))
                {
                    keyBoxes[k].isEnabled = true;
                }
                else
                {
                    keyBoxes[k].isEnabled = false;
                }
            }
        }
    }
Exemplo n.º 3
0
        private void KeyBox_KeyDown(object sender, KeyEventArgs e)
        {
            //Fix the position of the scrollviewer if necessary:
            var rect = KeyBox.CaretPosition.GetCharacterRect(LogicalDirection.Forward);

            if (rect.X < 0)
            {
                KeyBox.ScrollToHorizontalOffset(KeyBox.HorizontalOffset + rect.X - 5);
            }
            if (rect.X + rect.Width > KeyBox.ActualWidth)
            {
                KeyBox.ScrollToHorizontalOffset(KeyBox.HorizontalOffset + (rect.X + rect.Width - KeyBox.ActualWidth) + 5);
            }
        }
Exemplo n.º 4
0
        private void OldPassphrase_Load(object sender, EventArgs e)
        {
            IList <GnuKey> keys = Globals.OutlookGnuPG.GetKeys();

            KeyBox.DataSource    = keys;
            KeyBox.DisplayMember = "KeyDisplay";
            KeyBox.ValueMember   = "Key";

            if (KeyBox.Items.Count <= 0)
            {
                // No keys available, no use in showing this dialog at all
                Hide();
                return;
            }

            int boxHeight = (keys.Count > 10) ? KeyBox.ItemHeight * 10 : KeyBox.ItemHeight * keys.Count;

            KeyBox.Height = boxHeight + 5;
            Height        = boxHeight + 90;

            // Enlarge dialog to fit the longest key
            using (Graphics g = CreateGraphics())
            {
                int maxSize = Width;
                foreach (GnuKey key in keys)
                {
                    int textWidth = (int)g.MeasureString(key.KeyDisplay, KeyBox.Font).Width + 50;
                    if (textWidth > maxSize)
                    {
                        maxSize = textWidth;
                    }
                }
                Width = maxSize;
                CenterToScreen();
            }

            for (int i = 0; i < KeyBox.Items.Count; i++)
            {
                GnuKey recipient = (GnuKey)KeyBox.Items[i];
#if DISABLED
                KeyBox.SetItemChecked(i, _defaultKeys.Contains(recipient.Key));
#else
                // Update to support CN from X.400 mail address format.
                // Enable item if the associated key starts with one of the available _defaultKeys (hence a prefix match).
                KeyBox.SetItemChecked(i,
                                      null != _defaultKeys.Find(delegate(string gnuKey) { return(recipient.Key.StartsWith(gnuKey)); }));
#endif
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Constructor
        /// </summary>
        public InputSchemeForm(XmlNode node)
        {
            InitializeComponent();



            Scheme = new InputScheme();
            Scheme.Load(node);

            KeyBox.BeginUpdate();
            foreach (string s in Enum.GetNames(typeof(Keys)))
            {
                KeyBox.Items.Add(s);
            }
            KeyBox.EndUpdate();


            BuildList();
        }
Exemplo n.º 6
0
        private void KeyBox_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            var key = KeyManager.GetKey();

            switch (e.Key)
            {
            case Key.Space:
                e.Handled = true;
                HandleInput(" ");
                break;

            case Key.Back:
            case Key.Delete:
                e.Handled = true;
                var caretIndex = GetKeyOffset(KeyBox.CaretPosition);
                if (e.Key == Key.Back)
                {
                    if (caretIndex == 0)
                    {
                        break;
                    }
                    caretIndex--;
                }
                else if (e.Key == Key.Delete && caretIndex == key.Length)
                {
                    break;
                }
                ReplaceCharInKey(key, GetPossibleCharactersAtKeyEnd(key.Substring(0, caretIndex)), '*', caretIndex);
                SetKeyOffset(caretIndex);
                break;

            case Key.Home:
                KeyBox.ScrollToHome();
                break;

            case Key.End:
                var x = KeyBox.Document.ContentEnd.GetCharacterRect(LogicalDirection.Forward).X;
                KeyBox.ScrollToHorizontalOffset(x + KeyBox.HorizontalOffset - KeyBox.ActualWidth + 5);
                break;
            }
        }
Exemplo n.º 7
0
        public void When_Updating_key_stroke_text_gets_replaced()
        {
            var style = LayoutTestStyle.Create();
            var b     = new KeyBox(style, new KeyStroke(Keys.A));

            style.StyleResolver.AddRoot(b);

            b.Content.Text.Should().Be(Keys.A.ToString());
            b.Arrange(new Rectangle(10, 20, 200, 40));

            b.Key = new KeyStroke(Keys.B, InputFlags.Shift);
            b.Content.Text.Should().Be("Shift B");
            b.Arrange(new Rectangle(10, 20, 200, 40));

            b.Key = new KeyStroke(Keys.C, InputFlags.Control | InputFlags.Shift);
            b.Content.Text.Should().Be("Ctrl-Shift C");
            b.Arrange(new Rectangle(10, 20, 200, 40));

            b.Key = new KeyStroke(Keys.A);
            b.Content.Text.Should().Be("A");
            b.Arrange(new Rectangle(10, 20, 200, 40));
        }
Exemplo n.º 8
0
        /// <summary>
        /// функция, отвечающая за процесс шифрования
        /// </summary>
        public void CaesarEncryption()
        {
            richTextBox2.Text = "";
            string input = "";
            int    letterNumber;

            input = richTextBox1.Text;
            string tempKey = KeyBox.Text;
            int    key     = Int32.Parse(tempKey);

            //если оба основных бокса не пустые
            if (richTextBox1.Text != "" && KeyBox.Text != "")
            {
                //создание рег. выр. для поля "исходный текст"
                Regex rgx = new Regex(@"(^([а-яА-Я0-9\p{P}\s])+$)");
                //создание рег. выр для поля ввода ключа
                Regex keyRgx = new Regex(@"(?<=^|\s)([1-9]|([1-6]\d)|(7[0-5]))(?=\s|$)");
                //если хотя бы в одном из полей введены неверные символы
                if (!rgx.IsMatch(richTextBox1.Text) || !keyRgx.IsMatch(KeyBox.Text))
                {
                    MessageBox.Show("Были введены неверные символы! Введите другой текст.", "Ошибка!",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    richTextBox1.Clear();
                    KeyBox.Clear();
                }
                else
                {
                    //создание массива для символов вводимого текста
                    string[] inputArr = new string[input.Length];
                    //создание массива для номеров символов исходного текста
                    int[] inputIndex = new int[input.Length];
                    //создание массива для записи результатов шифрования
                    string[] encrypted = new string[input.Length];
                    //разбиваем исходный текст на символы типа string
                    for (int i = 0; i < input.Length; i++)
                    {
                        inputArr[i] = Convert.ToString(input[i]);
                    }
                    for (int i = 0; i < input.Length; i++)
                    {
                        for (int j = 0; j < alphabet.Length; j++)
                        {
                            //если символ исходного текста есть в алфавите
                            if (inputArr[i] == alphabet[j])
                            {
                                //запоминается номер этого символа в алфавите
                                inputIndex[i] = j;
                            }
                        }
                    }
                    //проверка, является ли знаком элемент, если является, переходим на след. итерацию
                    for (int i = 0; i < inputArr.Length; i++)
                    {
                        if (IsSign(inputArr[i]))
                        {
                            encrypted[i] = inputArr[i];
                            continue;
                        }
                        //вычисляем номер символа, получившегося в результате с помощью формулы:
                        //(номер символа исх. текста + номер символа ключа) / длину алфавита
                        letterNumber = (inputIndex[i] + key) % alphabet.Length;
                        //запоминаем этот символ
                        encrypted[i] = alphabet[letterNumber];
                        //обнуляем переменную, куда записывали номер элемента
                        letterNumber = 0;
                    }
                    //в текстбокс записываем результат шифрования
                    for (int i = 0; i < inputIndex.Length; i++)
                    {
                        richTextBox2.Text += encrypted[i];
                    }
                }
            }
            else
            {
                MessageBox.Show("Не все обязательные поля заполнены!", "Ошибка!", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
        private void Passphrase_Load(object sender, EventArgs e)
        {
            // Did we locate all recipients keys?
            var unfoundKeys = true;

            IList <GnuKey> keys = Encryption ? Globals.OutlookPrivacyPlugin.GetKeysForEncryption() : Globals.OutlookPrivacyPlugin.GetKeysForSigning();

            if (keys.Count <= 0)
            {
                // No keys available, no use in showing this dialog at all
                Hide();
                return;
            }

            var datasource    = new List <GnuKey>();
            var selectedCount = 0;

            // 1/ Collect selected keys and sort them.
            foreach (var gnuKey in keys)
            {
                if (_defaultKeys.Find(key => gnuKey.Key.StartsWith(key, true, null)) == null)
                {
                    continue;
                }
                selectedCount++;
                datasource.Add(gnuKey);
            }

            datasource.Sort(new GnuKeySorter());

            // If we found all the keys we don't need to show dialog
            if (datasource.Count == _defaultKeys.Count)
            {
                unfoundKeys = false;
            }

            // 2/ Collect unselected keys and sort them.
            var datasource2 = new List <GnuKey>();

            foreach (var gnuKey in keys)
            {
                if (_defaultKeys.Find(key => gnuKey.Key.StartsWith(key, true, null)) == null)
                {
                    datasource2.Add(gnuKey);
                }
            }

            datasource2.Sort(new GnuKeySorter());

            // Append unselected keys to datasource.
            datasource.AddRange(datasource2);

            // Setup KeyBox
            KeyBox.DataSource    = datasource;
            KeyBox.DisplayMember = "KeyDisplay";
            KeyBox.ValueMember   = "Key";

            var boxHeight = (keys.Count > 10) ? KeyBox.ItemHeight * 10 : KeyBox.ItemHeight * keys.Count;

            KeyBox.Height = boxHeight + 5;
            Height        = boxHeight + 90;

            // Enlarge dialog to fit the longest key
            using (var g = CreateGraphics())
            {
                var maxSize = Width;
                foreach (var key in datasource)
                {
                    var textWidth = (int)g.MeasureString(key.KeyDisplay, KeyBox.Font).Width + 50;
                    if (textWidth > maxSize)
                    {
                        maxSize = textWidth;
                    }
                }
                Width = maxSize;
                CenterToScreen();
            }

            // Note: Keybox sorted property MUST be False!
            //       unless the custom sort strategy is voided!
            for (var i = 0; i < selectedCount; i++)
            {
                KeyBox.SetItemChecked(i, true);
            }

            // If we found all the keys we don't need to show dialog
            if (!unfoundKeys)
            {
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Exemplo n.º 10
0
        public void VigenereDecryption()
        {
            richTextBox2.Text = "";
            string input = "", key = "", keyTemp = "";
            int    mod = 0, letterNumber;

            input   = richTextBox1.Text;
            keyTemp = KeyBox.Text;
            if (richTextBox1.Text != "" && KeyBox.Text != "")
            {
                Regex rgx    = new Regex(@"(^([а-яА-Я0-9\p{P}\s])+$)");
                Regex keyRgx = new Regex("[а-я]");
                if (!rgx.IsMatch(richTextBox1.Text) || !keyRgx.IsMatch(KeyBox.Text))
                {
                    MessageBox.Show("Были введены неверные символы! Введите другой текст.", "Ошибка!",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    richTextBox1.Clear();
                    KeyBox.Clear();
                }
                else
                {
                    mod = input.Length % keyTemp.Length;
                    for (int i = 0; i < (input.Length - mod) / keyTemp.Length; i++)
                    {
                        key += keyTemp;
                    }
                    for (int i = 0; i < mod; i++)
                    {
                        key += keyTemp[i];
                    }
                    string[] inputArr   = new string[input.Length];
                    int[]    inputIndex = new int[input.Length];
                    string[] keyArr     = new string[input.Length];
                    int[]    keyIndex   = new int[input.Length];
                    string[] decrypted  = new string[input.Length]; //создание массива для записи результатов дешифрования

                    for (int i = 0; i < input.Length; i++)
                    {
                        inputArr[i] = Convert.ToString(input[i]);
                    }
                    for (int i = 0; i < key.Length; i++)
                    {
                        keyArr[i] = Convert.ToString(key[i]);
                    }
                    for (int i = 0; i < input.Length; i++)
                    {
                        for (int j = 0; j < alphabet.Length; j++)
                        {
                            if (inputArr[i] == alphabet[j])
                            {
                                inputIndex[i] = j;
                            }
                            if (keyArr[i] == alphabet[j])
                            {
                                keyIndex[i] = j;
                            }
                        }
                    }
                    for (int i = 0; i < inputArr.Length; i++)
                    {
                        if (IsSign(inputArr[i]))
                        {
                            decrypted[i] = inputArr[i];
                            continue;
                        }
                        //вычисляем номер символа, получившегося в результате с помощью формулы:
                        //(номер символа исх. текста - номер символа ключа + длина алфавита) / длину алфавита
                        letterNumber = (inputIndex[i] - keyIndex[i] + alphabet.Length) % alphabet.Length;
                        decrypted[i] = alphabet[letterNumber];
                        letterNumber = 0;
                    }
                    for (int i = 0; i < inputIndex.Length; i++)
                    {
                        richTextBox2.Text += decrypted[i];
                    }
                }
            }
            else
            {
                MessageBox.Show("Не все обязательные поля заполнены!", "Ошибка!", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// функция, отвечающая за процесс шифрования
        /// </summary>
        public void VigenereEncryption()
        {
            richTextBox2.Text = "";
            string input = "", key = "", keyTemp = "";
            int    mod = 0, letterNumber;

            input   = richTextBox1.Text;
            keyTemp = KeyBox.Text;
            //если оба основных бокса не пустые
            if (richTextBox1.Text != "" && KeyBox.Text != "")
            {
                //создание рег. выр. для поля "исходный текст"
                Regex rgx = new Regex(@"(^([а-яА-Я0-9\p{P}\s])+$)");
                //создание рег. выр для поля ввода ключа
                Regex keyRgx = new Regex("[а-я]");
                //если хотя бы в одном из полей введены неверные символы
                if (!rgx.IsMatch(richTextBox1.Text) || !keyRgx.IsMatch(KeyBox.Text))
                {
                    MessageBox.Show("Были введены неверные символы! Введите другой текст.", "Ошибка!",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    richTextBox1.Clear();
                    KeyBox.Clear();
                }
                else
                {
                    //остаток от деления длины исходного текста на длину ключа
                    mod = input.Length % keyTemp.Length;
                    //формируем ключ таким образом, чтобы его длина равнялась длине исходного текста
                    for (int i = 0; i < (input.Length - mod) / keyTemp.Length; i++)
                    {
                        key += keyTemp;
                    }
                    for (int i = 0; i < mod; i++)
                    {
                        key += keyTemp[i];
                    }
                    //создание массива для символов вводимого текста
                    string[] inputArr = new string[input.Length];
                    //создание массива для номеров символов исходного текста
                    int[] inputIndex = new int[input.Length];
                    //создание массива для символов ключевого слова
                    string[] keyArr = new string[input.Length];
                    //создание массива для номеров символов ключевого слова
                    int[] keyIndex = new int[input.Length];
                    //создание массива для записи результатов шифрования
                    string[] encrypted = new string[input.Length];
                    //разбиваем исходный текст на символы типа string
                    for (int i = 0; i < input.Length; i++)
                    {
                        inputArr[i] = Convert.ToString(input[i]);
                    }
                    //разбиваем ключ на символы типа string
                    for (int i = 0; i < key.Length; i++)
                    {
                        keyArr[i] = Convert.ToString(key[i]);
                    }
                    for (int i = 0; i < input.Length; i++)
                    {
                        for (int j = 0; j < alphabet.Length; j++)
                        {
                            //если символ исходного текста есть в алфавите
                            if (inputArr[i] == alphabet[j])
                            {
                                //запоминается номер этого символа в алфавите
                                inputIndex[i] = j;
                            }
                            //если символ ключа находится в алфавите
                            if (keyArr[i] == alphabet[j])
                            {
                                //запоминается номер этого символа в алфавите
                                keyIndex[i] = j;
                            }
                        }
                    }
                    //проверка, является ли знаком элемент, если является, переходим на след. итерацию
                    for (int i = 0; i < inputArr.Length; i++)
                    {
                        if (IsSign(inputArr[i]))
                        {
                            encrypted[i] = inputArr[i];
                            continue;
                        }
                        //вычисляем номер символа, получившегося в результате с помощью формулы:
                        //(номер символа исх. текста + номер символа ключа) / длину алфавита
                        letterNumber = (inputIndex[i] + keyIndex[i]) % alphabet.Length;
                        //запоминаем этот символ
                        encrypted[i] = alphabet[letterNumber];
                        //обнуляем переменную, куда записывали номер элемента
                        letterNumber = 0;
                    }
                    //в текстбокс записываем результат шифрования
                    for (int i = 0; i < inputIndex.Length; i++)
                    {
                        richTextBox2.Text += encrypted[i];
                    }
                }
            }
            else
            {
                MessageBox.Show("Не все обязательные поля заполнены!", "Ошибка!", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Exemplo n.º 12
0
 private void KeyBox_PreviewMouseUp(object sender, MouseButtonEventArgs e)
 {
     KeyBox.SelectAll();
 }
Exemplo n.º 13
0
    void CreateKeyboard(float delay)
    {
        bool isNameAtMaxLength = (slot.player.name.Length >= Config.MAX_CHARS_PER_NAME);
        bool isNameEmpty       = (slot.player.name.Length == 0);

        FSoundManager.PlaySound("UI/LetterIn", 0.25f);

        for (int k = 0; k < 28; k++)
        {
            KeyBox keyBox = new KeyBox(slot.player, k);
            keyBox.soundVolume = 0.5f;

            if (k == SPACE_KEY)
            {
                keyBox.shouldRepeat = false;
            }

            keyBoxes.Add(keyBox);
            keyboardAndSwatchContainer.AddChild(keyBox);

            if (k == SPACE_KEY)
            {
                keyBox.normalSoundName = "UI/ButtonTick";
            }
            else if (k == BACKSPACE_KEY)
            {
                keyBox.normalSoundName = "UI/Backspace";

                FSprite backspaceSprite = new FSprite("Icons/Backspace");
                keyBox.contentContainer.AddChild(backspaceSprite);
                backspaceSprite.color = Color.black;
            }
            else             //the normal letters
            {
                FLabel keyLabel = new FLabel("Raleway", THE_KEYBOARD[k].ToString());
                keyLabel.color = Color.black;
                keyLabel.scale = 0.75f;
                keyBox.contentContainer.AddChild(keyLabel);
                keyBox.normalSoundName = "UI/ButtonTick";
            }

            //disable backspace if it's empty, disable everything BUT backspace if it's full
            if ((k == BACKSPACE_KEY && !isNameEmpty) || (k != BACKSPACE_KEY && !isNameAtMaxLength))
            {
                keyBox.isEnabled = true;
            }
            else
            {
                keyBox.isEnabled = false;
            }

            keyBox.SignalTick += HandleKeyTick;

            keyBox.scale = 0.0f;

            keyBox.colorTweenDelay = 0.019f * k;

            Go.to(keyBox, 0.25f, new TweenConfig()
                  .floatProp("scale", 1.0f)
                  .setDelay(delay + 0.025f * (28f - (float)k))
                  .setEaseType(EaseType.ExpoOut));
        }

        RepositionKeyboard();
    }
Exemplo n.º 14
0
        public void CaesarDecryption()
        {
            richTextBox2.Text = "";
            string input = "";
            int    letterNumber;

            input = richTextBox1.Text;
            string tempKey = KeyBox.Text;
            int    key     = Int32.Parse(tempKey);

            if (richTextBox1.Text != "" && KeyBox.Text != "")
            {
                Regex rgx    = new Regex(@"(^([а-яА-Я0-9\p{P}\s])+$)");
                Regex keyRgx = new Regex(@"(?<=^|\s)([1-9]|([1-6]\d)|(7[0-5]))(?=\s|$)");
                if (!rgx.IsMatch(richTextBox1.Text) || !keyRgx.IsMatch(KeyBox.Text))
                {
                    MessageBox.Show("Были введены неверные символы! Введите другой текст.", "Ошибка!",
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    richTextBox1.Clear();
                    KeyBox.Clear();
                }
                else
                {
                    string[] inputArr   = new string[input.Length];
                    int[]    inputIndex = new int[input.Length];
                    string[] decrypted  = new string[input.Length]; //создание массива для записи результатов дешифрования

                    for (int i = 0; i < input.Length; i++)
                    {
                        inputArr[i] = Convert.ToString(input[i]);
                    }
                    for (int i = 0; i < input.Length; i++)
                    {
                        for (int j = 0; j < alphabet.Length; j++)
                        {
                            if (inputArr[i] == alphabet[j])
                            {
                                inputIndex[i] = j;
                            }
                        }
                    }
                    for (int i = 0; i < inputArr.Length; i++)
                    {
                        if (IsSign(inputArr[i]))
                        {
                            decrypted[i] = inputArr[i];
                            continue;
                        }
                        //вычисляем номер символа, получившегося в результате с помощью формулы:
                        //(номер символа зашифр. текста - ключ + длина алфавита) / длина алфавита
                        letterNumber = (inputIndex[i] - key + alphabet.Length) % alphabet.Length;
                        decrypted[i] = alphabet[letterNumber];
                        letterNumber = 0;
                    }
                    for (int i = 0; i < inputIndex.Length; i++)
                    {
                        richTextBox2.Text += decrypted[i];
                    }
                }
            }
            else
            {
                MessageBox.Show("Не все обязательные поля заполнены!", "Ошибка!", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
Exemplo n.º 15
0
        private void Passphrase_Load(object sender, EventArgs e)
        {
            IList <GnuKey> keys = Globals.OutlookGnuPG.GetKeys();

            if (keys.Count <= 0)
            {
                // No keys available, no use in showing this dialog at all
                Hide();
                return;
            }

//    IList<GnuKey> datasource = new List<GnuKey>();
            List <GnuKey> datasource    = new List <GnuKey>();
            int           selectedCount = 0;

            // 1/ Collect selected keys and sort them.
            foreach (GnuKey gnuKey in keys)
            {
                if (null != _defaultKeys.Find(delegate(string key) { return(gnuKey.Key.StartsWith(key, true, null)); }))
                {
                    selectedCount++;
                    datasource.Add(gnuKey);
                }
            }
            datasource.Sort(new GnuKeySorter());

            // 2/ Collect unselected keys and sort them.
            List <GnuKey> datasource2 = new List <GnuKey>();

            foreach (GnuKey gnuKey in keys)
            {
                if (null == _defaultKeys.Find(delegate(string key) { return(gnuKey.Key.StartsWith(key, true, null)); }))
                {
                    datasource2.Add(gnuKey);
                }
            }
            datasource2.Sort(new GnuKeySorter());

            // Append unselected keys to datasource.
            foreach (GnuKey gnuKey in datasource2)
            {
                datasource.Add(gnuKey);
            }

            // Setup KeyBox
            KeyBox.DataSource    = datasource;
            KeyBox.DisplayMember = "KeyDisplay";
            KeyBox.ValueMember   = "Key";

            int boxHeight = (keys.Count > 10) ? KeyBox.ItemHeight * 10 : KeyBox.ItemHeight * keys.Count;

            KeyBox.Height = boxHeight + 5;
            Height        = boxHeight + 90;

            // Enlarge dialog to fit the longest key
            using (Graphics g = CreateGraphics())
            {
                int maxSize = Width;
                foreach (GnuKey key in datasource)
                {
                    int textWidth = (int)g.MeasureString(key.KeyDisplay, KeyBox.Font).Width + 50;
                    if (textWidth > maxSize)
                    {
                        maxSize = textWidth;
                    }
                }
                Width = maxSize;
                CenterToScreen();
            }

            // Note: Keybox sorted property MUST be False!
            //       unless the custom sort strategy is voided!
            for (int i = 0; i < selectedCount; i++)
            {
                KeyBox.SetItemChecked(i, true);
            }
        }
Exemplo n.º 16
0
 /// <summary>
 /// функция по очистке всех трех боксов: исходный текст, зашифрованный текст и бокс для ввода ключа
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Clear_Click(object sender, EventArgs e)
 {
     richTextBox1.Clear();
     richTextBox2.Clear();
     KeyBox.Clear();
 }
Exemplo n.º 17
0
    void CreateKeyboard(float delay)
    {
        bool isNameAtMaxLength = (slot.player.name.Length >= Config.MAX_CHARS_PER_NAME);
        bool isNameEmpty = (slot.player.name.Length == 0);

        FSoundManager.PlaySound("UI/LetterIn",0.25f);

        for(int k = 0; k<28; k++)
        {
            KeyBox keyBox = new KeyBox(slot.player,k);
            keyBox.soundVolume = 0.5f;

            if(k == SPACE_KEY)
            {
                keyBox.shouldRepeat = false;
            }

            keyBoxes.Add(keyBox);
            keyboardAndSwatchContainer.AddChild(keyBox);

            if(k == SPACE_KEY)
            {
                keyBox.normalSoundName = "UI/ButtonTick";
            }
            else if(k == BACKSPACE_KEY)
            {
                keyBox.normalSoundName = "UI/Backspace";

                FSprite backspaceSprite = new FSprite("Icons/Backspace");
                keyBox.contentContainer.AddChild(backspaceSprite);
                backspaceSprite.color = Color.black;
            }
            else //the normal letters
            {
                FLabel keyLabel = new FLabel("Raleway",THE_KEYBOARD[k].ToString());
                keyLabel.color = Color.black;
                keyLabel.scale = 0.75f;
                keyBox.contentContainer.AddChild(keyLabel);
                keyBox.normalSoundName = "UI/ButtonTick";
            }

            //disable backspace if it's empty, disable everything BUT backspace if it's full
            if((k == BACKSPACE_KEY && !isNameEmpty) || (k != BACKSPACE_KEY && !isNameAtMaxLength))
            {
                keyBox.isEnabled = true;
            }
            else
            {
                keyBox.isEnabled = false;
            }

            keyBox.SignalTick += HandleKeyTick;

            keyBox.scale = 0.0f;

            keyBox.colorTweenDelay = 0.019f*k;

            Go.to(keyBox, 0.25f, new TweenConfig()
                  .floatProp("scale",1.0f)
                  .setDelay(delay + 0.025f*(28f-(float)k))
                  .setEaseType(EaseType.ExpoOut));

        }

        RepositionKeyboard();
    }