예제 #1
0
        private void HandleEvent(KStudioEvent eventObj, EventTypePluginData data, EventType eventType)
        {
            Debug.Assert(data != null);

            if (eventObj != null)
            {
                if ((eventObj.EventStreamDataTypeId == KStudioEventStreamDataTypeIds.Ir) ||
                    (eventObj.EventStreamDataTypeId == HackKStudioEventStreamDataTypeIds.IrMonitor))
                {
                    bool doDataEvent    = false;
                    bool doVisibleEvent = false;

                    lock (this.lockObj)
                    {
                        bool isSelectedData = (this.selectedData == data);

                        HGlobalBuffer newSharedFrame = eventObj.GetRetainableEventDataBuffer();
                        doVisibleEvent     = isSelectedData && (newSharedFrame == null) != (data.sharedIrFrame == null);
                        data.sharedIrFrame = newSharedFrame;

                        uint newWidth  = nui.Constants.STREAM_IR_WIDTH;
                        uint newHeight = nui.Constants.STREAM_IR_HEIGHT;

                        if ((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;

                            IrPlugin.CreateTextures(data, context);
                        }

                        if (IrPlugin.UpdateSelectedPixelValue(data))
                        {
                            doDataEvent = isSelectedData;
                        }
                    }

                    if (doVisibleEvent)
                    {
                        this.RaisePropertyChanged("HasSelected2DPixelData");
                    }

                    if (doDataEvent)
                    {
                        this.RaisePropertyChanged("Selected2DPixelIrIntensity");
                    }
                }
            }
        }
예제 #2
0
        private void UpdatePropertyView(double x, double y, uint width, uint height, EventTypePluginData data)
        {
            bool doEvent = false;

            lock (this.lockObj)
            {
                if (this.selectedData != data)
                {
                    doEvent           = true;
                    this.selectedData = data;
                }

                data.selected2DPixelX           = 0;
                data.selected2DPixelY           = 0;
                data.selected2DPixelIrIntensity = 0;

                if (width == data.imageWidth)
                {
                    data.selected2DPixelX = (uint)x;
                }
                else
                {
                    data.selected2DPixelX = (uint)((x / width) * data.imageWidth);
                }

                if (height == data.imageHeight)
                {
                    data.selected2DPixelY = (uint)y;
                }
                else
                {
                    data.selected2DPixelY = (uint)((y / height) * data.imageHeight);
                }

                IrPlugin.UpdateSelectedPixelValue(data);
            }

            this.RaisePropertyChanged("Selected2DPixelX");
            this.RaisePropertyChanged("Selected2DPixelY");
            this.RaisePropertyChanged("Selected2DPixelIrIntensity");

            if (doEvent)
            {
                this.RaisePropertyChanged("HasSelected2DPixelData");
            }
        }