Beispiel #1
0
        /// <summary>
        /// Hidden UIelement carrying SessionId. It is used to synchronize data between XmlDataProvider
        /// and object data context in order to call Edit and Delete commands on the right session record.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lbId_TextChanged(object sender, TextChangedEventArgs e)
        {
            SessionsViewModel session = (SessionsViewModel)this.DataContext;
            TextBox           txt     = (TextBox)sender;

            session.SessionId = Int32.Parse(txt.Text);
        }
Beispiel #2
0
        private SessionsViewModel _sessionsViewModel;           // List of sessions

        public ApplicationViewModel()
        {
            // Navigation pages
            // Sessions
            _sessionsViewModel = new SessionsViewModel(this);

            // Add all navigation pages.
            PageViewModels.Add(_sessionsViewModel);

            // Set up initial page.
            CurrentPageViewModel = PageViewModels[0];
        }
Beispiel #3
0
        /// <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);
        }