private void Menu_1() { string dateTime; bool isEscaped; DateTime epochStart; epochStart = default; Console.CursorVisible = true; while (true) { Console.Clear(); Console.WriteLine("Please enter the year and month (yyyy-mm) of the source files:"); (dateTime, isEscaped) = VdsToolUtilities.ReadLine(new List <string>()); if (isEscaped) { Console.CursorVisible = false; return; } else if (string.IsNullOrWhiteSpace(dateTime) || DateTime.TryParseExact(dateTime, "yyyy-MM", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out epochStart)) { break; } } Console.CursorVisible = false; Program.CreateVirtualDatasetFile(Program.BaseDirectoryPath, epochStart); }
protected override bool OnWaitForUserInput() { _totalCount = _vdsTransferFunctionSet.Count() + _vdsMetaTransferFunctionSet.Count(); if (this.SelectedIndex < 0) { this.SelectedIndex = _totalCount > 0 ? 0 : -1; } else if (this.SelectedIndex >= _totalCount) { this.SelectedIndex = _totalCount - 1; } if (this.SelectedIndex >= _vdsTransferFunctionSet.Count()) { _offset = 3; } else { _offset = 0; } if (this.LastIndex >= 0) { Console.SetCursorPosition(1, this.LastIndex); Console.Write(" "); } if (this.SelectedIndex >= 0) { Console.SetCursorPosition(1, this.SelectedIndex + _offset + 4); Console.Write("x"); } _consoleKeyInfo = Console.ReadKey(true); switch (_consoleKeyInfo.Key) { case ConsoleKey.UpArrow: if (this.SelectedIndex > 0) { this.LastIndex = Console.CursorTop; this.SelectedIndex -= 1; } break; case ConsoleKey.DownArrow: if (this.SelectedIndex < _totalCount - 1) { this.LastIndex = Console.CursorTop; this.SelectedIndex += 1; } break; case ConsoleKey.Enter: case ConsoleKey.RightArrow: if (this.SelectedIndex >= _vdsTransferFunctionSet.Count()) { int index = this.SelectedIndex - _vdsTransferFunctionSet.Count(); _vdsMetaTransferFunctionSet[index] = Program.PromptTransferFunctionData(_vdsMetaTransferFunctionSet[index]); _updateAttribute = true; } break; case ConsoleKey.N: if ((_consoleKeyInfo.Modifiers & ConsoleModifiers.Control) != 0) { _vdsMetaTransferFunctionSet.Add(Program.PromptTransferFunctionData(new hdf_transfer_function_t(DateTime.MinValue.ToString("yyyy-MM-dd"), "polynomial", "permanent", string.Empty))); } else { _vdsMetaTransferFunctionSet.Add(Program.PromptTransferFunctionData(new hdf_transfer_function_t())); } this.SelectedIndex = _totalCount; _updateAttribute = true; break; case ConsoleKey.C: if (this.SelectedIndex >= 0) { if (this.SelectedIndex >= 0 && this.SelectedIndex < _vdsTransferFunctionSet.Count()) { _vdsMetaTransferFunctionSet.Add(_vdsTransferFunctionSet[this.SelectedIndex]); } else { _vdsMetaTransferFunctionSet.Add(_vdsMetaTransferFunctionSet[this.SelectedIndex - _vdsTransferFunctionSet.Count()]); } _updateAttribute = true; this.SelectedIndex = _totalCount; this.OnRedraw(); } break; case ConsoleKey.U: Console.CursorVisible = true; Console.Clear(); Console.Write($"Enter value for unit ({ _unit }): "); (_unit, _isEscaped) = VdsToolUtilities.ReadLine(_vdsUnitSet); if (!_isEscaped) { _updateUnit = true; } Console.CursorVisible = false; break; case ConsoleKey.Delete: if (this.SelectedIndex >= _vdsTransferFunctionSet.Count()) { Console.Clear(); Console.Write("The selected item will be deleted. Proceed (Y/N)? "); if (Console.ReadKey().Key == ConsoleKey.Y) { _vdsMetaTransferFunctionSet.RemoveAt(this.SelectedIndex - _vdsTransferFunctionSet.Count()); _updateAttribute = true; } else { this.OnRedraw(); } } break; case ConsoleKey.PageUp: if (this.SelectedIndex >= _vdsTransferFunctionSet.Count() + 1 && this.SelectedIndex < _totalCount) { int index = this.SelectedIndex - _vdsTransferFunctionSet.Count(); hdf_transfer_function_t hdf_transfer_function = _vdsMetaTransferFunctionSet[index]; _vdsMetaTransferFunctionSet.RemoveAt(index); _vdsMetaTransferFunctionSet.Insert(index - 1, hdf_transfer_function); this.SelectedIndex -= 1; _updateAttribute = true; } break; case ConsoleKey.PageDown: if (this.SelectedIndex >= _vdsTransferFunctionSet.Count() && this.SelectedIndex < _totalCount - 1) { int index = this.SelectedIndex - _vdsTransferFunctionSet.Count(); hdf_transfer_function_t hdf_transfer_function = _vdsMetaTransferFunctionSet[index]; _vdsMetaTransferFunctionSet.RemoveAt(index); _vdsMetaTransferFunctionSet.Insert(index + 1, hdf_transfer_function); this.SelectedIndex += 1; _updateAttribute = true; } break; case ConsoleKey.Escape: case ConsoleKey.LeftArrow: return(true); } // update unit if (_updateUnit) { _groupId = IOHelper.OpenOrCreateGroup(_vdsMetaFileId, _currentPath).GroupId; IOHelper.PrepareAttribute(_groupId, "unit", new string[] { _unit }, new ulong[] { 1 }, true); _updateUnit = false; this.OnRedraw(); } // update attribute if (_updateAttribute) { _groupId = IOHelper.OpenOrCreateGroup(_vdsMetaFileId, _currentPath).GroupId; IOHelper.PrepareAttribute(_groupId, "transfer_function_set", _vdsMetaTransferFunctionSet.ToArray(), new ulong[] { (ulong)_vdsMetaTransferFunctionSet.Count() }, true); _updateAttribute = false; this.OnRedraw(); } // clean up if (H5I.is_valid(_groupId) > 0) { H5F.flush(_groupId, H5F.scope_t.GLOBAL); H5G.close(_groupId); } return(false); }