private static List <ICommand> HelpScreen(UmlWindow umlWindow) { var titled = new TitledWindow(umlWindow, "About...") { BackGround = ConsoleColor.DarkBlue, Foreground = ConsoleColor.White }; var pop = new Popup(titled, @" * * **** * **** * * * * * * **** ** * **** * * * * * * * **** **** * space ................ (un)select object at cursor or choose object s .................... select an object cursor keys........... move cursor or selected object shift + cursor ....... move object under cursor r .................... rotate selected object (only text label) ctrl + cursor ........ move selected object (only box) b .................... Create a Box c .................... Create a connection line between boxes d .................... Create a Database t .................... Create a text label l .................... Create a free-style line x / Del............... Delete selected object enter ................ Enter command mode Esc .................. Abort input ctrl+c ............... Exit program") { Foreground = titled.Foreground, BackGround = titled.BackGround }; return(Noop); }
private static Option <List <ICommand> > HandleKeys(State state, ConsoleKeyInfo key, List <List <ICommand> > commandLog, UmlWindow umlWindow) { var model = state.Model; var selected = state.SelectedIndexInModel; switch (key.Key) { case ConsoleKey.UpArrow: if (state.TheCurser.Pos.Y > 0) { return(MoveCursorAndSelectPaintable(Vector.DeltaNorth)); } break; case ConsoleKey.DownArrow: if (state.TheCurser.Pos.Y < State.MaxY - 2) { return(MoveCursorAndSelectPaintable(Vector.DeltaSouth)); } break; case ConsoleKey.LeftArrow: if (state.TheCurser.Pos.X > 0) { return(MoveCursorAndSelectPaintable(Vector.DeltaWest)); } break; case ConsoleKey.RightArrow: if (state.TheCurser.Pos.X < State.MaxX - 2) { return(MoveCursorAndSelectPaintable(Vector.DeltaEast)); } break; case ConsoleKey.Spacebar: return(SelectDeselect(selected, state)); case ConsoleKey.S: return(PrintIdsAndLetUserSelectObject(state) .Match(x => Lst(new SelectObject(x, true)), () => Noop)); case ConsoleKey.X: case ConsoleKey.Delete: return(Lst(new DeleteSelectedElement())); case ConsoleKey.D: return(Lst(new CreateDatabase(state.TheCurser.Pos))); case ConsoleKey.H: return(HelpScreen(umlWindow)); case ConsoleKey.B: return(ConsoleInputColors(() => CommandParser.TryReadLineWithCancel("Create box. Title: ") .Match(x => Lst(new CreateBox(state.TheCurser.Pos, x), new TmpForceRepaint()), () => NoopForceRepaint))); case ConsoleKey.C: return(ConnectObjects(state)); case ConsoleKey.L: return(SlopedLine(state)); case ConsoleKey.T: return(ConsoleInputColors(() => CommandParser.TryReadLineWithCancel("Create a label. Text: ") .Match(x => Lst(new CreateLabel(state.TheCurser.Pos, x), new TmpForceRepaint()), () => NoopForceRepaint))); case ConsoleKey.R: return(Rotate(selected, model)); case ConsoleKey.Enter: return(CommandMode(state, commandLog)); } return(Noop); }
public static List <ICommand> HandleKeyPress(State state, ConsoleKeyInfo key, List <List <ICommand> > commandLog, UmlWindow umlWindow) { return(ControlKeys(state, key, commandLog) .IfNone(() => ShiftKeys(state, key) .IfNone(() => HandleKeys(state, key, commandLog, umlWindow) .IfNone(() => Noop)))); }