private async void photoCapturedEventHandler(LowLagPhotoSequenceCapture senders, PhotoCapturedEventArgs args) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { try { if (m_frameNum == (m_pastFrame + m_futureFrame)) { btnStartStopPhotoSequence.IsEnabled = false; await m_photoSequenceCapture.StopAsync(); btnStartStopPhotoSequence.IsEnabled = true; btnSaveToFile.IsEnabled = true; ThumbnailGrid.SelectedIndex = m_selectedIndex; } else if (m_frameNum < (m_pastFrame + m_futureFrame)) { var bitmap = new BitmapImage(); m_framePtr[m_frameNum] = args.Frame; bitmap.SetSource(args.Thumbnail); var image = new Image(); image.Source = bitmap; image.Width = 160; image.Height = 120; var ThumbnailItem = new Windows.UI.Xaml.Controls.GridViewItem(); ThumbnailItem.Content = image; ThumbnailGrid.Items.Add(ThumbnailItem); if ((!m_highLighted) && (args.CaptureTimeOffset.Ticks > 0)) { //first picture with timeSpam > 0 get highlighted m_highLighted = true; ThumbnailItem.BorderThickness = new Thickness(1); ThumbnailItem.BorderBrush = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Red); m_selectedIndex = (int)m_ThumbnailNum; } m_ThumbnailNum++; } m_frameNum++; } catch (Exception ex) { ShowExceptionMessage(ex); } }); }
public MainPage() { this.InitializeComponent(); sds = new SampleDataSource(); for (int i = 1; i <= 3; i++) sds.AddGroup(i); selectedItem = Psych; Psych.Foreground = SelectedColor; dataGrid.ItemsSource = sds.grps[0].group; flipStatic.ItemsSource = sds.grps[0].group; }
private async void CameraHelper_OnCaptureOver(List <StorageFile> files, CaptureOverResType overType) { if (overType != CaptureOverResType.Error) { LogHelper.AddString("CaptureTime:" + (DateTime.Now - CaptureTime).TotalMilliseconds.ToString()); } await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { try { foreach (var item in files) { using (var s = await item.OpenReadAsync()) { var bitmap = new BitmapImage(); bitmap.SetSource(s); var image = new Image(); image.Width = 128; image.Height = 72; image.Source = bitmap; var thumbnailItem = new Windows.UI.Xaml.Controls.GridViewItem(); thumbnailItem.Content = image; gvwImageList.Items.Add(thumbnailItem); } await Task.Delay(200); } } catch (Exception ex) { LogHelper.AddString(ex.Message); } finally { BottomAppBar.IsEnabled = true; } }); }
private void Name_Tapped(object sender, TappedRoutedEventArgs e) { (sender as GridViewItem).Foreground = SelectedColor; selectedItem.Foreground = MainForeground; selectedItem = (sender as GridViewItem); var number = Convert.ToInt32((sender as GridViewItem).Tag); dataGrid.ItemsSource = sds.grps[number].group; flipStatic.ItemsSource = sds.grps[number].group; }
private async void photoCapturedEventHandler(LowLagPhotoSequenceCapture senders, PhotoCapturedEventArgs args) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () => { try { if (m_frameNum == (m_pastFrame + m_futureFrame)) { btnStartStopPhotoSequence.IsEnabled = false; await m_photoSequenceCapture.StopAsync(); btnStartStopPhotoSequence.IsEnabled = true; btnSaveToFile.IsEnabled = true; ThumbnailGrid.SelectedIndex = m_selectedIndex; } else if (m_frameNum < (m_pastFrame + m_futureFrame)) { var bitmap = new BitmapImage(); m_framePtr[m_frameNum] = args.Frame; bitmap.SetSource(args.Thumbnail); var image = new Image(); image.Source = bitmap; image.Width = 160; image.Height = 120; var ThumbnailItem = new Windows.UI.Xaml.Controls.GridViewItem(); ThumbnailItem.Content = image; ThumbnailGrid.Items.Add(ThumbnailItem); if ((!m_highLighted) && (args.CaptureTimeOffset.Ticks > 0)) { //first picture with timeSpam > 0 get highlighted m_highLighted = true; ThumbnailItem.BorderThickness = new Thickness(1); ThumbnailItem.BorderBrush = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Red); m_selectedIndex = (int)m_ThumbnailNum; } m_ThumbnailNum++; } m_frameNum++; } catch (Exception ex) { ShowExceptionMessage(ex); } }); }
/// <summary> /// Populates list from response of web service /// </summary> /// <param name="ReportsList"></param> private async void PopulateQueue(ObservableCollection<ReportObject> QueuedList, IReadOnlyList<StorageFile> pf) { //if (refreshMap) //{ // ClearMap(); //} queuedObjectList.Clear(); int count = 0; foreach (var Que in QueuedList) { Image image = new Image(); count++; var file = await pictureFolder.GetFileAsync(count + "_" + Que.ReportType.ToString() + ".png"); var fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read); var img = new BitmapImage(); img.SetSource(fileStream); image.Source = img; GridViewItem ReportView = new GridViewItem(); GridViewItem ImageView = new GridViewItem(); StackPanel listSP = new StackPanel(); LinearGradientBrush lgb = new LinearGradientBrush(); lgb.StartPoint = new Point(.5, 0); lgb.EndPoint = new Point(.5, 1); GradientStop lggs = new GradientStop(); lggs.Color = Color.FromArgb(255, 217, 214, 203); lggs.Offset = 0.0; lgb.GradientStops.Add(lggs); GradientStop ggs = new GradientStop(); ggs.Color = Color.FromArgb(255, 108, 108, 108); ggs.Offset = 1.25; lgb.GradientStops.Add(ggs); listSP.Background = lgb; listSP.Orientation = Orientation.Horizontal; StackPanel reportSP = new StackPanel(); queuedListIndex.Add(Que.ReportId); TextBlock ridTB = new TextBlock() { Text = Que.ReportId.ToString() }; ridTB.Foreground = new SolidColorBrush(Colors.Black); reportSP.Children.Add(ridTB); TextBlock rtypeTB = new TextBlock() { Text = Que.ReportType }; rtypeTB.Foreground = new SolidColorBrush(Colors.Black); reportSP.Children.Add(rtypeTB); TextBlock rtimeTB = new TextBlock() { Text = Que.ReportTime.ToString() }; rtimeTB.Foreground = new SolidColorBrush(Colors.Black); reportSP.Children.Add(rtimeTB); ReportObject queuedReportObject = new ReportObject(Que.ReportId, Que.ReportType, Que.ReportAuthor, Que.ReportDescription, Que.ReportLocation, Que.ReportTime, Que.ReportLatitude, Que.ReportLongitude, Que.ReportAccuracy, Que.ReportDirection); queuedObjectList.Add(queuedReportObject); if (!(queuedReportObject.ReportLatitude == "NA" || queuedReportObject.ReportLongitude == "NA")) { try { AddToMap(queuedReportObject); } catch (Exception) { } } image.Height = 110; image.Width = 175; ImageView.Content = image; ReportView.Content = reportSP; ImageView.AddHandler(UIElement.TappedEvent, new TappedEventHandler(QImageSelected), true); ReportView.AddHandler(UIElement.TappedEvent, new TappedEventHandler(QReportSelected), true); listSP.Children.Add(ReportView); listSP.Children.Add(ImageView); QueuedListView.Items.Add(listSP); } if (count > 0) { if (SIUC311.SettingsView.GetAutoSubmitSetting()) { await WaitablePromptMessage("You have " + count + " reports queued\n\nQueued reports will be automatically submitted."); } else { await WaitablePromptMessage("You have " + count + " reports queued."); } if (haveInternetAccess) { //NotifyUser("Processing queue . . . ", NotifyType.ReportMessage); try { inSession = await SIU311Service.IsSessionAliveAsync(sessionId); // SLOW TAKES TIME } catch (Exception) { inSession = false; } //NotifyUser("Session checked at " + string.Format("{0:M/d/yyyy H:mm:ss tt}", DateTime.Now), NotifyType.ReportMessage); if (inSession) { if (SIUC311.SettingsView.GetAutoSubmitSetting()) { await SubmitQueue(); } } } } }
/// <summary> /// Populates list from response of web service /// </summary> /// <param name="ReportsList"></param> private async void PopulateList(ObservableCollection<SIUC311ServiceRef.ReportObject> ReportsList, bool byOwner) { // add condition from checkbox if (refreshMap) { ClearMap(); reportObjectList.Clear(); } foreach (var Rep in ReportsList) { Image image = new Image(); var photoObject = await SIU311Service.GetPhotoAsync(Rep.ReportId); BitmapImage bimage; if (photoObject != null && photoObject.ReportPhoto != null) { bimage = await ByteToImage(photoObject.ReportPhoto); } else { bimage = new BitmapImage(new Uri("ms-appx:///Assets/ImagePlaceHolder.png")); } string status = await SIU311Service.GetStatusAsync(Rep.ReportId); image.Source = bimage; GridViewItem ReportView = new GridViewItem(); GridViewItem ImageView = new GridViewItem(); StackPanel listSP = new StackPanel(); LinearGradientBrush lgb = new LinearGradientBrush(); lgb.StartPoint = new Point(.5, 0); lgb.EndPoint = new Point(.5, 1); GradientStop lggs = new GradientStop(); lggs.Color = Color.FromArgb(255, 217, 214, 203); lggs.Offset = 0.0; lgb.GradientStops.Add(lggs); GradientStop ggs = new GradientStop(); ggs.Color = Color.FromArgb(255, 108, 108, 108); ggs.Offset = 1.25; lgb.GradientStops.Add(ggs); listSP.Background = lgb; listSP.Orientation = Orientation.Horizontal; StackPanel reportSP = new StackPanel(); reportListIndex.Add(Rep.ReportId); StackPanel idStatusSP = new StackPanel(); idStatusSP.Orientation = Orientation.Horizontal; TextBlock ridTB = new TextBlock() { Text = Rep.ReportId.ToString() }; ridTB.Foreground = new SolidColorBrush(Colors.Black); TextBlock statusTB = new TextBlock() { Text = " : " + status }; statusTB.Foreground = new SolidColorBrush(Colors.Black); idStatusSP.Children.Add(ridTB); idStatusSP.Children.Add(statusTB); reportSP.Children.Add(idStatusSP); TextBlock rtypeTB = new TextBlock() { Text = Rep.ReportType }; rtypeTB.Foreground = new SolidColorBrush(Colors.Black); reportSP.Children.Add(rtypeTB); if (!byOwner) { TextBlock rownTB = new TextBlock() { Text = Rep.ReportAuthor }; rownTB.Foreground = new SolidColorBrush(Colors.Black); reportSP.Children.Add(rownTB); } TextBlock rtimeTB = new TextBlock() { Text = Rep.ReportTime.ToString() }; rtimeTB.Foreground = new SolidColorBrush(Colors.Black); reportSP.Children.Add(rtimeTB); ReportObject reportObject = new ReportObject(Rep.ReportId, Rep.ReportType, Rep.ReportAuthor, Rep.ReportDescription, Rep.ReportLocation, Rep.ReportTime, Rep.ReportLatitude, Rep.ReportLongitude, Rep.ReportAccuracy, Rep.ReportDirection); reportObjectList.Add(reportObject); if (!(reportObject.ReportLatitude == "NA" || reportObject.ReportLatitude == "NA")) { try { AddToMap(reportObject); } catch (Exception) { } } image.Height = 110; image.Width = 175; ImageView.Content = image; ReportView.Content = reportSP; ImageView.AddHandler(UIElement.TappedEvent, new TappedEventHandler(ImageSelected), true); ReportView.AddHandler(UIElement.TappedEvent, new TappedEventHandler(ReportSelected), true); listSP.Children.Add(ReportView); listSP.Children.Add(ImageView); ReportsListView.Items.Add(listSP); } UnLockControls(); }