コード例 #1
0
 public void setfData(FuelReduceData frd)
 {
     foreach (FuelReduceData fd in frd.fuelReduceDatas)
     {
         if (fd.reductionlabel != null)
         {
             if (fd.reductionlabel.ToLower() == "sutto")
             {
                 sutto = fd.reductionval;
             }
         }
     }
 }
コード例 #2
0
 public AircraftDataChart(List <string> param, string mode)
 {
     InitializeComponent();
     opMode = mode;
     if (mode == "edit")
     {
         aircraftName = param[0];
     }
     else
     {
         nameList = param;
     }
     pdata  = new PerformanceData();
     fsdata = new FuelStartData();
     frdata = new FuelReduceData();
     performanceChart.Items.SortDescriptions.Add(new SortDescription(performanceChart.Columns[0].SortMemberPath, ListSortDirection.Ascending));
     performanceChart.Items.IsLiveSorting = true;
     performanceChart.DataContext         = pdata;
     performanceChart.ItemsSource         = pdata.performanceDatas;
     //startFuelChart.Items.SortDescriptions.Add(new SortDescription(performanceChart.Columns[0].SortMemberPath, ListSortDirection.Ascending));
     //startFuelChart.Items.IsLiveSorting = true;
     startFuelChart.DataContext = fsdata;
     startFuelChart.ItemsSource = fsdata.fuelStartDatas;
     //reductionFuelChart.Items.SortDescriptions.Add(new SortDescription(performanceChart.Columns[0].SortMemberPath, ListSortDirection.Ascending));
     //reductionFuelChart.Items.IsLiveSorting = true;
     reductionFuelChart.DataContext = frdata;
     reductionFuelChart.ItemsSource = frdata.fuelReduceDatas;
     if (!File.Exists(@".\test.db"))
     {
         using (IDbConnection conn = new SQLiteConnection(@"Data Source=.\test.db;Version=3"))
         {
             conn.Execute($"CREATE TABLE '{performanceTable}' ('Aircraft' TEXT, 'ALT' REAL, 'ClimbTime' REAL, 'ClimbDistance' REAL, 'ClimbFuel' REAL, 'DescendTime' REAL, 'DescendDistance' REAL, 'DescendFuel' REAL, 'Speed01' REAL, 'Speed02' REAL, 'Speed03' REAL, 'Speed04' REAL, 'Speed05' REAL)", new DynamicParameters());
             conn.Execute($"CREATE TABLE '{fuelTable}' ('Aircraft' TEXT, 'Type' TEXT, 'Label' TEXT, 'Value' REAL)", new DynamicParameters());
             conn.Execute($"CREATE TABLE '{speedUnitTable}' ('Aircraft' TEXT, 'SpeedID' INTEGER NOT NULL UNIQUE, 'Value' REAL, 'Unit' TEXT, PRIMARY KEY(SpeedID AUTOINCREMENT))", new DynamicParameters());
         }
     }
     if (mode == "edit")
     {
         aircraftNameBx.Text       = aircraftName;
         aircraftNameBx.IsReadOnly = true;
         using (IDbConnection conn = new SQLiteConnection(@"Data Source=.\test.db;Version=3"))
         {
             var      uOutput = conn.Query <String>($"SELECT Unit FROM '{speedUnitTable}' WHERE Aircraft='{aircraftName}' ORDER BY SpeedID", new DynamicParameters());
             String[] units   = uOutput.ToArray();
             alt_units.SelectedValue   = units[0];
             dist_units.SelectedValue  = units[1];
             speed_units.SelectedValue = units[2];
             fuel_units.SelectedValue  = units[3];
             lfft_units.SelectedValue  = units[4];
             var pOutput = conn.Query <PerformanceData>($"SELECT * FROM '{performanceTable}' WHERE Aircraft='{aircraftName}' ORDER BY ALT", new DynamicParameters());
             pdata.performanceDatas.Clear();
             foreach (PerformanceData info in pOutput)
             {
                 pdata.performanceDatas.Add(info);
             }
             var fsOutput = conn.Query <FuelStartData>($"SELECT Label, Value FROM '{fuelTable}' WHERE Aircraft='{aircraftName}' AND Type='Starting' ORDER BY Label", new DynamicParameters());
             fsdata.fuelStartDatas.Clear();
             foreach (FuelStartData info in fsOutput)
             {
                 fsdata.fuelStartDatas.Add(info);
             }
             var frOutput = conn.Query <FuelReduceData>($"SELECT Label, Value FROM '{fuelTable}' WHERE Aircraft='{aircraftName}' AND Type='Reduction' ORDER BY Label", new DynamicParameters());
             frdata.fuelReduceDatas.Clear();
             foreach (FuelReduceData info in frOutput)
             {
                 frdata.fuelReduceDatas.Add(info);
             }
             var      dOutput     = conn.Query <Double>($"SELECT Value FROM '{speedUnitTable}' WHERE Aircraft='{aircraftName}' ORDER BY SpeedID", new DynamicParameters());
             Double[] columnNames = dOutput.ToArray();
             if (columnNames[0] != 0)
             {
                 dataspd1.Text = columnNames[0].ToString();
             }
             if (columnNames[1] != 0)
             {
                 dataspd2.Text = columnNames[1].ToString();
             }
             if (columnNames[2] != 0)
             {
                 dataspd3.Text = columnNames[2].ToString();
             }
             if (columnNames[3] != 0)
             {
                 dataspd4.Text = columnNames[3].ToString();
             }
             if (columnNames[4] != 0)
             {
                 dataspd5.Text = columnNames[4].ToString();
             }
         }
     }
 }