public static GridRender AddStyle <T>(this GridRender gridRender) where T : IBorderStyle, new() { gridRender.Styles.Add(new T()); return(gridRender); }
public void Case_01() { var grid = new GridDefinition { RowDefinitions = new List <RowDefinition> { new RowDefinition { HeightType = HeightType.Fixed, Height = 1 } }, ColumnDefinitions = new List <ColumnDefinition> { new ColumnDefinition { WidthType = WidthType.Star, Width = 1 } }, CellDefinitions = new List <CellDefinition> { new CellDefinition { Value = "Lorem Ipsum!", Border = BorderDefinition.Empty } } }; var gridRender = new GridRender(grid); var actual = gridRender.Render(20); Assert.AreEqual("Lorem Ipsum! ", actual); }
static void Main(string[] args) { int primeCount = 0; // A little sanity testing. try { primeCount = Int32.Parse(args[0]); } catch (FormatException) { Console.WriteLine($"{args[0]}: Bad Format"); return; } catch (OverflowException) { Console.WriteLine($"{args[0]}: Overflow"); return; } if (primeCount < 1) { Console.WriteLine("Please enter an integer greater than 0"); return; } // The required objects var primeFinder = new PrimesFinder(); IPrimeOutput outputGenerator; int[] primes = primeFinder.FindPrimes(primeCount); // It's a shame you can't just print the array directly like Swift and Python string primesDisplay = String.Join(", ", primes); Console.WriteLine($"The first {primeCount} primes are {primesDisplay}"); // What to do with the primes though? // Coding against an interface really is lovely. if (args.Length > 1) { if (args[1] == "-csv") { outputGenerator = new CsvSaver(); } else { Console.WriteLine($"The argument {args[1]} cannot be parsed, did you mean -csv ?"); return; } } else { outputGenerator = new GridRender(); } outputGenerator.Output(primes); }
public ConnectGame(ulong id, ulong[] players) : base(id, players) { GameGrid = new GridRender(id, "connect", 7, 6, FREE_STATE, 128); Turn = 0; Gamemode = GameType.CONNECT; Filled = false; Random rnd = new Random(); Turn = rnd.Next(0, 1); }
public void Case_02() { var grid = new GridDefinition { RowDefinitions = new List <RowDefinition> { new RowDefinition { HeightType = HeightType.Fixed, Height = 1 }, new RowDefinition { HeightType = HeightType.Fixed, Height = 1 } }, ColumnDefinitions = new List <ColumnDefinition> { new ColumnDefinition { WidthType = WidthType.Star, Width = 1 } }, CellDefinitions = new List <CellDefinition> { new CellDefinition { Row = 0, Value = "Lorem Ipsum!", HorizontalAlign = HorizontalAlign.Right, Border = BorderDefinition.Empty }, new CellDefinition { Row = 1, Value = "Dolor!", HorizontalAlign = HorizontalAlign.Center, Border = BorderDefinition.Empty } } }; var gridRender = new GridRender(grid); var actual = gridRender.Render(20); var expected = " Lorem Ipsum!" + Environment.NewLine + " Dolor! "; Assert.AreEqual(expected, actual); }
public void Case_01() { var grid = new GridDefinition { RowDefinitions = new List <RowDefinition> { new RowDefinition { HeightType = HeightType.Auto }, new RowDefinition { HeightType = HeightType.Auto }, new RowDefinition { HeightType = HeightType.Auto }, new RowDefinition { HeightType = HeightType.Auto }, new RowDefinition { HeightType = HeightType.Auto } }, ColumnDefinitions = new List <ColumnDefinition> { new ColumnDefinition { WidthType = WidthType.Star, Width = 1 }, new ColumnDefinition { WidthType = WidthType.Auto }, new ColumnDefinition { WidthType = WidthType.Auto }, new ColumnDefinition { WidthType = WidthType.Auto } } }; grid .AddCell("Produto", horizontalAlign: HorizontalAlign.Center) .AddCell("Valor", horizontalAlign: HorizontalAlign.Center) .AddCell("Qtd.", horizontalAlign: HorizontalAlign.Center) .AddCell("Total", horizontalAlign: HorizontalAlign.Center); grid .AddCell("Refeição") .AddCell("R$ 44,90") .AddCell("0,000 kg") .AddCell("R$ 8,89"); grid .AddCell("Refrigerantes") .AddCell(string.Empty) .AddCell(string.Empty) .AddCell(string.Empty); grid .AddCell("Sucos") .AddCell(string.Empty) .AddCell(string.Empty) .AddCell(string.Empty); grid .AddCell(string.Empty) .AddCell(string.Empty) .AddCell(string.Empty) .AddCell(string.Empty); var gridRender = new GridRender(grid); gridRender.AddStyle <WhiteSpaceVerticalBorderStyle>(); var actual = gridRender.Render(57); var expected = " Produto Valor Qtd. Total " + Environment.NewLine + " Refeição R$ 44,90 0,000 kg R$ 8,89 " + Environment.NewLine + " Refrigerantes " + Environment.NewLine + " Sucos " + Environment.NewLine + " "; Assert.AreEqual(expected, actual); }
public void Case_06() { var grid = new GridDefinition { RowDefinitions = new List <RowDefinition> { new RowDefinition { HeightType = HeightType.Auto }, new RowDefinition { HeightType = HeightType.Auto }, new RowDefinition { HeightType = HeightType.Auto }, new RowDefinition { HeightType = HeightType.Auto }, new RowDefinition { HeightType = HeightType.Auto } }, ColumnDefinitions = new List <ColumnDefinition> { new ColumnDefinition { WidthType = WidthType.Star, Width = 1 }, new ColumnDefinition { WidthType = WidthType.Auto }, new ColumnDefinition { WidthType = WidthType.Auto }, new ColumnDefinition { WidthType = WidthType.Fixed, Width = 8 } } }; grid .AddCell("Produto", horizontalAlign: HorizontalAlign.Center) .AddCell("Valor", horizontalAlign: HorizontalAlign.Center) .AddCell("Qtd.", horizontalAlign: HorizontalAlign.Center) .AddCell("Total", horizontalAlign: HorizontalAlign.Center); grid .AddCell("Refeição", horizontalAlign: HorizontalAlign.Right, verticalAlign: VerticalAlign.Middle) .AddCell("R$ 44,90") .AddCell("0,000 kg") .AddCell("R$ 167.008,89"); grid .AddCell("Refrigerantes") .AddCell(string.Empty) .AddCell(string.Empty) .AddCell(string.Empty); grid .AddCell("Sucos") .AddCell(string.Empty) .AddCell(string.Empty) .AddCell(string.Empty); grid .AddCell(string.Empty) .AddCell(string.Empty) .AddCell(string.Empty) .AddCell(string.Empty); var gridRender = new GridRender(grid); var actual = gridRender.Render(57); var expected = "+----------------------------+--------+--------+--------+" + Environment.NewLine + "| Produto | Valor | Qtd. | Total |" + Environment.NewLine + "+----------------------------+--------+--------+--------+" + Environment.NewLine + "| |R$ 44,90|0,000 kg|R$ |" + Environment.NewLine + "| Refeição| | |167.008,|" + Environment.NewLine + "| | | |89 |" + Environment.NewLine + "+----------------------------+--------+--------+--------+" + Environment.NewLine + "|Refrigerantes | | | |" + Environment.NewLine + "+----------------------------+--------+--------+--------+" + Environment.NewLine + "|Sucos | | | |" + Environment.NewLine + "+----------------------------+--------+--------+--------+" + Environment.NewLine + "| | | | |" + Environment.NewLine + "+----------------------------+--------+--------+--------+"; Assert.AreEqual(expected, actual); }
public void Case_04() { var grid = new GridDefinition { RowDefinitions = new List <RowDefinition> { new RowDefinition { HeightType = HeightType.Fixed, Height = 1 }, new RowDefinition { HeightType = HeightType.Fixed, Height = 1 } }, ColumnDefinitions = new List <ColumnDefinition> { new ColumnDefinition { WidthType = WidthType.Star, Width = 1 }, new ColumnDefinition { WidthType = WidthType.Star, Width = 1 } }, CellDefinitions = new List <CellDefinition> { new CellDefinition { Row = 0, Column = 0, Value = "Lorem Ipsum!", HorizontalAlign = HorizontalAlign.Right }, new CellDefinition { Row = 1, Column = 0, Value = "Dolor!", HorizontalAlign = HorizontalAlign.Center }, new CellDefinition { Row = 0, Column = 1, Value = "Lorem Ipsum!", HorizontalAlign = HorizontalAlign.Right }, new CellDefinition { Row = 1, Column = 1, Value = "Dolor!", HorizontalAlign = HorizontalAlign.Center } } }; var gridRender = new GridRender(grid); gridRender.AddStyle(new InsideBordersStyle()); var actual = gridRender.Render(40); var expected = " Lorem Ipsum!| Lorem Ipsum!" + Environment.NewLine + "--------------------+-------------------" + Environment.NewLine + " Dolor! | Dolor! "; Assert.AreEqual(expected, actual); }
public MainPage() { InitializeComponent(); Client = new ServiceClient(); Client.GetKeyWordsCompleted += client_GetKeyWordsCompleted; Client.GetAllSitesCompleted += Client_GetAllSitesCompleted; Client.GetSitesCompleted += client_GetSitesCompleted; Client.GetDoubleTimeSeriesCompleted += client_GetDoubleTimeSeriesCompleted; Client.GetGridCompleted += Client_GetGridCompleted; Client.GetTimeRangeCompleted += Client_GetTimeRangeCompleted; Client.GetPointProfileCompleted += Client_GetPointProfileCompleted; Client.DownloadImageCompleted += Client_DownloadImageCompleted; Client.DownloadLegendCompleted += Client_DownloadLegendCompleted; Client.GetSensorImageRecordCompleted += Client_GetSensorImageRecordCompleted; _GraphicsLayers = new Dictionary <string, GraphicsLayer>(); _MarkerSymbols = new Dictionary <string, MarkerSymbol>(); _MarkerSymbols.Add("Buoy", BuoyMarkerSymbol); _MarkerSymbols.Add("Tide", TideMarkerSymbol); _MarkerSymbols.Add("Water Quality", WQMarkerSymbol); _MarkerSymbols.Add("Hydrology", HydrologyMarkerSymbol); _GraphicsLayers.Add("Buoy", Map.Layers["Buoys"] as GraphicsLayer); _GraphicsLayers.Add("Tide", Map.Layers["Tide Stations"] as GraphicsLayer); _GraphicsLayers.Add("Water Quality", Map.Layers["Water Quality Stations"] as GraphicsLayer); _GraphicsLayers.Add("Hydrology", Map.Layers["Hydrological Stations"] as GraphicsLayer); _GraphicsLayers.Add("Weather", Map.Layers["Weather Stations"] as GraphicsLayer); _GraphicsLayers.Add("General", Map.Layers["General Stations"] as GraphicsLayer); _GeneralStationLayer = Map.Layers["General Stations"] as GraphicsLayer; _GridLayer = Map.Layers["Model Grid"] as GraphicsLayer; foreach (GraphicsLayer layer in _GraphicsLayers.Values) { layer.MouseLeftButtonDown += GraphicsLayer_MouseLeftButtonDown; layer.Clusterer = null; } ClustererOfStation = new FlareClusterer() { FlareBackground = new SolidColorBrush(Colors.Yellow), FlareForeground = new SolidColorBrush(Colors.Black), MaximumFlareCount = 100, Radius = 40, }; _ImageSeries = new ImageSeries(); _QueryCriteria = new QueryCriteria(); _Timer = new Storyboard(); _Timer.Duration = TimeSpan.FromMilliseconds(10000); _Timer.Completed += _timer_Completed; StatusBar.Visibility = System.Windows.Visibility.Collapsed; _Box = new BBox(); _IsDownloadingTimeSeries = false; _GridRender = new GridRender(); GridRender.Instance = _GridRender; animationPlayer.ServiceClient = Client; coastalWatch.ServiceClient = Client; coastalWatch.Map = this.Map; }
public void Case_01() { var grid = new GridDefinition { RowDefinitions = new List <RowDefinition> { new RowDefinition { HeightType = HeightType.Auto }, new RowDefinition { HeightType = HeightType.Auto }, new RowDefinition { HeightType = HeightType.Auto }, new RowDefinition { HeightType = HeightType.Auto }, new RowDefinition { HeightType = HeightType.Auto } }, ColumnDefinitions = new List <ColumnDefinition> { new ColumnDefinition { WidthType = WidthType.Star, Width = 1 }, new ColumnDefinition { WidthType = WidthType.Auto }, new ColumnDefinition { WidthType = WidthType.Auto }, new ColumnDefinition { WidthType = WidthType.Auto } } }; grid .AddCell("Produto", horizontalAlign: HorizontalAlign.Center) .AddCell("Valor", horizontalAlign: HorizontalAlign.Center) .AddCell("Qtd.", horizontalAlign: HorizontalAlign.Center) .AddCell("Total", horizontalAlign: HorizontalAlign.Center); grid .AddCell("Refeição") .AddCell("R$ 44,90") .AddCell("0,000 kg") .AddCell("R$ 8,89"); grid .AddCell("Refrigerantes") .AddCell(string.Empty) .AddCell(string.Empty) .AddCell(string.Empty); grid .AddCell("Sucos") .AddCell(string.Empty) .AddCell(string.Empty) .AddCell(string.Empty); grid .AddCell(string.Empty) .AddCell(string.Empty) .AddCell(string.Empty) .AddCell(string.Empty); var gridRender = new GridRender(grid); gridRender.AddStyle <InsideBordersStyle>(); gridRender.AddStyle <HeaderBorderStyle>(); var actual = gridRender.Render(57); var expected = "+-----------------------------+--------+--------+-------+" + Environment.NewLine + "| Produto | Valor | Qtd. | Total |" + Environment.NewLine + "+-----------------------------+--------+--------+-------+" + Environment.NewLine + "Refeição |R$ 44,90|0,000 kg|R$ 8,89 " + Environment.NewLine + "------------------------------+--------+--------+--------" + Environment.NewLine + "Refrigerantes | | | " + Environment.NewLine + "------------------------------+--------+--------+--------" + Environment.NewLine + "Sucos | | | " + Environment.NewLine + "------------------------------+--------+--------+--------" + Environment.NewLine + " | | | "; Assert.AreEqual(expected, actual); }
public static GridRender AddStyle(this GridRender gridRender, IBorderStyle borderStyle) { gridRender.Styles.Add(borderStyle); return(gridRender); }
public PrimesApp_GridRender() { _renderer = new GridRender(); _primeFinder = new PrimesFinder(); }
public TicTacToeGame(ulong id, ulong[] players) : base(id, players) { GameGrid = new GridRender(id, "ttt", 3, 3, "free", 128); Turn = 0; Gamemode = GameType.TICTACTOE; }