コード例 #1
0
        public override async Task InitializeAsync(object navigationData)
        {
            if (Observations == null)
            {
                Observations = new ObservableCollection <Observation>();
            }

            IEnumerable <Observation> observations = await _observationsService.GetObservationsAsync();

            Observations.Clear();
            foreach (Observation observation in observations)
            {
                Observations.Add(observation);
            }

            await base.InitializeAsync(navigationData);
        }
コード例 #2
0
 public override bool Load(ICancelProgressHandler progresshandler)
 {
     if (File.Exists(FileName))
     {
         var grid = (Owner.Grid as MFGrid);
         Observations.Clear();
         StreamReader sr   = new StreamReader(FileName);
         var          line = ReadComment(sr);
         var          strs = TypeConverterEx.Split <string>(line, 6);
         NH       = int.Parse(strs[0]);
         MOBS     = int.Parse(strs[1]);
         MAXM     = int.Parse(strs[2]);
         IUHOBSV  = int.Parse(strs[3]);
         HOBDRY   = float.Parse(strs[4]);
         Option   = strs[5];
         TOMULTH  = TypeConverterEx.Split <float>(sr.ReadLine(), 1)[0];
         Topology = new RegularGridTopology();
         int i = 0;
         while (!sr.EndOfStream)
         {
             line = sr.ReadLine();
             var vv = TypeConverterEx.SkipSplit <float>(line, 1, 8);
             strs = TypeConverterEx.Split <string>(line);
             HeadObservation obs = new HeadObservation(i)
             {
                 Layer      = (int)vv[0],
                 Row        = (int)vv[1],
                 Column     = (int)vv[2],
                 IREFSPFlag = (int)vv[3],
                 Name       = strs[0]
             };
             obs.CellID = grid.Topology.GetID(obs.Row - 1, obs.Column - 1);
             if (obs.IREFSPFlag < 0)
             {
                 line    = sr.ReadLine();
                 obs.ITT = TypeConverterEx.Split <int>(line, 1)[0];
                 int nsp = Math.Abs((int)vv[3]);
                 obs.IREFSP  = new int[nsp];
                 obs.TOFFSET = new float[nsp];
                 obs.HOBS    = new float[nsp];
                 obs.ROFF    = vv[5];
                 obs.COFF    = vv[6];
                 for (int t = 0; t < nsp; t++)
                 {
                     line           = sr.ReadLine();
                     vv             = TypeConverterEx.SkipSplit <float>(line, 1, 4);
                     obs.IREFSP[t]  = (int)vv[0];
                     obs.TOFFSET[t] = vv[1];
                     obs.HOBS[t]    = vv[2];
                 }
             }
             else
             {
                 int nsp = 1;
                 obs.IREFSP     = new int[nsp];
                 obs.TOFFSET    = new float[nsp];
                 obs.HOBS       = new float[nsp];
                 obs.IREFSP[0]  = (int)vv[3];
                 obs.TOFFSET[0] = vv[4];
                 obs.ROFF       = vv[5];
                 obs.COFF       = vv[6];
                 obs.HOBS[0]    = vv[7];
             }
             obs.Elevation = grid.GetElevationAt(obs.Row - 1, obs.Column - 1, obs.Layer - 1);
             Observations.Add(obs);
             i++;
         }
         if (Observations.Any())
         {
             Topology.ActiveCell      = new int[NH][];
             Topology.ActiveCellIDs   = new int[NH];
             Topology.RowCount        = grid.RowCount;
             Topology.ColumnCount     = grid.ColumnCount;
             Topology.ActiveCellCount = NH;
             var nsp1 = (Observations[0] as HeadObservation).IREFSP.Length;
             HOBS           = new DataCube <float>(1, nsp1, NH);
             HOBS.Variables = new string[] { "Head Observation" };
             for (int t = 0; t < nsp1; t++)
             {
                 for (int k = 0; k < NH; k++)
                 {
                     var hob = Observations[k] as HeadObservation;
                     HOBS[0, t, k]             = hob.HOBS[t];
                     Topology.ActiveCell[k]    = new int[] { hob.Row - 1, hob.Column - 1 };
                     Topology.ActiveCellIDs[k] = grid.Topology.GetID(hob.Row - 1, hob.Column - 1);
                 }
             }
             HOBS.Topology = this.Topology;
         }
         sr.Close();
         OnLoaded(progresshandler);
         return(true);
     }
     else
     {
         OnLoadFailed("Failed to load " + this.Name, progresshandler);
         return(false);
     }
 }