public IEnumerable <TranslationQuestion> LoadTranslations()
        {
            List <TranslationQuestion> translations = new List <TranslationQuestion>();

            string fileName = Path.Combine(_userAppdataPath, _filePath);
            var    data     = PersistenceHelper.Load <List <TranslationQuestion> >(fileName);

            if (data != null)
            {
                translations = (List <TranslationQuestion>)data;
            }

            return(translations);
        }
        //TODO: Implement load and save

        protected override void OnLoad(Stream inStrm)
        {
            SetupOp setupOp = null;

            try
            {
                // NOTE: Do not close or dispose BinaryReader, as this will close the Stream
                BinaryReader reader  = new BinaryReader(inStrm);
                int          version = reader.ReadInt32();

                // NOTE: With change to Add-In architecture, this extension is NOT backwards compatible with versions 1 and 2

                if (version == 3)
                {
                    //// Version 3:
                    //// Item 1: FeatureClassName: The orphan junction feature class of the Geometric Network for the underground conveyance system.
                    //// Item 2: FeatureClassName: The inlet feature class
                    //// Item 3: RasterDatasetName: The DEM dataset
                    //// Item 4: Boolean: Whether to smooth boundaries
                    //// Item 5: Boolean: Whether to include upstream pipe ends
                    //// Item 6: Boolean: Whether to exclude downstream pipe ends
                    //// Item 7: RasterDatasetName: The flow direction dataset
                    //// Item 8: FeatureClassName: The catchment feature class
                    //// Item 9: Boolean: Whether to exclude disabled nodes

                    setupOp = new SetupOp();
                    setupOp.ResultsDirectory = this.MxDocDirectoryName;
                    setupOp.ScratchDirectory = this.TemporaryDirectory;

                    FeatureClassName networkJunctionName = null;
                    PersistenceHelper.Load <FeatureClassName>(inStrm, ref networkJunctionName);
                    INetworkClass junctionClass = _SafeOpen(networkJunctionName) as INetworkClass;
                    if (junctionClass != null)
                    {
                        setupOp.GeometricNetwork = junctionClass.GeometricNetwork;
                    }

                    FeatureClassName inletClassName = null;
                    PersistenceHelper.Load <FeatureClassName>(inStrm, ref inletClassName);
                    setupOp.InletClass = _SafeOpen(inletClassName) as IFeatureClass;

                    RasterDatasetName demName = null;
                    PersistenceHelper.Load <RasterDatasetName>(inStrm, ref demName);
                    IRasterDataset demDataset = _SafeOpen(demName) as IRasterDataset;
                    if (demDataset != null)
                    {
                        setupOp.DEM = demDataset.CreateDefaultRaster();
                    }

                    setupOp.SmoothBoundaries          = reader.ReadBoolean();
                    setupOp.IncludeUpstreamPipeEnds   = reader.ReadBoolean();
                    setupOp.ExcludeDownstreamPipeEnds = reader.ReadBoolean();

                    RasterDatasetName flowDirName = null;
                    PersistenceHelper.Load <RasterDatasetName>(inStrm, ref flowDirName);
                    IRasterDataset flowDirDataset = _SafeOpen(flowDirName) as IRasterDataset;
                    if (flowDirDataset != null)
                    {
                        setupOp.FlowDirection = flowDirDataset.CreateDefaultRaster();
                    }

                    FeatureClassName catchmentClassName = null;
                    PersistenceHelper.Load <FeatureClassName>(inStrm, ref catchmentClassName);
                    setupOp.Catchments = _SafeOpen(catchmentClassName) as IFeatureClass;

                    setupOp.ExcludeDisabledNodes = reader.ReadBoolean();
                }

                _setupOp = setupOp;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.GetType().FullName + ": " + ex.Message);
            }
        }
Пример #3
0
 private void LoadConfig()
 {
     PersistenceHelper.Load();
 }