public void TextGrid_Basic() { var grid = new TextGrid(); // Assert.AreEqual("",grid.ToString()); grid[0, 0] = null; Assert.AreEqual("-na-\r\n", grid.ToString()); grid.NAString = "(null)"; Assert.AreEqual("(null)\r\n", grid.ToString()); grid[0, 0] = "Foo"; Assert.AreEqual("Foo\r\n", grid.ToString()); grid[1, 0] = "Bar"; Assert.AreEqual("Foo Bar\r\n", grid.ToString()); grid[0, 1] = "xxx"; grid[1, 1] = "yyy"; Assert.AreEqual("Foo Bar\r\nxxx yyy\r\n", grid.ToString()); grid[0, 1] = "x"; grid[1, 1] = "y"; Assert.AreEqual("Foo Bar\r\nx y \r\n", grid.ToString()); }
public void TextGrid_CellFormats() { var grid = new TextGrid(); grid.SetCellFormat(0, 0, new TextGridFormat(TextGridAlign.Default, 5)); grid[0, 0] = "a"; Assert.AreEqual("a \r\n", grid.ToString()); grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Default, 1)); Assert.AreEqual("a \r\n", grid.ToString()); grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Right, 1)); Assert.AreEqual(" a\r\n", grid.ToString()); grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Right, 5)); grid.SetCellFormat(0, 0, new TextGridFormat(TextGridAlign.Default, 5)); grid[0, 1] = "bb"; Assert.AreEqual(" a\r\n bb\r\n", grid.ToString()); grid.SetCellFormat(0, 0, new TextGridFormat(TextGridAlign.Left, 5)); Assert.AreEqual("a \r\n bb\r\n", grid.ToString()); grid.SetCellFormat(0, 0, new TextGridFormat(TextGridAlign.Right, 5)); Assert.AreEqual(" a\r\n bb\r\n", grid.ToString()); grid.SetCellFormat(0, 1, new TextGridFormat(TextGridAlign.Left, 5)); Assert.AreEqual(" a\r\nbb \r\n", grid.ToString()); }
public void SetTextGrid() { var grid = new TextGrid(new GridSize(24, 80)); _view.SetSize(new GridSize(24, 80)); _view.SetInternalPosition(new GridPosition(0)); _view.SetText(grid); Assert.AreEqual(grid.GetSize(), _view.textGrid.GetSize()); }
public Layer(GridSize size, int z = 0) { _size = size; textGrid = new TextGrid(_size); cursor = new Cursor(); view = new View(_size); zIndex = z; Change(); }
public void TextGrid_CellNames() { var grid = new TextGrid(); grid.NameCell("one", 0, 0); grid.NameCell("two", 0, 1); grid["one"] = "hello"; grid["two"] = "world"; Assert.AreEqual("hello", grid["one"]); Assert.AreEqual("hello", grid["ONE"]); Assert.AreEqual("world", grid["two"]); Assert.AreEqual("world", grid["TWO"]); Assert.AreEqual("hello\r\nworld\r\n", grid.ToString()); }
public void TextGrid_FillChar() { var grid = new TextGrid(); grid.SetCellFormat(0, 0, new TextGridFormat('-')); grid[0, 0] = ""; grid[0, 1] = "abcd"; Assert.AreEqual("----\r\nabcd\r\n", grid.ToString()); grid.Clear(); grid.SetCellFormat(0, 1, new TextGridFormat('-')); grid[0, 0] = "abcd"; grid[0, 1] = "efghijklmno"; Assert.AreEqual("abcd\r\n----\r\n", grid.ToString()); }
static void Main(string[] args) { var elements = new List <Tuple <string, string> >(); elements.Add(new Tuple <string, string>("Small", "Small\r\nxxx")); elements.Add(new Tuple <string, string>("Small", "huge xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")); elements.Add(new Tuple <string, string>("Small", "Small")); elements.Add(new Tuple <string, string>("Small", "huge xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")); elements.Add(new Tuple <string, string>("Small", "Small")); elements.Add(new Tuple <string, string>("Small", "huge xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")); elements.Add(new Tuple <string, string>("Small", "Small")); elements.Add(new Tuple <string, string>("Small", "huge xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")); var grid = new TextGrid <Tuple <string, string> >(); grid.ExpandConsole = false; grid.RenderRowNumber = true; grid.SourceList = new ObservableCollection <Tuple <string, string> >(elements); grid.RenderGrid(); System.Console.ReadKey(); }
public Program() { SpeedProcessors = new List <ISpeedTestProcessor>(); _pingOkRegex = new Regex(@"(?:Ping result (\w*) time=(\d*))+"); _pingFailRegex = new Regex(@"Error"); FromMinutesSlowNetwork = TimeSpan.FromSeconds(10); FasterLookup = true; State = new DataInfo { Name = nameof(State) }; TimeToNext = new DataInfo { Name = nameof(TimeToNext) }; LastNetworkSend = new DataInfo(false) { Name = nameof(LastNetworkSend) }; LastNetworkRecive = new DataInfo(false) { Name = nameof(LastNetworkRecive) }; AverageNetwork = new DataInfo(false) { Name = nameof(AverageNetwork) }; LowNetwork = new DataInfo(false) { Name = nameof(LowNetwork) }; MaxNetwork = new DataInfo(false) { Name = nameof(MaxNetwork) }; MinNetwork = new DataInfo(false) { Name = nameof(MinNetwork) }; MeasurementsCount = new DataInfo { Name = nameof(MeasurementsCount) }; PingAverage = new DataInfo { Name = nameof(PingAverage) }; PingsCount = new DataInfo { Name = nameof(PingsCount) }; PacketLoss = new DataInfo { Name = nameof(PacketLoss) + " 10 Minutes" }; PacketLossCurrently = new DataInfo { Name = nameof(PacketLossCurrently) + " Last 100" }; Imported = new DataInfo { Name = nameof(Imported) }; FileCache = new DataInfo { Name = nameof(FileCache) }; PingDestinations = new[] { new PingInfo("google.de"), new PingInfo("google-public-dns-b.google.com"), new PingInfo("Cloudflare.com") }; Output = new List <string>(); Console.WriteLine("Type H for help"); SteamBufferSize = 6142; FromMinutes = TimeSpan.FromMinutes(1); CurrentWaitTime = FromMinutesSlowNetwork; StatisticsDown = new ConcurrentBag <DataPoint>(); StatisticsUp = new ConcurrentBag <DataPoint>(); Pings = new ConcurrentBag <DataPoint>(); TextGrid = new TextGrid <DataInfo>(ColumnGenerationMode.NoColumns, false); TextGrid.Columns.Add(new BoundConsoleGridColumn(nameof(DataInfo.Name))); TextGrid.Columns.Add(new BoundConsoleGridColumn(nameof(DataInfo.Value))); TextGrid.Columns.Add(new BoundConsoleGridColumn(nameof(DataInfo.Tendecy))); for (var i = 1; i < 4; i++) { var i1 = i; var historyColumnName = "History #" + i; TextGrid.Columns.Add(new ConsoleGridColumn(historyColumnName) { GetValue = f => (f as DataInfo).History.ElementAtOrDefault(i1) }); TextGrid.ConsolePropertyGridStyle.ColumnStyles.Add(historyColumnName, new ConsoleColumnStyle { ConsoleCellStyle = new DelegateConsoleCellStyle { Background = dataPoint => { var dp = dataPoint as DataInfo; if (!DataInfo.ParseValue(dp.Value, out var val)) { return(null); } var previusValue = dp.History.ElementAtOrDefault(i1 - 1); if (previusValue == val) { return(null); } if (previusValue < val) { return(dp.SmallerBetter ? ConsoleColor.Red : ConsoleColor.Green); } if (previusValue > val) { return(dp.SmallerBetter ? ConsoleColor.Green : ConsoleColor.Red); } return((ConsoleColor?)null); } } });
public void TextGrid_ColumnFormats() { var grid = new TextGrid(); grid.NAString = "null"; grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Default, 5)); grid.SetColumnFormat(1, new TextGridFormat(TextGridAlign.Default, 10)); grid[0, 0] = null; grid[1, 0] = null; grid[2, 0] = "foo"; Assert.AreEqual("null null foo\r\n", grid.ToString()); grid = new TextGrid(); grid.NAString = "null"; grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Default, 5)); grid[0, 0] = "a"; grid[0, 1] = "ab"; grid[0, 2] = "abc"; grid[0, 3] = "abcd"; grid[0, 4] = "abcde"; grid[0, 5] = "abcdef"; Assert.AreEqual("a \r\nab \r\nabc \r\nabcd \r\nabcde\r\nab...\r\n", grid.ToString()); grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Default, 0)); Assert.AreEqual("\r\n\r\n\r\n\r\n\r\n\r\n", grid.ToString()); grid.ClearCells(); grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Default, 1)); grid[0, 0] = "a"; Assert.AreEqual("a\r\n", grid.ToString()); grid[0, 0] = "ab"; Assert.AreEqual(".\r\n", grid.ToString()); grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Default, 2)); Assert.AreEqual("ab\r\n", grid.ToString()); grid[0, 0] = "abc"; Assert.AreEqual("..\r\n", grid.ToString()); grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Default, 3)); Assert.AreEqual("abc\r\n", grid.ToString()); grid[0, 0] = "abcd"; Assert.AreEqual("...\r\n", grid.ToString()); grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Default, 4)); Assert.AreEqual("abcd\r\n", grid.ToString()); grid[0, 0] = "abcde"; Assert.AreEqual("a...\r\n", grid.ToString()); grid.Clear(); grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Left, -1)); grid[0, 0] = "ab"; grid[0, 1] = "a"; Assert.AreEqual("ab\r\na \r\n", grid.ToString()); grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Right, -1)); Assert.AreEqual("ab\r\n a\r\n", grid.ToString()); grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Left, 4)); grid[0, 0] = "ab"; grid[0, 1] = "a"; Assert.AreEqual("ab \r\na \r\n", grid.ToString()); grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Center, 4)); Assert.AreEqual(" ab \r\n a \r\n", grid.ToString()); grid.Clear(); grid.NAString = ""; grid.SetColumnFormat(0, new TextGridFormat(TextGridAlign.Center, 4)); grid[1, 0] = "foo"; Assert.AreEqual(" foo\r\n", grid.ToString()); }
public Cursor(TextGrid owner) {
protected override void ItemTransfer(string inputPath, string outputPath) { string intermediaPath = Path.Combine(WorkFolder, Guid.NewGuid() + ".wav"); try { if (ExistingFileDict.ContainsKey(outputPath)) { Console.WriteLine($"File exists: {outputPath}"); return; } string ext = inputPath.Split('.').Last().ToLower(); if (ext.ToLower() == "ds_store" || ext.ToLower() == "pdf") { return; } Sanity.Requires(ValidExtSet.Contains(ext), $"Invalid extension: {ext}"); ConvertToWave(inputPath, intermediaPath, outputPath); Wave w = new Wave(); w.ShallowParse(outputPath); string reportLine = $"{inputPath.Split('\\').Last()}\t{outputPath.Split('\\').Last()}\t{w.AudioLength}"; string key = w.DataChunk.Length.ToString(); lock (LockObj) { if (FileSizeDict.ContainsKey(key)) { foreach (string existingFilePath in FileSizeDict[key]) { if (LocalCommon.AudioIdenticalLocal(existingFilePath, outputPath)) { ErrorList.Add($"{outputPath}\t{existingFilePath}"); if (File.Exists(outputPath)) { File.Delete(outputPath); } return; } } FileSizeDict[key].Add(outputPath); } else { FileSizeDict[key] = new List <string> { outputPath } }; try { string outputTimeStampPath = outputPath.Replace(".wav", ".txt"); if (File.Exists(outputTimeStampPath)) { File.Delete(outputTimeStampPath); } SetTimeStamp(outputPath, outputTimeStampPath); CheckTimeStamp(outputTimeStampPath); Sanity.Requires(File.Exists(outputTimeStampPath)); string outputTextGridPath = outputPath.Replace(".wav", ".textgrid"); if (File.Exists(outputTextGridPath)) { File.Delete(outputTextGridPath); } TextGrid.TimeStampToTextGrid(outputTimeStampPath, outputTextGridPath); } catch { ErrorList.Add($"{outputPath}\tNo time stamp file."); } ReportList.Add(reportLine); NewFileList.Add($"{key}\t{outputPath}"); if (File.Exists(intermediaPath)) { File.Delete(intermediaPath); } } } catch (CommonException e) { string errorMessage = $"{inputPath}\t{e.Message}"; ErrorList.Add(errorMessage); Logger.WriteLineWithLock(errorMessage); if (File.Exists(intermediaPath)) { File.Delete(intermediaPath); } if (File.Exists(outputPath)) { File.Delete(outputPath); } } }
public void Setup() { _grid = new TextGrid(new GridSize(10, 10)); }