示例#1
0
 public void LoadTableFromFile(string fileName)
 {
     lock (saveLock)
     {
         //Deserialize user data OR create missing objects
         if (File.Exists(fileName))
         {
             string json = File.ReadAllText(fileName);
             try
             {
                 dataTable = JsonConvert.DeserializeObject <TemtemDataTable>(json);
             }
             catch
             {
                 new ErrorMessage(tableCorruptedErrorString, null);
                 CreateNewTable();
             }
         }
         else
         {
             CreateNewTable();
         }
         if (dataTable == null)
         {
             new ErrorMessage(tableCorruptedErrorString, null);
             CreateNewTable();
         }
         //Set up the UI
         foreach (TemtemDataRow row in dataTable.rows)
         {
             TemtemTableRowUI        rowUI  = new TemtemTableRowUI(row, this);
             IndividualTrackerWindow window = new IndividualTrackerWindow(row, settingsController, dataTable.timer.durationTime);
             UIElements[row] = new Tuple <TemtemTableRowUI, IndividualTrackerWindow>(rowUI, window);
             trackerUI.AddRowToTable(rowUI);
         }
         //Set up the total
         trackerUI.SetTotal(dataTable.total);
         //Update time and temtem/h
         trackerUI.UpdateTime(dataTable.timer.durationTime);
         UpdateTemtemH();
     }
 }
示例#2
0
 private void CreateNewTable()
 {
     dataTable = new TemtemDataTable
     {
         rows = new List <TemtemDataRow>(),
         //Total row
         total = new TemtemDataRow()
     };
     dataTable.total.name               = "Total";
     dataTable.total.encountered        = 0;
     dataTable.total.encounteredPercent = 0.0;
     dataTable.total.lumaChance         = 0.0;
     dataTable.total.timeToLuma         = 0;
     //Timer data
     dataTable.timer = new TimerData
     {
         durationTime = 0,
         temtemCount  = 0
     };
 }