Skip to main content
Code Review

Return to Question

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

GetBootstrap-2.0 update from GetBootstrap-1.0.0.2 GetBootstrap-1.0.0.2

GetBootstrap-2.0 update from GetBootstrap-1.0.0.2

GetBootstrap-2.0 update from GetBootstrap-1.0.0.2

deleted 19 characters in body; edited tags
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

Here is my sample preview of GetBootstrap-2.0:

Here is my code:

Here is my sample preview of GetBootstrap-2.0

Here is my code:

Here is my sample preview of GetBootstrap-2.0:

Source Link

Console Application Customizer - GetBootstrap v2.0

GetBootstrap-2.0 update from GetBootstrap-1.0.0.2

I just update my console application customizer and add some new features like disable minimize, maximize and close button, new color and simple popup box. Help me review my codes...

Here is my sample preview of GetBootstrap-2.0

GetBootstrap-2.0

The preview contains Write(), WriteLine(),Popup(), Typewriter effect and colors.

Here is my code:

Bootstrap.cs

public partial class Bootstrap
{
 public static void Write(string format, int min = 50, int max = 100, params object[] args)
 {
 format = String.Format(format, args);
 for (int i = 0; i < format.Length; i++)
 {
 Thread.Sleep(TypeWriter.Next(min, max));
 Console.Write(format.Substring(i, 1));
 }
 }
 public static void Write(string format, BootstrapStyle style, BootstrapType type, params object[] args)
 {
 Customize(style, type);
 Console.Write(String.Format(format, args));
 Console.ResetColor();
 }
 public static void Write(string format, int min, int max, BootstrapStyle style, BootstrapType type, params object[] args)
 {
 Customize(style, type);
 Write(format, min, max, args);
 Console.ResetColor();
 }
 #region Method WriteLine...
 public static void WriteLine(string format, int min = 50, int max = 100, params object[] args)
 {
 Write(format, min, max, args);
 Console.WriteLine();
 }
 public static void WriteLine(string format, BootstrapStyle style, BootstrapType type, params object[] args)
 {
 Write(format, style, type, args);
 Console.WriteLine();
 }
 public static void WriteLine(string format, int min, int max, BootstrapStyle style, BootstrapType type, params object[] args)
 {
 Write(format, min, max, style, type, args);
 Console.WriteLine();
 }
 #endregion
 #region Method MessageBox
 public static void Popup(string format, string caption, params object[] args)
 {
 MessageBox.Show(String.Format(format, args), caption);
 }
 #endregion
 #region Method Controller...
 public static void CloseBox(bool enable)
 {
 EnableMenu(GetSystemMenu(GetConsoleWindow(), enable), SC_CLOSE, MF_ENABLED);
 }
 public static void MaximizeBox(bool enable)
 {
 EnableMenu(GetSystemMenu(GetConsoleWindow(), enable), SC_MAXIMIZE, MF_ENABLED);
 }
 public static void MinimizeBox(bool enable)
 {
 EnableMenu(GetSystemMenu(GetConsoleWindow(), enable), SC_MINIMIZE, MF_ENABLED);
 }
 #endregion
 }

I decide to create a new file for my Bootstrap design and make it partial of Bootstrap.cs.

Bootstrap.Designer.cs

partial class Bootstrap
{
 static Random TypeWriter = new Random();
 const int MF_ENABLED = 0x00000000;
 const int SC_CLOSE = 0xF060;
 const int SC_MAXIMIZE = 0xF030;
 const int SC_MINIMIZE = 0xF020;
 [DllImport("user32.dll")]
 static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
 [DllImport("kernel32.dll", ExactSpelling = true)]
 static extern IntPtr GetConsoleWindow();
 [DllImport("user32.dll")]
 static extern int EnableMenu(IntPtr hMenu, int nPosition, int wFlags);
 static void Customize(BootstrapStyle style, BootstrapType type)
 {
 switch (type)
 {
 case BootstrapType.Success:
 Console.ForegroundColor = ConsoleColor.Green;
 if(style == BootstrapStyle.Alert)
 {
 Console.BackgroundColor = ConsoleColor.DarkGreen;
 }
 break;
 case BootstrapType.Info:
 Console.ForegroundColor = ConsoleColor.Cyan;
 if(style == BootstrapStyle.Alert)
 {
 Console.BackgroundColor = ConsoleColor.DarkCyan;
 }
 break;
 case BootstrapType.Warning:
 Console.ForegroundColor = ConsoleColor.Yellow;
 if(style == BootstrapStyle.Alert)
 {
 Console.BackgroundColor = ConsoleColor.DarkYellow;
 }
 break;
 case BootstrapType.Danger:
 Console.ForegroundColor = ConsoleColor.Red;
 if(style == BootstrapStyle.Alert)
 {
 Console.BackgroundColor = ConsoleColor.DarkRed;
 }
 break;
 case BootstrapType.Magenta:
 Console.ForegroundColor = ConsoleColor.Magenta;
 if(style == BootstrapStyle.Alert)
 {
 Console.BackgroundColor = ConsoleColor.DarkMagenta;
 }
 break;
 case BootstrapType.Cobalt:
 Console.ForegroundColor = ConsoleColor.Blue;
 if (style == BootstrapStyle.Alert)
 {
 Console.BackgroundColor = ConsoleColor.DarkBlue;
 }
 break;
 default:
 Console.ForegroundColor = ConsoleColor.Gray;
 if(style == BootstrapStyle.Alert)
 {
 Console.BackgroundColor = ConsoleColor.DarkGray;
 }
 break;
 }
 }
 }
 #region Enum...
 public enum BootstrapStyle
 {
 Default,
 Alert
 }
 public enum BootstrapType
 {
 Default,
 Success,
 Info,
 Warning,
 Danger,
 Magenta,
 Cobalt
 }
 #endregion

If you want to try it I have a download link below. -"Tutorial Inside"

You can download and edit the project if you want.

Updates:

  • Added New Color
  • Added Simple Popup
  • Added Disable Minimize
  • Added Disable Maximize
  • Added Disable Close Button
  • Download Link
lang-cs

AltStyle によって変換されたページ (->オリジナル) /