static void Main(string[] args) { var historyFile = "history.txt"; var sc = new SimpleConsole(); sc.Histories.RestoreFromFile(historyFile); Console.CancelKeyPress += (sen, arg) => { Console.WriteLine("exit..."); sc.Histories.SaveToFile(historyFile); }; sc.Prompts = "shell> "; sc.PromptsColor = ConsoleColor.Red; sc.CursorCountFromCharactersHandle = c => c > 128 ? (byte)2 : (byte)1; sc.AutoCompleteHandle = async str => { return(await Task.FromResult(new[] { "测试自动补全", "Test auto-replenishment", })); }; sc.OnConsoleKeyInfo += (sen, key) => { if (key.Key == ConsoleKey.Enter) { Console.Write($"\ntype result :{sc.Buffer}"); } }; sc.Start(); }
private bool Authenticate() { bool result = false; try { double fixedMsec = 500; DateTime begin = DateTime.Now; result = (ProtoController.Authenticate() == 1); //SimpleConsole.Write(string.Format(" try time {0},result {1}", 5 - tryTimes, result)); DateTime end = DateTime.Now; double totalMsecs = (end - begin).TotalMilliseconds; fixedMsec = fixedMsec - totalMsecs; Thread.Sleep((int)fixedMsec); SimpleConsole.WriteLine("RID Use Time:" + totalMsecs); } catch (Exception exception) { SimpleConsole.Write(exception); } return(result); }
private void btnOpen_Click(object sender, EventArgs e) { try { int result = controller.Scan(new IDReadCompletedHandler((RicTextInfo member) => { this.Invoke(new Action(() => { if (member != null) { this.RicContent.AppendText(member.ToString()); this.Photo.Image = member.Photo.ToBitmap(); } this.btnOpen.Enabled = true; })); }), (int)this.Channel.Value, (int)this.LiveTimeOut.Value); if (result == 1) { this.btnOpen.Enabled = false; } } catch (Exception exception) { SimpleConsole.WriteLine(exception); } }
private void Snapshot() { try { var start = DateTime.Now; byte[] snapshotImageBuffer = null; bool snapshot = simpleCamera.Snapshot(out snapshotImageBuffer); if (snapshot) { this.SnapshotImage.Image = new Bitmap(new MemoryStream(snapshotImageBuffer)); } SimpleConsole.WriteLine("Snapshot."); //byte[] encryptBuffer = AES.AESEncrypt(snapshotImageBuffer, "yuanfeng"); snapshotImageBuffer.Writer(FileNameGenerator.Generator()); var end = DateTime.Now; SimpleConsole.WriteLine("Use Time:" + (end - start).TotalSeconds); } catch (Exception exception) { SimpleConsole.WriteLine(exception.Message); } }
public byte[] Generator(string codeString, int size) { this.qrCodeSize = size; this.qrCodeString = codeString; QrEncoder qrEncoder = new QrEncoder(ErrorCorrectionLevel.H); Gma.QrCodeNet.Encoding.QrCode qrCode = new Gma.QrCodeNet.Encoding.QrCode(); qrEncoder.TryEncode(QrCodeString, out qrCode); var renderer = new GraphicsRenderer(new FixedCodeSize(QrCodeSize, QuietZoneModules.Zero), Brushes.Black, Brushes.White); MemoryStream stream = new MemoryStream(); renderer.WriteToStream(qrCode.Matrix, ImageFormat.Png, stream); byte[] qrCodeBuffer = null; try { qrCodeBuffer = stream.ToBuffer(); } catch (Exception exception) { SimpleConsole.WriteLine("Generator qr code fail. exception message:" + exception.Message); } return(qrCodeBuffer); }
private void btnClose_Click(object sender, EventArgs e) { int isClose = LFC.Close(); if (isClose == 0) { SimpleConsole.WriteLine("lf is not open."); } }
public async void DoClear() { working = true; SetColors(Color.black); SimpleConsole.AddLine(8, $"Clear cube, binder is {(binder == null ? "null" : binder.Name)}"); if (binder != null) { if (bindingOracle != null) { SimpleConsole.AddLine(8, $"Getting from {bindingOracle.Name}"); bindingOracle.Get(binder); } await binder.Clear(); if (bindingOracle != null) { SimpleConsole.AddLine(8, $"Putting empty binder to {bindingOracle.Name}"); bindingOracle.Put(binder); } } SimpleConsole.AddLine(8, $"Finished."); await ChangeColorForSeconds(finishSeconds, Color.green); working = true; }
void OnValidate() { if (test) { SimpleConsole.Log("rra" + Random.value); } }
protected override void OnUpdate() { var entities = m_NetworkConnection.ToEntityArray(Allocator.TempJob); var networkIds = m_NetworkConnection.ToComponentDataArray <NetworkIdComponent>(Allocator.TempJob); for (int i = 0; i < entities.Length; ++i) { var ent = entities[i]; var networkId = networkIds[i]; SimpleConsole.WriteLine(string.Format("New client(NetworkId={0}) connected.", networkId.Value)); // Load level RPC var rpcLoadLevelQueue = ClientServerSystemManager.serverWorld.GetOrCreateSystem <DotsNetKit193RpcSystem>().GetRpcQueue <RpcLoadLevel>(); var rpcBuf = EntityManager.GetBuffer <OutgoingRpcDataStreamBufferComponent>(ent); rpcLoadLevelQueue.Schedule(rpcBuf, new RpcLoadLevel { levelName = SceneManager.GetActiveScene().name }); PostUpdateCommands.AddComponent(ent, new LevelLoadingTag()); } entities.Dispose(); networkIds.Dispose(); }
private void TesoLFCDoc_FormClosing(object sender, FormClosingEventArgs e) { int isClose = LFC.Close(); if (isClose == 0) { SimpleConsole.WriteLine("lf is not open."); } }
/// <summary> /// Cache the coordinate system for the QR code's spatial node, and the root. /// </summary> /// <returns></returns> private bool CheckCoordinateSystem() { #if WLT_LEGACY_WSA if (coordinateSystem == null) { SimpleConsole.AddLine(trace, $"Creating coord for {spatialNodeId}"); coordinateSystem = global::Windows.Perception.Spatial.Preview.SpatialGraphInteropPreview.CreateCoordinateSystemForNode(SpatialNodeId); SimpleConsole.AddLine(trace, $"{spatialNodeId} create coord {(coordinateSystem == null ? "FAILED" : "success")}"); } if (rootCoordinateSystem == null) { rootCoordinateSystem = System.Runtime.InteropServices.Marshal.GetObjectForIUnknown( UnityEngine.XR.WSA.WorldManager.GetNativeISpatialCoordinateSystemPtr() ) as SpatialCoordinateSystem; SimpleConsole.AddLine(trace, $"Getting Legacy root coordinate system {(rootCoordinateSystem == null ? "null" : "succeeded")}"); } return(coordinateSystem != null); #elif WLT_SPATIAL_GRAPH_NODE if (spatialGraphNode == null) { spatialGraphNode = SpatialGraphNode.FromStaticNodeId(SpatialNodeId); } return(spatialGraphNode != null); #else // WINDOWS_UWP return(false); #endif // WINDOWS_UWP }
int sideChannelToken = 0; // <- Right now, the "side channel" for testing is "open in the debugger and sync this value by hand..." public SimpleNetworkMenu(string commandLineHost, SimpleConsole console, Func <BadNetworkSimulation, P2PNetwork> createNetwork, Func <RollbackDriver> createRollbackDriverAndGame) { this.commandLineHost = commandLineHost; this.console = console; this.createNetwork = createNetwork; this._createRollbackDriverAndGame = createRollbackDriverAndGame; }
public void WriteAllReadAll() { int w = 40; int h = 15; var console = new SimpleConsole(w, h); var tiles = new NativeArray <Tile>(w * h, Allocator.Temp); var exclamation = ToCP437('!'); for (int i = 0; i < tiles.Length; ++i) { var t = tiles[i]; t.glyph = exclamation; tiles[i] = t; } console.WriteAllTiles(tiles); var copy = console.ReadAllTiles(Allocator.Temp); for (int i = 0; i < copy.Length; ++i) { Assert.AreEqual(exclamation, copy[i].glyph); } console.Dispose(); }
public async void DoPurge() { working = true; SetColors(Color.black); SimpleConsole.AddLine(8, $"Purge cube, binder is {(binder == null ? "null" : binder.Name)}"); if (binder != null) { SimpleConsole.AddLine(8, $"Starting clear from {binder.Name}"); await binder.Clear(); SimpleConsole.AddLine(8, $"Starting purge from {binder.Name}"); await binder.Purge(); if (bindingOracle != null) { bindingOracle.Put(binder); } } SimpleConsole.AddLine(8, $"Finished."); await ChangeColorForSeconds(finishSeconds, Color.green); working = false; }
/// <summary> /// Convert the retrieved matrix to Unity lefthanded pose convention. /// </summary> /// <param name="newMatrix">Matrix to convert.</param> /// <returns>Unity pose equivalent.</returns> /// <remarks> /// Note that any scale is discarded, returned pose is position+rotation only. /// </remarks> private Pose AdjustNewMatrix(System.Numerics.Matrix4x4 newMatrix) { // Convert from right to left coordinate system newMatrix.M13 = -newMatrix.M13; newMatrix.M23 = -newMatrix.M23; newMatrix.M43 = -newMatrix.M43; newMatrix.M31 = -newMatrix.M31; newMatrix.M32 = -newMatrix.M32; newMatrix.M34 = -newMatrix.M34; /// Decompose into position + rotation (scale is discarded). System.Numerics.Vector3 sysScale; System.Numerics.Quaternion sysRotation; System.Numerics.Vector3 sysPosition; System.Numerics.Matrix4x4.Decompose(newMatrix, out sysScale, out sysRotation, out sysPosition); Vector3 position = new Vector3(sysPosition.X, sysPosition.Y, sysPosition.Z); Quaternion rotation = new Quaternion(sysRotation.X, sysRotation.Y, sysRotation.Z, sysRotation.W); Pose pose = new Pose(position, rotation); SimpleConsole.AddLine(trace, $"Adjusted {pose}"); return(pose); }
private void LoadTypeFromFile() { List <string> files = GetAssemblyFiles(); lock (lockObjs) { foreach (string file in files) { if (!assemblyFiles.ContainsKey(file)) { try { Console.WriteLine("Plugin Loading (" + file + ")"); byte[] buffer = file.Reader(); Assembly assembly = Assembly.Load(buffer); assemblys.Add(assembly); assemblyFiles.Add(file, true); } catch (Exception exception) { SimpleConsole.Write(exception); } } } } }
/// <summary> /// Record whether the QRCodeWatcher reports itself as supported, and request access. /// </summary> private async void Start() { _isSupported = QRCodeWatcher.IsSupported(); _capabilityTask = QRCodeWatcher.RequestAccessAsync(); _accessStatus = await _capabilityTask; _capabilityInitialized = true; SimpleConsole.AddLine(log, $"Requested caps, access: {_accessStatus.ToString()}"); }
/// <summary> /// Become active. /// </summary> private void OnEnable() { CheckComponents(); SetUpCallbacks(); SetUpSpacePins(); SimpleConsole.AddLine(trace, "QRSpacePin Enabled"); }
/// <summary> /// Release all resources. Package is unusable after Release. /// </summary> public void Release() { SimpleConsole.AddLine(log, $"Release SpacePin {spacePin.name}"); Destroy(spacePin); spacePin = null; Destroy(highlightProxy); highlightProxy = null; }
/// <summary> /// Reset package to initial state. If space pin has been committed, it will be rescinded. /// </summary> public void Reset() { SimpleConsole.AddLine(log, $"Reset SpacePin {spacePin.name}"); spacePin.Reset(); Destroy(highlightProxy); highlightProxy = null; isSet = false; }
/// <summary> /// Capture the Enumeration Ended event for later call on main thread. /// </summary> /// <param name="sender">Ignored.</param> /// <param name="e">Ignored.</param> private void OnQREnumerationEnded(object sender, object e) { SimpleConsole.AddLine(log, "Enumerated"); lock (pendingActions) { pendingActions.Enqueue(new PendingQRCode(PendingQRCode.QRAction.Enumerated, null)); } }
protected override void OnStartRunning() { var mapData = _mapQuery.GetSingleton <MapData>(); _console = new SimpleConsole(mapData.width, mapData.height); RenderUtility.AdjustCameraToConsole(_console); }
/// <summary> /// Capture a Removed event for later call on main thread. /// </summary> /// <param name="sender">Ignored.</param> /// <param name="args">Args containing relevant QRCode.</param> private void OnQRCodeRemovedEvent(object sender, QRCodeRemovedEventArgs args) { SimpleConsole.AddLine(trace, $"Removing {args.Code.Data}"); lock (pendingActions) { pendingActions.Enqueue(new PendingQRCode(PendingQRCode.QRAction.Remove, args.Code)); } }
/// <summary> /// Record whether the QRCodeWatcher reports itself as supported, and request access. /// </summary> private async void Start() { isSupported = QRCodeWatcher.IsSupported(); var capabilityTask = QRCodeWatcher.RequestAccessAsync(); accessStatus = await capabilityTask; SimpleConsole.AddLine(log, $"Requested caps, access: {accessStatus.ToString()}"); }
private void SimpleFprCaptureToolStripMenuItem_Click(object sender, EventArgs e) { InitSimpleFprCaptureDoc(); this.SimpleFprCaptureToolStripMenuItem.Checked = false; this.simpleFprCaptureDoc.Show(MainDockPanel, DockState.Document); this.simpleFprCaptureDoc.FormClosing += DummyClosing; SimpleConsole.WriteLine("The SimpleFprCapture dummy loaded."); }
private void pluginsConfigToolStripMenuItem_Click(object sender, EventArgs e) { InitPluginsConfigDoc(); this.pluginsConfigToolStripMenuItem.Checked = true; PluginsConfigDoc.Show(MainDockPanel, DockState.Document); PluginsConfigDoc.FormClosing += DummyClosing; SimpleConsole.WriteLine("The PluginsConfigDoc dummy loaded."); }
/// <summary> /// Unregister from callbacks. /// </summary> private void TearDownCallbacks() { miniManager.OnQRAdded -= OnQRCodeAdded; miniManager.OnQRUpdated -= OnQRCodeUpdated; miniManager.OnQRRemoved -= OnQRCodeRemoved; miniManager.OnQREnumerated -= OnQRCodeEnumerated; miniManager = null; SimpleConsole.AddLine(trace, "Callbacks torn down"); }
private void simpleUdpServerToolStripMenuItem_Click(object sender, EventArgs e) { InitSsimpleUdpServerDoc(); this.simpleUdpServerToolStripMenuItem.Checked = true; simpleUdpServerDoc.Show(MainDockPanel, DockState.Document); simpleUdpServerDoc.FormClosing += DummyClosing; SimpleConsole.WriteLine("The simpleUdpServerDoc dummy loaded."); }
private void dynamicInvokeToolStripMenuItem_Click(object sender, EventArgs e) { InitDynamicHttpRequestDoc(); this.dynamicInvokeToolStripMenuItem.Checked = true; dynamicHttpRequestDoc.Show(MainDockPanel, DockState.Document); dynamicHttpRequestDoc.FormClosing += DummyClosing; SimpleConsole.WriteLine("The dynamicHttpRequestDoc dummy loaded."); }
private void tesoLFCDocToolStripMenuItem_Click(object sender, EventArgs e) { InitTesoLFCDoc(); this.tesoLFCDocToolStripMenuItem.Checked = true; tesoLFCDoc.Show(MainDockPanel, DockState.Document); tesoLFCDoc.FormClosing += DummyClosing; SimpleConsole.WriteLine("The tesoLFCDoc dummy loaded."); }