예제 #1
0
            public void Execute()
            {
                this.OnBeforeExecute();
                List <ImageSop> images = new List <ImageSop>();

                try
                {
                    VolumeFunction function = _function.Normalize(100);
                    foreach (ISopDataSource sopDataSource in function.CreateSops(100, 100, 100, false))
                    {
                        this.InitializeSopDataSource(sopDataSource);
                        images.Add(new ImageSop(sopDataSource));
                    }

                    MprViewerComponent component = new MprViewerComponent(Volumes.Volume.Create(EnumerateFrames(images)));
                    component.Layout();
                    LaunchImageViewerArgs args = new LaunchImageViewerArgs(WindowBehaviour.Auto);
                    args.Title = component.Title;
                    MprViewerComponent.Launch(component, args);
                }
                catch (Exception ex)
                {
                    ExceptionHandler.Report(ex, Application.ActiveDesktopWindow);
                }
                finally
                {
                    DisposeAll(images);
                }
                this.OnAfterExecute();
            }
예제 #2
0
        /// <summary>
        /// Creates a 100x100x100 volume using the specified volume function using 100 frames of dimensions 100x100.
        /// </summary>
        /// <param name="function">The function with which to generate frame data - 0-99 in each dimension.</param>
        /// <param name="initializer">A delegate to initialize additional SOP attributes for each of the 100 frames.</param>
        /// <param name="testMethod">A test routine with which to exercise the volume. The volume is disposed automatically afterwards.</param>
        protected static void TestVolume(VolumeFunction function, InitializeSopDataSourceDelegate initializer, TestVolumeDelegate testMethod)
        {
            function = function.Normalize(100);
            List <ImageSop> images = new List <ImageSop>();

            try
            {
                foreach (ISopDataSource sopDataSource in function.CreateSops(100, 100, 100, false))
                {
                    if (initializer != null)
                    {
                        initializer.Invoke(sopDataSource);
                    }
                    images.Add(new ImageSop(sopDataSource));
                }

                using (Volume volume = Volume.Create(EnumerateFrames(images)))
                {
                    if (testMethod != null)
                    {
                        testMethod.Invoke(volume);
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(string.Format("Thrown: {0}", ex.GetType().Name));
                throw;
            }
            finally
            {
                DisposeAll(images);
            }
        }
예제 #3
0
        public void TestInsufficientFramesSource()
        {
            // it doesn't really matter what function we use
            VolumeFunction function = VolumeFunction.Void.Normalize(100);

            List <ImageSop> images = new List <ImageSop>();

            try
            {
                // create only 2 slices!!
                foreach (ISopDataSource sopDataSource in function.CreateSops(100, 100, 2, false))
                {
                    images.Add(new ImageSop(sopDataSource));
                }

                // this line *should* throw an exception
                using (Volume volume = Volume.Create(EnumerateFrames(images))) {}
            }
            finally
            {
                DisposeAll(images);
            }
        }