private void KeyPressed(object sender, GlobalKeyboardHookEventArgs e) { var pressedKey = (Keys)e.KeyboardData.VirtualCode; if (pressedKey == Keys.LShiftKey) { _shiftPressed = e.KeyboardState == KeyboardState.KeyDown; return; } if (e.KeyboardState != KeyboardState.KeyDown) { return; } char resultSymbol; if (pressedKey.TryToChar(_shiftPressed, out resultSymbol)) { AppendBuffer(resultSymbol, Strategy); NewSymbol?.Invoke(this, new NewSymbolEventArgs(resultSymbol)); } CheckBuffer(Strategy, pressedKey); }
public async Task <Symbol> WriteAsync(NewSymbol newSymbol) { using (var context = Context()) { var eSymbol = await context .Symbols .Include(s => s.Currency) .Where(s => s.Name == newSymbol.Name && s.ListingExchangeCode == newSymbol.ListingExchangeCode) .FirstOrDefaultAsync(); if (eSymbol == null) { eSymbol = new SymbolEntity { Name = newSymbol.Name, Description = newSymbol.Description, ListingExchangeCode = newSymbol.ListingExchangeCode, CurrencyCode = newSymbol.CurrencyCode, Currency = await context.Currencies.FirstAsync(c => c.Code == newSymbol.CurrencyCode), BrokerageSymbols = new List <BrokerageSymbolEntity>() }; context.Symbols.Add(eSymbol); } if (!eSymbol.BrokerageSymbols.Any(bs => bs.BrokerageId == newSymbol.BrokerageId)) { eSymbol.BrokerageSymbols.Add(new BrokerageSymbolEntity { BrokerageId = newSymbol.BrokerageId, ReferenceId = newSymbol.ReferenceId }); } await context.SaveChangesAsync(); return(eSymbol.ToModel()); } }
public bool Equals(SemanticEdit other) => Kind == other.Kind && (OldSymbol == null ? other.OldSymbol == null : OldSymbol.Equals(other.OldSymbol)) && (NewSymbol == null ? other.NewSymbol == null : NewSymbol.Equals(other.NewSymbol));