static void Main(string[] args) { Brain brain = new Brain(); // brain.doWork(); Thread myBrainThread = new Thread(new ThreadStart(brain.doWork)); myBrainThread.Start(); ConsoleKeyInfo cki = new ConsoleKeyInfo(); do { Console.WriteLine("\nPress 'x' key to logout."); while (Console.KeyAvailable == false) Thread.Sleep(250); // Loop until input is entered. cki = Console.ReadKey(true); // Console.WriteLine("You pressed the '{0}' key.", cki.Key); } while (cki.Key != ConsoleKey.X); IPEndPoint registryEP = getEndpoint(ConfigurationManager.AppSettings["registryIP"], ConfigurationManager.AppSettings["registryPort"]); socket.Connect(registryEP); LogoutRequest lor = new LogoutRequest(); byte[] logoutRequestMessage = lor.Encode(); socket.Send(logoutRequestMessage, logoutRequestMessage.Length); Console.WriteLine("You have logged out."); }
protected override void ProcessKey(ConsoleKeyInfo consoleKey, InputState inputState) { switch(consoleKey.Key) { case ConsoleKey.End: if(inputState.CarrageIndex < inputState.Line.Length) { inputState.GotoEnd(); } break; case ConsoleKey.Home: if(inputState.CarrageIndex > 0) { inputState.GotoBegin(); } break; case ConsoleKey.LeftArrow: if(inputState.CarrageIndex > 0) { inputState.CarrageIndex--; Console.Write('\b'); } break; case ConsoleKey.RightArrow: if(inputState.CarrageIndex < inputState.Line.Length) { Console.Write(inputState.Line.ToString().Substring(inputState.CarrageIndex, 1)); inputState.CarrageIndex++; } break; default: base.ProcessKey(consoleKey, inputState); return; } }
/// <summary> /// Delete to the end of the word. /// </summary> public static void DeleteEndOfWord(ConsoleKeyInfo? key = null, object arg = null) { int qty = (arg is int) ? (int)arg : 1; int endPoint = _singleton._current; for (int i = 0; i < qty; i++) { endPoint = _singleton.ViFindNextWordEnd(endPoint, _singleton.Options.WordDelimiters); } if (endPoint <= _singleton._current) { Ding(); return; } _singleton.SaveToClipboard(_singleton._current, 1 + endPoint - _singleton._current); _singleton.SaveEditItem(EditItemDelete.Create( _singleton._clipboard, _singleton._current, DeleteEndOfWord, arg )); _singleton._buffer.Remove(_singleton._current, 1 + endPoint - _singleton._current); if (_singleton._current >= _singleton._buffer.Length) { _singleton._current = Math.Max(0,_singleton._buffer.Length - 1); } _singleton.Render(); }
public static void ComputerMoveSecondRacket() { int randomNumber = randomGenerator.Next(1, 101); if (randomNumber <= MenuSettings.probability) { if (secondRacketY >= Ball.ballPositionY) { if (secondRacketY >= Table.offset + 2) { MoveSecondRacketUp(); } } else if ((secondRacketY + (MenuSettings.racketLength / 2)) < Ball.ballPositionY) { if ((secondRacketY + MenuSettings.racketLength) < (Console.WindowHeight - 1)) { MoveSecondRacketDown(); } } } while (Console.KeyAvailable) { key = Console.ReadKey(true); //// check for ESC and Spacebar SpecialKeys(); } }
private static void ConsoleLongTaskWithCancel() { var cancelKey = new ConsoleKeyInfo('\u0011', ConsoleKey.Q, false, false, true); ConsoleTask.StartNew ( cancellationToken => { var stopwatch = new Stopwatch(); stopwatch.Start(); var i = 0; while (i++ < 10) { if (cancellationToken.IsCancellationRequested) { Console.WriteLine("Cancelled"); return; } Console.WriteLine(stopwatch.ElapsedMilliseconds/1000); Thread.Sleep(1000); } Console.WriteLine("Completed"); }, cancelKey ).Wait(); }
/// <summary> /// Read a character and search forward for the next occurence of that character. /// If an argument is specified, search forward (or backward if negative) for the /// nth occurence. /// </summary> public static void CharacterSearch(ConsoleKeyInfo? key = null, object arg = null) { int occurence = (arg is int) ? (int)arg : 1; if (occurence < 0) { CharacterSearchBackward(key, -occurence); return; } char toFind = TryGetArgAsChar(arg); if (toFind == (char)0) { // Should we prompt? toFind = ReadKey().KeyChar; } for (int i = _singleton._current + 1; i < _singleton._buffer.Length; i++) { if (_singleton._buffer[i] == toFind) { occurence -= 1; if (occurence == 0) { _singleton._current = i; _singleton.PlaceCursor(); break; } } } if (occurence > 0) { Ding(); } }
/// <summary> /// Move the cursor back to the start of the current word, or if between words, /// the start of the previous word. Word boundaries are defined by a configurable /// set of characters. /// </summary> public static void BackwardWord(ConsoleKeyInfo? key = null, object arg = null) { int numericArg; if (!TryGetArgAsInt(arg, out numericArg, 1)) { return; } if (numericArg < 0) { if (CheckIsBound(ForwardWord)) { ForwardWord(key, -numericArg); } else { NextWord(key, -numericArg); } return; } while (numericArg-- > 0) { int i = _singleton.FindBackwardWordPoint(_singleton.Options.WordDelimiters); _singleton._current = i; _singleton.PlaceCursor(); } }
private bool ProcessCommand(ConsoleKeyInfo key) { if (key.Modifiers.HasFlag(ConsoleModifiers.Control)) { if (key.Key != ConsoleKey.Q) return false; _isExit = true; return true; } else if (key.Modifiers.HasFlag(ConsoleModifiers.Alt) || key.Modifiers.HasFlag(ConsoleModifiers.Shift)) { return false; } if (_commands.ContainsKey(key.Key)) { var command = _commands[key.Key]; try { Console.Clear(); command.Run(); } catch (Exception e) { Console.Clear(); Console.WriteLine($"There were some errors while running command {command}"); e.WriteLog(); ToMainMenu(); } return true; } else return false; }
static void Main(string[] args) { //ReflectionViewModel viewModel = new ReflectionViewModel(); SimpleIoc.Default.Register <ReflectionViewModel>(); Compose(ViewModelLocator.ReflectionVM); System.Console.WriteLine("Provide absolute path to .dll file you want to inspect:"); //ViewModelLocator.ReflectionVM.FileLoader = new ConsoleFileLoader(); ViewModelLocator.ReflectionVM.LoadCommand.Execute(null); TreeViewModel treeViewModel = new TreeViewModel(ViewModelLocator.ReflectionVM.FileName); System.Console.WriteLine(treeViewModel.Output); while (true) { System.ConsoleKeyInfo key = System.Console.ReadKey(); if (key.Key == ConsoleKey.Spacebar) { treeViewModel.Expand(); System.Console.Clear(); System.Console.WriteLine(treeViewModel.Output); } if (key.Key == ConsoleKey.Backspace) { treeViewModel.Shrink(); System.Console.Clear(); System.Console.WriteLine(treeViewModel.Output); } } }
private void Key_Pressed(ConsoleKeyInfo k) { Utilities.KeyEventArgs args = new Utilities.KeyEventArgs(k); if (KeyPressed != null) this.KeyPressed(this, args); }
private void ViewTypeCars() { Console.Clear(); Console.WriteLine("\nWhat type of car?\n" + "[1] Electric\n" + "[2] Hybrid\n" + "[3] Gas\n" + "[4] Cancel\n"); System.ConsoleKeyInfo input = Console.ReadKey(); Console.Clear(); int type = int.Parse(input.KeyChar.ToString()); if (type == 1 || type == 2 || type == 3) { List <Car> search = _carRepo.GetCars((CarTypes)type - 1); Console.Clear(); Console.WriteLine("Make\t\tModel\t\tYear\t\tMPG\t\tType\n"); foreach (Car car in search) { Console.WriteLine(car); } Console.WriteLine("\n\n" + "Press Any Key to Continue:"); Console.ReadKey(); Console.Clear(); } }
static void Main() { string decorationLine = new string('-', Console.WindowWidth); Console.Write(decorationLine); Console.WriteLine("***Dictionary application with options for adding a new entry,"); Console.WriteLine("listing all entries from it and finding the translation of a given word***"); Console.Write(decorationLine); // Start MongoDB server var mongoClient = new MongoClient(Settings.Default.MongoDBConnectionString); var mongoServer = mongoClient.GetServer(); var dictionaryDB = mongoServer.GetDatabase("DictionaryDB"); var dictionary = dictionaryDB.GetCollection<DictionaryEntry>("Dictionary"); ConsoleKeyInfo command = new ConsoleKeyInfo(); while (true) { DisplayMenu(); command = Console.ReadKey(); if (command.Key == ConsoleKey.Escape) { Console.WriteLine(); break; } ProccessCommand(dictionary, command); } }
private static void Menu() { bool shouldNotExit = true; while (shouldNotExit) { WriteLine("1.Registrera bil"); WriteLine("2.Lista bilar"); WriteLine("3.Avsluta"); System.ConsoleKeyInfo keyPressed = ReadKey(true); Clear(); switch (keyPressed.Key) { case System.ConsoleKey.D1: RegisterCar(); break; case System.ConsoleKey.D2: ListRegisterdCars(); break; case System.ConsoleKey.D3: shouldNotExit = false; break; } } }
public static void readFromDB(OleDbConnection conn) { string testSelect = " SELECT * FROM ImportAccess"; OleDbCommand comm = new OleDbCommand(testSelect, conn); OleDbDataReader dr = comm.ExecuteReader(); object[] buffer = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; StringBuilder sb = new StringBuilder(); while (dr.Read())// populate buffer with values from db { int value = dr.GetValues(buffer); for (int i = 0; i < buffer.Length; i++) { sb.Append(buffer[i] + ","); } sb.Remove(buffer.Length - 1, 1); } ConsoleKeyInfo cki = new ConsoleKeyInfo(); while (true) // keep console window open { Console.WriteLine("Returned values " + sb.ToString()); cki = Console.ReadKey(true); if (cki.Key == ConsoleKey.X) { break; } } dr.Close(); }
public static string GetCVV(string message) { Console.WriteLine(message); System.Console.Write("Enter CVV: "); string password = ""; while (true) { System.ConsoleKeyInfo input = System.Console.ReadKey(true); if (input.Key == ConsoleKey.Enter) { break; } else if (input.Key == ConsoleKey.Backspace) { if (password.Length > 0 && password != null && password != "") { password = password.Remove(password.Length - 1); Console.Write("\b \b"); } } else { password += input.KeyChar; Console.Write("X"); } } Console.WriteLine(); return(password); }
internal ConsoleKeyInfo(System.ConsoleKeyInfo info) { Key = info.Key; Modifiers = info.Modifiers; KeyChar = info.KeyChar; KeyString = Extensions.ConvertToString(info.Key); }
public static void ShowMenu() { Console.WriteLine("*** MENU ***"); Console.WriteLine("1. Overzicht mp3 spelers"); Console.WriteLine("2. Overzicht voorraad"); Console.WriteLine("3. Muteer voorraad"); Console.WriteLine("4. Statistieken"); Console.WriteLine("5. Toevoegen mp3 speler"); Console.WriteLine("6. "); Console.WriteLine("7. "); Console.WriteLine("8. Toon menu"); Console.WriteLine("9. Exit"); //Invoer wordt gelezen ConsoleKeyInfo userinput = new ConsoleKeyInfo(); userinput = Console.ReadKey(); while (userinput.KeyChar != '9') { switch (userinput.KeyChar) { case '1': Console.Clear(); Console.WriteLine("\rGekozen actie: {0}. Overzicht mp3 spelers\n", userinput.KeyChar); //oude optie >> Gegevensspelers.showmp3(); Gegevenslist.overzichtzicht(); break; case '2': Console.Clear(); Console.WriteLine("\rGekozen actie: {0}. Overzicht voorraad\n", userinput.KeyChar); Gegevenslist.showvoorraad(); break; case '3': Console.Clear(); Console.WriteLine("\rGekozen actie: {0}. Muteer voorraad\n", userinput.KeyChar); Gegevenslist.muteren(); break; case '4': Console.Clear(); Console.WriteLine("\rGekozen actie: {0}. Statistieken", userinput.KeyChar); Gegevenslist.tien(); break; case '5': Console.Clear(); Console.WriteLine("\rGekozen actie: {0}. Toevoegen mp3 speler", userinput.KeyChar); Gegevenslist.mp3toevoeg(); break; case '6': break; case '7': break; case '8': voorraad.toonmenu(); break; default: break; } userinput = Console.ReadKey(true); } }
public void Move(ConsoleKeyInfo c, Map m) { bool move = false; if ((c.Key == ConsoleKey.UpArrow) && (Y>0)) { move = m.location[X,Y-1].CanMoveTo(); m.location[X,Y-1].AutomaticAction(this); if (move) Y--; } else if ((c.Key == ConsoleKey.DownArrow) && (Y<(m.Heigth-1))) { move = m.location[X,Y+1].CanMoveTo(); m.location[X,Y+1].AutomaticAction(this); if (move) Y++; } else if ((c.Key == ConsoleKey.LeftArrow) && (X>0)) { move = m.location[X-1,Y].CanMoveTo(); m.location[X-1,Y].AutomaticAction(this); if (move) X--; } else if ((c.Key == ConsoleKey.RightArrow) && (X<(m.Width-1))) { move = m.location[X+1,Y].CanMoveTo(); m.location[X+1,Y].AutomaticAction(this); if (move) X++; } }
static void ChangePlayerDirection(ConsoleKeyInfo key) { if (key.Key == ConsoleKey.W) firstPlayerDirection = up; if (key.Key == ConsoleKey.A) firstPlayerDirection = left; if (key.Key == ConsoleKey.D) firstPlayerDirection = right; if (key.Key == ConsoleKey.S) firstPlayerDirection = down; if (key.Key == ConsoleKey.UpArrow) secondPlayerDirection = up; if (key.Key == ConsoleKey.LeftArrow) secondPlayerDirection = left; if (key.Key == ConsoleKey.RightArrow) secondPlayerDirection = right; if (key.Key == ConsoleKey.DownArrow) secondPlayerDirection = down; }
static void Main(string[] args) { DNA firstStep = new DNA(); spark = firstStep.Strand; bool t = false; int iteration = 0; ConsoleKeyInfo end = new ConsoleKeyInfo(); Console.WriteLine("AI solver will attempt equations after GA designs them"); NaturalSelection ns = new NaturalSelection(); IntellegentDesign id = new IntellegentDesign(); id.initialize(); ns.darwin(spark); do { if (t==false) { t = true; Root(ns,id); } ns.darwin(id.dueronomy(ns.vA)); Root(ns, id); if (iteration>100||novelAns>=cap) { end = Console.ReadKey(); iteration = 0; novelAns = 0; } iteration++; } while (end.Key != ConsoleKey.Escape); }
private void CreateCar() { Console.Clear(); Console.WriteLine("\nWhat type of car is this?\n" + "[1] Electric\n" + "[2] Hybrid\n" + "[3] Gas\n" + "[4] Cancel\n"); System.ConsoleKeyInfo input = Console.ReadKey(); Console.Clear(); int type = int.Parse(input.KeyChar.ToString()); if (type == 1 || type == 2 || type == 3) { Console.WriteLine("\nEnter the make:"); string make = Console.ReadLine(); Console.WriteLine("\nEnter the model:"); string model = Console.ReadLine(); Console.WriteLine("\nEnter the year:"); int year = int.Parse(Console.ReadLine()); Console.WriteLine("\nEnter the MPG / MPGe:"); decimal mpg = decimal.Parse(Console.ReadLine()); Car newCar = new Car(make, model, year, mpg, (CarTypes)type - 1); _carRepo.AddCar(newCar); } Console.Clear(); }
public static void BackwardDeleteChar(ConsoleKeyInfo? key = null, object arg = null) { if (_singleton._visualSelectionCommandCount > 0) { int start, length; _singleton.GetRegion(out start, out length); Delete(start, length); return; } if (_singleton._buffer.Length > 0 && _singleton._current > 0) { int qty = (arg is int) ? (int) arg : 1; qty = Math.Min(qty, _singleton._current); int startDeleteIndex = _singleton._current - qty; _singleton.SaveEditItem( EditItemDelete.Create( _singleton._buffer.ToString(startDeleteIndex, qty), startDeleteIndex, BackwardDeleteChar, arg) ); _singleton.SaveToClipboard(startDeleteIndex, qty); _singleton._buffer.Remove(startDeleteIndex, qty); _singleton._current = startDeleteIndex; _singleton.Render(); } else { Ding(); } }
public override bool ProcessKey(ConsoleKeyInfo key) { if (key.Key == ConsoleKey.Enter) { if (OnPressed != null) OnPressed (this); return true; } return false; }
static void Main(string[] args) { Console.ForegroundColor = ConsoleColor.White; empApp = new EmployeeApp(); empApp.CallRestApi(); do { try { Console.TreatControlCAsInput = true; // Prevent example from ending if CTL+C is pressed. empApp.PrintMenu(); _ckiUser = Console.ReadKey(true); _appComandUser = Utils.IsValidCommand(_ckiUser.Key.ToString()); switch (_appComandUser) { case Utils.AppCommand.InvalidInput: empApp.ErrorOp(); break; case Utils.AppCommand.SearchEmployee: SearchOptions(); break; } } catch { empApp.ErrorOp(); } } while (!Utils.IsEndCommand(_ckiUser.Key.ToString())); }
public void Execute(ConsoleKeyInfo request) { foreach (Filter filter in _filters) { filter.Execute(request); } _target.MovePlayer(request); }
public static void DrawCurrentScene(bool i_Waitforkey = true) { ConsoleKeyInfo info = new ConsoleKeyInfo(); if (i_Waitforkey) { while(!Console.KeyAvailable) { GetCurrentScene().Idle(); } info = Console.ReadKey(true); if (info.Key == ConsoleKey.Escape) { Game.InChat(!Game.IsInChat()); } if (Game.IsInChat()) { Chat.WriteMSGUpdate(info); info = new ConsoleKeyInfo(); } } GetCurrentScene().Draw(info); }
protected override void ProcessKey(ConsoleKeyInfo consoleKey, InputState inputState) { switch(consoleKey.Key) { case ConsoleKey.Backspace: if(inputState.CarrageIndex > 0) { inputState.Line.Remove(inputState.CarrageIndex - 1, 1); inputState.CarrageIndex--; Console.Write("\b"); inputState.RefreshTail(1); } break; case ConsoleKey.Delete: if(inputState.CarrageIndex < inputState.Line.Length) { inputState.Line.Remove(inputState.CarrageIndex, 1); inputState.RefreshTail(1); } break; default: base.ProcessKey(consoleKey, inputState); break; } }
public void Enqueue(ConsoleKeyInfo key) { lock (inputQueue) { inputQueue.Enqueue(new HumanInputItem(key, TimeSpan.Zero, HumanInputItem.NormalDelay)); } }
public override bool TryHandleKeyboardInput(ConsoleKeyInfo key) { List<KeyboardEventHandler> potentialHandlers = new List<KeyboardEventHandler>(); if(Application.FocusManager.FocusedControl != null) { Application.FocusManager.FocusedControl.HandleKeyInput() } if(key.Modifiers.HasFlag(ConsoleModifiers.Alt)) { } else if (key.Modifiers.HasFlag(ConsoleModifiers.Control)) { } else if (key.Modifiers.HasFlag(ConsoleModifiers.Shift)) { } else { } handlers.Peek()[KeyboardEventHandler.CreateLookupKey(key.Key, KeyboardEventMatchMode.NoModifiers)]; }
public ModoDeJogo() { cki = new ConsoleKeyInfo(); tabuleiro = new Tabuleiro(); acabou = false; selecionarModoDeJogo(); }
public static void ExchangePointAndMark(ConsoleKeyInfo? key = null, object arg = null) { var tmp = _singleton._mark; _singleton._mark = _singleton._current; _singleton._current = tmp; _singleton.PlaceCursor(); }
static void Main(string[] args) { IPersoneelTaken bungalow = new Bungalow(); Console.WriteLine("Wil je een barbeque bij de bungalow? j/n"); System.ConsoleKeyInfo antwoord = Console.ReadKey(); Console.WriteLine(); while (antwoord.Key != ConsoleKey.J && antwoord.Key != ConsoleKey.N) { Console.WriteLine("Voer j of n in"); antwoord = Console.ReadKey(); } bungalow = antwoord.Key == ConsoleKey.J ? new Barbecue(bungalow) : bungalow; Console.WriteLine("Wil je een fiets bij de bungalow? j/n"); antwoord = Console.ReadKey(); Console.WriteLine(); while (antwoord.Key != ConsoleKey.J && antwoord.Key != ConsoleKey.N) { Console.WriteLine("Voer j of n in"); antwoord = Console.ReadKey(); } Console.WriteLine(); bungalow = antwoord.Key == ConsoleKey.J ? new Fiets(bungalow) : bungalow; Console.WriteLine("Taken:"); bungalow.ToonTaak(); Console.ReadLine(); }
private static string GetVerbForKeySelection(ConsoleKeyInfo keyInfo) { switch (keyInfo.Key) { case ConsoleKey.D1: case ConsoleKey.NumPad1: return "Update"; case ConsoleKey.D2: case ConsoleKey.NumPad2: return "Create"; case ConsoleKey.D3: case ConsoleKey.NumPad3: return "Rebuild"; case ConsoleKey.D4: case ConsoleKey.NumPad4: return "TestData"; case ConsoleKey.D5: case ConsoleKey.NumPad5: return "Baseline"; case ConsoleKey.D6: case ConsoleKey.NumPad6: return "Exit"; default: return string.Empty; } }
static void Main(string[] args) { //Make sure to set value in config for appSetting key: Microsoft.ServiceBus.ConnectionString if (ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"] == defaultAppSettingValue) { Console.WriteLine("You need to set your own service bus endpoint in the config file."); Console.WriteLine("Press any key to Exit"); Console.ReadKey(); return; } //it is a good practice to try and create topic instead of hoping it is there CreateTopic(); var keyEntered = new ConsoleKeyInfo(); do { Console.WriteLine("Enter message then press Enter"); var message = Console.ReadLine(); //not validating because we won't enter bad data :) Console.WriteLine("Enter priority 1 or 2 then press Enter"); var priority = Console.ReadLine(); //not validating because we won't enter bad data :) SendMessage(message, priority); Console.WriteLine("Press 'q' to quit or any other key to send more messages"); keyEntered = Console.ReadKey(); Console.WriteLine("\n"); } while (keyEntered.KeyChar.ToString() != "q"); }
public string HandleKey(ConsoleKeyInfo input) { lock (m_threadLock) { // Ignore blacklisted characters. if (IsBlacklisted(input)) return null; switch (input.Key) { // The enter key submits the input buffer for processing. case ConsoleKey.Enter: // Construct the final submitted text to return. string text = m_buffer.ToString(); // Clear the buffer and the display. Buffer_Clear(m_buffer); // Return the final contents of the buffer. return text; // The delete key removes one character from the end of the input buffer. case ConsoleKey.Backspace: case ConsoleKey.Delete: //TODO: handle forward-delete and all four arrow keys Buffer_Backspace(m_buffer); return null; // All other keys are appended to the input buffer. default: Buffer_Append(m_buffer, input.KeyChar); return null; } } }
/// <summary> /// Edit the command line in a text editor specified by $env:EDITOR or $env:VISUAL /// </summary> public static void ViEditVisually(ConsoleKeyInfo? key = null, object arg = null) { string editorOfChoice = GetPreferredEditor(); if (string.IsNullOrWhiteSpace(editorOfChoice)) { Ding(); return; } _singleton._visualEditTemporaryFilename = GetTemporaryPowerShellFile(); using (FileStream fs = File.OpenWrite(_singleton._visualEditTemporaryFilename)) { using (TextWriter tw = new StreamWriter(fs)) { tw.Write(_singleton._buffer.ToString()); } } _singleton._savedAddToHistoryHandler = _singleton.Options.AddToHistoryHandler; _singleton.Options.AddToHistoryHandler = ((string s) => { return false; }); _singleton._buffer.Clear(); _singleton._current = 0; _singleton.Render(); _singleton._buffer.Append(editorOfChoice + " \'" + _singleton._visualEditTemporaryFilename + "\'"); AcceptLine(); }
public void StartReading() { //engine.Connect(); //engine.RemoteConnect("127.0.0.1", 3008); engine.RemoteConnect("127.0.0.1", 1726); ConsoleKeyInfo cki = new ConsoleKeyInfo(); while (true) { try { if (Console.KeyAvailable) { cki = Console.ReadKey(true); if (cki.Key == ConsoleKey.X) { break; } } engine.ProcessEvents(1000); } catch (EmoEngineException e) { Console.WriteLine("{0}", e.ToString()); } catch (Exception e) { Console.WriteLine("{0}", e.ToString()); } } engine.Disconnect(); }
private void EditCar() { Console.Clear(); Console.WriteLine("\nWhat type of car is this?\n" + "[1] Electric\n" + "[2] Hybrid\n" + "[3] Gas\n" + "[4] Cancel\n"); System.ConsoleKeyInfo input = Console.ReadKey(); Console.Clear(); int type = int.Parse(input.KeyChar.ToString()); if (type == 1 || type == 2 || type == 3) { List <Car> search = _carRepo.GetCars((CarTypes)type - 1); Console.WriteLine("\nEnter the make:"); string make = Console.ReadLine(); Console.WriteLine("\nEnter the model:"); string model = Console.ReadLine(); Console.WriteLine("\nEnter the year:"); int year = int.Parse(Console.ReadLine()); Console.Clear(); foreach (Car car in search) { if (car.Make == make && car.Model == model && car.Year == year) { bool loop = true; while (loop) { Console.WriteLine("Make\t\tModel\t\tYear\t\tMPG\t\tType\n"); Console.WriteLine(car); Console.WriteLine("\n" + "What would you like to update?\n" + "[1] Make\n" + "[2] Model\n" + "[3] Year\n" + "[4] Miles per Gallon\n" + "[5] Type of Car\n" + "[6] Delete Car\n" + "[7] Nothing\n"); System.ConsoleKeyInfo editInput = Console.ReadKey(); Console.Clear(); int edit = int.Parse(editInput.KeyChar.ToString()); if (edit == 1 || edit == 2 || edit == 3 || edit == 4 || edit == 5 || edit == 6) { UpdateCar(car, edit); } else { loop = false; break; } } } } Console.Read(); } }
private void AddCustomer() { Console.Clear(); bool trying = true; Console.WriteLine("\nEnter the Customer's First Name:\t"); string firstName = Console.ReadLine(); Console.WriteLine("\nEnter the Customer's Last Name:\t"); string lastName = Console.ReadLine(); while (trying) { Console.WriteLine("\nSelect the Customer's status:\n" + "[1] Potential\n" + "[2] Current\n" + "[3] Past\n"); System.ConsoleKeyInfo key = Console.ReadKey(); Console.Clear(); string response = key.KeyChar.ToString(); CustomerType type; string email = ""; Customer customer; switch (response) { case "1": type = CustomerType.Potential; trying = false; email = GetEmail(type); customer = new Customer(firstName, lastName, type, email); _customerRepo.AddToList(customer); Console.Clear(); break; case "2": type = CustomerType.Current; trying = false; email = GetEmail(type); customer = new Customer(firstName, lastName, type, email); _customerRepo.AddToList(customer); Console.Clear(); break; case "3": type = CustomerType.Past; trying = false; email = GetEmail(type); customer = new Customer(firstName, lastName, type, email); _customerRepo.AddToList(customer); Console.Clear(); break; default: Console.WriteLine("Error: Select defined option"); break; } } }
public void Run() { while (Listen) { System.ConsoleKeyInfo key = Console.ReadKey(); handler.input(key); } }
static void ContinueUntilKeyPressedOrInactive() { while ((!Console.KeyAvailable) && (VideoGrabber.CurrentState != VidGrabNoForm.TCurrentState.cs_Down)) { VideoGrabber.ContinueProcessing(); } KeyRead = Console.ReadKey(); }
public void KeyPressed( System.ConsoleKeyInfo key) { DefaultEventSource.Current.KeyPressed( _process, key ); }
public Outing AddOuting() { EventTypes eventType = new EventTypes(); bool trying = true; while (trying) { Console.WriteLine("Select Event Type\n" + "[1] Golf\n" + "[2] Bowling\n" + "[3] Amusement Park\n" + "[4] Concert\n"); System.ConsoleKeyInfo input = Console.ReadKey(); Console.Clear(); string answer = input.KeyChar.ToString(); switch (answer) { case "1": eventType = EventTypes.Golf; trying = false; Console.Clear(); break; case "2": eventType = EventTypes.Bowling; trying = false; Console.Clear(); break; case "3": eventType = EventTypes.Park; trying = false; Console.Clear(); break; case "4": eventType = EventTypes.Concert; trying = false; Console.Clear(); break; default: Console.WriteLine("Error: Select defined option"); break; } } Console.WriteLine("Enter the number of atendees:"); int numPeople = int.Parse(Console.ReadLine()); Console.WriteLine("\nEnter the date of the outing: (MM/dd/yyyy)"); DateTime date = _outingRepo.StringToDateTime(Console.ReadLine()); Console.WriteLine("\nEnter the total cost:"); decimal totalCost = decimal.Parse(Console.ReadLine()); Outing outing = new Outing(eventType, numPeople, date, totalCost); return(outing); }
private char GetKey() { /*if (!System.Console.KeyAvailable) * { * input = EInput.none; * return; * }*/ System.ConsoleKeyInfo keyInfo = System.Console.ReadKey(true); return(keyInfo.KeyChar); }
public void KeyPressed(System.ConsoleKeyInfo key) { if (key.Key == right) { Move(1); } else if (key.Key == left) { Move(-1); } }
static void Main(string[] args) { // Not Üniversite 1 de iken ders anında aldığım notlar açıklama satırları. Nostalji olması açısından silmedim :D // anladığım kadarıyla keyinfo metodunda şu satır kod kesin kullanılacak // system.consolekeyinfo keyinfo= console.readkey(true); // konsole ekranını kapatmak için system.environment.exit(0); kodu kullanılabiir. // bastığımız tuşu keyinfo ya atamak için keyinfo.key==consolekey.istediğimiz tuş // 1. PROGRAM Console.Write("Bir tuşa basınız: "); System.ConsoleKeyInfo KeyInfo = Console.ReadKey(true); Console.Write(KeyInfo.Key.ToString() + " tuşuna bastınız"); Console.ReadKey(); Console.Clear(); // bu metod ekranımızı temizlemize yardımcı olur. /* **************************************************************************************** */ // 2. PROGRAM string ad, soyad; Console.WriteLine("Adınızı Giriniz:"); ad = Console.ReadLine(); Console.WriteLine("Soyadınızı Giriniz:"); soyad = Console.ReadLine(); Console.Clear(); // Bu metod console ekranını temizlememize yardımcı olur. Console.WriteLine("Ekrana yazdırmak için F2, Çıkmak için ESC tuşuna basınız!!!"); ConsoleKeyInfo a = Console.ReadKey(); if (a.Key == ConsoleKey.Escape) { System.Environment.Exit(0); // programı kapatmamızı sağladı. } else if (a.Key == ConsoleKey.F2) { Console.Write(ad + " " + soyad); } Console.ReadKey(); Console.ReadKey(); }
public string ConsoleMenu() { Console.WriteLine($"Select an option:\r\n" + $"\r\n" + $"[1] Add Item to Menu\r\n" + $"[2] View Menu\n" + $"[3] Remove an Item\n" + $"[X] Exit\n"); System.ConsoleKeyInfo input = Console.ReadKey(); Console.Clear(); return(input.KeyChar.ToString()); }
public string ConsoleMenu() { Console.WriteLine($"\r\nHello Security Admin, What would you like to do?\r\n" + $"\r\n" + $"[1] Add new Badge\r\n" + $"[2] Edit existing Badge\n" + $"[3] View all Badges\n" + $"[X] Exit\n"); System.ConsoleKeyInfo input = Console.ReadKey(); Console.Clear(); return(input.KeyChar.ToString()); }
public void KeyPressed( System.Diagnostics.Process process, System.ConsoleKeyInfo key) { if (this.IsEnabled()) { KeyPressed( process.MachineName, process.Id, key.ToString()); } }
public string ConsoleMenu() { Console.WriteLine($"\r\nSelect an option:\r\n" + $"\r\n" + $"[1] See all claims\r\n" + $"[2] Take care of next claim\n" + $"[3] Enter a new claim\n" + $"[X] Exit\n"); System.ConsoleKeyInfo input = Console.ReadKey(); Console.Clear(); return(input.KeyChar.ToString()); }
public string ConsoleMenu() { Console.WriteLine($"\r\nSelect an option:\r\n" + $"\r\n" + $"[1] See all outings\r\n" + $"[2] Add another outing to list\n" + $"[3] Cost calculations\n" + $"[X] Exit\n"); System.ConsoleKeyInfo input = Console.ReadKey(); Console.Clear(); return(input.KeyChar.ToString()); }
private void EditCustomer(string lastName) { Console.Clear(); int count = 0; List <Customer> allcustomers = _customerRepo.GetCustomers(); List <Customer> foundCustomers = new List <Customer>(); foreach (Customer customer in allcustomers) { if (customer.LastName == lastName) { count++; foundCustomers.Add(customer); } } if (count == 1) { Console.WriteLine($"Last Name\tFirst Name\ttype\t\temail\n"); Console.WriteLine(foundCustomers[0]); Console.WriteLine("\n\nPress any key to continue"); Console.ReadKey(); Console.Clear(); } else { Console.WriteLine("Multiple Customers Found:\n" + "\n"); Console.WriteLine($"Last Name\tFirst Name\ttype\t\temail\n"); foreach (Customer customer in foundCustomers) { Console.WriteLine(customer); } Console.WriteLine("Enter the first name of the customer you would like to edit"); count = 0; string firstName = Console.ReadLine(); foreach (Customer customer in foundCustomers) { if (customer.FirstName == firstName) { //Menu for editing Console.WriteLine($"\r\nWhat would you like to do?\r\n" + $"\r\n" + $"[1] Change customer status\r\n" + $"[2] Delete customer\n" + $"[3] Cancel\n"); System.ConsoleKeyInfo input = Console.ReadKey(); Console.Clear(); string answer = input.KeyChar.ToString(); } } } }
private string ConsoleMenu() { Console.WriteLine($"\r\nWhat would you like to do?\r\n" + $"\r\n" + $"[1] Add new Car\r\n" + $"[2] Edit existing Car information\n" + $"[3] View Car\n" + $"[4] View Cars by Type\n" + $"[X] Exit\n"); System.ConsoleKeyInfo input = Console.ReadKey(); Console.Clear(); return(input.KeyChar.ToString()); }
private string ConsoleMenu() { Console.WriteLine($"\r\nWhat would you like to do?\r\n" + $"\r\n" + $"[1] View All Parties\r\n" + $"[2] Add New Party\n" + $"[3] View Specific Party Data\n" + $"[4] Delete Party Data\n" + $"[X] Exit\n"); System.ConsoleKeyInfo input = Console.ReadKey(); Console.Clear(); return(input.KeyChar.ToString()); }
static bool evaluateKey(System.ConsoleKeyInfo key) { x = Console.CursorLeft - 1; y = Console.CursorTop; if (key.Key == ConsoleKey.Spacebar) { return(true); } if (key.Key == ConsoleKey.LeftArrow) { x -= 1; if (x < startGrid) { x = startGrid; } } if (key.Key == ConsoleKey.RightArrow) { x += 1; if (x > startGrid + game.Width - 1) { x = startGrid + game.Width - 1; } } if (key.Key == ConsoleKey.UpArrow) { y -= 1; if (y < startGrid) { y = startGrid; } } if (key.Key == ConsoleKey.DownArrow) { y += 1; if (y > startGrid + game.Height - 1) { y = startGrid + game.Height - 1; } } if (key.Key == ConsoleKey.M) { game.markSquare(x - startGrid, y - startGrid); } Console.SetCursorPosition(x, y); return(false); }
static bool isCharKey(System.ConsoleKeyInfo info) { if ((info.Modifiers & ConsoleModifiers.Alt) == ConsoleModifiers.Alt || (info.Key == ConsoleKey.Tab) || (info.Key == ConsoleKey.Enter) || (info.Key == ConsoleKey.Escape) || (info.Key == ConsoleKey.EraseEndOfFile) || (info.Key == ConsoleKey.CrSel) || (info.Key == ConsoleKey.Applications) || (info.KeyChar == '\u0000') ) { return(false); } return(true); }
public void ProcessInput() { if (Console.KeyAvailable) { pressedKey = Console.ReadKey(true); // true за да не печати на конзолата при натискане на клавиш if (char.IsLetter(pressedKey.KeyChar)) { if (LetterPressed != null) { LetterPressed(this, new EventArgs()); } } if (pressedKey.Key.Equals(ConsoleKey.Spacebar)) { if (SpacePressed != null) { SpacePressed(this, new EventArgs()); } } if (pressedKey.Key.Equals(ConsoleKey.Enter)) { if (EnterPressed != null) { EnterPressed(this, new EventArgs()); } } if (pressedKey.Key.Equals(ConsoleKey.UpArrow) || pressedKey.Key.Equals(ConsoleKey.DownArrow)) { if (UpDownPressed != null) { UpDownPressed(this, new EventArgs()); } } if (pressedKey.Key.Equals(ConsoleKey.LeftArrow) || pressedKey.Key.Equals(ConsoleKey.RightArrow)) { if (LeftRightPressed != null) { LeftRightPressed(this, new EventArgs()); } } } }
static void Main(string[] args) { //Example Products Product product1 = new Product(); product1.Id = 0001; product1.ProductName = "Apple"; product1.ProductAmount = 120; product1.ProductPrice = 3.99; product1.ProductDetail = "Red Apple"; Product product2 = new Product(); product2.Id = 0002; product2.ProductName = "Pear"; product2.ProductAmount = 135; product2.ProductPrice = 3.75; product2.ProductDetail = "Yellow Pear"; Product product3 = new Product(); product3.Id = 0003; product3.ProductName = "Grape"; product3.ProductAmount = 150; product3.ProductPrice = 5.00; product3.ProductDetail = "Black Grapes"; Product[] products = new Product[] { product1, product2, product3 }; foreach (var product in products) { Console.WriteLine("We have " + product.ProductName + "!"); Console.WriteLine("------------------"); } Console.WriteLine("If you want to see all the details please click Escape button!"); System.ConsoleKeyInfo KeyInfo = Console.ReadKey(true); if (KeyInfo.Key == ConsoleKey.Escape) { foreach (var item in products) { Console.WriteLine("The " + item.ProductName + " is " + item.ProductPrice + "$ and " + item.ProductAmount + " kg has left!"); } } }
public void Menu() { Round round = new Round(); string informationString = "Total score: \tUser {0} \tComputer {1}"; Console.Clear(); round.DeckInitialization(); OutputСard(round.GetCardForUser()); OutputСard(round.GetCardForUser()); Console.WriteLine(informationString, AllScore.TotalScoreForUser, AllScore.TotalScoreForComputer); while (true) { Console.WriteLine("\n Press 'space' to get new card, esc - pass the course to computer "); enter = Console.ReadKey(); Console.Clear(); round.CardForUserOrComputer(enter); Console.WriteLine(informationString, AllScore.TotalScoreForUser, AllScore.TotalScoreForComputer); } }
public void CardForUserOrComputer(System.ConsoleKeyInfo keyEnter) { if (keyEnter.Key == ConsoleKey.Spacebar) { Card card = deck.PullCard(); AllScore.UserScore += deck.CardValue(card.Nominal); view.OutputСard(card); ConditionsForUser(); } if (keyEnter.Key == ConsoleKey.Escape) { while (true) { Card card = deck.PullCard(); AllScore.ComputerScore += deck.CardValue(card.Nominal); ConditionsForComputer(); } } }