public override void Unload() { base.Unload(); this.subObjects.Remove(this.rect); this.subObjects.Remove(this.label); BoundKey.Remove(this.controlKey); }
void ReleaseSerializationKey(string initiationSource) { try { if (initiationSource == null) { return; } while (true) { try { BoundKey binding = _Keys.Values.FirstOrDefault(i => i.InitiationSource != null && i.InitiationSource.ToUpper() == initiationSource.ToUpper()); if (binding != null) { lock (binding) { binding.Clear(); } } break; } catch { } } } catch (Exception ex) { STEM.Sys.EventLog.WriteEntry("KeyedDeploymentController.ReleaseSerializationKey", ex.ToString(), STEM.Sys.EventLog.EventLogEntryType.Error); } }
public override sealed DeploymentDetails GenerateDeploymentDetails(IReadOnlyList <string> listPreprocessResult, string initiationSource, string recommendedBranchIP, IReadOnlyList <string> limitedToBranches) { DeploymentDetails ret = null; try { recommendedBranchIP = LockSerializationKey(initiationSource, recommendedBranchIP); if (recommendedBranchIP != null) { ret = GenerateDeploymentDetailsSerializationVerified(listPreprocessResult, initiationSource, recommendedBranchIP); if (ret == null) { lock (_Keys) { BoundKey binding = _Keys.Values.FirstOrDefault(i => i.InitiationSource.ToUpper() == initiationSource.ToUpper()); if (binding != null) { binding.InitiationSource = null; binding.Assigned = false; binding.FileSize = 0; } } } } } catch (Exception ex) { STEM.Sys.EventLog.WriteEntry("KeyedDeploymentController.GenerateDeploymentDetails", ex.ToString(), STEM.Sys.EventLog.EventLogEntryType.Error); ReleaseSerializationKey(initiationSource); ret = null; } return(ret); }
private ManualMove AddMove(ManualMove move, BoundKey binding) { int id = moves.Count; move.SetIdAndListener(id, HandleMoveStateChange); moves.Add(move); StateHandler.keyBindings.ListenKeyUp(binding, move.HandleKeyUp); StateHandler.keyBindings.ListenKeyDown(binding, move.HandleKeyDown); return(move); }
public void RegisterHotKey(BoundKeys BK) { _currentId++; BoundKey temp = new BoundKey(); temp.Key = BK; temp.Id = _currentId; keyList.Add(temp); if (!RegisterHotKey(_window.Handle, _currentId, 0u, (uint)BK.Key)) { throw new InvalidOperationException("Couldn’t register the hot key."); } }
private void Initalize(string defaultKey) { if (this.collisionCheck && BoundKey.ContainsValue(defaultKey) && defaultKey != none) { //defaultKey Conflict! //string anotherControlKey; foreach (KeyValuePair <string, string> item in BoundKey) { if (item.Value == defaultKey) { string anotherMod = Regex.Split(item.Key, "_")[0]; if (modID != anotherMod) { Debug.LogError(string.Concat("More than two mods are using same defaultKey!", Environment.NewLine, "Conflicting Control: ", item.Key, " & ", controlKey, " (duplicate defalutKey: ", item.Value, ")" )); this._desError = string.Concat("Conflicting defaultKey with Mod ", anotherMod); break; } throw new ElementFormatException(this, "You are using duplicated defaultKey for OpKeyBinders!", key); } } } else { this._desError = ""; } if (this.collisionCheck) { BoundKey.Add(this.controlKey, defaultKey); } this._description = ""; this.rect = new DyeableRect(menu, owner, this.pos, this.size, true); this.subObjects.Add(this.rect); this.rect.fillAlpha = 0.3f; this.label = new MenuLabel(menu, owner, defaultKey, this.pos, this.size, true); this.subObjects.Add(this.label); this.sprite = new FSprite("GamepadIcon", true) { anchorX = 0f, anchorY = 0.5f, scale = 0.333f }; this.myContainer.AddChild(sprite); this.OnChange(); }
protected void ReleaseSerializationKey(string initiationSource, bool successfulAssignment) { try { if (initiationSource == null) { return; } while (true) { try { BoundKey binding = _Keys.Values.FirstOrDefault(i => i.InitiationSource != null && i.InitiationSource.ToUpper() == initiationSource.ToUpper()); if (binding != null) { lock (binding) { binding.InitiationSource = null; binding.Assigned = false; if (successfulAssignment) { binding.LastSuccessfulAssignment = DateTime.UtcNow; } } } break; } catch { } } } catch (Exception ex) { STEM.Sys.EventLog.WriteEntry("SerialDeploymentController.ReleaseSerializationKey", ex.ToString(), STEM.Sys.EventLog.EventLogEntryType.Error); } }
private ManualMove AddMove(ManualMove move, BoundKey binding) { int id = moves.Count; move.SetIdAndListener(id, HandleMoveStateChange); moves.Add(move); State.keyBindings.ListenKeyUp(binding, move.HandleKeyUp); State.keyBindings.ListenKeyDown(binding, move.HandleKeyDown); return move; }
private ManualMove AddTrn(Vector3 trn, BoundKey binding) { return AddMove(new TranslateMove(trn), binding); }
bool LockSerializationKey(string initiationSource) { try { string key = GenerateKey(initiationSource); BoundKey binding = null; while (true) { try { binding = _Keys.Values.FirstOrDefault(i => i.InitiationSource != null && i.InitiationSource.ToUpper() == initiationSource.ToUpper()); if (binding != null) { lock (binding) { if (key != null) { if (!binding.Key.Equals(key, StringComparison.InvariantCultureIgnoreCase)) { CoordinatedKeyManager.Unlock(binding.Key, binding); } } else if (!CoordinatedKeyManager.Locked(binding.InitiationSource)) { CoordinatedKeyManager.Unlock(binding.Key, binding); return(false); } } } break; } catch { } } if (key == null) { return(true); } lock (_Keys) { key = key.ToUpper(); binding = null; if (_Keys.ContainsKey(key)) { binding = _Keys[key]; } if (binding != null) { lock (binding) { if (binding.Assigned) { if (binding.InitiationSource != null) { if (!CoordinatedKeyManager.Locked(binding.InitiationSource)) { binding.InitiationSource = null; binding.Assigned = false; } else { return(false); } } else { binding.Assigned = false; } if (binding.Assigned) { return(false); } } if (CoordinatedKeyManager.CoordinatedMachineHasLock(key, CoordinateWith) == CoordinatedKeyManager.RemoteLockExists.True) { CoordinatedKeyManager.Unlock(key, binding); STEM.Sys.EventLog.WriteEntry("SerialDeploymentController.KeyedBranchIP", "A previously bound key has been found to be owned by a different DeploymentService.", STEM.Sys.EventLog.EventLogEntryType.Error); return(false); } _Keys[key].InitiationSource = initiationSource; _Keys[key].Assigned = true; } } else { binding = new BoundKey(this, initiationSource, key, true); if (UseSubnetCoordination) { if (!CoordinatedKeyManager.Lock(key, binding, CoordinateWith)) { return(false); } } else { if (!CoordinatedKeyManager.Lock(key, binding)) { return(false); } } } } } catch (Exception ex) { STEM.Sys.EventLog.WriteEntry("SerialDeploymentController.LockSerializationKey", ex.ToString(), STEM.Sys.EventLog.EventLogEntryType.Error); return(false); } return(true); }
private ManualMove AddTrn(Vector3 trn, BoundKey binding) { return(AddMove(new TranslateMove(trn), binding)); }
private ManualMove AddRot(Vector3 axis, BoundKey binding) { return(AddMove(new RotateMove(axis), binding)); }
public override void Unload() { base.Unload(); BoundKey.Remove(this.controlKey); }
void ReleaseSerializationKey(string initiationSource, bool successfulAssignment) { try { if (initiationSource == null) { return; } string key = GenerateKey(initiationSource); BoundKey keyBinding = null; BoundKey fileBinding = null; key = key.ToUpper(); lock (_Keys) { try { if (key != null) { if (_Keys.ContainsKey(key)) { keyBinding = _Keys[key]; } } fileBinding = _Keys.Values.FirstOrDefault(i => i.InitiationSource != null && i.InitiationSource.ToUpper() == initiationSource.ToUpper()); } catch { } } if (fileBinding != null) { lock (fileBinding) { fileBinding.InitiationSource = null; fileBinding.Assigned = false; if (successfulAssignment) { fileBinding.LastSuccessfulAssignment = DateTime.UtcNow; } if (key != null) { string k = fileBinding.Key; _Keys[key] = fileBinding; _Keys[key].Key = key; if (k != key) { _Keys.Remove(k); } } } } if (keyBinding != null && keyBinding != fileBinding) { lock (keyBinding) { if (keyBinding.InitiationSource != null) { if (keyBinding.InitiationSource.ToUpper() == initiationSource.ToUpper()) { keyBinding.InitiationSource = null; keyBinding.Assigned = false; if (successfulAssignment) { keyBinding.LastSuccessfulAssignment = DateTime.UtcNow; } } } } } } catch (Exception ex) { STEM.Sys.EventLog.WriteEntry("KeyedFileController.ReleaseSerializationKey", ex.ToString(), STEM.Sys.EventLog.EventLogEntryType.Error); } }
string LockSerializationKey(string initiationSource, string branchIP) { try { string key = GenerateKey(initiationSource); BoundKey binding = null; while (true) { try { binding = _Keys.Values.FirstOrDefault(i => i.InitiationSource != null && i.InitiationSource.ToUpper() == initiationSource.ToUpper()); if (binding != null) { lock (binding) { if (key != null) { if (!binding.Key.Equals(key, StringComparison.InvariantCultureIgnoreCase)) { CoordinatedKeyManager.Unlock(binding.Key, binding); } } else if (!CoordinatedKeyManager.Locked(binding.InitiationSource)) { CoordinatedKeyManager.Unlock(binding.Key, binding); return(null); } } } break; } catch { } } if (key == null) { return(branchIP); } lock (_Keys) { key = key.ToUpper(); binding = null; if (_Keys.ContainsKey(key)) { binding = _Keys[key]; } if (binding != null) { lock (binding) { if (binding.Assigned) { if (binding.InitiationSource != null) { if (!CoordinatedKeyManager.Locked(binding.InitiationSource)) { binding.InitiationSource = null; binding.Assigned = false; } else { return(null); } } else { binding.Assigned = false; } if (binding.Assigned) { return(null); } } if (CoordinatedKeyManager.CoordinatedMachineHasLock(key, CoordinateWith) == CoordinatedKeyManager.RemoteLockExists.True) { CoordinatedKeyManager.Unlock(key, binding); STEM.Sys.EventLog.WriteEntry("KeyedDeploymentController.LockSerializationKey", "A previously bound key has been found to be owned by a different DeploymentService.", STEM.Sys.EventLog.EventLogEntryType.Error); return(null); } if (FileExists(initiationSource)) { _Keys[key].FileSize = new FileInfo(initiationSource).Length; } _Keys[key].InitiationSource = initiationSource; _Keys[key].Assigned = true; return(_Keys[key].BranchIP); } } else { if (String.IsNullOrEmpty(branchIP) || branchIP == STEM.Sys.IO.Net.EmptyAddress) { return(null); } if (!_BranchBoundWeight.ContainsKey(branchIP)) { return(null); } branchIP = BestBranchByWeight(branchIP); if (branchIP == null) { return(null); } long fileLen = 0; if (FileExists(initiationSource)) { fileLen = GetFileInfo(initiationSource).Size; } binding = new BoundKey(this, initiationSource, key, branchIP, fileLen, true); if (!CoordinatedKeyManager.Lock(key, binding, CoordinateWith)) { return(null); } return(binding.BranchIP); } } } catch (Exception ex) { STEM.Sys.EventLog.WriteEntry("KeyedDeploymentController.LockSerializationKey", ex.ToString(), STEM.Sys.EventLog.EventLogEntryType.Error); } return(null); }
private ManualMove AddRot(Vector3 axis, BoundKey binding) { return AddMove(new RotateMove(axis), binding); }
void ReleaseSerializationKey(string initiationSource) { try { if (initiationSource == null) { return; } string key = GenerateKey(initiationSource); if (key == null) { while (true) { try { BoundKey binding = _Keys.Values.FirstOrDefault(i => i.InitiationSource != null && i.InitiationSource.ToUpper() == initiationSource.ToUpper()); if (binding != null) { lock (binding) { binding.InitiationSource = null; binding.Assigned = false; } } break; } catch { } } return; } key = key.ToUpper(); lock (_Keys) { if (_Keys.ContainsKey(key)) { if (_Keys[key].InitiationSource != null) { if (_Keys[key].InitiationSource.ToUpper() == initiationSource.ToUpper()) { _Keys[key].InitiationSource = null; _Keys[key].Assigned = false; } } } else { BoundKey binding = _Keys.Values.FirstOrDefault(i => i.InitiationSource != null && i.InitiationSource.ToUpper() == initiationSource.ToUpper()); if (binding != null) { lock (binding) { string k = binding.Key; _Keys[key] = binding; _Keys[key].Key = key; _Keys[key].InitiationSource = null; _Keys[key].Assigned = false; if (k != key) { _Keys.Remove(k); } } } } } } catch (Exception ex) { STEM.Sys.EventLog.WriteEntry("KeyedFileController.ReleaseSerializationKey", ex.ToString(), STEM.Sys.EventLog.EventLogEntryType.Error); } }