コード例 #1
0
        public static void Initialize()
        {
            try
            {
                if (File.Exists(ApplicationSettingFilePath))
                {
                    var appSettingsPath = ApplicationSettingFilePath;

                    _instance = Deserialize(appSettingsPath);
                }
                else
                {
                    //previous versions stored app settings in the executing dir
                    //so if no app setting file exists check old location

                    var oldSettingsPath = System.IO.Path.Combine(GetExecutionDirectory()
                        , Constants.APP_SETTINGS_PATH);

                    if (File.Exists(oldSettingsPath))
                    {
                        _instance = ApplicationSettings.Deserialize(oldSettingsPath);
                        try
                        {
                            System.IO.File.Delete(oldSettingsPath);
                        }
                        catch { }
                    }
                    else
                    {
                        _instance = new ApplicationSettings();
                    }
                }
            }
            catch (Exception e)
            {
                ExceptionHandler.HandelEx(new UserFacingException("Fail to load application settings", e));
                _instance = new ApplicationSettings();
            }
        }
コード例 #2
0
        private void _selectCruiser_Click(object sender, EventArgs e)
        {
            var appSettings = new FSCruiser.Core.ApplicationSettings();

            appSettings.Cruisers.Add(new Cruiser("A"));
            appSettings.Cruisers.Add(new Cruiser("B"));

            FSCruiser.Core.ApplicationSettings.Instance = appSettings;

            var stratum = new Stratum()
            {
                Code = "st1", Method = "P"
            };
            var sg = new SampleGroup()
            {
                Code = "sg1"
            };



            using (var view = new FormCruiserSelection())
            {
                var tree = new Tree()
                {
                    TreeNumber     = 1,
                    Stratum        = stratum,
                    SampleGroup    = sg,
                    CountOrMeasure = "C"
                };

                view.Tree = tree;
                view.ShowDialog();

                tree = new Tree()
                {
                    TreeNumber     = 1,
                    Stratum        = stratum,
                    SampleGroup    = sg,
                    CountOrMeasure = "M"
                };

                view.Tree = tree;
                view.ShowDialog();

                tree = new Tree()
                {
                    TreeNumber     = 1,
                    Stratum        = stratum,
                    SampleGroup    = sg,
                    CountOrMeasure = "I"
                };

                view.Tree = tree;
                view.ShowDialog();

                tree = new Tree()
                {
                    TreeNumber  = 1,
                    Stratum     = stratum,
                    SampleGroup = sg,
                };

                view.Tree = tree;
                view.ShowDialog();
            }
        }