public TableSubject GetLocalSubject(string id)
        {
            using (SQLiteConnection connection = new SQLiteConnection($"Data Source={App.DatabasePath}"))
            {
                TableSubject RetrievedSubject = null;
                try
                {
                    connection.Open();
                    SQLiteCommand    command = new SQLiteCommand(SubjectByIdQuery(id), connection);
                    SQLiteDataReader reader  = command.ExecuteReader();

                    while (reader.Read())
                    {
                        string filename            = reader["filename"] as string;
                        string image               = CheckLocalPath(filename) ?? reader["image"] as string;
                        double ra                  = (double)reader["ra"];
                        double dec                 = (double)reader["dec"];
                        int    classificationCount = Convert.ToInt32(reader["classifications_count"]);
                        RetrievedSubject = new TableSubject(id, image, ra, dec, classificationCount);
                    }
                    connection.Close();
                } catch (SQLiteException exception)
                {
                    string ErrorMessage = $"Error Connecting to Database. Error: {exception.Message}";
                    Messenger.Default.Send(ErrorMessage, "DatabaseError");
                }
                return(RetrievedSubject);
            }
        }
        void IDroppableArea.Drop(FrameworkElement element)
        {
            TableSubject passedSubject             = element.DataContext as TableSubject;
            ClassificationPanelViewModel viewModel = DataContext as ClassificationPanelViewModel;

            viewModel.DropSubject(passedSubject);
        }
Exemplo n.º 3
0
        private void ShouldShowRetirementModal()
        {
            TableSubject subject = PanoptesServiceMockData.TableSubject();

            subject.IsRetired = true;
            _viewModel.DropSubject(subject);
            Assert.True(_viewModel.ShowRetirementModal);
        }
        public List <TableSubject> GetSubjects(string query, bool returnIfRetired, SpaceNavigation currentLocation = null)
        {
            List <string> idsToUpdate = new List <string>();

            using (SQLiteConnection connection = new SQLiteConnection($"Data Source={App.DatabasePath}"))
            {
                List <TableSubject> Subjects = new List <TableSubject>();
                try
                {
                    connection.Open();
                    SQLiteCommand    command = new SQLiteCommand(query, connection);
                    SQLiteDataReader reader  = command.ExecuteReader();

                    while (reader.Read())
                    {
                        string id = reader["subject_id"] as string;
                        idsToUpdate.Add(id);
                        string       filename            = reader["filename"] as string;
                        string       image               = CheckLocalPath(filename) ?? reader["image"] as string;
                        double       ra                  = (double)reader["ra"];
                        double       dec                 = (double)reader["dec"];
                        int          classificationCount = Convert.ToInt32(reader["classifications_count"]);
                        TableSubject RetrievedSubject    = new TableSubject(id, image, ra, dec, classificationCount, currentLocation);
                        Subjects.Add(RetrievedSubject);
                    }

                    connection.Close();
                } catch (SQLiteException exception)
                {
                    string ErrorMessage = $"Error Connecting to Database. Error: {exception.Message}";
                    Messenger.Default.Send(ErrorMessage, "DatabaseError");
                }
                UpdateDBFromIds(idsToUpdate);

                if (returnIfRetired)
                {
                    return(Subjects);
                }
                else
                {
                    return(Subjects.Any(subject => !subject.IsRetired) ? Subjects : new List <TableSubject>());
                }
            }
        }
 private void AssociatedObject_TouchLeave(object sender, TouchEventArgs e)
 {
     if (DragOverlay == null)
     {
         var visual = e.OriginalSource as Visual;
         DragOverlay = (DragCanvas)UIElementDragBehavior.FindAncestor(typeof(DragCanvas), visual);
     }
     if (isTouchDown && DragOverlay != null)
     {
         TouchPoint touchPosition = e.GetTouchPoint(DragOverlay);
         if (touchPosition != null)
         {
             Point            initialPoint   = new Point(touchPosition.Position.X, touchPosition.Position.Y);
             FrameworkElement adornedElement = sender as FrameworkElement;
             if (initialPoint != null && adornedElement != null)
             {
                 ConstructGhostAdornerWithHandlers(initialPoint, adornedElement, e);
                 using (TableSubject subject = adornedElement.DataContext as TableSubject)
                     GlobalData.GetInstance().Logger?.AddEntry(entry: "Drag_Galaxy", subjectId: subject?.Id);
             }
         }
     }
     isTouchDown = false;
 }