Exemple #1
0
        // background worker to actually perform the load and report status
        void LoadImageVolumeAndReportStatus(SynchronizationContext context)
        {
            // construct the test data
            var loader = _container.Resolve <IDicomImageVolumeLoadService>();

            Guid volumeGuid = Guid.Empty;
            Func <int, int, int, IUniformImageVolumeModel> allocator =
                (width, height, depth) =>
            {
                volumeGuid = _repository.CreateUniformImageVolume(width, height, depth);
                return(_repository.GetUniformImageVolume(volumeGuid));
            };

            bool bShowData    = false;
            var  statusStream = loader.LoadUniformImageVolumeFromDicom(DicomDirectory, allocator);
            int  nUpdateCount = 0;

            foreach (var status in statusStream)
            {
                context.Send(ignore => LoadProgress = status.Progress, null);
                if (!bShowData && volumeGuid.CompareTo(Guid.Empty) != 0)
                {
                    // now publish the load event
                    var showDataEvent = _eventAggregator.GetEvent <ImageDataLoadedEvent>();
                    showDataEvent.Publish(new ImageDataLoadedEventArgs()
                    {
                        ImageVolumeGuid = volumeGuid,
                    });

                    // don't show data again
                    bShowData = true;
                }

                if (status.ImageVolume != null)
                {
                    nUpdateCount++;
                    if (nUpdateCount % 30 == 0)
                    {
                        // now publish the load event
                        var volumeUpdateEvent = _eventAggregator.GetEvent <VolumeUpdatedEvent>();
                        volumeUpdateEvent.Publish(new VolumeUpdatedEventArgs()
                        {
                            TimeStamp       = DateTime.Now.Ticks,
                            ImageVolumeGuid = volumeGuid,
                        });
                    }
                }
            }

            //// now publish the load event
            //var showDataEvent = _eventAggregator.GetEvent<ShowDataEvent>();
            //showDataEvent.Publish(new ShowDataEventArgs()
            //{
            //    ImageVolumeGuid = volumeGuid,
            //});
        }
Exemple #2
0
        // background worker to actually perform the load and report status
        void GenerateImageVolumeAndReportStatus(SynchronizationContext context)
        {
            // construct the test data
            var guid         = _repository.CreateUniformImageVolume(Width, Height, Depth);
            var gauss        = _container.Resolve <IGaussianVolumeFunction>();
            var imageVolume  = _repository.GetUniformImageVolume(guid);
            var statusStream = gauss.PopulateGaussian(imageVolume);

            foreach (var status in statusStream)
            {
                context.Post(ignore => LoadProgress = status.Progress, null);
            }

            // now publish the load event
            var loadEvent = _eventAggregator.GetEvent <ImageDataLoadedEvent>();

            loadEvent.Publish(new ImageDataLoadedEventArgs()
            {
                ImageVolumeGuid = guid,
            });
        }