/// <summary> /// Deletes the selected video from VideoList. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnDeleteVideo_Click(object sender, RoutedEventArgs e) { Button button = (Button)sender; var list = button.FindName("NewVideoList") as ListBox; SessionViewModel session = (SessionViewModel)this.DataContext; if (list.SelectedItems.Count > 0) { session.VideoList.RemoveAt(list.SelectedIndex); } }
/// <summary> /// Adds a new video to VideoList. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnAddVideo_Click(object sender, RoutedEventArgs e) { VideoModel vm = new VideoModel(); SessionViewModel session = (SessionViewModel)this.DataContext; VideoInputDialog input = new VideoInputDialog(); input.DataContext = vm; if (input.ShowDialog() == true) { vm = (VideoModel)input.DataContext; if (vm.Filename.Length > 0 && vm.Power > 0) { session.VideoList.Add(vm); } } }
/// <summary> /// Loads specific information of the selected session. /// </summary> public void LoadExecutionModel() { _selectedId = _app.SessionsViewModel.SelectedSessionId; // If there is a selected session, loads it, everytime the tab is selected. if (_selectedId > 0) { _sessionVM = new SessionViewModel(_selectedId); _session = _sessionVM.Session; SelectedName = _session.SessionName; HasCalibration = _session.Calibration != null && _session.Calibration.Position != null ? true : false; } else { SelectedName = "Selected name not defined."; } Records = null; Records = new List <CameraSpacePoint[]>(); }
/// <summary> /// Load calibration data of the selected ID. (if a calibration had already been performed.) /// Returns the filename of the selected video for calibration /// Update calibration information of calibration view model. /// </summary> /// <param name="onlyFilename">Gets only filename or load full information</param> public string LoadCalibrationData(bool onlyFilename) { string filename = null; // This attribution is not inside the constructor method because it may be called every time the page is loaded. SessionsViewModel sessionsCtrl = (SessionsViewModel)_app.PageViewModels[0]; _selectedId = sessionsCtrl.SelectedSessionId; if (_selectedId > 0) { var page = _app.PageViewModels.Where(p => p.Name == "Session View"); // If exist already an instance of SessionViewModel, then use it, or instantiate one. if (page.Any()) { _sessionVM = (SessionViewModel)page; } else { _sessionVM = new SessionViewModel(_app); } // Gets persistent Session information. xmlSessionDoc = _sessionVM.XmlSessionDoc; // Find the selected session in order to pick up the calibration video. string xpath = "/Sessions/Session[@Id='{0}']"; xpath = String.Format(xpath, _selectedId); xNode = xmlSessionDoc.DocumentElement.SelectSingleNode(xpath); if (xNode != null) { _session = _sessionVM.LoadSession(xNode); SelectedName = _session.SessionName; foreach (VideoModel video in _session.VideoList) { if (video.IsCalibration) { filename = video.Filename; } } if (_session.Calibration != null && !onlyFilename) { _jointType = _session.Calibration.JointType; NumFrames = _session.Calibration.NumFrames; CalibrationResult = _session.Calibration.Position; CalibrationThreshold = _session.Calibration.Threshold; CalibrationSD = _session.Calibration.SD; InitialTime = _session.Calibration.InitialTime; CalibrationEstimated = _session.Calibration.Estimated; RightShankLength = _session.Calibration.RightShankLength; RightThighLength = _session.Calibration.RightThighLength; LeftShankLength = _session.Calibration.LeftShankLength; LeftThighLength = _session.Calibration.LeftThighLength; ConvertSelectedJointIndex(); _app.SessionsViewModel.CurrentSession = _session; } } } if (filename == null) { CalibrationStatus = "Configuring ...."; ProcessedFrames = 0; CalibrationResult = new Vector3(0, 0, 0); CalibrationSD = new Vector3(0, 0, 0); CalibrationThreshold = new Vector3(0, 0, 0); CalibrationEstimated = new Vector3(0, 0, 0); RightThighLength = 0; RightShankLength = 0; LeftThighLength = 0; LeftShankLength = 0; InitialTime = 0; SelectedJointIndex = 0; NumFrames = 0; } return(filename); }