public RonocoToolbarButton GetNavToolbarButton(Icon.IconType type, string unicodeIcon, Color color) { Icon icon = new Icon().MakeIconImage(type, unicodeIcon, color); TapGestureRecognizer tap = new TapGestureRecognizer(); RonocoToolbarButton toolbarButton = new RonocoToolbarButton { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.CenterAndExpand, Children = { icon } }; toolbarButton.GestureRecognizers.Add(tap); return(toolbarButton); }
protected virtual string GetTypeString(Icon.IconType type) { switch (type) { case Icon.IconType.Resource: return(ResourceTypeString); case Icon.IconType.Upload: return(UploadTypeString); case Icon.IconType.EncounterImage: return(EncounterImageTypeString); default: return(null); } }
/// <summary>Creates a dialog box</summary> /// <param name="Type"></param> /// <param name="Text"></param> /// <param name="Buttons"></param> public DialogBox(Icon.IconType Type, DialogBoxButtons Buttons, String Text) { //time to set up a window //MaxWidth-6 because 3 for the icon, 1 for spacing between icon and left, icon and text, and text and right //MaxHeight-5 because 1 for header, 1 for space between header and text, 1 for space between text and button, 1 for button, and 1 for footer FormattedText TextButFormatted = new FormattedText(Text, MaxWidth - 6, MaxHeight - 5); //find the minimum width of the window given the buttons: //5 is the base because that's the width of the icon; int MinWidth = 5; switch (Buttons) { case DialogBoxButtons.OK: //Single button (length of button, plus spacing with the left side of the window MinWidth += 12 + 1; break; case DialogBoxButtons.OKCancel: case DialogBoxButtons.YesNo: //two buttons //two single buttons MinWidth += 13 + 13; break; case DialogBoxButtons.YesNoCancel: case DialogBoxButtons.AbortRetryIgnore: //Three buttons //Three single buttons MinWidth += 13 * 3; break; default: break; } //Get the actual width of the window. //Max in case the text's width or height is smaller than the minimum required to display other elements. int WindowWidth = Math.Max(MinWidth, TextButFormatted.ActualWidth + 6); int WindowHeight = Math.Max(6, TextButFormatted.ActualHeight + 5); //OK now lets figure out which title/icon this will have. String Title; ConsoleColor HeaderBG = ConsoleColor.DarkBlue; switch (Type) { case Icon.IconType.ERROR: Title = "Error"; HeaderBG = ConsoleColor.DarkRed; break; case Icon.IconType.EXCLAMATION: Title = "Warning"; break; case Icon.IconType.INFORMATION: Title = "Information"; break; case Icon.IconType.QUESTION: Title = "Question"; break; default: Title = "Uh..."; break; } //Now we're ready to create the window MainWindow = new Window(false, true, ConsoleColor.Gray, HeaderBG, ConsoleColor.White, Title, WindowWidth, WindowHeight); //Now let's go ahead and populate the window MainWindow.AddElement(new Icon(MainWindow, Type, 1, 2)); MainWindow.AddElement(new Label(MainWindow, TextButFormatted, ConsoleColor.Gray, ConsoleColor.Black, 5, 2)); switch (Buttons) { case DialogBoxButtons.OK: OKButton = new FlaggedCloseButton(MainWindow, OKButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 13, MainWindow.Height - 2); MainWindow.AddElement(OKButton); MainWindow.HighlightedElement = OKButton; OKButton.Highlighted = true; break; case DialogBoxButtons.OKCancel: OKButton = new FlaggedCloseButton(MainWindow, OKButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 26, MainWindow.Height - 2); CancelButton = new FlaggedCloseButton(MainWindow, CancelButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 13, MainWindow.Height - 2); MainWindow.AddElement(OKButton); MainWindow.AddElement(CancelButton); OKButton.NextElement = CancelButton; CancelButton.PreviousElement = OKButton; MainWindow.HighlightedElement = OKButton; OKButton.Highlighted = true; break; case DialogBoxButtons.YesNo: YesButton = new FlaggedCloseButton(MainWindow, YesButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 26, MainWindow.Height - 2); NoButton = new FlaggedCloseButton(MainWindow, NoButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 13, MainWindow.Height - 2); MainWindow.AddElement(YesButton); MainWindow.AddElement(NoButton); YesButton.NextElement = NoButton; NoButton.PreviousElement = YesButton; MainWindow.HighlightedElement = YesButton; YesButton.Highlighted = true; break; case DialogBoxButtons.YesNoCancel: YesButton = new FlaggedCloseButton(MainWindow, YesButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 39, MainWindow.Height - 2); NoButton = new FlaggedCloseButton(MainWindow, NoButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 26, MainWindow.Height - 2); CancelButton = new FlaggedCloseButton(MainWindow, CancelButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 13, MainWindow.Height - 2); MainWindow.AddElement(YesButton); MainWindow.AddElement(NoButton); MainWindow.AddElement(CancelButton); YesButton.NextElement = NoButton; NoButton.PreviousElement = YesButton; NoButton.NextElement = CancelButton; CancelButton.PreviousElement = NoButton; MainWindow.HighlightedElement = YesButton; YesButton.Highlighted = true; break; case DialogBoxButtons.AbortRetryIgnore: AbortButton = new FlaggedCloseButton(MainWindow, AbortButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 39, MainWindow.Height - 2); RetryButton = new FlaggedCloseButton(MainWindow, RetryButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 26, MainWindow.Height - 2); IgnoreButton = new FlaggedCloseButton(MainWindow, IgnoreButtonText, ConsoleColor.DarkGray, ConsoleColor.White, ConsoleColor.DarkBlue, MainWindow.Length - 13, MainWindow.Height - 2); MainWindow.AddElement(AbortButton); MainWindow.AddElement(RetryButton); MainWindow.AddElement(IgnoreButton); AbortButton.NextElement = RetryButton; RetryButton.PreviousElement = AbortButton; RetryButton.NextElement = IgnoreButton; IgnoreButton.PreviousElement = RetryButton; MainWindow.HighlightedElement = AbortButton; AbortButton.Highlighted = true; break; default: break; } }
/// <summary>Shows a dialog box by first creating it, executing it, then disposing of it.</summary> /// <param name="Type"></param> /// <param name="Buttons"></param> /// <param name="Text"></param> /// <returns>Returns a DialogBoxResult based on whichever button was pressed.</returns> public static DialogBoxResult ShowDialogBox(Icon.IconType Type, DialogBoxButtons Buttons, String Text) { return(new DialogBox(Type, Buttons, Text).Execute()); }