private void InitializePairing()
 {
     do
     {
         this._pairingCodes = PairingCodeSet.GenerateRandom();
     }
     while (!_clientHandler.RegisterPairingCodes(_parent, _pairingCodes));
     // Update UI
     this.PincodeTextBlock.Text = _pairingCodes.PinCode.Code;
     this.PinCodeShowerBottom.PinCode = _pairingCodes.PinCode.Code;
     this.PinCodeShowerTop.PinCode = _pairingCodes.PinCode.Code;
 }
 /// <summary>
 /// When a set of pairing codes have been generated, they should be 
 /// registered, so that no one else can use them.
 /// A bool is returned indicating whether the registration went well.
 /// </summary>
 public bool RegisterPairingCodes(ClientTagVisualization visualization, PairingCodeSet codes)
 {
     bool codeNotInUse = true;
     lock (_pairingCodeToVisualisationDictionaryLock)
     {
         // Check if the pin code is already registered
         if (_pairingCodeToVisualisationLookUp.ContainsKey(codes.PinCode.Type))
         {
             if (_pairingCodeToVisualisationLookUp[codes.PinCode.Type].ContainsKey(codes.PinCode.Code))
             {
                 codeNotInUse = false; // Codes already in use
             }
         }
         else
         {
             // If there is not any Pin Codes registered
             _pairingCodeToVisualisationLookUp.Add(codes.PinCode.Type, new Dictionary<string, ClientTagVisualization>());
         }
         if (codeNotInUse)
         {
             _pairingCodeToVisualisationLookUp[codes.PinCode.Type].Add(codes.PinCode.Code, visualization);
         }
     }
     return codeNotInUse;
 }