예제 #1
0
        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);
        }
예제 #2
0
        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());
            }
        }
예제 #3
0
 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));