public void HelpTest1_WithResponseFile(IColors color) { string responseFile = Path.Combine(Helpers.GetTestLocation(), Path.Combine("SampleRspFiles", "response4.rsp")); TestWriter _printer = new TestWriter(); var options = Assert.Throws <HelpRequestedException>(() => Helpers.Parse <Options3NoRequired>($"@{responseFile}", _printer, color)); Validate(_printer, new TextAndColor(_printer.ForegroundColor, "Usage: "), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(color.AssemblyNameColor, $"{Assembly.GetEntryAssembly()?.GetName()?.Name}.exe"), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(_printer.ForegroundColor, "[-"), new TextAndColor(color.OptionalArgumentColor, "opt1"), new TextAndColor(_printer.ForegroundColor, " value] "), new TextAndColor(_printer.ForegroundColor, "[-"), new TextAndColor(color.OptionalArgumentColor, "opt2"), new TextAndColor(_printer.ForegroundColor, " value] "), new TextAndColor(_printer.ForegroundColor, "[-"), new TextAndColor(color.OptionalArgumentColor, "opt3"), new TextAndColor(_printer.ForegroundColor, " value] "), new TextAndColor(_printer.ForegroundColor, "For detailed information run '"), new TextAndColor(color.AssemblyNameColor, $"{Assembly.GetEntryAssembly()?.GetName()?.Name} --help"), new TextAndColor(_printer.ForegroundColor, "'.") ); }
private static int DisplayCommandLine(ArgumentGroupInfo arguments, IColors colors) { int maxStringSize = 0; for (int i = 0; i < arguments.RequiredArguments.Count; i++) { if (!arguments.RequiredArguments.ContainsKey(i)) { string requiredArgError = $"{Environment.NewLine}[{colors.ErrorColor}!Error]: Required argument expected at position[{colors.RequiredArgumentColor}!{{0}}]. Type declares arguments at position(s) [{colors.RequiredArgumentColor}!{{1}}]. [{colors.ErrorColor}!Check type definition]."; Colorizer.WriteLine(requiredArgError, i, string.Join(",", arguments.RequiredArguments.Keys.OrderBy(x => x))); return(-1); } var b = arguments.RequiredArguments[i].GetCustomAttribute <ActualArgumentAttribute>(); maxStringSize = Math.Max(maxStringSize, b.Name.Length); string argumentName = $"[{colors.RequiredArgumentColor}!{{0}}] "; Colorizer.Write(argumentName, b.Name); } foreach (var item in arguments.OptionalArguments.Values) { var b = item.GetCustomAttribute <ActualArgumentAttribute>(); maxStringSize = Math.Max(maxStringSize, b.Name.Length); string optionalArgumentFormat = $"\\[-[{colors.OptionalArgumentColor}!{{0}}] value\\] "; Colorizer.Write(optionalArgumentFormat, b.Name); } Colorizer.WriteLine(string.Empty); return(maxStringSize); }
public void TryParseObjectThatDefinesTwoRequiredLists() { var commandLine = $"element1 element2 element3"; TestWriter _printer = new TestWriter(); IColors color = Parser.ColorScheme.Get(); OutputColorizer.Colorizer.SetupWriter(_printer); bool value = Parser.TryParse(commandLine, out ComplexType2 options); Assert.False(value); Validate(_printer, new TextAndColor(color.ErrorColor, "Error"), new TextAndColor(_printer.ForegroundColor, $": Cannot declare two required collection arguments. Please convert one of them to an optional collection one. {Environment.NewLine}"), new TextAndColor(_printer.ForegroundColor, "Usage: "), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(color.AssemblyNameColor, $"{Assembly.GetEntryAssembly()?.GetName()?.Name}.exe"), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(color.RequiredArgumentColor, "repos"), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(_printer.ForegroundColor, "For detailed information run '"), new TextAndColor(color.AssemblyNameColor, "testhost --help"), new TextAndColor(_printer.ForegroundColor, "'.") ); }
public void TryParseObjectThatHasListAsFirstArgument() { var commandLine = $"element1 element2 element3"; TestWriter _printer = new TestWriter(); IColors color = Parser.ColorScheme.Get(); OutputColorizer.Colorizer.SetupWriter(_printer); bool value = Parser.TryParse(commandLine, out ComplexType5 options); Assert.False(value); Validate(_printer, new TextAndColor(color.ErrorColor, "Error"), new TextAndColor(_printer.ForegroundColor, $": The required collection argument needs to be on the last position of the required arguments. {Environment.NewLine}"), new TextAndColor(_printer.ForegroundColor, "Usage: "), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(color.AssemblyNameColor, "testhost.exe"), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(color.RequiredArgumentColor, "list1"), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(color.RequiredArgumentColor, "nonList"), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(_printer.ForegroundColor, "For detailed information run '"), new TextAndColor(color.AssemblyNameColor, "testhost --help"), new TextAndColor(_printer.ForegroundColor, "'.") ); }
public static void Set(IColors colors) { lock (s_lockObj) { s_helpColors = colors; } }
private string GetColorPropertyNameForColor() { IColors currentColorScheme = Parser.ColorScheme.Get(); string propertyName = ""; // check which color matches the current ForegroundColor. if (currentColorScheme.ArgumentGroupColor == ForegroundColor) { propertyName = nameof(currentColorScheme.ArgumentGroupColor); } if (currentColorScheme.ArgumentValueColor == ForegroundColor) { propertyName = nameof(currentColorScheme.ArgumentValueColor); } if (currentColorScheme.AssemblyNameColor == ForegroundColor) { propertyName = nameof(currentColorScheme.AssemblyNameColor); } if (currentColorScheme.ErrorColor == ForegroundColor) { propertyName = nameof(currentColorScheme.ErrorColor); } if (currentColorScheme.OptionalArgumentColor == ForegroundColor) { propertyName = nameof(currentColorScheme.OptionalArgumentColor); } if (currentColorScheme.RequiredArgumentColor == ForegroundColor) { propertyName = nameof(currentColorScheme.RequiredArgumentColor); } return(propertyName); }
/// <param name='operations'> /// Reference to the ZtherApiIntegration.API.IColors. /// </param> /// <param name='type'> /// Required. /// </param> public static ColorList GetAllByGroupTypeAsync(this IColors operations, string type) { return(Task.Factory.StartNew((object s) => { return ((IColors)s).GetAllByGroupTypeAsyncAsync(type); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <param name='operations'> /// Reference to the ZtherApiIntegration.API.IColors. /// </param> /// <param name='model'> /// Required. /// </param> public static string UpdateAsync(this IColors operations, ColorUpdate model) { return(Task.Factory.StartNew((object s) => { return ((IColors)s).UpdateAsyncAsync(model); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <inheritdoc /> public void Initialize(Settings.Settings settings) { if (settings.ColorSettings.ElsEnabled) { _colors = new ElsColors(_elsSettingsManager); } else { _colors = new PluginConfigColors(settings.ColorSettings); } }
private static void DisplayDetailedHelp(TypeArgumentInfo type, IColors colors) { string exeName = Assembly.GetEntryAssembly()?.GetName()?.Name; Colorizer.WriteLine("Usage: "); foreach (var item in type.ArgumentGroups.Keys) { DisplayDetailedArgumentHelp(exeName, item, type.ArgumentGroups[item], colors); } }
public static Border GridLine(this IColors colors) { return(new Border { All = new GrapeCity.Win.MultiRow.Line { Color = colors.GridLineColor, Style = LineStyle.Thin, }, }); }
private static void DisplayShortHelp(TypeArgumentInfo type, IColors colors) { string exeName = Assembly.GetEntryAssembly()?.GetName()?.Name; Colorizer.WriteLine("Usage: "); DisplayCommandLine(exeName, type, colors); Colorizer.WriteLine(string.Empty); string errorFormat = $"For detailed information run '[{colors.AssemblyNameColor}!{{0}} --help]'."; Colorizer.WriteLine(errorFormat, exeName); }
public void TryParseWithoutLoggingToConsole() { TestWriter _printer = new TestWriter(); ParserOptions parserOptions = new ParserOptions() { LogParseErrorToConsole = false }; IColors color = Parser.ColorScheme.Get(); OutputColorizer.Colorizer.SetupWriter(_printer); bool value = Parser.TryParse("foo", out Options1 options, parserOptions); Assert.False(value); Validate(_printer); }
private void drawingCanvas_Tapped(object sender, TappedRoutedEventArgs e) { Point mouseLocation = e.GetPosition(this.drawingCanvas); Square mySquare = new Square(100); if (mySquare is IDraw) { IDraw drawSquare = mySquare; drawSquare.SetLocations((int)mouseLocation.X, (int)mouseLocation.Y); drawSquare.Draw(drawingCanvas); } if (mySquare is IColors) { IColors colorSquare = mySquare; colorSquare.SetColor(Colors.BlueViolet); } }
public static T Parse <T>(string argString, IOutputWriter writer = null, IColors colors = null, ParserOptions parserOptions = null) where T : new() { if (writer == null) { writer = new ConsoleWriter(); } if (colors == null) { colors = new DarkBackground(); } Colorizer.SetupWriter(writer); Parser.ColorScheme.Set(colors); return(Parser.Parse <T>(argString, parserOptions)); }
/// <summary>Template Builder のインスタンスを生成する拡張メソッド</summary> /// <param name="app"></param> /// <param name="color"></param> /// <param name="autoLocationSet"></param> /// <param name="allowHorizontalResize"></param> /// <param name="sortable"></param> /// <returns></returns> public static GcMultiRowTemplateBuilder CreateGcMultirowTemplateBuilder( this IApplication app, IColors color, bool autoLocationSet = true, bool allowHorizontalResize = true, bool sortable = false) { var builer = new GcMultiRowTemplateBuilder() { AutoLocationSet = autoLocationSet, AllowHorizontalResize = allowHorizontalResize, Sortable = sortable, Font = new Font(app.FontFamilyName, (float)9.0, FontStyle.Regular, GraphicsUnit.Point, (byte)128), Border = color.GridLine(), }; return(builer); }
public static void SetRowColor(this VOneGridControl grid, IColors colors, GridColorType type = GridColorType.General) { switch (type) { case GridColorType.General: grid.RowsDefaultCellStyle.BackColor = colors.GridRowBackColor; grid.AlternatingRowsDefaultCellStyle.BackColor = colors.GridAlternatingRowBackColor; break; case GridColorType.Input: grid.RowsDefaultCellStyle.BackColor = colors.InputGridBackColor; grid.AlternatingRowsDefaultCellStyle.BackColor = colors.InputGridAlternatingBackColor; break; default: break; } }
private void drawingCanvas_RightTapped(object sender, RightTappedRoutedEventArgs e) { Point mouseLocation = e.GetPosition(this.drawingCanvas); Circle myCircle = new Circle(100); if (myCircle is IDraw) { IDraw drawCircle = myCircle; drawCircle.SetLocations((int)mouseLocation.X, (int)mouseLocation.Y); drawCircle.Draw(drawingCanvas); } if (myCircle is IColors) { IColors colorCircle = myCircle; colorCircle.SetColor(Colors.HotPink); } }
public void TryParseWithLoggingToConsole() { TestWriter _printer = new TestWriter(); ParserOptions parserOptions = new ParserOptions() { LogParseErrorToConsole = true }; IColors color = Parser.ColorScheme.Get(); OutputColorizer.Colorizer.SetupWriter(_printer); bool value = Parser.TryParse("foo", out Options1 options, parserOptions); Assert.False(value); Validate(_printer, new TextAndColor(color.ErrorColor, "Error"), new TextAndColor(_printer.ForegroundColor, $": Not all required arguments have been specified {Environment.NewLine}"), new TextAndColor(_printer.ForegroundColor, "Usage: "), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(color.AssemblyNameColor, $"{Assembly.GetEntryAssembly()?.GetName()?.Name}.exe"), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(color.RequiredArgumentColor, "p1"), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(color.RequiredArgumentColor, "p2"), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(_printer.ForegroundColor, "[-"), new TextAndColor(color.OptionalArgumentColor, "opt1"), new TextAndColor(_printer.ForegroundColor, " value] "), new TextAndColor(_printer.ForegroundColor, "[-"), new TextAndColor(color.OptionalArgumentColor, "opt2"), new TextAndColor(_printer.ForegroundColor, " value] "), new TextAndColor(_printer.ForegroundColor, "[-"), new TextAndColor(color.OptionalArgumentColor, "opt3"), new TextAndColor(_printer.ForegroundColor, " value] "), new TextAndColor(_printer.ForegroundColor, "[-"), new TextAndColor(color.OptionalArgumentColor, "opt4"), new TextAndColor(_printer.ForegroundColor, " value] "), new TextAndColor(_printer.ForegroundColor, "For detailed information run '"), new TextAndColor(color.AssemblyNameColor, "testhost --help"), new TextAndColor(_printer.ForegroundColor, "'.") ); }
private static void SetTextBoxColor(Control control, IColors colorContext) { var ignorable = control as IIgnoreableFocusChange; if (!(ignorable?.IgnoreFocusChange ?? false)) { control.GotFocus += (sender, e) => control.BackColor = colorContext.ControlActiveBackColor; control.LostFocus += (sender, e) => control.BackColor = ((control as IRequired)?.Required ?? false) ? colorContext.ControlRequiredBackColor : colorContext.ControlEnableBackColor; } control.ForeColor = colorContext.ControlForeColor; var editBase = control as GrapeCity.Win.Editors.EditBase; if (editBase == null) { return; } editBase.DisabledBackColor = colorContext.ControlDisableBackColor; editBase.DisabledForeColor = colorContext.ControlForeColor; var required = control as IRequired; if (required == null) { editBase.BackColor = colorContext.ControlEnableBackColor; return; } editBase.BackColor = required.Required ? colorContext.ControlRequiredBackColor : colorContext.ControlEnableBackColor; required.RequiredChanged += (sender, e) => editBase.BackColor = required.Required ? colorContext.ControlRequiredBackColor : colorContext.ControlEnableBackColor; }
private static void SetGridColor(Control control, IColors colorContext) { var grid = control as Controls.VOneGridControl; if (grid == null) { return; } grid.DefaultCellStyle.BackColor = colorContext.GridRowBackColor; grid.DefaultCellStyle.DisabledBackColor = colorContext.GridRowBackColor; grid.DefaultCellStyle.Border = new GcMultiRow.Border(GcMultiRow.LineStyle.Thin, colorContext.GridLineColor); switch (grid.GridColorType) { case GridColorType.General: grid.AlternatingRowsDefaultCellStyle.BackColor = colorContext.GridAlternatingRowBackColor; grid.AlternatingRowsDefaultCellStyle.DisabledBackColor = colorContext.GridAlternatingRowBackColor; grid.AlternatingRowsDefaultCellStyle.Border = new GcMultiRow.Border(GcMultiRow.LineStyle.Thin, colorContext.GridLineColor); grid.CurrentCellBorderLine = new GcMultiRow.Line(GcMultiRow.LineStyle.Thick, Color.Black); grid.CurrentRowBorderLine = new GcMultiRow.Line(GcMultiRow.LineStyle.None, Color.Black); break; case GridColorType.Input: grid.DefaultCellStyle.BackColor = colorContext.InputGridBackColor; grid.DefaultCellStyle.DisabledBackColor = colorContext.InputGridBackColor; grid.DefaultCellStyle.SelectionBackColor = colorContext.InputGridBackColor; grid.DefaultCellStyle.SelectionForeColor = colorContext.ControlForeColor; grid.AlternatingRowsDefaultCellStyle.BackColor = colorContext.InputGridAlternatingBackColor; grid.AlternatingRowsDefaultCellStyle.DisabledBackColor = colorContext.InputGridAlternatingBackColor; grid.AlternatingRowsDefaultCellStyle.SelectionBackColor = colorContext.InputGridAlternatingBackColor; grid.AlternatingRowsDefaultCellStyle.SelectionForeColor = colorContext.ControlForeColor; grid.AlternatingRowsDefaultCellStyle.Border = new GcMultiRow.Border(GcMultiRow.LineStyle.Thin, colorContext.GridLineColor); break; default: break; } }
/// <summary> /// Initializes a new instance of the LandauWebAPI class. /// </summary> /// <param name='rootHandler'> /// Optional. The http client handler used to handle http transport. /// </param> /// <param name='handlers'> /// Optional. The set of delegating handlers to insert in the http /// client pipeline. /// </param> public LandauWebAPI(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) { this._banners = new Banners(this); this._brands = new Brands(this); this._catalogs = new Catalogs(this); this._colors = new Colors(this); this._contactUs = new ContactUsOperations(this); this._countries = new Countries(this); this._groupOrders = new GroupOrders(this); this._images = new Images(this); this._productImages = new ProductImages(this); this._productReviews = new ProductReviews(this); this._products = new Products(this); this._questions = new Questions(this); this._retailers = new Retailers(this); this._seo = new SeoOperations(this); this._signUps = new SignUps(this); this._states = new States(this); this._swatches = new Swatches(this); this._baseUri = new Uri("http://microsoft-apiapp5dcb282abbf74b72ad1667c2-staging.azurewebsites.net:80"); }
public static void InitializeColor(this Control control, IColors colors) { DoAllControls(control, c => { if (c is Label || c is Panel || c is GroupBox || c is CheckBox || c is RadioButton || c is TabPage) { SetDefaultColor(c, colors); } else if (c is Button) { c.BackColor = colors.ButtonBackColor; } else if (c is TextBoxBase || c is ListControl || c is GrapeCity.Win.Editors.EditBase) { SetTextBoxColor(c, colors); } else if (c is GcMultiRow.GcMultiRow) { SetGridColor(c, colors); } }); }
public void DefineTwoRequiredCollectionsSameGroup() { string expectedRepo1 = "azure\azure-powershell"; string expectedRepo2 = "azure\azure-sdk-for-net"; var commandLine = $"Create {expectedRepo1} {expectedRepo2}"; TestWriter _printer = new TestWriter(); IColors color = Parser.ColorScheme.Get(); OutputColorizer.Colorizer.SetupWriter(_printer); bool value = Parser.TryParse(commandLine, out ComplexType6 options); Assert.False(value); Validate(_printer, new TextAndColor(color.ErrorColor, "Error"), new TextAndColor(_printer.ForegroundColor, $": Cannot declare two required collection arguments. Please convert one of them to an optional collection one. {Environment.NewLine}"), new TextAndColor(_printer.ForegroundColor, "Usage: "), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(color.AssemblyNameColor, "testhost.exe"), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(color.ArgumentValueColor, "Create"), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(color.RequiredArgumentColor, "repos2"), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(color.AssemblyNameColor, "testhost.exe"), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(color.ArgumentValueColor, "List"), new TextAndColor(_printer.ForegroundColor, " "), new TextAndColor(_printer.ForegroundColor, "For detailed information run '"), new TextAndColor(color.AssemblyNameColor, "testhost --help"), new TextAndColor(_printer.ForegroundColor, "'.") ); }
/// <summary> /// /// </summary> /// <param name="original">Typically a <see cref="Skin"/>.</param> /// <param name="desired">Typically a <see cref="ColorScheme"/>.</param> public void SetColors(IColors original, IColors desired) { if (original.Length != desired.Length) { throw new System.ArgumentException("Mismatched original/desired, lengths do not match."); } // Unregister from the previous scheme if (this.desired != null) { this.desired.OnModified -= HandleModified; } this.original = original; this.desired = desired; // Register with the new scheme if (this.desired != null) { this.desired.OnModified += HandleModified; } // Build an array of ColorSwaps that will map the r values // from the original colors to the desired colors colorsToSwap.Clear(); for (int i = 0; i < original.Length; i++) { colorsToSwap.Add(new ColorSwap { rValue = original[i].r, swapColor = desired[i] }); } SetColorsInternal(); }
public static IColors Get(ConsoleColor backgroundColor = (ConsoleColor)(-1)) { if (s_helpColors != null) { return(s_helpColors); } // if the color is not specified, default to the current console's background color. if (backgroundColor == (ConsoleColor)(-1)) { backgroundColor = Console.BackgroundColor; } // Get the color scheme. lock (s_lockObj) { if (s_helpColors == null) { s_helpColors = GetDefault(backgroundColor); } } return(s_helpColors); }
/// <summary> /// Initializes a new instance of the LandauPortalWebAPI class. /// </summary> /// <param name='rootHandler'> /// Optional. The http client handler used to handle http transport. /// </param> /// <param name='handlers'> /// Optional. The set of delegating handlers to insert in the http /// client pipeline. /// </param> public LandauPortalWebAPI(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) { this._banners = new Banners(this); this._brands = new Brands(this); this._cache = new Cache(this); this._catalogs = new Catalogs(this); this._colors = new Colors(this); this._contactUs = new ContactUsOperations(this); this._countries = new Countries(this); this._emailFavorites = new EmailFavorites(this); this._groupOrders = new GroupOrders(this); this._images = new Images(this); this._productImages = new ProductImages(this); this._productReviews = new ProductReviews(this); this._products = new Products(this); this._questions = new Questions(this); this._retailers = new Retailers(this); this._seo = new SeoOperations(this); this._signUps = new SignUps(this); this._states = new States(this); this._swatches = new Swatches(this); this._baseUri = new Uri(API_ENDPOINT); }
/// <param name='operations'> /// Reference to the ZtherApiIntegration.API.IColors. /// </param> /// <param name='model'> /// Required. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> public static async Task <string> UpdateAsyncAsync(this IColors operations, ColorUpdate model, CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { Microsoft.Rest.HttpOperationResponse <string> result = await operations.UpdateAsyncWithOperationResponseAsync(model, cancellationToken).ConfigureAwait(false); return(result.Body); }
/// <param name='operations'> /// Reference to the ZtherApiIntegration.API.IColors. /// </param> /// <param name='type'> /// Required. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> public static async Task <ColorList> GetAllByGroupTypeAsyncAsync(this IColors operations, string type, CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { Microsoft.Rest.HttpOperationResponse <ZtherApiIntegration.API.Models.ColorList> result = await operations.GetAllByGroupTypeAsyncWithOperationResponseAsync(type, cancellationToken).ConfigureAwait(false); return(result.Body); }
private static void DisplayCommandLine(string exeName, TypeArgumentInfo type, IColors colors) { foreach (var group in type.ArgumentGroups) { string assemblyNameFormat = $" [{colors.AssemblyNameColor}!{{0}}.exe] "; // " [White!{{0}}.exe] " Colorizer.Write(assemblyNameFormat, exeName); if (!string.IsNullOrEmpty(group.Key)) { string groupFormat = $" [{colors.ArgumentGroupColor}!{{0}}] "; // " [Green!{{0}}] " Colorizer.Write(string.Format(groupFormat, group.Key)); } DisplayCommandLine(group.Value, colors); } }