Example #1
0
 public OverlayPanel(Entities session, PlaybackPage main)
 {
     Session = session;
     Main    = main;
     InitializeComponent();
     SetupButtons();
 }
Example #2
0
        void _new_Click(object sender, RoutedEventArgs args)
        {
            if (!Validate())
            {
                return;
            }
            var duration = (from c in Unordered select
                            c.GetCaptureProperty(CapProp.FrameCount) /
                            c.GetCaptureProperty(CapProp.Fps)).Min();
            var date = (DateTime)_date.SelectedDate +
                       ((DateTime)_time.Value).TimeOfDay;
            var videoHash = 0;

            foreach (var capture in Ordered)
            {
                videoHash ^= capture.GetHashCode();
            }
            Case = new Case()
            {
                Maze      = (Maze)mazeCombo.SelectedItem, Substance = _substance.Text,
                Dose      = _dose.Value, Date = date, Duration = (short)duration,
                Subject   = _subject.Text, Weight = (decimal)_weight.Value,
                VideoHash = videoHash, Notes = _notes.Text,
            };
            try {
                Session.Cases.Add(Case);
                PlaybackPage = new PlaybackPage(Session, Case, Ordered);
                Session.SaveChangesAsync();
            } catch (Exception exc) when(exc is DbEntityValidationException ||
                                         exc is ArgumentException)
            {
                var result = MessageBox.Show(exc.Message, "Error", MessageBoxButton.OK,
                                             MessageBoxImage.Error);

                if (result == MessageBoxResult.OK)
                {
                    NavigationService.GoBack();
                    return;
                }
            }
            NavigationService.Navigate(PlaybackPage);
        }