private async Task StartStopFunc() { if (_isOnStart) { TimerInit(); IsOnStart = false; IsSplitViewPaneOpen = false; currentRecordScreen = new RecordScreenModel(_webview.Source.AbsoluteUri, await DoCaptureWebView()); _screens.Add(currentRecordScreen); using (var db = new PrototypingContext()) { Record record = db.Records.Single(rp => rp.RecordId == recordSettings.RecordId); createdDate = DateTime.Now; record.CreatedDate = createdDate; db.Records.Update(record); if (recordSettings.FrontCamera) { string pathtoVideo = await CreateVideoFile(record.RecordId); record.PathToVideo = pathtoVideo; db.Records.Update(record); var encodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto); if (AnalyticsInfo.VersionInfo.DeviceFamily.Equals("Windows.Mobile")) { encodingProfile.Video.Properties.Add(RotationKey, 270); } await _mediaCapture.StartRecordToStorageFileAsync(encodingProfile, videoFile); _isRecording = true; } db.SaveChanges(); } } else { //add lastRecordingDate in user and prototype using (var db = new PrototypingContext()) { Record record = db.Records.Single(rp => rp.RecordId == recordSettings.RecordId); User user = db.Users.Single(u => u.UserId == record.UserId); user.LastRecordingDate = createdDate; db.Users.Update(user); Prototype prototype = db.Prototypes.Single(p => p.PrototypeId == user.PrototypeId); prototype.LastRecordingDate = createdDate; db.Prototypes.Update(prototype); db.SaveChanges(); } ((Windows.UI.Xaml.Controls.Frame)Windows.UI.Xaml.Window.Current.Content).Navigate(typeof(ResultRecordPage), _screens); } }
public async void WebView_ScriptNotify(object sender, Windows.UI.Xaml.Controls.NotifyEventArgs e) { if (e.Value.Contains("tap") && !IsOnStart && recordSettings.Touches) { if (currentRecordScreen == null) { currentRecordScreen = new RecordScreenModel(previousUrl, await DoCaptureWebView()); } float x; float y; string[] arr = e.Value.Split(new char[] { ':' }); if (!float.TryParse(arr[1], out x)) { System.Diagnostics.Debug.WriteLine("ErrorX"); } if (!float.TryParse(arr[2], out y)) { System.Diagnostics.Debug.WriteLine("ErrorY"); } int iX = (int)Math.Round(x); int iY = (int)Math.Round(y); HeatPoint hp = new HeatPoint(iX, iY); currentRecordScreen.ListPoints.Add(hp); if (!_webview.Source.AbsoluteUri.Equals(currentRecordScreen.UriPage)) { int indexFind = _screens.FindIndex(s => s.UriPage.Equals(currentRecordScreen.UriPage)); if (indexFind != -1) { _screens[indexFind].ListPoints = currentRecordScreen.ListPoints; } else { _screens.Add(currentRecordScreen); } indexFind = _screens.FindIndex(s => s.UriPage.Equals(_webview.Source.AbsoluteUri)); if (indexFind != -1) { currentRecordScreen = _screens[indexFind]; } else { currentRecordScreen = null; previousUrl = _webview.Source.AbsoluteUri; } } } }