public MessageBox(string message, Action <MessageBoxResultEnum, object> result, string title, MessageBoxTypeEnum type, MessageBoxButtonsEnum buttons, MessageBoxButtonsDirectionEnum direction = MessageBoxButtonsDirectionEnum.Horizontal) : base(new Panel()) { _message = message; _buttonsType = buttons; _direction = direction; _messageBoxType = type; _result = result; Title = title; }
public MessageBox(string message, Action <MessageBoxResultEnum, object> result, string title, MessageBoxTypeEnum type, MessageBoxButtonsDirectionEnum direction = MessageBoxButtonsDirectionEnum.Horizontal, IEnumerable <SubmenuContext <object> > buttonsList = null) : base(new Panel()) { _message = message; _direction = direction; _buttonsList = buttonsList; _messageBoxType = type; _result = result; Title = title; }
public static void Show(string message, IEnumerable <SubmenuContext <object> > buttonsList, Action <MessageBoxResultEnum, object> resultAction = null, string title = "Message", MessageBoxTypeEnum type = MessageBoxTypeEnum.Info, MessageBoxButtonsDirectionEnum direction = MessageBoxButtonsDirectionEnum.Horizontal) { int width = 0; int height = 0; ScoreboardContext.CurrentState.IsNavigating = true; MessageBox mb; int minWidth = 16; var largestTextLength = buttonsList.Select(i => i.Text.Length).Max(); width = largestTextLength + 6 > minWidth ? largestTextLength + 6 : minWidth; int left = ScoreboardContext.Navigation.Current.Scoreboard.Size.Width / 2 - width / 2; int top = ScoreboardContext.Navigation.Current.Scoreboard.Size.Height / 2 - 5; left = left < 0 ? 1 : left; top = top < 0 ? 1 : top; width = width > ScoreboardContext.Navigation.Current.Scoreboard.Size.Width ? ScoreboardContext.Navigation.Current.Scoreboard.Size.Width - 2 : width; height = direction == MessageBoxButtonsDirectionEnum.Horizontal ? 10 : buttonsList.Count() * 2 + 5; height = height > ScoreboardContext.Navigation.Current.Scoreboard.Size.Height ? ScoreboardContext.Navigation.Current.Scoreboard.Size.Height - 2 : height; mb = new MessageBox(message, resultAction, title, type, direction, buttonsList) { BackgroundColor = GetBackgroundColor(type), ForegroundColor = GetForegroundColor(type), BorderForegroundColor = GetForegroundColor(type), BorderBackgroundColor = GetBackgroundColor(type), Size = new Size { Height = height, Width = width }, Location = new Point { Left = left, Top = top } }; ScoreboardContext.Navigation.Navigate(mb); ScoreboardContext.RenderEngine.ConsoleAdapter.Beep(); }
public static void Show(string message, Action <MessageBoxResultEnum, object> resultAction = null, string title = "Message", MessageBoxTypeEnum type = MessageBoxTypeEnum.Info, MessageBoxButtonsEnum buttons = MessageBoxButtonsEnum.Ok, MessageBoxButtonsDirectionEnum direction = MessageBoxButtonsDirectionEnum.Horizontal) { int width = 0; ScoreboardContext.CurrentState.IsNavigating = true; MessageBox mb; int minWidth = ScoreboardContext.Navigation.Current.Scoreboard.Size.Width / 2; width = message.Length > minWidth ? message.Length + 2 : minWidth; int left = ScoreboardContext.Navigation.Current.Scoreboard.Size.Width / 2 - width / 2; int top = ScoreboardContext.Navigation.Current.Scoreboard.Size.Height / 2 - 4; left = left < 0 ? 1 : left; top = top < 0 ? 1 : top; width = width > ScoreboardContext.Navigation.Current.Scoreboard.Size.Width ? ScoreboardContext.Navigation.Current.Scoreboard.Size.Width - 2 : width; mb = new MessageBox(message, resultAction, title, type, buttons, direction) { BackgroundColor = GetBackgroundColor(type), ForegroundColor = GetForegroundColor(type), BorderForegroundColor = GetForegroundColor(type), BorderBackgroundColor = GetBackgroundColor(type), Size = new Size { Height = direction == MessageBoxButtonsDirectionEnum.Horizontal ? 10 : 20, Width = width }, Location = new Point { Left = left, Top = top } }; ScoreboardContext.Navigation.Navigate(mb); ScoreboardContext.RenderEngine.ConsoleAdapter.Beep(); }