private void HandleEvent(KStudioEvent eventObj, EventTypePluginData data, EventType eventType) { if ((eventObj != null) && (data != null)) { if ((eventObj.EventStreamDataTypeId == KStudioEventStreamDataTypeIds.BodyIndex) || (eventObj.EventStreamDataTypeId == HackKStudioEventStreamDataTypeIds.BodyIndexMonitor)) { bool doDataEvent = false; bool doVisibleEvent = false; lock (this.lockObj) { bool isSelectedData = (this.selectedData == data); HGlobalBuffer newSharedFrame = eventObj.GetRetainableEventDataBuffer(); doVisibleEvent = isSelectedData && (newSharedFrame == null) != (data.sharedBodyIndexFrame == null); data.sharedBodyIndexFrame = newSharedFrame; uint newWidth = nui.Constants.STREAM_BODY_INDEX_WIDTH; uint newHeight = nui.Constants.STREAM_BODY_INDEX_HEIGHT; if ((data.rawBodyIndexTexture == null) || (newWidth != data.imageWidth) || (newHeight != data.imageHeight)) { data.imageWidth = newWidth; data.imageHeight = newHeight; viz.Context context = null; if (this.pluginService != null) { context = this.pluginService.GetContext(eventType); } if (context != null) { BodyIndexPlugin.CreateTextures(data, context); } } if (BodyIndexPlugin.UpdateSelectedPixelValue(data)) { doDataEvent = isSelectedData; } } if (doVisibleEvent) { this.RaisePropertyChanged("HasSelected2DPixelData"); } if (doDataEvent) { this.RaisePropertyChanged("Selected2DPixelBodyIndex"); } } } }
private void HandleEvent(KStudioEvent eventObj, EventTypePluginData data, EventType eventType) { Debug.Assert(data != null); if (eventObj != null) { if ((eventObj.EventStreamDataTypeId == KStudioEventStreamDataTypeIds.UncompressedColor) || (eventObj.EventStreamDataTypeId == HackKStudioEventStreamDataTypeIds.UncompressedColorMonitor) || (eventObj.EventStreamDataTypeId == KStudioEventStreamDataTypeIds.CompressedColor) || (eventObj.EventStreamDataTypeId == HackKStudioEventStreamDataTypeIds.CompressedColorMonitor)) { lock (this.lockObj) { data.needsUpdate = true; HGlobalBuffer newSharedFrame = eventObj.GetRetainableEventDataBuffer(); data.visibleChanged = (newSharedFrame == null) != (data.sharedColorFrame == null); data.sharedColorFrame = newSharedFrame; data.doDecompress = (eventObj.EventStreamDataTypeId == KStudioEventStreamDataTypeIds.CompressedColor) || (eventObj.EventStreamDataTypeId == HackKStudioEventStreamDataTypeIds.CompressedColorMonitor); uint newWidth = nui.Constants.STREAM_COLOR_WIDTH; uint newHeight = nui.Constants.STREAM_COLOR_HEIGHT; if ((newWidth != data.imageWidth) || (newHeight != data.imageHeight)) { data.imageWidth = newWidth; data.imageHeight = newHeight; viz.Context context = null; if (this.pluginService != null) { context = this.pluginService.GetContext(eventType); } ColorPlugin.CreateTextures(data, context); } if (!data.timer.IsEnabled) { data.timer.Start(); } } } } }
public void ReadWriteSpanArray_RoundTrip() { using var buffer = new HGlobalBuffer(200); int[] intArray = new int[] { 11, 22, 33, 44 }; TestArray(intArray); TestSpan <int>(intArray); TestStruct[] structArray = new TestStruct[] { new TestStruct { I = 11, L = 22, D = 33 }, new TestStruct { I = 44, L = 55, D = 66 }, new TestStruct { I = 77, L = 88, D = 99 }, new TestStruct { I = 100, L = 200, D = 300 }, }; TestArray(structArray); TestSpan <TestStruct>(structArray); void TestArray <T>(T[] data) where T : struct { T[] destination = new T[data.Length]; buffer.WriteArray(0, data, 0, data.Length); buffer.ReadArray(0, destination, 0, data.Length); Assert.Equal(data, destination); } void TestSpan <T>(ReadOnlySpan <T> data) where T : unmanaged { Span <T> destination = stackalloc T[data.Length]; buffer.WriteSpan(0, data); buffer.ReadSpan(0, destination); for (int i = 0; i < data.Length; i++) { Assert.Equal(data[i], destination[i]); } } }
public void ReadWrite_RoundTrip() { using var buffer = new HGlobalBuffer(100); int intValue = 1234; buffer.Write <int>(0, intValue); Assert.Equal(intValue, buffer.Read <int>(0)); double doubleValue = 123.45; buffer.Write <double>(10, doubleValue); Assert.Equal(doubleValue, buffer.Read <double>(10)); TestStruct structValue = new TestStruct { I = 1234, L = 987654321, D = double.MaxValue }; buffer.Write <TestStruct>(0, structValue); Assert.Equal(structValue, buffer.Read <TestStruct>(0)); }
private void HandleEvent(EventType eventType, KStudioEvent eventObj, EventTypePluginData data) { Debug.Assert(data != null); if (eventObj != null) { bool doDataEvent = false; bool doVisibleEvent = false; if ((eventObj.EventStreamDataTypeId == KStudioEventStreamDataTypeIds.Depth) || (eventObj.EventStreamDataTypeId == HackKStudioEventStreamDataTypeIds.DepthMonitor)) { lock (this.lockObj) { bool isSelectedData = (this.selectedData == data); HGlobalBuffer newSharedFrame = eventObj.GetRetainableEventDataBuffer(); doVisibleEvent = isSelectedData && (newSharedFrame == null) != (data.sharedDepthFrame == null); data.sharedDepthFrame = newSharedFrame; uint newWidth = nui.Constants.STREAM_DEPTH_WIDTH; uint newHeight = nui.Constants.STREAM_DEPTH_HEIGHT; if ((data.depthMap == null) || (newWidth != data.imageWidth) || (newHeight != data.imageHeight)) { viz.Context context = null; if (this.pluginService != null) { context = this.pluginService.GetContext(eventType); } data.imageWidth = newWidth; data.imageHeight = newHeight; DepthPlugin.CreateTextures(data, context); } if (data.sharedDepthFrame != null) { unsafe { data.depthMap.UpdateData((ushort *)data.sharedDepthFrame.Buffer, data.sharedDepthFrame.Size); } } if (DepthPlugin.UpdateSelectedPixelValue(data)) { doDataEvent = isSelectedData; } } if (doVisibleEvent) { this.RaisePropertyChanged("HasSelected2DPixelData"); } if (doDataEvent) { this.RaisePropertyChanged("Selected2DPixelDepth"); } } } }
public static extern bool GetTokenInformation( SafeHandleZeroIsInvalid TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, HGlobalBuffer TokenInformation, int TokenInformationLength, out int ReturnLength);
private void HandleEvent(EventType eventType, KStudioEvent eventObj, EventTypePluginData data) { Debug.Assert(data != null); if (eventObj != null) { bool doDataEvent = false; bool doVisibleEvent = false; if (eventObj.EventStreamDataTypeId == KStudioEventStreamDataTypeIds.RawIr) { lock (this.lockObj) { bool isSelectedData = (this.selectedData == data); HGlobalBuffer newSharedFrame = eventObj.GetRetainableEventDataBuffer(); doVisibleEvent = isSelectedData && (newSharedFrame == null) != (data.sharedRawFrame == null); data.sharedRawFrame = newSharedFrame; uint newWidth = nui.Constants.STREAM_IR_WIDTH; uint newHeight = nui.Constants.STREAM_IR_HEIGHT; if ((data.rawIrTexture == null) || (newWidth != data.imageWidth) || (newHeight != data.imageHeight)) { data.imageWidth = newWidth; data.imageHeight = newHeight; viz.Context context = null; if (this.pluginService != null) { context = this.pluginService.GetContext(eventType); } RawIrPlugin.CreateTextures(data, context); } DepthIrEngine depthIrEngine = this.pluginService.DepthIrEngine; if ((depthIrEngine != null) && (data.depthFrame != null) && (data.irFrame != null)) { unsafe { fixed(ushort *pDepthFrame = &data.depthFrame[0], pIrFrame = &data.irFrame[0]) { depthIrEngine.HandleEvent(data.sharedRawFrame.Buffer, data.sharedRawFrame.Size, pDepthFrame, pIrFrame, data.imageWidth, data.imageHeight); uint imageDataSize = data.imageWidth * data.imageHeight * sizeof(ushort); if (data.rawIrTexture != null) { data.rawIrTexture.UpdateData((byte *)pIrFrame, imageDataSize); } if (data.depthMap != null) { data.depthMap.UpdateData(pDepthFrame, imageDataSize); } } } } if (RawIrPlugin.UpdateSelectedPixelValue(data)) { doDataEvent = isSelectedData; } } if (doVisibleEvent) { this.RaisePropertyChanged("HasSelected2DPixelData"); } if (doDataEvent) { this.RaisePropertyChanged("Selected2DPixelIrIntensity"); this.RaisePropertyChanged("Selected2DPixelDepth"); } } } }