Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static Dictionary <string, KeySet> LoadSettings(string fileName)
        {
            var shortcutKeys = new Dictionary <string, KeySet>();

            try
            {
                var xml = XDocument.Load(fileName);

                var root = xml.Element(ElementNameShortcutkeys);

                var keys = root.Elements(ElementNameKey);
                foreach (var key in keys)
                {
                    var keyName = key.Attribute(AttributeName)?.Value;
                    if (!string.IsNullOrWhiteSpace(keyName))
                    {
                        var keySet = new KeySet();
                        keySet.Name    = keyName;
                        keySet.KeyText = key.Value;
                        keySet.Keys    = KeyTextToKey(key.Value);
                        shortcutKeys.Add(keyName, keySet);
                    }
                }
            }
            catch
            {
                return(null);
            }

            return(shortcutKeys);
        }
Ejemplo n.º 2
0
        public void TestSymetricKeyExport()
        {
            var ks = new KeySet(Util.TestDataPath(TEST_DATA, "aes"));

            Expect(() => ks.ExportPrimaryAsPkcs(Path.Combine(Path.GetTempPath(), "dummy.pem"), () => "dummy"),
                   Throws.InstanceOf <InvalidKeyTypeException>());
        }
Ejemplo n.º 3
0
        public static Horizon CreateBasicHorizon()
        {
            IFileSystem rootFs = new InMemoryFileSystem();
            var         keySet = new KeySet();

            var horizon = new Horizon(new HorizonConfiguration());

            HorizonClient fsServerClient = horizon.CreatePrivilegedHorizonClient();
            var           fsServer       = new FileSystemServer(fsServerClient);

            var defaultObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(rootFs, keySet, fsServer);

            var config = new FileSystemServerConfig();

            config.FsCreators     = defaultObjects.FsCreators;
            config.DeviceOperator = defaultObjects.DeviceOperator;
            config.ExternalKeySet = new ExternalKeySet();

            FileSystemServerInitializer.InitializeWithConfig(fsServerClient, fsServer, config);

            HorizonClient bcatServerClient = horizon.CreateHorizonClient();

            _ = new BcatServer(bcatServerClient);

            return(horizon);
        }
Ejemplo n.º 4
0
        public void ToStringKeySetFromRanges()
        {
            var ranges = KeySet.FromRanges(
                KeyRange.ClosedOpen(new Key("beginKeyPart1", "beginKeyPart2"), new Key("endKeyPart1", "endKeyPart2")), KeyRange.ClosedClosed(new Key(1L), new Key(2L)));

            Assert.Equal("KeySet {Ranges = [[[ \"beginKeyPart1\", \"beginKeyPart2\" ], [ \"endKeyPart1\", \"endKeyPart2\" ]), [[ \"1\" ], [ \"2\" ]]]}", ranges.ToString());
        }
Ejemplo n.º 5
0
 public TLSSession(IPEndPoint ipEndPoint, QueueItem toSend, KeySet clientKeys, TlsKeyPairSet signingKeys)
 {
     _ipEndPoint  = ipEndPoint;
     _toSend      = toSend;
     _clientKeys  = clientKeys;
     _signingKeys = signingKeys;
 }
Ejemplo n.º 6
0
        private static string BuildDefaultKeySetFile(KeySet keySet)
        {
            var sb = new IndentingStringBuilder();

            sb.AppendLine(GetHeader());
            sb.AppendLine();

            sb.AppendLine("using System;");
            sb.AppendLine();

            sb.AppendLine("namespace LibHac.Common.Keys");
            sb.AppendLineAndIncrease("{");

            sb.AppendLine("internal static partial class DefaultKeySet");
            sb.AppendLineAndIncrease("{");

            BuildArray(sb, "RootKeysDev", SpanHelpers.AsReadOnlyByteSpan(in keySet.KeyStruct._rootKeysDev));
            BuildArray(sb, "RootKeysProd", SpanHelpers.AsReadOnlyByteSpan(in keySet.KeyStruct._rootKeysProd));
            BuildArray(sb, "KeySeeds", SpanHelpers.AsReadOnlyByteSpan(in keySet.KeyStruct._keySeeds));
            BuildArray(sb, "StoredKeysDev", SpanHelpers.AsReadOnlyByteSpan(in keySet.KeyStruct._storedKeysDev));
            BuildArray(sb, "StoredKeysProd", SpanHelpers.AsReadOnlyByteSpan(in keySet.KeyStruct._storedKeysProd));
            BuildArray(sb, "DerivedKeysDev", SpanHelpers.AsReadOnlyByteSpan(in keySet.KeyStruct._derivedKeysDev));
            BuildArray(sb, "DerivedKeysProd", SpanHelpers.AsReadOnlyByteSpan(in keySet.KeyStruct._derivedKeysProd));
            BuildArray(sb, "DeviceKeys", SpanHelpers.AsReadOnlyByteSpan(in keySet.KeyStruct._deviceKeys));
            BuildArray(sb, "RsaSigningKeysDev", SpanHelpers.AsReadOnlyByteSpan(in keySet.KeyStruct._rsaSigningKeysDev));
            BuildArray(sb, "RsaSigningKeysProd", SpanHelpers.AsReadOnlyByteSpan(in keySet.KeyStruct._rsaSigningKeysProd));
            BuildArray(sb, "RsaKeys", SpanHelpers.AsReadOnlyByteSpan(in keySet.KeyStruct._rsaKeys));

            sb.DecreaseAndAppendLine("}");
            sb.DecreaseAndAppendLine("}");

            return(sb.ToString());
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Creates the A-Z keys, start value changes the displayed characters
        /// </summary>
        void CreateAlphabet(int start, ref List <KeySet> list)
        {
            int count   = 0;
            int codeVal = 65;

            if (start == 65)
            {
                codeVal += 256;
            }

            for (int i = start; i < start + 26; i = i + 3)
            {
                KeySet temp = new KeySet();

                for (int j = 0; j < 3; j++)
                {
                    if (count == 26)
                    {
                        break;
                    }

                    temp.keygroup.Add(new Key((char)(i + j), codeVal + count));
                    temp.size += 1;
                    count++;
                }

                list.Add(new KeySet(temp));
            }

            CreateKeyGroup(new char[] { '.', ',', '\'' }, new int[] { 190, 188, 192 }, 3, ref list);
            CreateKeyGroup(new char[] { '!', '?', '@' }, new int[] { 49 + 256, 191 + 256, 192 + 256 }, 3, ref list);
        }
Ejemplo n.º 8
0
 public override bool Control( GameEntity control, TimeSpan gameTime, Microsoft.Xna.Framework.Input.KeyboardState keyState )
 {
     if ( selectedTank == null )
     {
         List<Tank> TanksCopy = new List<Tank>( Tanks );
         if ( TanksCopy.Count == 0 )
             return true;
         int i = r.Next( TanksCopy.Count );
         while ( TanksCopy[ i ].Controller is MindController )
         {
             TanksCopy.RemoveAt( i );
             i = r.Next( TanksCopy.Count );
             if ( TanksCopy.Count == 0 )
                 return true;
         }
         selectedTank = TanksCopy[ i ];
     }
     if ( controlKeys == null )
     {
         controlKeys = selectedTank.Keys;
         selectedTank.Keys = Owner.Keys;
         Owner.Keys = new KeySet( Keys.None, Keys.None, Keys.None, Keys.None, Owner.Keys.KeyPlace, Keys.None );
     }
     base.Control( control, gameTime, keyState );
     return true;
 }
Ejemplo n.º 9
0
 public MindController( int LifeTime )
     : base(LifeTime)
 {
     controlKeys = null;
     r = new Random();
     Tanks = new List<Tank>();
 }
Ejemplo n.º 10
0
 public DTLSClientChannel(CWT cwt, OneKey userKey, KeySet cwtTrustKeys, int port)
 {
     _port          = port;
     _userKey       = userKey;
     _userCwt       = cwt;
     CwtTrustKeySet = cwtTrustKeys;
 }
Ejemplo n.º 11
0
        private void Initialize()
        {
            KeySet loggerSettings = KeySetConfiguration.Config(LOGGER_SECTION);

            if (loggerSettings == null)
            {
                throw new ConfigurationErrorsException(string.Format(CultureInfo.CurrentCulture, ResourceData.MissingConfigSetting, LOGGER_SECTION));
            }

            _applicationId             = int.Parse(loggerSettings.Keys[APPLICATION_ID_KEY].Value, CultureInfo.InvariantCulture);
            _logFrameworkTraceMessages = string.Compare(loggerSettings.Keys[LOG_FRAMEWORK_TRACE_MESSAGES_KEY].Value, "true", true, CultureInfo.InvariantCulture) == 0 ? true : false;

            LoggerTraceListener listener = new LoggerTraceListener();

            if (Trace.Listeners.Contains(listener) == false)
            {
                Trace.Listeners.Add(listener);
            }

            _logFailuresToDisk = string.Compare(loggerSettings.Keys[LOG_FAILURES_TO_DISK_KEY].Value, "true", true, CultureInfo.InvariantCulture) == 0 ? true : false;
            if (_logFailuresToDisk == true)
            {
                _failurePath = loggerSettings.Keys[FAILURE_PATH_KEY].Value;
            }

            _loggingLevels = new LogLevelSettings(loggerSettings);

            _transports = new TransportSettings[loggerSettings.KeySets[TRANSPORTS_KEY].KeySets.Count];

            for (int i = 0; i < loggerSettings.KeySets[TRANSPORTS_KEY].KeySets.Count; i++)
            {
                _transports[i] = new TransportSettings(loggerSettings.KeySets[TRANSPORTS_KEY].KeySets[i]);
            }
        }
Ejemplo n.º 12
0
        public VirtualKey(VirtualKeyboard keyboard, KeySet keySet, KeySetRow row, Key key)
        {
            _keyboard = keyboard;
            _keySet   = keySet;
            _key      = key;

            if (row.IndexOf(key) < row.Count / 2)
            {
                _popupFlowDirection = FlowDirection.LeftToRight;
            }
            else
            {
                _popupFlowDirection = FlowDirection.RightToLeft;
            }

            PrimaryAction = new VirtualKeyAction(keyboard, keySet, key.DefaultAction, key.Width);
            Loaded       += (s, e) =>
            {
                if (AlternativesPopup != null)
                {
                    if (_popupFlowDirection == FlowDirection.LeftToRight)
                    {
                        AlternativesPopup.HorizontalOffset = -ActualWidth;
                        AlternativesPopup.Placement        = PlacementMode.Right;
                    }
                    else
                    {
                        AlternativesPopup.HorizontalOffset = ActualWidth;
                        AlternativesPopup.Placement        = PlacementMode.Left;
                    }
                }
            };
        }
Ejemplo n.º 13
0
 public XciItem(Xci xci, string name, IFile file, KeySet keySet)
 {
     Xci    = xci ?? throw new ArgumentNullException(nameof(xci));
     Name   = name ?? throw new ArgumentNullException(nameof(name));
     _file  = file ?? throw new ArgumentNullException(nameof(file));
     KeySet = keySet ?? throw new ArgumentNullException(nameof(keySet));
 }
Ejemplo n.º 14
0
        public void Add(Keybind keybind, Action keyDown, Action keyUp, bool canActWhenKeyRepeat = false)
        {
            var keys = new KeySet(keybind);

            Add(KeyState.Down, keys, keyDown, canActWhenKeyRepeat);
            Add(KeyState.Up, keys, keyUp, canActWhenKeyRepeat);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Clear all items of the Collection
        /// </summary>
        public override void Clear()
        {
            if (RootNode == null)
            {
                throw new InvalidOperationException("Can't Clear items of a Close ObjectStore.");
            }

            RemoveDeletedDataBlocks();
            if (HintSequentialRead)
            {
                HintSequentialRead = false;
            }
            if (Count > 0)
            {
                CurrentSequence = 0;
                RootNode.Clear();
                SetCurrentItemAddress(-1, 0);
                if (DataSet != null)
                {
                    DataSet.Clear();
                }
                if (KeySet != null)
                {
                    KeySet.Clear();
                }
                base.Clear();
            }
            PromoteLookup.Clear();
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Close the collection
        /// </summary>
        public override void Close()
        {
            if (!IsOpen)
            {
                return;
            }
            RemoveDeletedDataBlocks();
            HintSequentialRead = false;
            base.Close();
            if (DataSet != null)
            {
                DataSet.Close();
            }
            KeySet.Close();
            SetCurrentItemAddress(-1, 0);

            if (!IsCloned)
            {
                RootNode.Dispose();
            }
            RootNode         = null;
            currentDataBlock = null;
            currentEntry     = null;

            if (IsCloned || Transaction == null)
            {
                return;
            }
            // remove this collection from being processed in Transaction Commit (as was fully flushed and stream was closed).
            ((Transaction.Transaction)Transaction).TrackModification(this, true);

            DisposeCachedItems();
        }
Ejemplo n.º 17
0
 public DtlsServer(TlsKeyPairSet serverKeys, KeySet userKeys)
 {
     _serverKeys         = serverKeys;
     _userKeys           = userKeys;
     mPskIdentityManager = new MyIdentityManager(userKeys);
     mPskIdentityManager.TlsEventHandler += OnTlsEvent;
 }
Ejemplo n.º 18
0
            internal MyIdentityManager(KeySet keys)
            {
                _userKeys = keys;
#if SUPPORT_TLS_CWT
                CwtAuthenticationKey = null;
#endif
            }
Ejemplo n.º 19
0
 /// <summary>
 /// Open the collection
 /// </summary>
 public override void Open()
 {
     RemoveDeletedDataBlocks();
     base.Open();
     if (DataSet != null)
     {
         DataSet.IsDeletedBlocksList = IsDeletedBlocksList;
     }
     KeySet.IsDeletedBlocksList = IsDeletedBlocksList;
     if (DataSet != null)
     {
         DataSet.Open();
     }
     KeySet.Open();
     if (RootNode != null)
     {
         if (!RootNeedsReload)
         {
             MoveFirst();
         }
     }
     else
     {
         RootNode = new BTreeNodeOnDisk(this);
     }
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Open the collection
        /// </summary>
        public override void Open()
        {
            RemoveDeletedDataBlocks();
            base.Open();
            if (DataSet != null)
            {
                DataSet.IsDeletedBlocksList = IsDeletedBlocksList;
            }
            KeySet.IsDeletedBlocksList = IsDeletedBlocksList;
            if (DataSet != null)
            {
                DataSet.Open();
            }
            KeySet.Open();
            if (RootNode != null)
            {
                if (!RootNeedsReload)
                {
                    MoveFirst();
                }
            }
            else
            {
                RootNode = new BTreeNodeOnDisk(this);
            }

            // log the read HeaderData information useful for debugging.
            //Log.Logger.Instance.Warning(ToString());
        }
Ejemplo n.º 21
0
 internal DtlsServer(KeySet serverKeys, KeySet userKeys)
 {
     _serverKeys         = serverKeys;
     _userKeys           = userKeys;
     mPskIdentityManager = new MyIdentityManager(userKeys);
     mPskIdentityManager.TlsEventHandler += OnTlsEvent;
 }
Ejemplo n.º 22
0
        public void TestDemoteRevoke()
        {
            string result;

            var path = Util.TestDataPath(TEST_DATA, "demote");

            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }

            result = Util.KeyczarTool(create: null, location: path, purpose: "crypt");

            Expect(result, Is.StringContaining(KeyczarTool.Localized.MsgCreatedKeySet));

            result = Util.KeyczarTool(addkey: null, location: path, status: "primary");

            Expect(result, Is.StringContaining(KeyczarTool.Localized.MsgCreatedKey));


            result = Util.KeyczarTool(demote: null, location: path, version: 1);
            Expect(result, Is.StringContaining("ACTIVE"));

            result = Util.KeyczarTool(demote: null, location: path, version: 1);
            Expect(result, Is.StringContaining("INACTIVE"));

            result = Util.KeyczarTool(revoke: null, location: path, version: 1);
            Expect(result, Is.StringContaining(KeyczarTool.Localized.MsgRevokedVersion));

            var ks = new KeySet(path);

            Expect(ks.Metadata.Versions.Any(), Is.False);

            Directory.Delete(path, true);
        }
Ejemplo n.º 23
0
        public VirtualKey(VirtualKeyboard keyboard, KeySet keySet, KeySetRow row, Key key)
        {
            _keyboard = keyboard;
            _keySet = keySet;
            _key = key;

            if (row.IndexOf(key) < row.Count/2)
                _popupFlowDirection = FlowDirection.LeftToRight;
            else
                _popupFlowDirection = FlowDirection.RightToLeft;

            PrimaryAction = new VirtualKeyAction(keyboard, keySet, key.DefaultAction, key.Width);
            Loaded += (s, e) =>
            {
                if (AlternativesPopup != null)
                {
                    if (_popupFlowDirection == FlowDirection.LeftToRight)
                    {
                        AlternativesPopup.HorizontalOffset = -ActualWidth;
                        AlternativesPopup.Placement = PlacementMode.Right;
                    }
                    else
                    {
                        AlternativesPopup.HorizontalOffset = ActualWidth;
                        AlternativesPopup.Placement = PlacementMode.Left;
                    }
                }
            };
        }
Ejemplo n.º 24
0
 public TLSSession(TcpClient client, KeySet clientKeys, TlsKeyPairSet signingKeys)
 {
     _client      = client;
     _ipEndPoint  = (IPEndPoint)client.Client.RemoteEndPoint;
     _clientKeys  = clientKeys;
     _signingKeys = signingKeys;
 }
Ejemplo n.º 25
0
 public DTLSChannel(TlsKeyPairSet serverKeys, KeySet userKeys, Int32 port, KeySet cwtTrustRoots = null)
 {
     _port          = port;
     _userKeys      = userKeys;
     _serverKeys    = serverKeys;
     _cwtTrustRoots = cwtTrustRoots;
 }
Ejemplo n.º 26
0
        public void TestEncryptedKeysetForNonEncryptedData()
        {
            var nonEncryptedPath = Util.TestDataPath(TEST_DATA, "rsa");

            using (var pbereader = KeySet.LayerSecurity(
                       FileSystemKeySet.Creator(nonEncryptedPath),
                       PbeKeySet.Creator(() => "dummy")

                       ))
            {
                var key = pbereader.GetKey(1);
                Expect(key, Is.Not.Null);
            }


            using (var crypter = new Crypter(nonEncryptedPath))
                using (var encreader = KeySet.LayerSecurity(
                           FileSystemKeySet.Creator(nonEncryptedPath),
                           EncryptedKeySet.Creator(crypter)
                           ))
                {
                    var key = encreader.GetKey(1);
                    Expect(key, Is.Not.Null);
                }
        }
Ejemplo n.º 27
0
 /// <summary>
 /// Sets the set for all keys.
 /// </summary>
 /// <param name="state"></param>
 private void SetKeys(KeySet state)
 {
     for (int i = 0; i < keys.Length; i++)
     {
         keys[i].SetKeyText(state);
     }
 }
Ejemplo n.º 28
0
        public static Horizon CreateWithDefaultFsConfig(HorizonConfiguration config, IFileSystem rootFileSystem,
                                                        KeySet keySet)
        {
            var horizon = new Horizon(config);

            HorizonClient fsServerClient = horizon.CreatePrivilegedHorizonClient();
            var           fsServer       = new FileSystemServer(fsServerClient);

            var defaultObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(rootFileSystem, keySet, fsServer);

            var fsServerConfig = new FileSystemServerConfig
            {
                DeviceOperator = defaultObjects.DeviceOperator,
                ExternalKeySet = keySet.ExternalKeySet,
                FsCreators     = defaultObjects.FsCreators,
            };

            FileSystemServerInitializer.InitializeWithConfig(fsServerClient, fsServer, fsServerConfig);

            HorizonClient bcatServerClient = horizon.CreateHorizonClient();

            _ = new BcatServer(bcatServerClient);

            return(horizon);
        }
Ejemplo n.º 29
0
        private KeySet GenerateKeySet(Key key, KeySet keysState)
        {
            var mod    = keysState.Keys.Where(x => x.IsModifiersKey());
            var result = new KeySet(mod.Concat(new[] { key }).ToArray());

            return(result);
        }
Ejemplo n.º 30
0
        public override int Run(string[] remainingArguments)
        {
            var     ret     = 0;
            Crypter crypter = null;
            IKeySet ks      = new KeySet(_location);

            Func <string> prompt = CachedPrompt.Password(() =>
            {
                Console.WriteLine(Localized.MsgForKeySet);
                return(Util.PromptForPassword());
            }).Prompt;

            IDisposable dks = null;

            if (!String.IsNullOrWhiteSpace(_crypterLocation))
            {
                if (_password)
                {
                    var cks = new PbeKeySet(_crypterLocation, prompt);
                    crypter = new Crypter(cks);
                    dks     = cks;
                }
                else
                {
                    crypter = new Crypter(_crypterLocation);
                }
                ks = new EncryptedKeySet(ks, crypter);
            }
            else if (_password)
            {
                ks = new PbeKeySet(ks, prompt);
            }
            var d2ks = ks as IDisposable;


            using (crypter)
                using (dks)
                    using (d2ks)
                    {
                        if (!ks.ExportPrimaryAsPkcs(_destination, CachedPrompt.Password(() =>
                        {
                            Console.WriteLine(
                                Localized.MsgForExport);
                            return
                            (Util.DoublePromptForPassword
                                 ());
                        }).Prompt))
                        {
                            ret = -1;
                        }
                        else
                        {
                            Console.WriteLine(Localized.MsgExportedPem);
                        }
                    }


            return(ret);
        }
Ejemplo n.º 31
0

        
Ejemplo n.º 32
0
 public Action GetAction(KeySet keys, KeyState state = KeyState.Down)
 {
     if (_keybinds[state].ContainsKey(keys))
     {
         return(_keybinds[state][keys]);
     }
     return(null);
 }
Ejemplo n.º 33
0
 public bool CanActWhenKeyRepeat(KeySet keys)
 {
     if (_canActWhenKeyRepeat.ContainsKey(keys))
     {
         return(_canActWhenKeyRepeat[keys]);
     }
     return(false);
 }
        public VirtualKeyAction(VirtualKeyboard keyboard, KeySet keySet, KeyActionPair pair, double keyWidth)
        {
            _keyboard = keyboard;
            _keySet = keySet;
            _pair = pair;
            _width = keyWidth;

            _keyboard.IsShiftHeldChanged += IsShiftHeldChanged;
            _keyboard.KeySetChanged += KeySetChanged;
        }
Ejemplo n.º 35
0
 public Concealer( GameTime gameTime )
     : base(gameTime, 10000)
 {
     toSwitch = random.Next( 2 ) == 0;
     if ( Owner != null )
     {
         SwitchedTank = Owner;
         origColor = Owner.TankColor;
         origKeys = Owner.Keys;
     }
 }
Ejemplo n.º 36
0
 public override void DoPickup( TankObject[] Tanks, HashSet<ProjectileObject> Projectiles, HashSet<FenceObject> Fences )
 {
     if ( SwitchedTank == null )
     {
         SwitchedTank = Owner;
         origColor = Owner.TankColor;
         origKeys = Owner.Keys;
     }
     if ( !didSwitch && Tanks.Count<TankObject>(x => x.IsInGame) > 1)
     {
         HashSet<TankObject> TankSet = new HashSet<TankObject>( Tanks );
         foreach ( TankObject tank in Tanks )
         {
             if ( !tank.IsInGame || tank == Owner )
             {
                 TankSet.Remove( tank );
             }
         }
         SwitchedTank = ( TankSet.ToArray<TankObject>() )[ random.Next( TankSet.Count ) ];
         if ( toSwitch )
         {
             Vector2 OwnerPos = Owner.Position;
             float OwnerRot = Owner.Rotation;
             float OwnerScale = Owner.Scale;
             Owner.Position = SwitchedTank.Position;
             Owner.Rotation = SwitchedTank.Rotation;
             Owner.Scale = SwitchedTank.Scale;
             SwitchedTank.Position = OwnerPos;
             SwitchedTank.Rotation = OwnerRot;
             SwitchedTank.Scale = OwnerScale;
         }
         didSwitch = true;
     }
     Owner.TankColor = SwitchedTank.TankColor;
     Owner.Keys = SwitchedTank.Keys;
 }
 public VirtualKeySet(VirtualKeyboard keyboard, KeySet keySet)
 {
     Rows = keySet.Select(row => new VirtualKeySetRow(keyboard, keySet, row)).ToArray();
 }
		internal void AddPropertyValues (string[] names, string[] values)
		{
			var key = new KeySet (names);
			ImmutableList<ValueSet> list;
			ValueSet valueSet;

			// First register the combination of values

			if (!combinedProps.TryGetValue (key, out list)) {
				list = ImmutableList<ValueSet>.Empty;
				valueSet = new ValueSet (names, names, values);
			} else {
				// If there is already a list, there must be at least one item.
				// Use the reference key of that item, so they share the same reference key array
				valueSet = new ValueSet (list [0].ReferenceKeys, names, values);
			}

			if (!list.Contains (valueSet))
				combinedProps[key] = list.Add (valueSet);

			// Now register each value individually

			ImmutableList<string> valList;
			for (int n = 0; n < names.Length; n++) {
				var name = names [n];
				var val = values [n];
				if (!props.TryGetValue (name, out valList))
					valList = ImmutableList<string>.Empty;
				if (!valList.Contains (val))
					props[name] = valList.Add (val);
			}
		}
 public VirtualKeySetRow(VirtualKeyboard keyboard, KeySet keySet, KeySetRow row)
 {
     _row = row;
     Keys = row.Select(key => new VirtualKey(keyboard, keySet, row, key)).ToArray();
 }
Ejemplo n.º 40
0
				public IteratorOverKeySet(KeySet keySet)
				{
					mMapEntrySet = keySet;
				}
        public static KeySet En()
        {
            var group = new KeySetGroup();

            var letters = new KeySet("EN")
            {
                new KeySetRow
                {
                    new Key('q'),
                    new Key('w'),
                    new Key('e', 'ë', 'é', 'ê', 'è'),
                    new Key('r'),
                    new Key('t', 'þ', 'ť', 'ţ'),
                    new Key('y', 'Ÿ', 'ý'),
                    new Key('u', 'ü', 'ú', 'û', 'ù'),
                    new Key('i', 'ï', 'í', 'î', 'ì'),
                    new Key('o', 'ö', 'ó', 'ô', 'ò', 'ø', 'œ'),
                    new Key('p'),
                    new Key(new BackspaceAction()) {Width = 2}
                },
                new KeySetRow(0.25)
                {
                    new Key('a', 'ä', 'á', 'â', 'à', 'å', 'æ'),
                    new Key('s', 'ß', '§'),
                    new Key('d', 'ð'),
                    new Key('f'),
                    new Key('g'),
                    new Key('h'),
                    new Key('j'),
                    new Key('k'),
                    new Key('l'),
                    new Key('\''),
                    new Key(new AcceptAction()) {Width = 1.75}
                },
                new KeySetRow
                {
                    new Key(new ShiftAction()),
                    new Key('z'),
                    new Key('x'),
                    new Key('c', 'ç', '©'),
                    new Key('v'),
                    new Key('b'),
                    new Key('n', 'ñ'),
                    new Key('m', 'µ'),
                    new Key(','),
                    new Key('.'),
                    new Key('?', '¿'),
                    new Key(new ShiftAction())
                },
                new KeySetRow
                {
                    new Key(new KeySetAction(group)) {Width = 1.25},
                    new Key('/'),
                    new Key(' ') {Width = 6.75},
                    new Key(new LeftAction()),
                    new Key(new RightAction()),
                    new Key(new CancelAction())
                }
            };

            var numbers = new KeySet("EN")
            {
                new KeySetRow
                {
                    new Key('1'),
                    new Key('2'),
                    new Key('3'),
                    new Key('4'),
                    new Key('5'),
                    new Key('6'),
                    new Key('7'),
                    new Key('8'),
                    new Key('9'),
                    new Key('0'),
                    new Key(new BackspaceAction()) {Width = 2}
                },
                new KeySetRow(0.25)
                {
                    new Key('\\'),
                    new Key('@'),
                    new Key('#'),
                    new Key(':'),
                    new Key(';'),
                    new Key('~'),
                    new Key('-'),
                    new Key('+'),
                    new Key('(', '{', '[', '<'),
                    new Key(')', '}', ']', '>'),
                    new Key(new AcceptAction()) {Width = 1.75}
                },
                new KeySetRow
                {
                    new Key('&'),
                    new Key('?', '¿'),
                    new Key('!', '¡'),
                    new Key('$', '£', '€', '¥', '¢', '₹', '¤'),
                    new Key('£', '$', '€', '¥', '¢', '₹', '¤'),
                    new Key('€', '$', '£', '¥', '¢', '₹', '¤'),
                    new Key('%', '‰'),
                    new Key('_'),
                    new Key('^'),
                    new Key('*'),
                    new Key('"'),
                    new Key('=')
                },
                new KeySetRow
                {
                    new Key(new KeySetAction(group)) {Width = 1.25},
                    new Key('/'),
                    new Key(' ') {Width = 6.75},
                    new Key(new LeftAction()),
                    new Key(new RightAction()),
                    new Key(new CancelAction())
                }
            };

            group.Add("abc", letters);
            group.Add("&123", numbers);

            return letters;
        }
Ejemplo n.º 42
0
        /// <summary>
        /// Creates the A-Z keys, start value changes the displayed characters
        /// </summary>
        void CreateAlphabet(int start, ref List<KeySet> list)
        {
            int count = 0;
            int codeVal = 65;

            if (start == 65)
                codeVal += 256;

            for (int i = start; i < start+26; i = i + 3)
            {
                KeySet temp = new KeySet();

                for (int j = 0; j < 3; j++)
                {
                    if (count == 26)
                        break;

                    temp.keygroup.Add(new Key((char)(i + j), codeVal + count));
                    temp.size += 1;
                    count++;
                }

                list.Add(new KeySet(temp));
            }

            CreateKeyGroup(new char[] { '.', ',', '\'' }, new int[] { 190, 188, 192 }, 3, ref list);
            CreateKeyGroup(new char[] { '!', '?', '@' }, new int[] { 49 + 256, 191 + 256, 192 + 256 }, 3, ref list);
        }
Ejemplo n.º 43
0
        /// <summary>
        /// Create a set of keys and add it to an existing list of keysets / module
        /// </summary>
        void CreateKeyGroup(char[] items, int[] codes, int size, ref List<KeySet> set)
        {
            KeySet temp = new KeySet();
            temp.size = size;

            for (int i = 0; i < size; i++)
            {
                temp.keygroup.Add(new Key(items[i], codes[i]));
            }

            set.Add(new KeySet(temp));
        }
Ejemplo n.º 44
0
 public KeySet(KeySet t)
 {
     keygroup = t.keygroup;
     size = t.size;
 }