protected override bool IsValue(string name) { if (ColumnsDef.Any(c => c.Name == name && c.Role != ColumnRole.Value)) { return(false); } if (ColumnsDef.Any(c => c.Name == name && c.Role == ColumnRole.Value)) { return(true); } if (KeyNames.Contains(name)) { return(false); } if (ValueNames.Contains(name)) { return(true); } if (ValueNames.Count > 0) { return(false); } return(false); }
/// <summary> /// 获取以制表符分开的行,按照表对应的列进行填充。 /// </summary> /// <param name="valDic"></param> /// <returns></returns> public string GetTabValues(Dictionary <string, T> valDic) { StringBuilder sb = new StringBuilder(); int i = -1; foreach (var item in WholeColTitles) { i++; //非关键标题则跳过 if (KeyNames != null && !KeyNames.Contains(item)) { continue; } if (i != 0) { sb.Append("\t"); } if (valDic.ContainsKey(item)) { sb.Append(String.Format(new NumeralFormatProvider(), "{0}", valDic[item])); } else { sb.Append(String.Format(new NumeralFormatProvider(), "{0}", Placeholder)); }; //占位 } return(sb.ToString()); }
protected override bool IsKey(string name) { if (ColumnsDef.Any(c => (c.Identifier as ColumnNameIdentifier)?.Name == name && c.Role != ColumnRole.Key)) { return(false); } if (ColumnsDef.Any(c => (c.Identifier as ColumnNameIdentifier)?.Name == name && c.Role == ColumnRole.Key)) { return(true); } if (KeyNames.Contains(name)) { return(true); } if (ValueNames.Contains(name)) { return(false); } if (ValueNames.Count > 0 && KeyNames.Count == 0) { return(true); } return(false); }
public void Randomize() { //Rng between 0 and 3 (inclusive) int rand = Random.Range(0, 4); //Attach new ui sprite to button ButtonImage.sprite = ABXYButtons[rand]; //Get the corresponding key name keyName = (KeyNames)rand; }
public static string GetKey(KeyNames name) { switch (name) { case KeyNames.DatabaseConnectionString: return("DbConStr"); default: throw new NotImplementedException(); } }
protected override void ExecuteNoRet() { StringBuilder sql = new StringBuilder(); int notNullFields = 0; var valueKeyList = new List <string>(); var columnList = new List <string>(); var valueList = new List <object>(); foreach (var p in ColumnProperties) { columnList.Add(p.Name); var val = p.GetValue(Entity, null); if (val != null) { valueKeyList.Add("{" + (notNullFields++) + "}"); valueList.Add(val); } else { valueKeyList.Add("null"); } } var columns = columnList.ToArray(); sql.Append("merge into "); sql.Append(TableName); sql.Append(" as T "); sql.Append("using (values ("); sql.Append(string.Join(",", valueKeyList.ToArray())); sql.Append(")) as S ("); sql.Append(string.Join(",", columns)); sql.Append(") "); sql.Append("on ("); var mergeCond = string.Join(" and ", KeyNames.Select(kn => "T." + kn + "=S." + kn)); sql.Append(mergeCond); sql.Append(") "); sql.Append("when matched then update set "); sql.Append(string.Join(",", columns.Select(c => "T." + c + "=S." + c).ToArray())); sql.Append(" when not matched then insert ("); sql.Append(string.Join(",", columns)); sql.Append(") values (S."); sql.Append(string.Join(",S.", columns)); sql.Append(");"); Context.Database.ExecuteSqlCommand(sql.ToString(), valueList.ToArray()); }
/// <summary> /// Removes all keys from this keyring. /// </summary> public void Clear() { if (ReadOnly) { throw new Exception("Keyring is read-only."); } Keys.Clear(); KeyNames.Clear(); GC.Collect(); if (KeyringChanged != null) { KeyringChanged(); } }
/// <summary> /// Removes a key from this keyring. /// </summary> /// <param name="name">Name of key to remove</param> public void Remove(string name) { if (ReadOnly) { throw new Exception("Keyring is read-only."); } if (KeyNames.Contains(name)) { throw new Exception("Key not found."); } Keys.RemoveAll(k => k.Name == name); KeyNames.Remove(name); KeyringChanged?.Invoke(); }
/// <summary> /// Adds a key to this keyring. /// </summary> /// <param name="name">Name of the key</param> /// <param name="key">Key encryption data</param> /// <param name="preLocked">If the key should be locked immediately</param> public void Add(string name, EncryptionKey key, bool preLocked = false) { if (ReadOnly) { throw new Exception("Keyring is read-only."); } if (KeyNames.Contains(name)) { throw new Exception("Key already exists. If replacing, use Remove() first."); } var newKey = new KeyDescriptor(name, key, preLocked); newKey.KeyLockChanged += locked => { KeyringChanged?.Invoke(); }; Keys.Add(newKey); KeyNames.Add(newKey.Name); KeyringChanged?.Invoke(); }
/// <summary> /// Creates a string for the button to show. /// </summary> /// <returns>A human readable string.</returns> public override string ToString() { var text = string.Empty; if (Control) { text += TranslationServer.Translate("CTRL") + "+"; } if (Alt) { text += TranslationServer.Translate("ALT") + "+"; } if (Shift) { text += TranslationServer.Translate("SHIFT") + "+"; } if (Type == InputType.Key) { // If the key is not defined in KeyNames.cs, the string will just be returned unmodified by Translate() text += KeyNames.Translate(Code); } else if (Type == InputType.MouseButton) { text += Code switch { 1 => TranslationServer.Translate("LEFT_MOUSE"), 2 => TranslationServer.Translate("RIGHT_MOUSE"), 3 => TranslationServer.Translate("MIDDLE_MOUSE"), 4 => TranslationServer.Translate("WHEEL_UP"), 5 => TranslationServer.Translate("WHEEL_DOWN"), 6 => TranslationServer.Translate("WHEEL_LEFT"), 7 => TranslationServer.Translate("WHEEL_RIGHT"), 8 => TranslationServer.Translate("SPECIAL_MOUSE_1"), 9 => TranslationServer.Translate("SPECIAL_MOUSE_2"), _ => TranslationServer.Translate("UNKNOWN_MOUSE"), }; } return(text); }
public string this[KeyNames name] { get => keysDict[name];
public static extern bool LogiLedSetLightingForKeyWithKeyName(KeyNames keyCode, int redPercentage, int greenPercentage, int bluePercentage);
public bool LoadBindingsFile() { devices = new Dictionary <string, Device>(); // clear values = new Dictionary <string, string>(); string path = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Frontier Developments\Elite Dangerous\Options\Bindings"); string optsel = System.IO.Path.Combine(path, "StartPreset.start"); try { string sel = System.IO.File.ReadAllText(optsel); System.Diagnostics.Debug.WriteLine("Bindings file " + sel); FileInfo[] allFiles = Directory.EnumerateFiles(path, sel + "*.binds", SearchOption.TopDirectoryOnly).Select(f => new System.IO.FileInfo(f)).OrderByDescending(p => p.LastWriteTime).ToArray(); if (allFiles.Length >= 1) { XElement bindings = XElement.Load(allFiles[0].FullName); foreach (XElement x in bindings.Elements()) { //System.Diagnostics.Debug.WriteLine("Reader " + x.NodeType + " " + x.Name); if (x.HasElements) { foreach (XElement y in x.Descendants()) { if (y.Name == "Binding") { AxisNames.Add(x.Name.LocalName); AssignToDevice(x, y); } else if (y.Name == "Primary" || y.Name == "Secondary") { //System.Diagnostics.Debug.WriteLine("Binding Point " + x.NodeType + " " + x.Name + " Element " + y.Name); KeyNames.Add(x.Name.LocalName); AssignToDevice(x, y); } else { foreach (XAttribute z in y.Attributes()) { values[x.Name + "." + y.Name + ChkValue(z.Name.ToString())] = z.Value; } } } } if (x.HasAttributes) { foreach (XAttribute y in x.Attributes()) { values[x.Name + ChkValue(y.Name.ToString())] = y.Value; } } } return(true); } } catch { } return(false); }
public static extern bool LogiLedRestoreLightingForKey(KeyNames keyName);
public AxisEventArgs(KeyNames keyName, bool isLeft, Vector2 value) { KeyName = keyName; IsLeft = isLeft; Value = value; }
public static extern bool LogiLedFlashSingleKey(KeyNames keyName, int redPercentage, int greenPercentage, int bluePercentage, int msDuration, int msInterval);
public static extern bool LogiLedPulseSingleKey(KeyNames keyName, int startRedPercentage, int startGreenPercentage, int startBluePercentage, int finishRedPercentage, int finishGreenPercentage, int finishBluePercentage, int msDuration, bool isInfinite);
public static extern bool LogiLedStopEffectsOnKey(KeyNames keyName);
/// <summary> /// Checks if the keyring has a definition for the given key name. /// </summary> /// <param name="name">Name of key to check</param> /// <returns></returns> public bool HasKey(string name) { return(KeyNames.Contains(name)); }
public KeyEventArgs(KeyNames keyName, bool isLeft) { KeyName = keyName; IsLeft = isLeft; }
public static int GetKeycode(KeyNames key) { return(1 << ((int)key)); }
public Key(KeyNames key, int x, int y) { Name = key; Coordinate = new KeyCoordinate(x, y); }
protected override void ExecuteNoRet() { var currentCommandTimeout = Context.Database.CommandTimeout; try { // Up the timeout as this may take a while for scheduled batch jobs. Context.Database.CommandTimeout = 300; StringBuilder sql = new StringBuilder(); int notNullFields = 0; var valueKeyList = new List <string>(); var columnList = new List <string>(); var columnProperties = ColumnProperties.ToArray(); foreach (var p in columnProperties) { if (!p.IsDefined(typeof(DoNotIncludeInUpsertAttribute), false)) { columnList.Add(p.Name); valueKeyList.Add("{" + (notNullFields++) + "}"); } } var columns = columnList.ToArray(); sql.Append("merge into "); sql.Append(TableName); sql.Append(" as T "); sql.Append("using (values ("); sql.Append(string.Join(",", valueKeyList.ToArray())); sql.Append(")) as S ("); sql.Append(string.Join(",", columns.Select(x => $"[{x}]"))); sql.Append(") "); sql.Append("on ("); var mergeCond = string.Join(" and ", KeyNames.Select(kn => "T.[" + kn + "]=S.[" + kn + "]")); sql.Append(mergeCond); sql.Append(") "); sql.Append("when matched then update set "); // If Identity Insert is on, we will have been supplied the PK in the list of columns. Wish to exclude this from the update statement as updating a PK is not allowed. var colsToUpdate = _identityInsertOn ? columns.Where(pr => pr != EntityPrimaryKeyName) : columns; sql.Append(string.Join(",", colsToUpdate.Select(c => "T.[" + c + "]=S.[" + c + "]").ToArray())); sql.Append(" when not matched then insert ("); sql.Append(string.Join(",", columns.Select(x => $"[{x}]"))); sql.Append(") values (S."); sql.Append(string.Join(",S.", columns.Select(x => $"[{x}]"))); sql.Append(");"); var command = sql.ToString(); foreach (var entity in EntityList) { var valueList = new List <object>(); foreach (var p in columnProperties) { if (!p.IsDefined(typeof(DoNotIncludeInUpsertAttribute), false)) { var val = p.GetValue(entity, null); valueList.Add(val ?? DBNull.Value); } } Context.Database.ExecuteSqlCommand(command, valueList.ToArray()); } } finally { // Reset the timeout to the original value. Context.Database.CommandTimeout = currentCommandTimeout; } }