コード例 #1
0
 /// <summary>
 /// Gets or sets the value with the given index.
 /// </summary>
 /// <param name="key1">The first key defining the index.</param>
 /// <param name="key2">The second key defining the index.</param>
 /// <returns>The value at this index.</returns>
 public TValue this[TKeys key1, TKeys key2]
 {
     get { if (_storage.ContainsKey(key1, key2))
           {
               return(_storage[key1, key2]);
           }
           else
           {
               return(_storage[key2, key1]);
           } }
     set { _storage[key1, key2] = value; if (!(_storage.ContainsKey(key1, key2) || _storage.ContainsKey(key2, key1)))
           {
               _keys.Add(new Tuple <TKeys, TKeys>(key1, key2));
           }
     }
 }
コード例 #2
0
        private void RemoveClient(ClientType clientType, int clientID)
        {
            if (_clientItems.ContainsKey(clientType, clientID))
            {
                this.Dispatcher.Invoke(() =>
                {
                    // Remove the controls
                    switch (clientType)
                    {
                    case ClientType.R:
                        {
                            TreeViewItemRobots.Items.Remove(_clientItems[clientType, clientID]);
                            _botPositionBlocks.Remove(clientID);
                            _botOrientationBlocks.Remove(clientID);
                        }
                        break;

                    case ClientType.I: { TreeViewItemIStations.Items.Remove(_clientItems[clientType, clientID]); } break;

                    case ClientType.O: { TreeViewItemOStations.Items.Remove(_clientItems[clientType, clientID]); } break;

                    case ClientType.C: { TreeViewItemControllers.Items.Remove(_clientItems[clientType, clientID]); } break;

                    default: throw new ArgumentException("Unknown client-type: " + clientType.ToString());
                    }
                    _clientItems.Remove(clientType, clientID);
                    // Remove direct command box
                    TextBox relatedDirectTextBox = _inputBoxClients.First(e => e.Value.Type == clientType && e.Value.ID == clientID).Key;
                    _inputBoxClients.Remove(relatedDirectTextBox);
                    // Remove control emulation box if one was attached
                    if (clientType != ClientType.C)
                    {
                        TextBox relatedEmulatedControlTextBox = _inputBoxEmulatedControls.First(e => e.Value.Type == clientType && e.Value.ID == clientID).Key;
                        _inputBoxEmulatedControls.Remove(relatedEmulatedControlTextBox);
                    }
                });
            }
        }