public void Verify_setting_properties()
        {
            var viewModel = new EllipsoidRegionViewModel(new EllipsoidTissueRegion(), "CurrentName");

            viewModel.Dx = 0.7;
            viewModel.Dy = 0.4;
            viewModel.Dz = 5.0;
            viewModel.X  = 0.1;
            viewModel.Y  = 0.2;
            viewModel.Z  = 0.3;
            viewModel.OpticalPropertyVM = new OpticalPropertyViewModel(new OpticalProperties()
            {
                G = 0.8, Mua = 0.1, Musp = 0.01, N = 1.4
            }, "cm", "NewTitle");
            viewModel.Name = "NewName";
            Assert.AreEqual("NewName" + StringLookup.GetLocalizedString("Label_Tissue"), viewModel.Name);
            Assert.AreEqual(0.1, viewModel.OpticalPropertyVM.Mua);
            Assert.AreEqual(0.8, viewModel.OpticalPropertyVM.G);
            Assert.AreEqual(0.01, viewModel.OpticalPropertyVM.Musp);
            Assert.AreEqual(1.4, viewModel.OpticalPropertyVM.N);
            Assert.AreEqual("cm", viewModel.OpticalPropertyVM.Units);
            Assert.AreEqual(0.1, viewModel.X);
            Assert.AreEqual(0.2, viewModel.Y);
            Assert.AreEqual(0.3, viewModel.Z);
            Assert.AreEqual(0.7, viewModel.Dx);
            Assert.AreEqual(0.4, viewModel.Dy);
            Assert.AreEqual(5.0, viewModel.Dz);
        }
        private void PlotMuspSpectrum_Executed()
        {
            var axisType   = IndependentVariableAxis.Wavelength;
            var axisUnits  = IndependentVariableAxisUnits.NM;
            var axesLabels = new PlotAxesLabels(
                StringLookup.GetLocalizedString("Label_MuSPrime"),
                StringLookup.GetLocalizedString("Measurement_Inv_mm"),
                new IndependentAxisViewModel
            {
                AxisType    = axisType,
                AxisLabel   = axisType.GetInternationalizedString(),
                AxisUnits   = axisUnits.GetInternationalizedString(),
                AxisRangeVM = WavelengthRangeVM
            });

            WindowViewModel.Current.PlotVM.SetAxesLabels.Execute(axesLabels);

            var tissue      = SelectedTissue;
            var wavelengths = WavelengthRangeVM.Values.ToArray();
            var points      = new Point[wavelengths.Length];

            for (var wvi = 0; wvi < wavelengths.Length; wvi++)
            {
                var wavelength = wavelengths[wvi];
                points[wvi] = new Point(wavelength, tissue.GetMusp(wavelength));
            }

            WindowViewModel.Current.PlotVM.PlotValues.Execute(new[] { new PlotData(points, StringLookup.GetLocalizedString("Label_MuSPrimeSpectra")) });

            var minWavelength = WavelengthRangeVM.Values.Min();
            var maxWavelength = WavelengthRangeVM.Values.Max();

            WindowViewModel.Current.TextOutputVM.TextOutput_PostMessage.Execute(
                StringLookup.GetLocalizedString("Message_PlotMuSPrimeSpectrum") + "[" + minWavelength + ", " + maxWavelength + "]\r");
        }
        public void verify_method_ConvertBack_returns_correct_value()
        {
            var dtsConverter = new DoubleToStringConverter();

            Assert.That(dtsConverter.ConvertBack(
                            s1,   // string to convert (double)
                            typeof(String),
                            null, // no parameters
                            System.Globalization.CultureInfo.CurrentCulture).Equals(d1));
            Assert.That(dtsConverter.ConvertBack(
                            s2,   // string to convert (int)
                            typeof(String),
                            null, // no parameters
                            System.Globalization.CultureInfo.CurrentCulture).Equals((double)i1));
            Assert.That(dtsConverter.ConvertBack(
                            "t",  // string to convert (NaN)
                            typeof(String),
                            null, // no parameters
                            System.Globalization.CultureInfo.CurrentCulture).Equals(0));
            var exception = Assert.Throws <ArgumentException>(() => dtsConverter.ConvertBack(
                                                                  12,   // int value
                                                                  typeof(String),
                                                                  null, // no parameters
                                                                  System.Globalization.CultureInfo.CurrentCulture));

            Assert.That(exception.Message, Is.EqualTo(StringLookup.GetLocalizedString("Exception_String")));
        }
 private void MC_SetStatisticsFolder_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     if (TrackStatistics)
     {
         using (var dialog = new FolderBrowserDialog())
         {
             dialog.Description = StringLookup.GetLocalizedString("Message_TrackStatisticsFolder");
             var dialogResult = dialog.ShowDialog();
             if (dialogResult == DialogResult.OK)
             {
                 // create the root directory
                 try
                 {
                     OutputFolder = dialog.SelectedPath;
                 }
                 catch (Exception)
                 {
                     TrackStatistics = false;
                 }
             }
             else
             {
                 TrackStatistics = false;
             }
         }
     }
 }
        public MapViewModel(int MapViewId = 0)
        {
            _mapViewId = MapViewId;
            MinValue   = 1E-9;
            MaxValue   = 1.0;
            AutoScale  = false;

            ScalingTypeOptionVm =
                new OptionViewModel <ScalingType>(StringLookup.GetLocalizedString("Label_ScalingType") + _mapViewId,
                                                  false);
            ScalingTypeOptionVm.PropertyChanged += (sender, args) => UpdateImages();

            ColormapTypeOptionVm =
                new OptionViewModel <ColormapType>(StringLookup.GetLocalizedString("Label_ColormapType"));
            ColormapTypeOptionVm.PropertyChanged += (sender, args) =>
            {
                _colormap = new Colormap(ColormapTypeOptionVm.SelectedValue);
                UpdateImages();
            };

            _colormap = new Colormap(ColormapTypeOptionVm.SelectedValue);

            PlotMap  = new RelayCommand <object>(PlotMap_Executed);
            ClearMap = new RelayCommand <object>(ClearMap_Executed);

            ExportDataToTextCommand = new RelayCommand(() => Maps_ExportDataToText_Executed(null, null));
            DuplicateWindowCommand  = new RelayCommand(() => Map_DuplicateWindow_Executed(null, null));
        }
        public void verify_ExecuteFluenceSolverCommand_returns_correct_values()
        {
            // WindowViewModel needs to be instantiated for default constructor
            var windowViewModel = new WindowViewModel();
            var viewModel       = windowViewModel.FluenceSolverVM;

            viewModel.ForwardSolverTypeOptionVM.SelectedValue         = ForwardSolverType.PointSourceSDA;
            viewModel.FluenceSolutionDomainTypeOptionVM.SelectedValue = FluenceSolutionDomainType.FluenceOfRhoAndZ;
            var result = viewModel.GetMapData();

            result.Wait();
            // ExecuteForwardSolver default settings
            PlotViewModel plotViewModel = windowViewModel.PlotVM;

            Assert.AreEqual(plotViewModel.Labels.Count, 0);
            Assert.AreEqual(plotViewModel.Title, null);
            TextOutputViewModel textOutputViewModel = windowViewModel.TextOutputVM;
            double d1 = 0.01;
            int    i1 = 1;
            double g  = 0.8;
            double n  = 1.4;
            var    s1 = StringLookup.GetLocalizedString("Label_FluenceSolver") +
                        StringLookup.GetLocalizedString("Label_MuA") + "=" +
                        d1.ToString(CultureInfo.CurrentCulture) + " " +
                        StringLookup.GetLocalizedString("Label_MuSPrime") + "=" +
                        i1.ToString(CultureInfo.CurrentCulture) + " g=" +
                        g.ToString(CultureInfo.CurrentCulture) + " n=" +
                        n.ToString(CultureInfo.CurrentCulture) + "; " +
                        StringLookup.GetLocalizedString("Label_Units") + " = 1/mm\r";

            Assert.AreEqual(textOutputViewModel.Text, s1);
        }
示例#7
0
 public LayerRegionViewModel(LayerTissueRegion region, string name)
 {
     _region            = region;
     _name              = name ?? "";
     _zRangeVM          = new RangeViewModel(_region.ZRange, StringLookup.GetLocalizedString("Measurement_mm"), IndependentVariableAxis.Z, "", false);
     _opticalPropertyVM = new OpticalPropertyViewModel(_region.RegionOP, StringLookup.GetLocalizedString("Measurement_Inv_mm"), "", true, true, true, true);
     _opticalPropertyVM.PropertyChanged += (s, a) => OnPropertyChanged("Name");
 }
示例#8
0
        internal static MapData Create(double[,] rawData, double[] x, double[] y, double[] dx, double[] dy)
        {
            if (rawData.GetLength(0) != x.Length || rawData.GetLength(1) != y.Length)
            {
                throw new ArgumentException(StringLookup.GetLocalizedString("Exception_MismatchedArrays"));
            }

            return(new MapData(rawData.ToEnumerable <double>().ToArray(), x, y, dx, dy));
        }
示例#9
0
        public static MapData Create(double[] rawData, double[] x, double[] y, double[] dx, double[] dy)
        {
            if (rawData.Length != x.Length * y.Length)
            {
                throw new ArgumentException(StringLookup.GetLocalizedString("Exception_MismatchedArrays"));
            }

            return(new MapData(rawData.ToArray(), x, y, dx, dy));
        }
示例#10
0
        public void verify_default_constructor_sets_properties_correctly()
        {
            var viewModel = new VoxelRegionViewModel();

            Assert.AreEqual(viewModel.Name, StringLookup.GetLocalizedString("Label_Tissue"));
            Assert.IsFalse(viewModel.IsLayer);
            Assert.AreEqual(viewModel.Units, StringLookup.GetLocalizedString("Measurement_mm"));
            Assert.IsTrue(viewModel.OpticalPropertyVM != null);
        }
        public void verify_method_Convert_returns_correct_value()
        {
            var rtsConverter = new ResourceToStringConverter();

            Assert.That(rtsConverter.Convert(
                            null,
                            typeof(String),
                            "Button_PlotMeasured", // resource is passed as a parameter
                            System.Globalization.CultureInfo.CurrentCulture).Equals(StringLookup.GetLocalizedString("Button_PlotMeasured")));
        }
        public void Verify_constructor_sets_properties_correctly()
        {
            var viewModel = new EllipsoidRegionViewModel(new EllipsoidTissueRegion(), "TestEllipsiodTissue");

            Assert.AreEqual("TestEllipsiodTissue" + StringLookup.GetLocalizedString("Label_Tissue"), viewModel.Name);
            Assert.IsTrue(viewModel.IsEllipsoid);
            Assert.IsFalse(viewModel.IsLayer);
            Assert.AreEqual(StringLookup.GetLocalizedString("Measurement_mm"), viewModel.Units);
            Assert.IsTrue(viewModel.OpticalPropertyVM != null);
        }
        public static bool BlockFilterFunction(BlockTypes blockType)
        {
            if (filter == "")
            {
                return(true);
            }
            var blockName = StringLookup.GetItemName(ObjectTypes.Block, (int)blockType).ToLower();

            return(blockName.Contains(filter.ToLower()));
        }
        public void verify_default_constructor_sets_properties_correctly()
        {
            MonteCarloSolverViewModel viewModel = new MonteCarloSolverViewModel();

            Assert.IsTrue(viewModel.CanDownloadInfiles);
            Assert.IsTrue(viewModel.CanLoadInputFile);
            Assert.IsTrue(viewModel.CanRunSimulation);
            Assert.IsTrue(viewModel.CanRunSimulation);
            Assert.IsFalse(viewModel.CanCancelSimulation);
            Assert.IsFalse(viewModel.CanSaveResults);
            Assert.AreEqual(viewModel.CancelButtonText, StringLookup.GetLocalizedString("Button_Cancel"));
        }
        public void Verify_region_is_air()
        {
            var ellisoidTissueRegion = new EllipsoidTissueRegion {
                RegionOP = { G = 0.8, Mua = 0D, Mus = 1E-10 }
            };

            ellisoidTissueRegion.RegionOP.G = 1.4;
            var viewModel = new EllipsoidRegionViewModel(ellisoidTissueRegion, "TestEllipsiodTissue");

            Assert.IsTrue(ellisoidTissueRegion.IsAir());
            Assert.AreEqual("TestEllipsiodTissue" + StringLookup.GetLocalizedString("Label_Air"), viewModel.Name);
        }
        private void AddDescription(Item item)
        {
            var key = GetKey(item.Name);

            if (key != null)
            {
                var desc = ReplaceNewLines(StringLookup.ReadDescription(key));
                item.Description = new ItemDescription {
                    Text = desc
                };
            }
        }
示例#17
0
        private object GetTissueInputVM(string tissueType)
        {
            // ops to use as the basis for instantiating multi-region tissues based on homogeneous values (for differential comparison)
            if (_currentHomogeneousOpticalProperties == null)
            {
                _currentHomogeneousOpticalProperties = new OpticalProperties(0.01, 1, 0.8, 1.4);
            }

            switch (tissueType)
            {
            case "SemiInfinite":
                if (_currentSemiInfiniteTissueInput == null)
                {
                    _currentSemiInfiniteTissueInput =
                        new SemiInfiniteTissueInput(
                            new SemiInfiniteTissueRegion(_currentHomogeneousOpticalProperties));
                }
                return(new OpticalPropertyViewModel(
                           _currentSemiInfiniteTissueInput.Regions.First().RegionOP,
                           IndependentVariableAxisUnits.InverseMM.GetInternationalizedString(),
                           StringLookup.GetLocalizedString("Heading_OpticalProperties")));

            case "MultiLayer":
                if (_currentMultiLayerTissueInput == null)
                {
                    _currentMultiLayerTissueInput = new MultiLayerTissueInput(new ITissueRegion[]
                    {
                        new LayerTissueRegion(new DoubleRange(0, 2), _currentHomogeneousOpticalProperties.Clone()),
                        new LayerTissueRegion(new DoubleRange(2, double.PositiveInfinity),
                                              _currentHomogeneousOpticalProperties.Clone())
                    });
                }
                return(new MultiRegionTissueViewModel(_currentMultiLayerTissueInput));

            case "SingleEllipsoid":
                if (_currentSingleEllipsoidTissueInput == null)
                {
                    _currentSingleEllipsoidTissueInput = new SingleEllipsoidTissueInput(
                        new EllipsoidTissueRegion(new Position(0, 0, 10), 5, 5, 5,
                                                  new OpticalProperties(0.05, 1.0, 0.8, 1.4)),
                        new ITissueRegion[]
                    {
                        new LayerTissueRegion(new DoubleRange(0, double.PositiveInfinity),
                                              _currentHomogeneousOpticalProperties.Clone())
                    });
                }
                return(new MultiRegionTissueViewModel(_currentSingleEllipsoidTissueInput));

            default:
                throw new ArgumentOutOfRangeException(nameof(tissueType));
            }
        }
        public void validate_ExecuteMonteCarloSolverCommand_failure_sets_properties_correctly()
        {
            var viewModel = new MonteCarloSolverViewModel();

            // this execution of ExecuteMonteCarloSolverCommand errors in "try"
            // because threading not established, so values are as initialized
            viewModel.ExecuteMonteCarloSolverCommand.Execute(null);
            Assert.IsFalse(viewModel.CanRunSimulation);
            Assert.IsFalse(viewModel.CanLoadInputFile);
            Assert.IsTrue(viewModel.CanCancelSimulation);
            Assert.IsFalse(viewModel.CanSaveResults);
            Assert.IsTrue(viewModel.CancelButtonText == StringLookup.GetLocalizedString("Button_CancelSimulation"));
        }
 public EntityRules(string name, StringLookup lookup)
 {
     ActionMatrix         = new Dictionary <ActionMatrixEntryKey, ActionMatrixEntry>();
     PreBattleEffects     = new List <EffectBase>().AsReadOnly();
     PostBattleEffects    = new List <EffectBase>().AsReadOnly();
     PreTurnEffects       = new List <EffectBase>().AsReadOnly();
     PostTurnEffects      = new List <EffectBase>().AsReadOnly();
     EliminationCondition = AlwaysCondition.False;
     Actions      = new List <Action>().AsReadOnly();
     Results      = new List <Result>().AsReadOnly();
     Name         = name;
     StringLookup = lookup;
 }
示例#20
0
        public EntityRules ToEntityRules()
        {
            var entity = new EntityRules(m_name, StringLookup.ToStringLookup());

            entity.PreBattleEffects     = m_preBattleEffectsNode.GetChildren().Select(x => x.ToEffectBase()).ToList().AsReadOnly();
            entity.PostBattleEffects    = m_postBattleEffectsNode.GetChildren().Select(x => x.ToEffectBase()).ToList().AsReadOnly();
            entity.PreTurnEffects       = m_preTurnEffectsNode.GetChildren().Select(x => x.ToEffectBase()).ToList().AsReadOnly();
            entity.PostTurnEffects      = m_postTurnEffectsNode.GetChildren().Select(x => x.ToEffectBase()).ToList().AsReadOnly();
            entity.EliminationCondition = m_eliminationCondition.ToConditionBase();
            entity.Actions = m_actionsNode.GetChildren().Select(x => x.ToAction()).ToList().AsReadOnly();
            entity.Results = m_resultsNode.GetChildren().Select(x => x.ToResult()).ToList().AsReadOnly();
            entity.SetActionMatrix(ActionMatrix.ToActionMatrixEntries());
            return(entity);
        }
 private EntityRules(IDeserializer deserializer)
 {
     ActionMatrix         = new Dictionary <ActionMatrixEntryKey, ActionMatrixEntry>();
     Name                 = deserializer.GetValue <string>(nameof(Name));
     StringLookup         = deserializer.GetValue <StringLookup>("Lookup");
     PreBattleEffects     = deserializer.GetValues <EffectBase>(nameof(PreBattleEffects)).ToList().AsReadOnly();
     PostBattleEffects    = deserializer.GetValues <EffectBase>(nameof(PostBattleEffects)).EmptyIfNull().ToList().AsReadOnly();
     PreTurnEffects       = deserializer.GetValues <EffectBase>(nameof(PreTurnEffects)).EmptyIfNull().ToList().AsReadOnly();
     PostTurnEffects      = deserializer.GetValues <EffectBase>(nameof(PostTurnEffects)).EmptyIfNull().ToList().AsReadOnly();
     EliminationCondition = deserializer.GetValue <ConditionBase>(nameof(EliminationCondition));
     Actions              = deserializer.GetValues <Action>(nameof(Actions)).EmptyIfNull().ToList().AsReadOnly();
     Results              = deserializer.GetValues <Result>(nameof(Results)).EmptyIfNull().ToList().AsReadOnly();
     ActionMatrix         = deserializer.GetValues <ActionMatrixEntry>(nameof(ActionMatrix)).EmptyIfNull().ToDictionary(x => x.Key, x => x);
 }
示例#22
0
        public SimulationInputViewModel(SimulationInput input)
        {
            _simulationInput = input; // use the property to invoke the appropriate change notification

            _simulationOptionsVM = new SimulationOptionsViewModel(_simulationInput.Options);
            _outputName          = input.OutputName;

#if WHITELIST
            TissueTypeVM = new OptionViewModel <string>("Tissue Type:", true, _simulationInput.TissueInput.TissueType, WhiteList.TissueTypes);
#else
            TissueTypeVM = new OptionViewModel <string>("Tissue Type:", true, _simulationInput.TissueInput.TissueType,
                                                        new[]
            {
                "MultiLayer",
                "SingleEllipsoid",
                "SingleVoxel"
            });
#endif
            UpdateTissueTypeVM(_simulationInput.TissueInput.TissueType);
            _simulationOptionsVM.PropertyChanged += (sender, args) =>
            {
                if (_simulationOptionsVM.TrackStatistics && _simulationOptionsVM.OutputFolder != null)
                {
                    _simulationInput.OutputName = Path.Combine(_simulationOptionsVM.OutputFolder, _outputName);
                }
            };
            _tissueTypeVM.PropertyChanged += (sender, args) =>
            {
                switch (_tissueTypeVM.SelectedValue)
                {
                case "MultiLayer":
                    _simulationInput.TissueInput = new MultiLayerTissueInput();
                    break;

                case "SingleEllipsoid":
                    _simulationInput.TissueInput = new SingleEllipsoidTissueInput();
                    break;

                case "SingleVoxel":
                    _simulationInput.TissueInput = new SingleVoxelTissueInput();
                    break;

                default:
                    throw new InvalidEnumArgumentException(StringLookup.GetLocalizedString("Error_NoTissueTypeExists"));
                }
                UpdateTissueTypeVM(_simulationInput.TissueInput.TissueType);
            };

            UpdateTissueInputVM(_simulationInput.TissueInput);
        }
        private void SimulateMeasuredDataCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var measuredDataValues = GetSimulatedMeasuredData();
            var measuredDataPoints = GetDataPoints(measuredDataValues);

            //Report the results
            var axesLabels = GetPlotLabels();

            WindowViewModel.Current.PlotVM.SetAxesLabels.Execute(axesLabels);
            var plotLabels = GetLegendLabels(PlotDataType.Simulated);
            var plotData   = measuredDataPoints.Zip(plotLabels, (p, el) => new PlotData(p, el)).ToArray();

            WindowViewModel.Current.PlotVM.PlotValues.Execute(plotData);
            WindowViewModel.Current.TextOutputVM.TextOutput_PostMessage.Execute(StringLookup.GetLocalizedString("Label_SimulatedMeasuredData") + MeasuredOpticalPropertyVM + " \r");
        }
        private void LoadFiles()
        {
            var rootPath = RootPathProvider.GetRootPathStatic();

            ReverseItemLookup.ReadStats(Path.Combine(rootPath, WebSettings.Settings.FileStringsEnglish));
            StringLookup.ReadStats(Path.Combine(rootPath, WebSettings.Settings.FileStringsEnglish));

            CabinStatsCollection.ReadStats <PartStatsCabin>(Path.Combine(rootPath, WebSettings.Settings.FileCarEditorCabinsLua));
            DecorumStatsCollection.ReadStats <PartStatsDecor>(Path.Combine(rootPath, WebSettings.Settings.FileCarEditorDecorumLua));
            WeaponStatsCollection.ReadStats <PartStatsWeapon>(Path.Combine(rootPath, WebSettings.Settings.FileCarEditorWeaponsExLua));
            MovementStatsCollection.ReadStats <PartStatsWheel>(Path.Combine(rootPath, WebSettings.Settings.FileCarEditorWheelsLua));
            CoreStatsCollection.ReadStats <PartStatsCore>(Path.Combine(rootPath, WebSettings.Settings.FileCarEditorCoreLua));

            PremiumPackagesCollection.ReadPackages(Path.Combine(rootPath, WebSettings.Settings.DirectoryPremiumPackages));
        }
        private void CalculateInitialGuessCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            var initialGuessDataValues = CalculateInitialGuess();
            var initialGuessDataPoints = GetDataPoints(initialGuessDataValues);

            //Report the results
            var axesLabels = GetPlotLabels();

            WindowViewModel.Current.PlotVM.SetAxesLabels.Execute(axesLabels);
            var plotLabels = GetLegendLabels(PlotDataType.Guess);
            var plotData   = initialGuessDataPoints.Zip(plotLabels, (p, el) => new PlotData(p, el)).ToArray();

            WindowViewModel.Current.PlotVM.PlotValues.Execute(plotData);
            WindowViewModel.Current.TextOutputVM.TextOutput_PostMessage.Execute(StringLookup.GetLocalizedString("Label_InitialGuess") +
                                                                                InitialGuessOpticalPropertyVM + " \r");
        }
示例#26
0
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(value is string))
            {
                throw new ArgumentException(StringLookup.GetLocalizedString("Exception_String"));
            }
            double d;

            if (double.TryParse((string)value, NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out d))
            {
                return(d);
            }
            else
            {
                return(0);
            }
        }
示例#27
0
        private FluenceSolutionDomainOptionViewModel GetSelectedSolutionDomain()
        {
            switch (MapTypeOptionVM.SelectedValue)
            {
            case MapType.Fluence:
                return(FluenceSolutionDomainTypeOptionVM);

            case MapType.AbsorbedEnergy:
                return(AbsorbedEnergySolutionDomainTypeOptionVM);

            case MapType.PhotonHittingDensity:
                return(PhotonHittingDensitySolutionDomainTypeOptionVM);

            default:
                throw new InvalidEnumArgumentException(StringLookup.GetLocalizedString("Error_NoMapTypeExists"));
            }
        }
        public MultiRegionTissueViewModel(ITissueInput input)
        {
            _currentRegionIndex = 0;
            _input = input;

            switch (input.TissueType)
            {
            case "MultiLayer":
                var multiLayerTissueInput = (MultiLayerTissueInput)_input;
                _regionsVM = new ObservableCollection <object>(
                    multiLayerTissueInput.Regions.Select((r, i) => (object)new LayerRegionViewModel(
                                                             (LayerTissueRegion)r,
                                                             StringLookup.GetLocalizedString("Label_Layer") + i)));
                break;

            case "SingleEllipsoid":
                var singleEllipsoidTissueInput = (SingleEllipsoidTissueInput)_input;
                _regionsVM = new ObservableCollection <object>(
                    singleEllipsoidTissueInput.LayerRegions
                    .Select((r, i) => (object)new LayerRegionViewModel(
                                (LayerTissueRegion)r,
                                StringLookup.GetLocalizedString("Label_Layer") + i))
                    .Concat(
                        new EllipsoidRegionViewModel(
                            (EllipsoidTissueRegion)singleEllipsoidTissueInput.EllipsoidRegion,
                            StringLookup.GetLocalizedString("Label_EllipsoidRegion"))));
                break;

            case "SingleVoxel":
                var singleVoxelTissueInput = (SingleVoxelTissueInput)_input;
                _regionsVM = new ObservableCollection <object>(
                    singleVoxelTissueInput.LayerRegions
                    .Select((r, i) => (object)new LayerRegionViewModel(
                                (LayerTissueRegion)r,
                                StringLookup.GetLocalizedString("Label_Layer") + i))
                    .Concat(
                        new VoxelRegionViewModel(
                            (VoxelTissueRegion)singleVoxelTissueInput.VoxelRegion,
                            StringLookup.GetLocalizedString("Label_VoxelRegion"))));
                break;

            default:
                throw new InvalidEnumArgumentException(StringLookup.GetLocalizedString("Error_NoTissueTypeExists"));
            }
        }
示例#29
0
 static void GetRecipe(JObject BLOCK, int Id, ObjectTypes type = ObjectTypes.Block)
 {
     try
     {
         var DATA = new JArray();
         foreach (var thing in RecipeManager.inst.GetRecipeByOutputType(new ItemTypeInfo(type, Id)).m_InputItems)
         {
             var ITEM = new JObject
             {
                 { "name", StringLookup.GetItemName(ObjectTypes.Chunk, thing.m_Item.ItemType) },
                 { "id", thing.m_Item.ItemType },
                 { "count", thing.m_Quantity }
             };
             DATA.Add(ITEM);
         }
         BLOCK.Add("recipe", DATA);
     }
     catch { }
 }
        public void verify_method_Convert_returns_correct_value()
        {
            var dtsConverter = new DoubleToStringConverter();

            Assert.That(dtsConverter.Convert(
                            12.3, // double to convert
                            typeof(String),
                            null, // no parameters
                            System.Globalization.CultureInfo.CurrentCulture).Equals(d1.ToString(System.Globalization.CultureInfo.CurrentCulture)));
            Assert.That(dtsConverter.Convert(
                            12,   // int to convert - OK
                            typeof(String),
                            null, // no parameters
                            System.Globalization.CultureInfo.CurrentCulture).Equals(d2.ToString(System.Globalization.CultureInfo.CurrentCulture)));
            var exception = Assert.Throws <ArgumentException>(() => dtsConverter.Convert(
                                                                  "string", // string not a double
                                                                  typeof(String),
                                                                  null,     // no parameters
                                                                  System.Globalization.CultureInfo.CurrentCulture));

            Assert.That(exception.Message, Is.EqualTo(StringLookup.GetLocalizedString("Exception_DoubleOrInt")));
        }
示例#31
0
 public static string ReplaceGroups(string target, string beforeGroup, string afterGroup, StringLookup lookup)
 {
     int targetLength = target.Length;
     StringCollection strings = FindGroups(target,beforeGroup,afterGroup,false);
     foreach(string substring in strings) {
         target = target.Replace(beforeGroup + substring + afterGroup, lookup(substring) );
     }
     return target;
 }
示例#32
0
		/// <summary>
		/// Replaces the groups.
		/// </summary>
		/// <param name="target">The target.</param>
		/// <param name="beforeGroup">The before group.</param>
		/// <param name="afterGroup">The after group.</param>
		/// <param name="lookup">The lookup.</param>
		/// <returns></returns>
		public static string ReplaceGroups(string target, string beforeGroup, string afterGroup, StringLookup lookup) {
			if( target == null )
			{
				throw new ArgumentNullException("target");
			}
			//int targetLength = target.Length;
			StringCollection strings = FindGroups(target,beforeGroup,afterGroup,false);
			if( lookup == null )
			{
				throw new ArgumentNullException("lookup");
			}
			foreach(string substring in strings) 
			{
				target = target.Replace(beforeGroup + substring + afterGroup, lookup(substring) );
			}
			return target;
		}
示例#33
0
		/// <summary>
		/// Replaces ${var} statements in a string with the corresonding values as detirmined by the lookup delegate
		/// </summary>
		/// <param name="target">The target.</param>
		/// <param name="lookup">The lookup.</param>
		/// <returns></returns>
		public static string InterpolateForVariables(string target, StringLookup lookup) 
		{
			return ReplaceGroups(target, "${" , "}" , lookup);
		}