コード例 #1
0
        /*
         * Method name: OnReceive
         * Purpose: To generate stories when the alarm manager is triggered
         */
        public override void OnReceive(Context context, Intent intent)
        {
            var             _db             = new Database.Database(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), "ShareMyDay.db3");
            StoryGeneration storyGeneration = new StoryGeneration(_db, context);

            storyGeneration.Create();
        }
コード例 #2
0
        /*
         * Method Name: EventsPopulate
         * Purpose: To populate the spinner with events
         */
        public void EventsPopulate()
        {
            StoryGeneration   generator = new StoryGeneration(new Database.Database(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), "ShareMyDay.db3"), _context);
            List <StoryEvent> events    = generator.GetEvents();
            List <string>     list      = new List <string>
            {
                "New Event"
            };

            foreach (var i in events)
            {
                list.Add(i.Value);
            }

            var adapter = new ArrayAdapter <string>(_context,
                                                    Android.Resource.Layout.SimpleSpinnerItem, list);

            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            _spinner.Adapter = adapter;
        }
コード例 #3
0
        public void D_FindStoryById_FindStoryWithId1_ReturnsNotNull()
        {
            StoryEvent storyEvent = new StoryEvent
            {
                Value    = DateTime.Now.ToLongTimeString() + "-" + "Picture Taken",
                DateTime = DateTime.Now,
                Finished = true
            };

            Card card = new Card
            {
                Message      = "test",
                StoryEventId = storyEvent.Id,
                Type         = "1"
            };

            Picture picture = new Picture
            {
                Path    = "Test",
                EventId = storyEvent.Id
            };

            List <Database.Models.VoiceRecording> voiceRecordings = new List <Database.Models.VoiceRecording>
            {
                new Database.Models.VoiceRecording
                {
                    Path    = "Test",
                    EventId = storyEvent.Id
                }
            };

            _db.CreateConnection();

            _db.Create();
            _db.InsertEvent(true, storyEvent, card, picture, voiceRecordings);
            StoryGeneration generator = new StoryGeneration(_db, null);

            generator.Create();
            Assert.IsNotNull(_db.FindStoryById("1"), "FindStoryById_FindStoryWithId1_ReturnsNotNull: Returned Null - No story with Id 1 not found");
        }
コード例 #4
0
        public void C_GetAllStories_GeneratesStory_ReturnsNotNull()
        {
            StoryEvent storyEvent = new StoryEvent
            {
                Value    = DateTime.Now.ToLongTimeString() + "-" + "Picture Taken",
                DateTime = DateTime.Now,
                Finished = true
            };

            Card card = new Card
            {
                Message      = "test",
                StoryEventId = storyEvent.Id,
                Type         = "1"
            };

            Picture picture = new Picture
            {
                Path    = "Test",
                EventId = storyEvent.Id
            };

            List <Database.Models.VoiceRecording> voiceRecordings = new List <Database.Models.VoiceRecording>
            {
                new Database.Models.VoiceRecording
                {
                    Path    = "Test",
                    EventId = storyEvent.Id
                }
            };

            _db.CreateConnection();
            _db.Create();
            _db.InsertEvent(true, storyEvent, card, picture, voiceRecordings);
            StoryGeneration generator = new StoryGeneration(_db, null);

            generator.Create();
            Assert.IsNotNull(_db.GetAllStories(), "GetAllStories_GeneratesStory_ReturnsOneStory: Returned Null - No stories were made");
        }
コード例 #5
0
        /*
         * Method Name: OnCreate
         * Purpose: To dynamically create the list of events page
         */
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Typeface buttonFont = Typeface.CreateFromAsset(Assets, "Kano.otf");

            var             db     = new Database.Database(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), "ShareMyDay.db3");
            StoryGeneration story  = new StoryGeneration(db, this);
            var             events = story.GetEvents();

            LinearLayout outerLayout = new LinearLayout(this)
            {
                Orientation = Orientation.Vertical
            };

            ScrollView innerLayout = new ScrollView(this);

            LinearLayout buttonLayout = new LinearLayout(this)
            {
                Orientation = Orientation.Vertical
            };

            TextView title = new TextView(this)
            {
                Text          = "Today's Events",
                TextSize      = 40,
                TextAlignment = TextAlignment.Center
            };

            title.SetTextColor(Color.Black);
            buttonLayout.AddView(title);

            if (events != null && events.Count != 0)
            {
                foreach (var i in events)
                {
                    Button eventButton = new Button(this)
                    {
                        Text = i.Value
                    };
                    eventButton.SetTypeface(buttonFont, TypefaceStyle.Bold);
                    eventButton.Click += delegate
                    {
                        Intent eventClickIntent = new Intent(this, typeof(EditEventsActivity));
                        eventClickIntent.PutExtra("Event", eventButton.Text);
                        StartActivity(eventClickIntent);
                    };

                    eventButton.SetBackgroundResource(Resource.Drawable.ButtonGenerator);
                    eventButton.SetTextColor(Color.ParseColor("#ffffff"));

                    eventButton.TextSize = 15;


                    buttonLayout.AddView(eventButton,
                                         1415,
                                         450);
                }
            }
            else
            {
                TextView noStoriesTextView = new TextView(this)
                {
                    Text          = "You have not made any events yet. Tap an action card, take a picture or make a voice recording for events to be made.",
                    TextAlignment = TextAlignment.Center,
                    TextSize      = 30,
                };
                noStoriesTextView.SetTextColor(Color.Black);
                buttonLayout.AddView(noStoriesTextView);
            }


            _close = new Button(this);
            _close.SetBackgroundResource(Resource.Drawable.Back);

            _close.Click += delegate
            {
                _close.SetBackgroundResource(Resource.Drawable.BackClicked);
                Intent back = new Intent(this, typeof(TeacherMainMenuActivity));
                StartActivity(back);
            };

            buttonLayout.AddView(_close, ViewGroup.LayoutParams.MatchParent,
                                 450);

            innerLayout.AddView(buttonLayout,
                                ViewGroup.LayoutParams.MatchParent,
                                ViewGroup.LayoutParams.WrapContent);

            outerLayout.AddView(innerLayout);

            SetContentView(outerLayout);
        }
コード例 #6
0
 public void Setup()
 {
     _db = new Database.Database(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "ShareMyDay.db3");
     _db.Create();
     _storyGenerator = new StoryGeneration(_db, null);
 }
コード例 #7
0
        /*
         * Method name: Show
         * Purpose: To display the quick menu
         */
        public void Show()
        {
            Button    button    = _activity.FindViewById <Button>(Resource.Id.quickMenuButton);
            PopupMenu quickMenu = new PopupMenu(_context, button);

            quickMenu.Inflate(Resource.Menu.TeacherQuickMenu);

            quickMenu.MenuItemClick += (s1, arg1) =>
            {
                Console.WriteLine("{0} selected", arg1.Item.TitleFormatted);
                switch (arg1.Item.TitleFormatted.ToString())
                {
                case "Generate Stories":
                    AlertDialog.Builder alertBox = new AlertDialog.Builder(_context);
                    alertBox.SetTitle("Generate Stories");
                    alertBox.SetMessage("Do you want to generate stories? Stories cannot be edited and any new events will not be added once they have been made.");
                    alertBox.SetPositiveButton("Yes", (senderAlert, args) => {
                        Database.Database db            = new Database.Database(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), "ShareMyDay.db3");
                        StoryGeneration storyGeneration = new StoryGeneration(db, _context);
                        storyGeneration.Create();
                        if (db.GetAllStories() != null && db.GetAllStories().Count != 0)
                        {
                            AlertDialog.Builder alertBoxGenerated = new AlertDialog.Builder(_context);
                            alertBoxGenerated.SetTitle("Stories Generated");
                            alertBoxGenerated.SetMessage("Stories have been generated! Go to the story button to see the stories.");
                            alertBoxGenerated.SetNeutralButton("OK", (senderAlerts, argss) => {
                            });
                            alertBoxGenerated.Create();
                            alertBoxGenerated.Show();
                        }
                        else
                        {
                            AlertDialog.Builder noStoriesBox = new AlertDialog.Builder(_context);
                            noStoriesBox.SetTitle("No Stories");
                            noStoriesBox.SetMessage(
                                "No events have been recorded to be able to make stories yet. Please try adding events first.");
                            noStoriesBox.SetNeutralButton("OK", (senderAlertss, argss) => { });
                            noStoriesBox.Create();
                            noStoriesBox.Show();
                        }
                    });
                    alertBox.SetNegativeButton("No", (senderAlert, args) => {
                    });
                    alertBox.Create();
                    alertBox.Show();
                    break;

                case "Take A Picture":
                    var cameraIntent = new Intent(_context, typeof(CameraActivity));
                    cameraIntent.PutExtra("PreviousActivity", "QuickMenu");
                    _activity.StartActivity(cameraIntent);
                    break;

                case "Make A Voice Recording":
                    var voiceRecordingIntent = new Intent(_context, typeof(VoiceRecordingActivity));
                    voiceRecordingIntent.PutExtra("PreviousActivity", "QuickMenu");
                    _activity.StartActivity(voiceRecordingIntent);
                    break;

                case "Go To Main Menu":
                    var mainMenuIntent = new Intent(_context, typeof(TeacherMainMenuActivity));
                    _activity.StartActivity(mainMenuIntent);
                    break;
                }
            };

            quickMenu.DismissEvent += (s2, arg2) => { Console.WriteLine("menu dismissed"); };
            quickMenu.Show();
        }