public void TeamsPath_Changed(object sender, PropertyChangedEventArgs e) { if (e.PropertyName != "FilePath") { return; // none of my business } if (File.Exists(FilePath)) { if (Util.IsPathOnRemovableDevice(FilePath)) { PathBrush = new SolidColorBrush(Colors.Orange); PathTooltip = "File is on removable device. Local " + "storage or a cloud folder is ideal."; } else { PathBrush = new SolidColorBrush(Colors.Black); PathTooltip = FilePath; } Teams = ScoutingJson.ParseTeamsList(FilePath); SelectedTeam = Teams.FirstOrDefault(); } else { PathBrush = new SolidColorBrush(Colors.Red); PathTooltip = "File does not exist."; } }
public void NewEvent() { NewEventDialog ned = new NewEventDialog(EventPath); bool? res = ned.ShowDialog(); if (res == true) // Nullable<bool> { MessageBoxResult mbr = MessageBox.Show( "Do you want to save this event before creating a new one?", "Save Event", MessageBoxButton.YesNoCancel); if (mbr == MessageBoxResult.Yes) { SaveAll(); } else if (mbr == MessageBoxResult.Cancel) { return; } FrcEvent frc = new FrcEvent(ned.EventName); Event = frc; ScoutingJson.SaveEvent(Event, ned.Path); EventPath = ned.Path; if (teamsList != null) { Event.PostJsonLoading(teamsList); } } }
private void Window_Loaded(object sender, RoutedEventArgs e) { hasLoaded = true; LoadSettings(); if (Directory.Exists(EventPathBox.Text)) { Event = ScoutingJson.ParseFrcEvent(EventPathBox.Text); } if (Directory.Exists(TeamsPathBox.Text)) { Teams = ScoutingJson.ParseTeamsList(TeamsPathBox.Text); if (Event != null) { Event.PostJsonLoading(Teams); } } SortDataGrid.ItemsSource = DataGridSummaries; UpdateEventPathBox(); UpdateTeamsPathBox(); RefreshDrives(); }
public void SaveAll() { List <RecordLite> records = MakeRecords(); ConfirmSaveDialog csd = new ConfirmSaveDialog(); bool?result = csd.ShowDialog(); if (result == true) { string rootFolder = csd.SelectedPath; if (!rootFolder.EndsWith("\\")) { rootFolder += "\\"; } if (!Directory.Exists(rootFolder)) { Directory.CreateDirectory(rootFolder); } foreach (RecordLite rec in records) { string teamFolder = rootFolder + rec.TeamID.ToString() + "\\"; if (!Directory.Exists(teamFolder)) { Directory.CreateDirectory(teamFolder); } string recordPath = teamFolder + "Match" + rec.MatchID.ToString("00") + ScoutingJson.LiteRecordExtension; ScoutingJson.SaveLiteRecord(rec, recordPath); } } }
public void MergeMatchRecords() { foreach (RecordedMatch record in Records) { Merging.AdjustTeamInfo(Event, record); } Match merged = Merging.Merge(Event, Records[0], Records[1], Records[2], Records[3], Records[4], Records[5]); int index = Event.Matches.FindIndex((m) => m.Number == merged.Number); if (index != -1) { Event.Matches[index] = merged; } else { Event.Matches.Add(merged); } ScoutingJson.SaveEvent(Event, SavePath + Event.EventName + ScoutingJson.EventExtension); ArchiveRecords(merged.Number); Records = new RecordedMatch[6]; OnPropertyChanged("CanMerge"); }
public void LoadAndTransferRecords(string path) { List <string> files = Directory.EnumerateFiles(path, "*" + ScoutingJson.MatchRecordExtension, SearchOption.TopDirectoryOnly).ToList(); foreach (string f in files) { if (!f.EndsWith(ScoutingJson.MatchRecordExtension)) { continue; } string fn = Util.GetFileName(f, false); int position = GetPositionFromFilename(fn); RecordedMatch rec = ScoutingJson.ParseMatchRecord(f); rec.PostJsonLoading(Event); Records[position] = rec; OnPropertyChanged("CanMerge"); MarkReady(position); bool result = MoveFileToEventPath(f); } }
public void SaveAll() { if (Event == null) { return; } ScoutingJson.SaveEvent(Event, EventPath); }
private void ScoutingMainWindow_Loaded(object sender, RoutedEventArgs e) { DispTimer.Interval = UPDATE_INTERVAL; DispTimer.Tick += timer_Tick; ScoutingJson.Initialize(false); RunSetup(true); }
public void SaveFile() { if (Teams == null) { return; } ScoutingJson.SaveTeamsList(Teams, FilePath); DoSendData(); }
public void UpdateTeamsAndEvent(string path) { if (Event.AllTeams != null) { ScoutingJson.SaveTeamsList(Event.AllTeams, path + "Teams" + ScoutingJson.TeamsListExtension); } ScoutingJson.SaveEvent(Event, path + Event.EventName + ScoutingJson.EventExtension); }
public void LoadCreateAnalysis() { string analysisPath = EventPath + "\\" + Event.EventName + ScoutingJson.AnalysisExtension; if (File.Exists(analysisPath)) { FrcAnalysis = ScoutingJson.ParseAnalysis(analysisPath); } else { FrcAnalysis = new EventAnalysis(Event); } FrcAnalysis.PostJsonLoading(Event); }
public bool IsPathValid() { if (!File.Exists(EventPath)) { return(false); } FrcEvent frc = ScoutingJson.ParseFrcEvent(EventPath); if (frc == null) { return(false); } return(frc.EventName != null && frc.EventName != ""); }
public void LoadEventFile(string file) { if (!File.Exists(file)) { Event = null; } else { Event = ScoutingJson.ParseFrcEvent(file); } EventPath_Color = GetPathBrush(); EventPath_Tooltip = GetPathTooltip(); DoSendData(); }
private void TeamsPathBox_TextChanged(object sender, TextChangedEventArgs e) { if (!hasLoaded || !File.Exists(TeamsPathBox.Text)) { return; } AppSettings.TeamsPath = TeamsPathBox.Text; Teams = ScoutingJson.ParseTeamsList(TeamsPathBox.Text); if (Event != null) { Event.PostJsonLoading(Teams); } UpdateTeamsPathBox(); }
private void EventPathBox_TextChanged(object sender, TextChangedEventArgs e) { if (!hasLoaded || !File.Exists(EventPathBox.Text)) { return; } AppSettings.EventPath = EventPathBox.Text; Event = ScoutingJson.ParseFrcEvent(EventPathBox.Text); if (Teams != null) { Event.PostJsonLoading(Teams); } UpdateEventPathBox(); }
public void CheckForRecordData() { CheckedPaths.Clear(); foreach (string drive in Util.GetAllUsbDrivePaths()) { UpdateModel added = new UpdateModel() { Path = drive }; added.IsSelected = ScoutingJson.HasRecordInFolder(drive); CheckedPaths.Add(added); } OnPropertyChanged("CheckedPaths"); SelectedPathModel = CheckedPaths.FirstOrDefault((um) => um.IsSelected); }
public TeamsViewModel() { ScoutingJson.Initialize(false); BreakCmd = new DoStuffCommand(Break, obj => true); OpenTeamsFileCmd = new DoStuffCommand(OpenFile, obj => true); CellEditedCmd = new DoStuffCommand(OnDataGridCellChanged, obj => true); NewTeamCmd = new DoStuffCommand(OnNewTeamBtn_Clicked, obj => true); DeleteTeamCmd = new DoStuffCommand(OnDeleteTeamBtn_Clicked, obj => true); PropertyChanged += SelectedTeam_Changed; PropertyChanged += TeamsList_Changed; PropertyChanged += TeamsPath_Changed; PropertyChanged += TeamsList_Adjusted; // Load Default FilePath = ScoutingJson.LocalPath + "Teams" + ScoutingJson.TeamsListExtension; }
public void Calculate() { FrcEvent before = Event; try { Event = ScoutingJson.ParseFrcEvent(EventPath + "\\" + Event.EventName + ScoutingJson.EventExtension); FrcAnalysis.Event = Event; } catch (Exception e) { Util.DebugLog(LogLevel.Error, "ANALYSIS", "Could not load Event:\n\t" + e.Message); Event = before; } FrcAnalysis.Calculate(); SaveAnalysis(); }
public void LoadAllRecords() { if (!Directory.Exists(RecordsRoot)) { return; } DirectoryInfo root = new DirectoryInfo(RecordsRoot); List <DirectoryInfo> teamInfos = root.EnumerateDirectories().ToList(); teamInfos.RemoveAll((di) => !di.Name.IsInteger()); AllRecords.Clear(); foreach (DirectoryInfo di in teamInfos) { List <RecordLite> recordSet = new List <RecordLite>(); List <FileInfo> recordFiles = di.EnumerateFiles().ToList(); foreach (FileInfo fi in recordFiles) { RecordLite rec = ScoutingJson.ParseLiteRecord(fi.FullName); if (Event != null && Teams != null) { rec.PostJsonLoading(Event); } recordSet.Add(rec); } AllRecords.Add(recordSet); } if (!hasCrunched) { DoCrunching(); } }
public void LoadTeams(string filepath) { if (!File.Exists(filepath)) { return; } TeamsList temp = ScoutingJson.ParseTeamsList(filepath); if (temp != null) { AppSettings.TeamsFile = filepath; if (Event != null) { Event.PostJsonLoading(temp); UpdateRatingViewsMatch(SelectedMatch); } Teams = temp; } UpdateTextBoxInfo(); }
public void LoadEvent(string filepath) { if (!File.Exists(filepath)) { return; } FrcEvent temp = ScoutingJson.ParseFrcEvent(filepath); if (temp != null) { Event = temp; AppSettings.EventFile = filepath; if (Teams != null) { Event.PostJsonLoading(Teams); } SelectedMatch = Event.Matches.FirstOrDefault(); } UpdateTextBoxInfo(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { var spsd = new StartupPathSelectionDialog(); bool?res = spsd.ShowDialog(); if (res != true) { Application.Current.Shutdown(); return; } Event = ScoutingJson.ParseFrcEvent(spsd.EventPath); Teams = ScoutingJson.ParseTeamsList(spsd.TeamsPath); EventPath = Util.GetFolderPath(spsd.EventPath); if (Event != null && Teams != null) { Event.PostJsonLoading(Teams); } hasLoaded = true; LoadCreateAnalysis(); MatchSelectionList.ItemsSource = Event.Matches; }
public void Save() { string path = SavePathBox.Text; ScoutingJson.SaveMatchRecord(Record, path); }
public StartupPathSelectionDialog() { InitializeComponent(); ScoutingJson.Initialize(false); }
public void DoContextualLoading() { if (CantTakeNo) { OKBtn.IsEnabled = File.Exists(TeamsPathBox.Text) && File.Exists(EventPathBox.Text); } bool matchIDReady = true; if (File.Exists(EventPathBox.Text)) { FrcEvent frc = ScoutingJson.ParseFrcEvent(EventPathBox.Text); if (frc.IsCorrectlyLoaded()) { Settings.Frc = frc; EventPathBox.Foreground = new SolidColorBrush(Colors.Black); EventPathBox.ToolTip = null; } else { EventPathBox.Foreground = new SolidColorBrush(Colors.Red); EventPathBox.ToolTip = "File is invalid or corrupted."; matchIDReady = false; } } else { EventPathBox.Foreground = new SolidColorBrush(Colors.Red); EventPathBox.ToolTip = "File does not exist."; matchIDReady = false; } if (Settings.Frc != null && File.Exists(TeamsPathBox.Text)) { TeamsList teams = ScoutingJson.ParseTeamsList(TeamsPathBox.Text); if (teams != null && teams.IsCorrectlyLoaded()) { Settings.Frc.PostJsonLoading(teams); MatchID = 1; TeamsPathBox.Foreground = new SolidColorBrush(Colors.Black); TeamsPathBox.ToolTip = null; } else { TeamsPathBox.Foreground = new SolidColorBrush(Colors.Red); TeamsPathBox.ToolTip = "File is invalid or corrupted."; matchIDReady = false; } } else { TeamsPathBox.Foreground = new SolidColorBrush(Colors.Red); TeamsPathBox.ToolTip = "File does not exist."; matchIDReady = false; } MatchIDDownBtn.IsEnabled = matchIDReady; MatchIDUpBtn.IsEnabled = matchIDReady; UpdateTeamPreviews(); }
public void SaveAnalysis() { ScoutingJson.SaveAnalysis(FrcAnalysis, EventPath + "\\" + Event.EventName + ScoutingJson.AnalysisExtension); }