public void GenerateDefault()
        {
            var singlePlaneModalities = new[] { @"CR", @"DX", @"MG", @"KO" };
            var collection            = new ToolModalityBehaviorCollection();

            foreach (var modality in singlePlaneModalities)
            {
                collection[modality] = new ToolModalityBehavior
                {
                    SelectedImageWindowLevelTool        = true,
                    SelectedImageWindowLevelPresetsTool = true,
                    SelectedImageInvertTool             = true,
                    SelectedImageZoomTool   = true,
                    SelectedImagePanTool    = true,
                    SelectedImageFlipTool   = true,
                    SelectedImageRotateTool = true,
                    SelectedImageResetTool  = true
                };
            }

            using (var stream = File.Open(typeof(ToolModalityBehaviorCollection).FullName + @".default.xml", FileMode.Create))
            {
                _xmlSerializer.Serialize(stream, collection);
            }
        }
Beispiel #2
0
 public ToolModalityBehaviorSettings(ToolModalityBehavior item, string modality)
 {
     _item     = item;
     _modality = modality;
     _selectedOnlyWindowLevel = _item.SelectedImageWindowLevelTool || _item.SelectedImageWindowLevelPresetsTool || _item.SelectedImageInvertTool;
     _selectedOnlyOrientation = _item.SelectedImageFlipTool || _item.SelectedImageRotateTool;
     _selectedOnlyZoom        = _item.SelectedImageZoomTool;
     _selectedOnlyPan         = _item.SelectedImagePanTool;
     _selectedOnlyReset       = _item.SelectedImageResetTool;
 }
        public void TestRoundtripSerialization()
        {
            var collection = new ToolModalityBehaviorCollection();

            collection[@"CT"] = new ToolModalityBehavior {
                SelectedImageFlipTool = true, SelectedImagePanTool = true, SelectedImageWindowLevelPresetsTool = true
            };
            collection[@"DX"] = new ToolModalityBehavior {
                SelectedImageResetTool = true, SelectedImageInvertTool = true, SelectedImageWindowLevelTool = true
            };
            collection[null] = new ToolModalityBehavior {
                SelectedImageRotateTool = true, SelectedImageZoomTool = true
            };

            using (var stream = new MemoryStream())
            {
                _xmlSerializer.Serialize(stream, collection);

                stream.Seek(0, SeekOrigin.Begin);
                collection = _xmlSerializer.Deserialize(stream) as ToolModalityBehaviorCollection;
            }

            Assert.IsNotNull(collection);
            Assert.AreEqual(3, collection.Count);
            Assert.AreEqual(true, collection.Contains(@"CT"));
            Assert.AreEqual(true, collection.Contains(@"ct"));
            Assert.AreEqual(true, collection.Contains(@"DX"));
            Assert.AreEqual(true, collection.Contains(@""));
            Assert.AreEqual(true, collection.Contains(null));
            Assert.AreEqual(false, collection.Contains(@"XA"));

            Assert.AreEqual(true, collection[@"CT"].SelectedImageFlipTool);
            Assert.AreEqual(true, collection[@"CT"].SelectedImagePanTool);
            Assert.AreEqual(true, collection[@"CT"].SelectedImageWindowLevelPresetsTool);
            Assert.AreEqual(false, collection[@"CT"].SelectedImageResetTool);
            Assert.AreEqual(false, collection[@"CT"].SelectedImageInvertTool);

            Assert.AreEqual(true, collection[@"DX"].SelectedImageResetTool);
            Assert.AreEqual(true, collection[@"DX"].SelectedImageInvertTool);
            Assert.AreEqual(true, collection[@"DX"].SelectedImageWindowLevelTool);
            Assert.AreEqual(false, collection[@"DX"].SelectedImagePanTool);
            Assert.AreEqual(false, collection[@"DX"].SelectedImageZoomTool);

            Assert.AreEqual(true, collection[null].SelectedImageRotateTool);
            Assert.AreEqual(true, collection[@""].SelectedImageZoomTool);
            Assert.AreEqual(false, collection[null].SelectedImageWindowLevelPresetsTool);
            Assert.AreEqual(false, collection[@""].SelectedImageWindowLevelTool);
            Assert.AreEqual(false, collection[@""].SelectedImageFlipTool);
        }
		public void GenerateDefault()
		{
			var singlePlaneModalities = new[] {@"CR", @"DX", @"MG", @"KO"};
			var collection = new ToolModalityBehaviorCollection();
			foreach (var modality in singlePlaneModalities)
			{
				collection[modality] = new ToolModalityBehavior
				                       	{
				                       		SelectedImageWindowLevelTool = true,
				                       		SelectedImageWindowLevelPresetsTool = true,
				                       		SelectedImageInvertTool = true,
				                       		SelectedImageZoomTool = true,
				                       		SelectedImagePanTool = true,
				                       		SelectedImageFlipTool = true,
				                       		SelectedImageRotateTool = true,
				                       		SelectedImageResetTool = true
				                       	};
			}

			using (var stream = File.Open(typeof (ToolModalityBehaviorCollection).FullName + @".default.xml", FileMode.Create))
			{
				_xmlSerializer.Serialize(stream, collection);
			}
		}
		public void TestRoundtripSerialization()
		{
			var collection = new ToolModalityBehaviorCollection();
			collection[@"CT"] = new ToolModalityBehavior {SelectedImageFlipTool = true, SelectedImagePanTool = true, SelectedImageWindowLevelPresetsTool = true};
			collection[@"DX"] = new ToolModalityBehavior {SelectedImageResetTool = true, SelectedImageInvertTool = true, SelectedImageWindowLevelTool = true};
			collection[null] = new ToolModalityBehavior {SelectedImageRotateTool = true, SelectedImageZoomTool = true};

			using (var stream = new MemoryStream())
			{
				_xmlSerializer.Serialize(stream, collection);

				stream.Seek(0, SeekOrigin.Begin);
				collection = _xmlSerializer.Deserialize(stream) as ToolModalityBehaviorCollection;
			}

			Assert.IsNotNull(collection);
			Assert.AreEqual(3, collection.Count);
			Assert.AreEqual(true, collection.Contains(@"CT"));
			Assert.AreEqual(true, collection.Contains(@"ct"));
			Assert.AreEqual(true, collection.Contains(@"DX"));
			Assert.AreEqual(true, collection.Contains(@""));
			Assert.AreEqual(true, collection.Contains(null));
			Assert.AreEqual(false, collection.Contains(@"XA"));

			Assert.AreEqual(true, collection[@"CT"].SelectedImageFlipTool);
			Assert.AreEqual(true, collection[@"CT"].SelectedImagePanTool);
			Assert.AreEqual(true, collection[@"CT"].SelectedImageWindowLevelPresetsTool);
			Assert.AreEqual(false, collection[@"CT"].SelectedImageResetTool);
			Assert.AreEqual(false, collection[@"CT"].SelectedImageInvertTool);

			Assert.AreEqual(true, collection[@"DX"].SelectedImageResetTool);
			Assert.AreEqual(true, collection[@"DX"].SelectedImageInvertTool);
			Assert.AreEqual(true, collection[@"DX"].SelectedImageWindowLevelTool);
			Assert.AreEqual(false, collection[@"DX"].SelectedImagePanTool);
			Assert.AreEqual(false, collection[@"DX"].SelectedImageZoomTool);

			Assert.AreEqual(true, collection[null].SelectedImageRotateTool);
			Assert.AreEqual(true, collection[@""].SelectedImageZoomTool);
			Assert.AreEqual(false, collection[null].SelectedImageWindowLevelPresetsTool);
			Assert.AreEqual(false, collection[@""].SelectedImageWindowLevelTool);
			Assert.AreEqual(false, collection[@""].SelectedImageFlipTool);
		}