//Fall2018 Team: to do item?
 //Spring2018 Team: we need to have a way to load task information, but data files should be specified before that
 public static NestedStackLayout LoadLayout(DomainGroup dg, NestedStackLayout par, string n, NestedTypes t, NestedTaskLayout.TaskType tt = NestedTaskLayout.TaskType.PassFail)
 {
     if (t == NestedTypes.Task)
     {
         return(new NestedTaskLayout(dg, par, n, tt));
     }
     else
     {
         return(new NestedStackLayout(dg, par, n, t));
     }
 }
 public static NestedStackLayout CreateLayout(DomainGroup dg, NestedStackLayout par, string n, NestedTypes t, NestedTaskLayout.TaskType tt = NestedTaskLayout.TaskType.PassFail)
 {
     if (t == NestedTypes.Task)
     {
         NestedTaskLayout res = new NestedTaskLayout(dg, par, n, tt);
         res.EditTask();
         return(res);
     }
     else
     {
         return(new NestedStackLayout(dg, par, n, t));
     }
 }
 public Patient(string name, bool fromApp = false)
 {
     PatientName = name;
     //Spring2018 Team: a user will be defining the domains
     if (fromApp)
     {
         DGroup = new DomainGroup();
         DGroup.EmptyInitialize(name);
     }
     else
     {
         //Spring2018 Team: we need to load a DomainGroup here
         DGroup = DomainGroup.LoadDomains(PatientName /*Spring2018 Team: , pathToData*/);
     }
 }
Beispiel #4
0
        //Spring2018 Team: potential function to load a domain from a data file?
        public static DomainGroup LoadDomains(string patient, string path = "")
        {
            if (path == "")
            {
                //Spring2018 Team: provide a test domain
                DomainGroup       result    = new DomainGroup();
                NestedStackLayout testStack = NestedStackLayout.LoadLayout(result, null, patient, NestedStackLayout.NestedTypes.DomainGroup);
                BuildTestNestedLayout(result, orderedTestNames, 0, testStack);
                result.domainLayout = testStack;
                result.SetStack(testStack);
                return(result);
            }

            //Spring2018 Team: otherwise load stuff
            return(null);
        }
Beispiel #5
0
        //Spring2018 Team: this will need to be rewritten to use a data file
        private static void BuildTestNestedLayout(DomainGroup dg, List <List <string> > orderedNames, int curIndex, NestedStackLayout parent)
        {
            if (curIndex >= orderedNames.Count)
            {
                return;
            }
            var names = orderedNames[curIndex];

            foreach (string name in names)
            {
                //Fall2018 Team: we may need to find a better way to do the NestedStackLayout
                //Spring2018 Team: this is a really hacky way to set the NestedStackLayout type but this is just a test
                NestedStackLayout child = NestedStackLayout.LoadLayout(dg, parent, name, (NestedStackLayout.NestedTypes)curIndex + 1);
                BuildTestNestedLayout(dg, orderedNames, curIndex + 1, child);
                parent.AddSubView(child);
            }
        }
        //Spring2018 Team: we default to a PassFail for testing purposes
        public NestedTaskLayout(DomainGroup dg, NestedStackLayout par, string n, TaskType t = TaskType.PassFail)
            : base(dg, par, n, NestedStackLayout.NestedTypes.Task)
        {
            taskType = t;
            switch (taskType)
            {
            case TaskType.Duration:
                taskPage = new DurationTask(this, n);
                break;

            case TaskType.Frequency:
                taskPage = new FrequencyTask(this, n);
                break;

            case TaskType.Opportunity:
                taskPage = new OpportunityTask(this, n);
                break;

            case TaskType.PassFail:
                taskPage = new PassFailTask(this, n);
                break;
            }
        }
Beispiel #7
0
        public DomainGroupEditor(DomainGroup dg, NestedStackLayout orig = null) : base()
        {
            original = orig;
            parent   = dg;
            List <string>            groupNames = new List <string>();
            List <NestedStackLayout> groups     = dg.GetAllStacks();

            foreach (NestedStackLayout ss in groups)
            {
                groupNames.Add(ss.GetName());
            }
            List <NestedStackLayout.NestedTypes> groupTypes = new List <NestedStackLayout.NestedTypes>()
            {
                NestedStackLayout.NestedTypes.Domain, NestedStackLayout.NestedTypes.Subcategory, NestedStackLayout.NestedTypes.Goal, NestedStackLayout.NestedTypes.Task
            };
            List <string> groupTypeNames = new List <string>()
                                           //Fall2018 Team: can we change the names of these according to what the project partner wants?
            {
                "Domain", "Subcategory", "Goal", "Task"
            };
            List <NestedTaskLayout.TaskType> taskTypes = new List <NestedTaskLayout.TaskType>()
            {
                NestedTaskLayout.TaskType.Duration, NestedTaskLayout.TaskType.Frequency, NestedTaskLayout.TaskType.Opportunity, NestedTaskLayout.TaskType.PassFail
            };
            List <string> taskNames = new List <string>()
                                      //Fall2018 Team: option to add icons here that represent these 4 items:
            {
                "Duration", "Frequency", "Opportunity", "PassFail"
            };


            mainView = new ScrollView();
            StackLayout intermediate = new StackLayout();

            newName                         = new Entry();
            newName.Placeholder             = "Enter Name...";
            newName.Text                    = original == null ? "" : original.GetName();
            newName.HorizontalOptions       = LayoutOptions.Center;
            newName.HorizontalTextAlignment = TextAlignment.Center;
            newName.Margin                  = new Thickness(0, 5, 0, 0);
            newName.WidthRequest            = Application.Current.MainPage.Width / 2;

            newDescription = new Editor();
            newDescription.HorizontalOptions = LayoutOptions.FillAndExpand;
            newDescription.BackgroundColor   = Color.GhostWhite;
            newDescription.HeightRequest     = 200;
            newDescription.WidthRequest      = Application.Current.MainPage.Width - 20;
            newDescription.Text = original == null ? "" : original.GetDescription();
            Label descriptionLabel = new Label();

            descriptionLabel.Text = "Details";

            categorySelect = new DropDownList <NestedStackLayout.NestedTypes>(intermediate, "Type", groupTypeNames, groupTypes);
            categorySelect.HeightRequest   = 30;
            categorySelect.VerticalOptions = LayoutOptions.Start;
            if (original != null)
            {
                categorySelect.SetSelected(original.GetStackType());
                categorySelect.Disable();
            }
            categorySelect.OnSelected = new Command(o => CategorySelected((NestedStackLayout.NestedTypes)o));

            parentSelect = new DropDownList <NestedStackLayout>(intermediate, "Parent", groupNames, groups);
            parentSelect.HeightRequest   = 30;
            parentSelect.VerticalOptions = LayoutOptions.Start;
            if (original != null)
            {
                parentSelect.SetSelected(original.GetParent());
            }

            taskSelect = new DropDownList <NestedTaskLayout.TaskType>(intermediate, "Task Type", taskNames, taskTypes);
            taskSelect.VerticalOptions = LayoutOptions.Start;
            if (original != null && original.GetStackType() == NestedStackLayout.NestedTypes.Task)
            {
                taskSelect.HeightRequest = 30;
            }
            else
            {
                taskSelect.HeightRequest = 0;
                taskSelect.IsVisible     = false;
            }

            Button finish = new Button();

            finish.Text     = "Finish";
            finish.Clicked += FinishClicked;

            intermediate.Children.Add(newName);
            intermediate.Children.Add(categorySelect);
            intermediate.Children.Add(taskSelect);
            intermediate.Children.Add(parentSelect);
            intermediate.Children.Add(descriptionLabel);
            intermediate.Children.Add(newDescription);
            intermediate.Children.Add(finish);

            mainView.Content = intermediate;
            Content          = mainView;
        }
Beispiel #8
0
        public PatientManager()
        {
            if (instance != null)
            {
                throw new Exception("There should only be one PatientManager!");
            }
            instance = this;
            patients = new ObservableCollection <Patient>();
            //Fall2018 Team: here is where you can change the names of the default patients in the list
            patients.Add(new Patient("John Doe")
            {
                PatientAge = "18", Gender = "Male"
            });
            patients.Add(new Patient("Jane Doe")
            {
                PatientAge = "8", Gender = "Female"
            });

            //Spring2018 Team: adding a patient with real data
            //Spring2018 Team: using .LoadLayout instead of .CreateLayout because Create will ask for task information
            Patient p = new Patient("Jane", true)
            {
                PatientAge = "14", Gender = "Female"
            };
            DomainGroup       pd = p.DGroup;
            NestedStackLayout dl = pd.domainLayout;

            //Fall2018 Team: here is where we can change the names of the default domains
            NestedStackLayout behavior = NestedStackLayout.LoadLayout(pd, dl,
                                                                      "Behavior", NestedStackLayout.NestedTypes.Domain);
            NestedStackLayout commun = NestedStackLayout.LoadLayout(pd, dl,
                                                                    "Communication", NestedStackLayout.NestedTypes.Domain);
            NestedStackLayout play = NestedStackLayout.LoadLayout(pd, dl,
                                                                  "Play", NestedStackLayout.NestedTypes.Domain);
            NestedStackLayout visual = NestedStackLayout.LoadLayout(pd, dl,
                                                                    "Visual Performance", NestedStackLayout.NestedTypes.Domain);
            NestedStackLayout self = NestedStackLayout.LoadLayout(pd, dl,
                                                                  "Self Care", NestedStackLayout.NestedTypes.Domain);

            dl.AddSubView(behavior);
            dl.AddSubView(commun);
            dl.AddSubView(play);
            dl.AddSubView(visual);
            dl.AddSubView(self);

            //Fall2018 Team: here are the default goals and tasks and subcategory
            NestedStackLayout refrain = NestedStackLayout.LoadLayout(pd, behavior,
                                                                     "Refrain Aggression", NestedStackLayout.NestedTypes.Subcategory);
            NestedStackLayout tSelf = NestedStackLayout.LoadLayout(pd, refrain,
                                                                   "Towards Self", NestedStackLayout.NestedTypes.Goal);
            NestedStackLayout tOthers = NestedStackLayout.LoadLayout(pd, refrain,
                                                                     "Towards Others", NestedStackLayout.NestedTypes.Goal);
            NestedStackLayout restroom = NestedStackLayout.LoadLayout(pd, behavior,
                                                                      "Restroom Training", NestedStackLayout.NestedTypes.Subcategory);
            NestedStackLayout dontHit = NestedStackLayout.LoadLayout(pd, tOthers,
                                                                     "Refrain from hitting others", NestedStackLayout.NestedTypes.Task, NestedTaskLayout.TaskType.PassFail);

            behavior.AddSubView(refrain);
            behavior.AddSubView(restroom);
            refrain.AddSubView(tSelf);
            refrain.AddSubView(tOthers);
            tOthers.AddSubView(dontHit);

            pd.RegisterStack(behavior.GetStackType(), behavior);
            pd.RegisterStack(commun.GetStackType(), commun);
            pd.RegisterStack(play.GetStackType(), play);
            pd.RegisterStack(visual.GetStackType(), visual);
            pd.RegisterStack(self.GetStackType(), self);

            pd.RegisterStack(refrain.GetStackType(), refrain);
            pd.RegisterStack(restroom.GetStackType(), restroom);
            pd.RegisterStack(tSelf.GetStackType(), tSelf);
            pd.RegisterStack(tOthers.GetStackType(), tOthers);
            pd.RegisterStack(dontHit.GetStackType(), dontHit);

            patients.Add(p);
        }
        protected NestedStackLayout(DomainGroup dgPar, NestedStackLayout par, string n, NestedTypes type)
        {
            dgParent  = dgPar;
            parent    = par;
            this.type = type;
            subViews  = new ObservableCollection <View>();

            //Spring2018 Team: special casing for the top-level (displays patient name and add button)
            if (type == NestedTypes.DomainGroup)
            {
                AbsoluteLayout topper = new AbsoluteLayout();
                topper.WidthRequest  = Application.Current.MainPage.Width;
                topper.HeightRequest = 25;

                name.Text = n;
                name.HorizontalTextAlignment = TextAlignment.Center;

                Button add = new Button();
                add.Text     = "Add";
                add.Margin   = new Thickness(0, 0, 10, 0);
                add.Clicked += dgParent.AddButtonPressed;

                AbsoluteLayout.SetLayoutBounds(name, new Rectangle(0.5, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
                AbsoluteLayout.SetLayoutFlags(name, AbsoluteLayoutFlags.PositionProportional);
                AbsoluteLayout.SetLayoutBounds(add, new Rectangle(1, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
                AbsoluteLayout.SetLayoutFlags(add, AbsoluteLayoutFlags.PositionProportional);

                topper.Children.Add(name);
                topper.Children.Add(add);
                Children.Add(topper);

                isChildVisible = true;
            }
            else
            {
                StackLayout nameStack = new StackLayout();
                nameStack.Margin = new Thickness(0, 0, 0, 0);

                name.Text = n;
                name.HorizontalTextAlignment = TextAlignment.Start;
                name.Margin = new Thickness(20, 0, 20, 0);

                nameStack.Orientation = StackOrientation.Horizontal;
                nameStack.Children.Add(name);
                nameStack.Children.Add(complete);
                complete.Margin            = new Thickness(20, 0, 20, 0);
                complete.HorizontalOptions = LayoutOptions.EndAndExpand;
                complete.IsVisible         = false;

                description.Margin = new Thickness(20, 0, 20, 0);
                //Fall2018 Team: I think this is where user taps "add" to add a new item to the list
                name.GestureRecognizers.Add(new TapGestureRecognizer {
                    Command = new Command(() => { ToggleChildVisibility(); })
                });
                name.HorizontalOptions = LayoutOptions.Start;

                StackLayout buttonLayout = new StackLayout();
                buttonLayout.Orientation   = StackOrientation.Horizontal;
                buttonLayout.HeightRequest = 20;
                AddButtons(buttonLayout);

                isChildVisible = false;

                Children.Add(nameStack);
                AddSubView(buttonLayout);
                AddSubView(description);
                Children.Add(divisionLine);
                SetDescription("I am a description for " + n + ".");
            }
            dgParent.RegisterStack(type, this);
        }