Exemplo n.º 1
0
        public ParticipationComparisonMenu(LayoutStack layoutStack, ActivityDatabase activityDatabase, Engine engine)
        {
            this.layoutStack      = layoutStack;
            this.activityDatabase = activityDatabase;
            this.engine           = engine;

            this.SetTitle("Finding which activities often precede another");

            Vertical_GridLayout_Builder builder = new Vertical_GridLayout_Builder();

            this.activityToPredict_box = new ActivityNameEntryBox("Activity:", activityDatabase, layoutStack);
            builder.AddLayout(this.activityToPredict_box);

            builder.AddLayout(new TextblockLayout("Window duration:"));
            this.durationBox = new DurationEntryView();
            builder.AddLayout(this.durationBox);

            this.activityToPredictFrom_box = new ActivityNameEntryBox("Predictor Activity (default = all categories):", activityDatabase, layoutStack);
            builder.AddLayout(this.activityToPredictFrom_box);

            builder.AddLayout(new TextblockLayout("Comparison Type:"));
            this.typebox = new VisiPlacement.CheckBox("Linear Regression", "Bin Comparison");
            builder.AddLayout(this.typebox);

            this.okButton          = new Button();
            this.okButton.Clicked += OkButton_Click;
            builder.AddLayout(new ButtonLayout(this.okButton, "Ok"));

            this.SetContent(builder.Build());
        }
Exemplo n.º 2
0
        public Choose_LayoutDefaults_Layout(IEnumerable <VisualDefaults> choices)
        {
            // title
            Vertical_GridLayout_Builder builder = new Vertical_GridLayout_Builder();

            builder.AddLayout(new TextblockLayout("Choose a theme!"));

            Editor sampleTextbox = new Editor();

            // There's a bug in Uniforms.Misc where it saves the first font you ask about and always returns sizes for that font
            sampleTextbox.Text = "Sample editable text";
            builder.AddLayout(new TextboxLayout(sampleTextbox));

            // individual themes
            List <VisualDefaults> choiceList = new List <VisualDefaults>(choices);
            int        numColumns            = 2;
            int        numRows = (choiceList.Count + 1) / 2;
            GridLayout grid    = GridLayout.New(BoundProperty_List.Uniform(numRows), BoundProperty_List.Uniform(numColumns), LayoutScore.Zero);

            foreach (VisualDefaults choice in choiceList)
            {
                // add a separator so the user can see when it changes
                OverrideLayoutDefaults_Layout container = new OverrideLayoutDefaults_Layout(choice);
                container.SubLayout = this.makeDemoLayout(choice);
                grid.AddLayout(container);
            }
            builder.AddLayout(grid);

            // scrollable
            this.SubLayout = ScrollLayout.New(builder.Build());
        }
Exemplo n.º 3
0
        private void calculate()
        {
            List <Activity> activities = this.engine.ActivitiesSortedByAverageRating;
            List <string>   texts      = new List <string>();

            GridLayout_Builder gridBuilder = new Vertical_GridLayout_Builder().Uniform();

            foreach (Activity activity in activities)
            {
                string text = "" + activity.Ratings.Mean + " (" + activity.Ratings.Weight + ") : " + activity.Name;
                texts.Add(text);
            }
            string   fileText = String.Join("\n", texts);
            DateTime now      = DateTime.Now;
            string   nowText  = now.ToString("yyyy-MM-dd-HH-mm-ss");
            string   fileName = "ActivityPrefSummary-" + nowText + ".txt";

            Task t = this.fileIo.Share(fileName, fileText);

            t.ContinueWith(task =>
            {
                string title = "Exported " + fileName;
                gridBuilder.AddLayout(new TextblockLayout("(" + title + ")"));
                gridBuilder.AddLayout(new TextblockLayout(" avg (count) : name"));
                foreach (string text in texts)
                {
                    gridBuilder.AddLayout(new TextblockLayout(text));
                }

                LayoutChoice_Set newLayout = ScrollLayout.New(gridBuilder.Build());
                this.layoutStack.AddLayout(newLayout, "Preferences");
            });
        }
        private void ConfirmButton_Clicked(object sender, EventArgs e)
        {
            DateTime            start    = DateTime.Now;
            EngineTesterResults results  = this.activityRecommender.TestEngine();
            DateTime            end      = DateTime.Now;
            TimeSpan            duration = end.Subtract(start);

            GridLayout_Builder builder = new Vertical_GridLayout_Builder().Uniform()
                                         .AddLayout(new TextblockLayout("Results"))
                                         .AddLayout(this.resultLayout("typical longtermHappinessPredictionIfSuggested error:\n", results.Longterm_PredictionIfSuggested_Error))
                                         .AddLayout(this.resultLayout("typical longtermHappinessPredictionIfParticipated error:\n", results.Longterm_PredictionIfParticipated_Error))
                                         .AddLayout(this.resultLayout("typicalScoreError:\n", results.TypicalScoreError))
                                         .AddLayout(new TextblockLayout("equivalentWeightedProbability:\n" + results.TypicalProbability))
                                         .AddLayout(this.resultLayout("typicalEfficiencyError:\n", results.TypicalEfficiencyError))
                                         .AddLayout(this.resultLayout("typical longtermEfficiencyIfParticipated error:\n", results.Longterm_EfficiencyIfPredicted_Error));

            ParticipationSurprise surprise = results.ParticipationHavingMostSurprisingScore;

            if (surprise != null)
            {
                builder = builder.AddLayout(new TextblockLayout("Most surprising participation: " + surprise.ActivityDescriptor.ActivityName + " at " +
                                                                surprise.Date + ": expected rating " + surprise.ExpectedRating + ", got " + surprise.ActualRating));
            }

            builder = builder.AddLayout(new TextblockLayout("Computed results in " + duration));
            LayoutChoice_Set resultsView = builder.Build();

            this.layoutStack.AddLayout(resultsView, "Test Results");
        }
        private LayoutChoice_Set makeHelpLayout(bool hasActivities)
        {
            Vertical_GridLayout_Builder builder = new Vertical_GridLayout_Builder();

            builder.AddLayout(new TextblockLayout("This screen is where you will be able to view statistics about things you've done."));
            builder.AddLayout(
                new HelpButtonLayout("There will be cool graphs!",
                                     new HelpWindowBuilder()
                                     .AddMessage("After you've entered some data, this screen will allow you analyze your data in lots of cool ways.")
                                     .AddMessage("You will be able to view a graph of your data, including how much time you spent, how much you liked it, and " +
                                                 "how efficient you were.")
                                     .AddMessage("You will be able to reminisce about your most favorite events and read any nice comment you entered for them.")
                                     .AddMessage("You will be able to search for the most significant events to have happened to you and contemplate how to make the " +
                                                 "happy events occur more often and the sad events occur less often.")
                                     .Build(),
                                     this.layoutStack
                                     )
                );
            builder.AddLayout(new TextblockLayout("Before you can browse things that you've done, you need to go back and do these things first:"));
            if (!hasActivities)
            {
                Button visitActivitiesButton = new Button();
                visitActivitiesButton.Clicked += VisitActivitiesButton_Clicked;
                builder.AddLayout(new ButtonLayout(visitActivitiesButton, "Enter an activity that you like to do"));
            }
            Button recordParticipationsButton = new Button();

            recordParticipationsButton.Clicked += RecordParticipationsButton_Clicked;
            builder.AddLayout(new ButtonLayout(recordParticipationsButton, "Record having participated in an activity"));
            return(builder.Build());
        }
Exemplo n.º 6
0
        public ActivitySuggestion_Explanation_Layout(ActivitySuggestion_Explanation explanation)
        {
            this.explanation = explanation;
            ActivitySuggestion          suggestion = explanation.Suggestion;
            Vertical_GridLayout_Builder builder    = new Vertical_GridLayout_Builder();

            builder.AddLayout(this.newTextBlock("I suggested " + suggestion.ActivityDescriptor.ActivityName + " at " +
                                                explanation.Suggestion.StartDate.ToString("HH:mm") + "\n"));
            builder.AddLayout(this.newTextBlock("I had time to consider " + suggestion.NumActivitiesConsidered + " activities."));
            if (suggestion.ParticipationProbability != null)
            {
                builder.AddLayout(this.newTextBlock("Participation probability: " + Math.Round(suggestion.ParticipationProbability.Value, 3) + "\n"));
            }
            if (suggestion.PredictedScoreDividedByAverage != null)
            {
                builder.AddLayout(this.newTextBlock("Rating: " + Math.Round(explanation.Score, 3) + " (" +
                                                    Math.Round(suggestion.PredictedScoreDividedByAverage.Value, 3) + " x avg)\n"));
            }

            Button explainQuality_button = new Button();

            explainQuality_button.Clicked   += ExplainQuality_button_Clicked;
            explainQuality_button.Text       = "Suggestion quality: " + Math.Round(explanation.SuggestionValue, 3);
            this.suggestionQuality_container = new ContainerLayout();
            builder.AddLayout(this.suggestionQuality_container);
            this.suggestionQuality_container.SubLayout = new ButtonLayout(explainQuality_button);

            this.SubLayout = ScrollLayout.New(builder.Build());
        }
Exemplo n.º 7
0
        public void testList()
        {
            Vertical_GridLayout_Builder builder = new Vertical_GridLayout_Builder();

            for (int i = 0; i < 20; i++)
            {
                builder.AddLayout(new TextblockLayout("Sample text " + i, 16));
            }
            this.Verify(builder.Build(), new Xamarin.Forms.Size(400, 1000), 1784);
        }
Exemplo n.º 8
0
        private LayoutChoice_Set MakeSublayout(double fontSize)
        {
            Vertical_GridLayout_Builder builder = new Vertical_GridLayout_Builder();

            foreach (HelpBlock block in this.components)
            {
                builder.AddLayout(block.Get(fontSize, this.components.Count()));
            }
            return(builder.Build());
        }
Exemplo n.º 9
0
 private LayoutChoice_Set MakeSublayout(double fontSize)
 {
     Vertical_GridLayout_Builder builder = new Vertical_GridLayout_Builder();
     GridLayout gridLayout = GridLayout.New(new BoundProperty_List(this.components.Count()), BoundProperty_List.Uniform(1), LayoutScore.Zero);
     foreach (HelpBlock block in this.components)
     {
         builder.AddLayout(block.Get(fontSize, this.components.Count()));
     }
     return builder.Build();
 }
Exemplo n.º 10
0
        public LayoutChoice_Set Build()
        {
            Vertical_GridLayout_Builder builder = new Vertical_GridLayout_Builder();
            int minIndex = Math.Max(this.contributions.Count - 12, 0);

            for (int i = this.contributions.Count - 1; i >= minIndex; i--)
            {
                builder.AddLayout(this.MakeSublayout(this.contributions[i]));
            }

            return(ScrollLayout.New(builder.Build()));
        }
        private void regenerateEntries()
        {
            List <Inheritance> unchosenInheritances          = this.findUnchosenInheritances();
            List <Inheritance> immediatelyUsableInheritances = this.selectUsableInheritances(unchosenInheritances);

            if (immediatelyUsableInheritances.Count < 1)
            {
                if (this.dismissedInheritances.Count > 0)
                {
                    this.SubLayout = new TextblockLayout("You have already accepted or dismissed all of the built-in activity inheritances. Go back to the Add Activities screen to enter your own!");
                }
                else
                {
                    this.SubLayout = new TextblockLayout("You have already accepted all of the built-in activity inheritances. Go back to the Add Activities screen to enter your own!");
                }
            }
            else
            {
                GridLayout_Builder gridBuilder = new Vertical_GridLayout_Builder().Uniform();
                LayoutChoice_Set   helpLayout  = new HelpWindowBuilder()
                                                 .AddMessage("ActivityRecommender needs to know what you like to do, for providing suggestions, autocomplete, and more.")
                                                 .AddMessage("Do you like any of the activities here?")
                                                 .AddMessage("Selecting 'I like this' on an item of the form 'child (parent)' indicates two things: A: that you believe that the child is encompassed by the parent, and B: that the child is relevant to you.")
                                                 .AddMessage("Pushing the 'I like all kinds' button is equivalent to pushing the 'I like this' button on the given activity and all of its descendants.")
                                                 .AddMessage("Pushing the 'Not Interested' button will simply hide the given activity in this screen")
                                                 .Build();

                gridBuilder.AddLayout(new TextblockLayout("Press everything you like to do! Then go back.\n" +
                                                          "" + unchosenInheritances.Count + " remaining, built-in activity ideas:", 30).AlignHorizontally(TextAlignment.Center));

                int count = 0;
                foreach (Inheritance inheritance in immediatelyUsableInheritances)
                {
                    int numDescendants = this.FindDescendants(inheritance).Count;
                    Import_SpecificActivities_Layout specific = new Import_SpecificActivities_Layout(inheritance, numDescendants);
                    specific.Dismissed      += DismissedInheritance;
                    specific.AcceptedSingle += AcceptedSingleInheritance;
                    specific.AcceptedAll    += AcceptedInheritanceRecursive;
                    gridBuilder.AddLayout(specific);
                    // Don't display too many results at once to avoid taking to long to update the screen.
                    // The user should dismiss the ones they're not interested in, anyway
                    count++;
                    if (count >= 10)
                    {
                        gridBuilder.AddLayout(new TextblockLayout("Dismiss or accept an idea to see more!"));
                        break;
                    }
                }
                gridBuilder.AddLayout(new HelpButtonLayout(helpLayout, this.layoutStack, 30));

                this.SubLayout = ScrollLayout.New(gridBuilder.Build());
            }
        }
        public void UpdateLayout()
        {
            Vertical_GridLayout_Builder builder        = new Vertical_GridLayout_Builder();
            List <TextRule>             TextPredicates = this.userPreferencesDatabase.ScoringRules;

            foreach (TextRule rule in TextPredicates)
            {
                string text       = rule.ToString();
                Button ruleButton = new Button();
                ruleButton.Clicked += RuleButton_Clicked;
                ButtonLayout buttonLayout = new ButtonLayout(ruleButton, text, 16);
                builder.AddLayout(buttonLayout);
            }
            this.SubLayout = ScrollLayout.New(builder.Build());
        }
        private void draw()
        {
            Vertical_GridLayout_Builder mainGrid_builder = new Vertical_GridLayout_Builder();

            mainGrid_builder.AddLayout(new TextblockLayout(participation.ActivityDescriptor.ActivityName, 30));
            mainGrid_builder.AddLayout(new TextblockLayout(participation.StartDate.ToString() + " - " + participation.EndDate.ToString(), 16));
            if (showCalculatedValues)
            {
                if (participation.GetAbsoluteRating() != null)
                {
                    mainGrid_builder.AddLayout(new TextblockLayout("Score: " + participation.GetAbsoluteRating().Score, 16));
                }
                if (participation.RelativeEfficiencyMeasurement != null)
                {
                    string message = "Efficiency: " + participation.RelativeEfficiencyMeasurement.RecomputedEfficiency.Mean;
                    mainGrid_builder.AddLayout(new HelpButtonLayout(message, new ExperimentResultsView(participation), layoutStack, 16));
                }
                Distribution netPresentHappiness = ratingSummarizer.GetValueDistributionForDates(participation.StartDate, ratingSummarizer.LatestKnownDate, true, true);
                if (netPresentHappiness.Weight > 0)
                {
                    mainGrid_builder.AddLayout(new TextblockLayout("Net present happiness: " + netPresentHappiness.Mean));
                }
            }
            if (participation.Comment != null)
            {
                mainGrid_builder.AddLayout(new TextblockLayout("Comment: " + participation.Comment, 16));
            }
            if (participation.PostComments.Count > 0)
            {
                foreach (ParticipationComment comment in participation.PostComments)
                {
                    mainGrid_builder.AddLayout(new TextblockLayout("Comment on " + comment.CreatedDate + ":" + comment.Text));
                }
            }
            if (showCalculatedValues)
            {
                this.feedbackHolder = new ContainerLayout();
                Button feedbackButton = new Button();
                feedbackButton.Clicked       += FeedbackButton_Clicked;
                this.feedbackHolder.SubLayout = new ButtonLayout(feedbackButton, "Compute Feedback");
                mainGrid_builder.AddLayout(this.feedbackHolder);
            }
            New_ParticipationComment_Layout commentBox = new New_ParticipationComment_Layout(participation, this.layoutStack);

            commentBox.AddParticipationComment += CommentBox_AddParticipationComment;
            mainGrid_builder.AddLayout(new HelpButtonLayout("Add comment", commentBox, layoutStack));
            this.SubLayout = mainGrid_builder.Build();
        }
Exemplo n.º 14
0
 private void makeArrows()
 {
     this.arrowLayouts = new List <LayoutChoice_Set>();
     for (int i = 0; i < this.itemLayouts.Count; i++)
     {
         GridLayout_Builder arrowBuilder = new Vertical_GridLayout_Builder().Uniform();
         if (i != 0)
         {
             arrowBuilder.AddLayout(this.Make_PrevButton(i));
         }
         if (i != this.itemLayouts.Count - 1)
         {
             arrowBuilder.AddLayout(this.Make_NextButton(i));
         }
         this.arrowLayouts.Add(arrowBuilder.Build());
     }
 }
Exemplo n.º 15
0
        public DemoLayout(ViewManager viewManager, ActivityDatabase activityDatabase)
        {
            this.viewManager      = viewManager;
            this.activityDatabase = activityDatabase;

            Vertical_GridLayout_Builder builder = new Vertical_GridLayout_Builder();

            builder.AddLayout(new TextblockLayout("Usage Demo"));
            this.feedbackLabel = new TextblockLayout();
            this.feedbackLabel.setText("You probably don't want to use this feature because it will make changes to your data.");
            builder.AddLayout(this.feedbackLabel);
            Button okButton = new Button();

            okButton.Clicked += OkButton_Clicked;
            builder.AddLayout(new ButtonLayout(okButton, "See Demo!"));
            this.SubLayout = builder.Build();
        }
        public ActivityVisualizationMenu(Engine engine, LayoutStack layoutStack)
        {
            this.SetTitle("View Statistics");
            this.engine      = engine;
            this.layoutStack = layoutStack;

            GridLayout_Builder gridBuilder = new Vertical_GridLayout_Builder().Uniform();

            this.yAxisNameBox = new ActivityNameEntryBox("Activity", engine.ActivityDatabase, layoutStack);
            gridBuilder.AddLayout(this.yAxisNameBox);

            this.okButton          = new Button();
            this.okButton.Clicked += OkButton_Clicked;

            gridBuilder.AddLayout(new ButtonLayout(this.okButton, "Visualize"));

            this.SetContent(gridBuilder.Build());
        }
Exemplo n.º 17
0
        private LayoutChoice_Set MakeSublayout(AppContribution contribution)
        {
            // get some properties
            AppContributor who         = contribution.Contributor;
            string         name        = who.Name;
            string         when        = contribution.DateTime.ToString("yyyy-MM-dd");
            string         description = contribution.Description;
            double         fontSize    = 16;
            double         nameSize    = 30;

            // build the name button layout
            LayoutChoice_Set nameLayout;

            if (who.Email != null || who.Website != null)
            {
                // If this contributor provided details, then make a button to show those details
                Vertical_GridLayout_Builder detailBuilder = new Vertical_GridLayout_Builder();
                detailBuilder.AddLayout(new TextblockLayout("Contributor Name: " + name, fontSize));
                if (who.Email != null)
                {
                    detailBuilder.AddLayout(new TextblockLayout("Email: " + who.Email, fontSize));
                }
                if (who.Website != null)
                {
                    detailBuilder.AddLayout(new TextblockLayout("Website: " + who.Website, fontSize));
                }
                nameLayout = new HelpButtonLayout(name, detailBuilder.Build(), layoutStack, nameSize);
            }
            else
            {
                // If this contributor didn't provide details, then just display their name
                TextblockLayout l = new TextblockLayout(name, nameSize);
                l.AlignHorizontally(TextAlignment.Center);
                nameLayout = l;
            }

            // build the rest of the layout
            Vertical_GridLayout_Builder fullBuilder = new Vertical_GridLayout_Builder();

            fullBuilder.AddLayout(nameLayout);
            fullBuilder.AddLayout(new TextblockLayout("On " + when + ": " + description, fontSize));
            fullBuilder.AddLayout(new TextblockLayout("Thanks!", fontSize));
            return(fullBuilder.Build());
        }
        private LayoutChoice_Set Make_StatsView()
        {
            // many of the entries in this function are disabled because they're probably not that useful but might be worth re-adding somehow

            // setup a display for some statistics
            GridLayout_Builder builder = new Vertical_GridLayout_Builder().Uniform();

            // display an editable date range
            this.participationDataDisplay = new TitledControl("Stats:");
            this.queryStartDateDisplay    = new DateEntryView("From", this.layoutStack);
            this.queryStartDateDisplay.SetDay(this.yAxisActivity.GetEarliestInteractionDate());
            this.queryStartDateDisplay.Add_TextChanged_Handler(new EventHandler <TextChangedEventArgs>(this.DateTextChanged));
            builder.AddLayout(this.queryStartDateDisplay);
            this.queryEndDateDisplay = new DateEntryView("until", this.layoutStack);
            this.queryEndDateDisplay.SetDay(DateTime.Today.AddDays(1));
            this.queryEndDateDisplay.Add_TextChanged_Handler(new EventHandler <TextChangedEventArgs>(this.DateTextChanged));
            builder.AddLayout(this.queryEndDateDisplay);

            // display the total time spanned by the current window
            this.totalTimeDisplay = new TextblockLayout();
            this.totalTimeDisplay.AlignHorizontally(TextAlignment.Center);
            builder.AddLayout(this.totalTimeDisplay);
            this.timeFractionDisplay = new TextblockLayout();
            this.timeFractionDisplay.AlignHorizontally(TextAlignment.Center);
            builder.AddLayout(this.timeFractionDisplay);
            this.timePerInstance_Display = new TextblockLayout();
            this.timePerInstance_Display.AlignHorizontally(TextAlignment.Center);
            builder.AddLayout(this.timePerInstance_Display);

            // display rating statistics
            this.ratingWhenNotSuggested_Display      = new TitledTextblock("Mean rating:");
            this.ratingWhenNotSuggested_Display.Text = Math.Round(this.yAxisActivity.Ratings.Mean, 5).ToString();
            builder.AddLayout(this.ratingWhenNotSuggested_Display);

            this.ratingWhenSuggested_Display      = new TitledTextblock("Mean rating when suggested:");
            this.ratingWhenSuggested_Display.Text = Math.Round(this.yAxisActivity.RatingsWhenSuggested.Mean, 5).ToString();
            builder.AddLayout(this.ratingWhenSuggested_Display);


            builder.AddLayout(this.make_helpLayout());

            return(builder.Build());
        }
        private void updateLayout()
        {
            Vertical_GridLayout_Builder largeFont_builder = new Vertical_GridLayout_Builder();
            Vertical_GridLayout_Builder smallFont_builder = new Vertical_GridLayout_Builder();

            foreach (string url in this.FeedUrls)
            {
                Button feedButton = new Button();
                feedButton.Clicked += FeedButton_Clicked;
                largeFont_builder.AddLayout(new ButtonLayout(feedButton, url, 24, true, false, false, true));
                smallFont_builder.AddLayout(new ButtonLayout(feedButton, url, 16, true, false, false, true));
            }

            LayoutChoice_Set topLayout = ScrollLayout.New(new LayoutUnion(largeFont_builder.Build(), smallFont_builder.Build()));

            this.SubLayout = new Vertical_GridLayout_Builder()
                             .AddLayout(topLayout)
                             .AddLayout(this.newFeedsLayout)
                             .Build();
        }
Exemplo n.º 20
0
        public Browse_RecentSignificantActivities_Layout(Engine engine, ScoreSummarizer scoreSummarizer, LayoutStack layoutStack)
        {
            this.SetTitle("Significant recent activities");
            this.engine          = engine;
            this.scoreSummarizer = scoreSummarizer;
            this.layoutStack     = layoutStack;

            Button okButton = new Button();

            okButton.Clicked += OkButton_Clicked;

            this.durationLayout = new DurationEntryView();

            GridLayout_Builder gridBuilder = new Vertical_GridLayout_Builder().Uniform();

            gridBuilder.AddLayout(new TextblockLayout("What changed your happiness most"));
            gridBuilder.AddLayout(new TitledControl("in the last:", durationLayout));
            gridBuilder.AddLayout(new ButtonLayout(okButton, "OK"));
            this.SetContent(gridBuilder.Build());
        }
        public ExperimentationDifficultySelectionLayout(List <SuggestedMetric> suggestions, ActivityDatabase activityDatabase)
        {
            int requiredNumChoices = 3;

            if (suggestions.Count != requiredNumChoices)
            {
                throw new ArgumentException("ExperimentationDifficultySelectionLayout unsupported number of choices: got " + suggestions.Count + ", expected " + requiredNumChoices);
            }

            this.difficultyOptions = new List <ExperimentDifficultyEstimateLayout>();

            for (int i = 0; i < 3; i++)
            {
                this.difficultyOptions.Add(this.newItem(suggestions[i], activityDatabase));
            }

            string instructions = "Estimate the relative difficulty for each of these tasks. Also, you may change which metric you would like to use to measure your efficiency.";

            Button okButton = new Button();

            okButton.Clicked        += OkButton_Clicked;
            this.okButtonLayout      = new ButtonLayout(okButton, "Accept");
            this.invalidOrder_layout = new TextblockLayout("Illegal ordering! Each difficulty must be a positive number!");
            this.okButtonHolder      = new ContainerLayout();


            GridLayout_Builder builder = new Vertical_GridLayout_Builder().Uniform();

            builder.AddLayout(new TextblockLayout(instructions));
            foreach (ExperimentDifficultyEstimateLayout option in this.difficultyOptions)
            {
                builder.AddLayout(option);
            }
            builder.AddLayout(this.okButtonHolder);

            this.updateValidity();

            this.SubLayout = builder.Build();
        }
Exemplo n.º 22
0
        public TextMeasurement_Test_Layout()
        {
            GridLayout_Builder gridBuilder = new Vertical_GridLayout_Builder().Uniform();

            Editor textBox = new Editor();

            textBox.TextChanged += TextBox_TextChanged;
            this.textBox         = textBox;
            gridBuilder.AddLayout(new TextboxLayout(textBox, 16));

            for (double i = 0; i < 8; i += 1)
            {
                Label textBlock1 = new Label();
                textBlock1.BackgroundColor = Color.Red;
                TextblockLayout textBlockLayout = new TextblockLayout(textBlock1, i + 16, false, true);
                textBlockLayout.ScoreIfEmpty = false;
                gridBuilder.AddLayout(textBlockLayout);
                this.textBlockLayouts.Add(textBlockLayout);
            }

            this.SubLayout = ScrollLayout.New(gridBuilder.Build());
        }
        public Customize_FeedUrls_Layout(UserPreferences_Database userPreferencesDatabase)
        {
            // save some properties
            this.userPreferencesDatabase = userPreferencesDatabase;

            // setup display
            Vertical_GridLayout_Builder newFeedBuilder = new Vertical_GridLayout_Builder();
            TextblockLayout             newFeedHelp    = new TextblockLayout("Add new feed:");

            newFeedHelp.setBackgroundColor(Color.Black);
            newFeedHelp.setTextColor(Color.White);
            newFeedBuilder.AddLayout(newFeedHelp);
            this.newFeedBox = new Editor();
            newFeedBuilder.AddLayout(new TextboxLayout(this.newFeedBox));
            Button newFeedButton = new Button();

            newFeedButton.Clicked += NewFeedButton_Clicked;
            newFeedBuilder.AddLayout(new ButtonLayout(newFeedButton, "Add"));

            this.newFeedsLayout = newFeedBuilder.Build();

            this.updateLayout();
        }
        public TextMeasurement_Test_Layout()
        {
            Vertical_GridLayout_Builder grid1Builder = new Vertical_GridLayout_Builder().Uniform();

            //GridLayout grid2 = GridLayout.New(new BoundProperty_List(1), new BoundProperty_List(2), LayoutScore.Zero, 0.0625);
            Editor textBox = new Editor();

            textBox.TextChanged += TextBox_TextChanged;
            this.textBox         = textBox;
            grid1Builder.AddLayout(new TextboxLayout(textBox, 16));

            Label textBlock = new Label();

            textBlock.BackgroundColor           = Color.Red;
            this.textBlockLayout                = new TextblockLayout(textBlock, 16, false, true);
            this.textBlockLayout.ScoreIfEmpty   = false;
            this.textBlockLayout.LoggingEnabled = true;
            //grid2.PutLayout(this.textBlockLayout, 0, 0);
            //grid2.PutLayout(new ImageLayout(null, LayoutScore.Get_MinPriorityScore_ForTesting(1)), 1, 0);

            grid1Builder.AddLayout(this.textBlockLayout);
            this.SubLayout = grid1Builder.Build();
        }
Exemplo n.º 25
0
        public ProtoActivity_Editing_Layout(ProtoActivity protoActivity, ProtoActivity_Database database, ActivityDatabase activityDatabase, LayoutStack layoutStack)
        {
            this.protoActivity    = protoActivity;
            this.database         = database;
            this.activityDatabase = activityDatabase;
            this.activityDatabase.ActivityAdded += ActivityDatabase_ActivityAdded;
            this.layoutStack  = layoutStack;
            this.textBox      = new Editor();
            this.textBox.Text = protoActivity.Text;

            Vertical_GridLayout_Builder gridBuilder = new Vertical_GridLayout_Builder();
            string titleText;

            if (protoActivity.Id >= 0)
            {
                titleText = "ProtoActivity #" + protoActivity.Id;
            }
            else
            {
                titleText = "New ProtoActivity";
            }
            gridBuilder.AddLayout(new TextblockLayout(titleText));
            gridBuilder.AddLayout(ScrollLayout.New(new TextboxLayout(this.textBox)));

            Button saveButton = new Button();

            saveButton.Text     = "Save";
            saveButton.Clicked += SaveButton_Clicked;

            Button promoteButton = new Button();

            promoteButton.Text     = "Promote to Activity";
            promoteButton.Clicked += PromoteButton_Clicked;

            Button splitButton = new Button();

            splitButton.Text     = "Split";
            splitButton.Clicked += SplitButton_Clicked;

            HelpButtonLayout helpButtonLayout = new HelpButtonLayout(new HelpWindowBuilder()
                                                                     .AddMessage("This screen allows you to edit " + titleText + ".")
                                                                     .AddMessage("Enter as much text as you like.")
                                                                     .AddMessage("To save your entry, either press Save or simply go back to another screen.")
                                                                     .AddMessage("  After you go back, if you later want to return to this same ProtoActivity, you will have to go to one of the screens for browsing existing ProtoActivities and then search for it.")
                                                                     .AddMessage("To turn this ProtoActivity into an Activity, press Promote to Activity.")
                                                                     .AddMessage("To delete this ProtoActivity, delete all of the text in the box and then either press Save or go back to a previous screen.")
                                                                     .AddLayout(new CreditsButtonBuilder(layoutStack)
                                                                                .AddContribution(ActRecContributor.AARON_SMITH, new DateTime(2019, 9, 16), "Pointed out that the promote-a-protoactivity button crashed if the text box was empty")
                                                                                .Build()
                                                                                )
                                                                     .Build()
                                                                     , layoutStack);

            LayoutChoice_Set buttonsLayout = new Horizontal_GridLayout_Builder()
                                             .AddLayout(new ButtonLayout(saveButton))
                                             .AddLayout(new ButtonLayout(promoteButton))
                                             .AddLayout(new ButtonLayout(splitButton))
                                             .AddLayout(helpButtonLayout)
                                             .BuildAnyLayout();

            gridBuilder.AddLayout(buttonsLayout);

            this.SubLayout = gridBuilder.Build();
        }
        public void setup(Activity activity)
        {
            this.activity = activity;
            List <Activity> children = activity.GetChildren();
            List <Activity> parents  = activity.Parents;
            string          title;

            if (activity == this.activityDatabase.RootActivity)
            {
                title = activity.Name + " is the built-in root activity.";
            }
            else
            {
                title = activity.Name;
                if (activity is Category)
                {
                    if (activity.IsSolution)
                    {
                        title += " (Category, Solution)";
                    }
                    else
                    {
                        title += " (Category)";
                    }
                }
                else if (activity is ToDo)
                {
                    title += " (ToDo)";
                }
                else if (activity is Problem)
                {
                    title += " (Problem)";
                }
            }
            this.SetTitle(title);
            this.TitleLayout.AlignHorizontally(Xamarin.Forms.TextAlignment.Start);


            Vertical_GridLayout_Builder gridBuilder = new Vertical_GridLayout_Builder();


            ToDo todo = activity as ToDo;

            if (todo != null)
            {
                if (todo.IsCompleted())
                {
                    if (todo.WasCompletedSuccessfully())
                    {
                        gridBuilder.AddLayout(new TextblockLayout("Status: Completed"));
                    }
                    else
                    {
                        gridBuilder.AddLayout(new TextblockLayout("Status: Obsolete"));
                    }
                }
                else
                {
                    gridBuilder.AddLayout(new TextblockLayout("Status: Incomplete"));
                }
            }

            foreach (Metric metric in activity.IntrinsicMetrics)
            {
                gridBuilder.AddLayout(new TextblockLayout("Has metric: " + metric.Name));
            }
            foreach (Metric metric in activity.InheritedMetrics)
            {
                gridBuilder.AddLayout(new TextblockLayout("Inherited metric: " + metric.Name));
            }
            if (parents.Count > 0)
            {
                gridBuilder.AddLayout(this.newListView(parents.Count.ToString() + " Parents:", parents));
            }

            List <Activity> openChildTodos      = new List <Activity>();
            List <Activity> completedChildTodos = new List <Activity>();
            List <Activity> childCategories     = new List <Activity>();
            List <Activity> childProblems       = new List <Activity>();

            foreach (Activity child in children)
            {
                ToDo childToDo = child as ToDo;
                if (childToDo != null)
                {
                    if (childToDo.IsCompleted())
                    {
                        completedChildTodos.Add(childToDo);
                    }
                    else
                    {
                        openChildTodos.Add(childToDo);
                    }
                }
                else if (child is Category)
                {
                    childCategories.Add(child);
                }
                else if (child is Problem)
                {
                    childProblems.Add(child);
                }
                else
                {
                    throw new InvalidCastException("Unrecognized object type " + child);
                }
            }

            if (children.Count > 0)
            {
                List <Activity> sortedToDos = new List <Activity>();
                sortedToDos.AddRange(openChildTodos);
                sortedToDos.AddRange(completedChildTodos);

                List <Activity> allOpenTodos = new List <Activity>();
                foreach (Activity otherToDo in activity.OtherOpenTodos)
                {
                    allOpenTodos.Add(otherToDo);
                }

                if (childCategories.Count > 0)
                {
                    gridBuilder.AddLayout(this.newListView(" " + childCategories.Count.ToString() + " Children of type Category:", childCategories));
                }
                if (sortedToDos.Count > 0)
                {
                    gridBuilder.AddLayout(this.newListView(" " + sortedToDos.Count.ToString() + " Children of type ToDo:", sortedToDos));
                }
                if (childProblems.Count > 0)
                {
                    gridBuilder.AddLayout(this.newListView(" " + childProblems.Count.ToString() + " Children of type Problem:", childProblems));
                }
                if (allOpenTodos.Count > openChildTodos.Count)
                {
                    gridBuilder.AddLayout(this.newListView(" " + allOpenTodos.Count.ToString() + " Total open ToDos:", allOpenTodos));
                }
            }

            gridBuilder.AddLayout(new TextblockLayout("You've done this " + activity.NumParticipations + " times since " + activity.DiscoveryDate.ToString("yyyy-MM-dd")));

            // If this activity has never been used, then it should be safe to delete it
            if (this.supportDeletion)
            {
                if (activity.GetChildren().Count < 1 && activity.NumParticipations < 1 && activity.NumConsiderations < 1 && !activity.HasAMetric)
                {
                    Button deleteButton = new Button();
                    deleteButton.Clicked += DeleteButton_Clicked;
                    gridBuilder.AddLayout(new ButtonLayout(deleteButton, "Delete"));
                }
            }

            this.SetContent(gridBuilder.Build());
        }
Exemplo n.º 27
0
        public ParticipationCorrelationView(Engine engine, IEnumerable <Activity> activitiesToPredictFrom, Activity activityToPredict, TimeSpan windowSize)
        {
            DateTime now = DateTime.Now;

            engine.EnsureRatingsAreAssociated();

            LinearProgression progressionToPredict = activityToPredict.ParticipationsSmoothed((new TimeSpan()).Subtract(windowSize));

            StatList <double, Activity> results = new StatList <double, Activity>(new DoubleComparer(), new NoopCombiner <Activity>());

            foreach (Activity activity in activitiesToPredictFrom)
            {
                System.Diagnostics.Debug.WriteLine("comparing " + activity + " and " + activityToPredict.Name);
                List <Datapoint> datapoints = activity.compareParticipations(windowSize, progressionToPredict, now.Subtract(windowSize));

                // now compute the value of the formula
                Correlator correlator = new Correlator();
                foreach (Datapoint datapoint in datapoints)
                {
                    correlator.Add(datapoint);
                }

                double outputIncreasePerInputIncrease = correlator.Slope;
                if (!double.IsNaN(outputIncreasePerInputIncrease))
                {
                    results.Add(outputIncreasePerInputIncrease, activity);
                }
            }

            IEnumerable <ListItemStats <double, Activity> > resultList = results.AllItems;

            GridLayout_Builder layoutBuilder = new Vertical_GridLayout_Builder().Uniform();
            List <ListItemStats <double, Activity> > mostPositivelyCorrelated = new List <ListItemStats <double, Activity> >();
            List <ListItemStats <double, Activity> > mostNegativelyCorrelated = new List <ListItemStats <double, Activity> >();
            int i            = 0;
            int numPositives = Math.Min(4, resultList.Count());

            foreach (ListItemStats <double, Activity> result in resultList.Reverse())
            {
                mostPositivelyCorrelated.Add(result);
                i++;
                if (i > numPositives)
                {
                    break;
                }
            }
            i = 0;
            int numNegatives = Math.Min(4, resultList.Count() - numPositives);

            foreach (ListItemStats <double, Activity> result in resultList)
            {
                mostNegativelyCorrelated.Add(result);
                i++;
                if (i > numNegatives)
                {
                    break;
                }
            }

            if (resultList.Count() <= 0)
            {
                // This shouldn't be able to happen unless we disallow predicting the activity from itself
                this.SubLayout = new TextblockLayout("No activities found!");
            }
            else
            {
                string title = "Things you do that are correlated with doing more or less of " + activityToPredict.Name + " over the following " +
                               Math.Round(windowSize.TotalDays, 0) + " days";
                layoutBuilder.AddLayout(new TextblockLayout(title));

                if (numPositives > 0)
                {
                    if (numPositives > 1)
                    {
                        layoutBuilder.AddLayout(new TextblockLayout("Doing one minute of these activities adds this many minutes:"));
                    }
                    else
                    {
                        layoutBuilder.AddLayout(new TextblockLayout("Doing one minute of this activity adds this many minutes:"));
                    }
                    foreach (ListItemStats <double, Activity> result in mostPositivelyCorrelated)
                    {
                        double   correlation = result.Key;
                        Activity activity    = result.Value;
                        String   message     = activity.Name + ": " + Math.Round(correlation, 5);
                        layoutBuilder.AddLayout(new TextblockLayout(message));
                    }
                }

                if (numNegatives > 0)
                {
                    if (numNegatives > 1)
                    {
                        layoutBuilder.AddLayout(new TextblockLayout("Doing one minute of these activities subtracts this many minutes:"));
                    }
                    else
                    {
                        layoutBuilder.AddLayout(new TextblockLayout("Doing one minute of this activity subtracts this many minutes:"));
                    }
                    foreach (ListItemStats <double, Activity> result in mostNegativelyCorrelated)
                    {
                        double   correlation = result.Key;
                        Activity activity    = result.Value;
                        String   message     = activity.Name + ": " + Math.Round(correlation, 5);
                        layoutBuilder.AddLayout(new TextblockLayout(message));
                    }
                }

                this.SubLayout = layoutBuilder.Build();
            }
        }
        public Participation_BinComparison_View(Engine engine, IEnumerable <Activity> activitiesToPredictFrom, Activity activityToPredict, TimeSpan windowSize)
        {
            DateTime now = DateTime.Now;

            engine.EnsureRatingsAreAssociated();

            LinearProgression progressionToPredict = activityToPredict.ParticipationsSmoothed((new TimeSpan()).Subtract(windowSize));

            StatList <NeighborhoodInterpolation, Activity> results = new StatList <NeighborhoodInterpolation, Activity>(new Neighborhood_MiddleOutputMean_Comparer(), new NoopCombiner <Activity>());

            foreach (Activity activity in activitiesToPredictFrom)
            {
                System.Diagnostics.Debug.WriteLine("comparing " + activity + " and " + activityToPredict.Name);
                List <Datapoint> datapoints = activity.compareParticipations(windowSize, progressionToPredict, now.Subtract(windowSize));

                // put data into the interpolator
                FloatRange inputRange = new FloatRange(0, true, windowSize.TotalSeconds, true);
                AdaptiveLinearInterpolator <Distribution> interpolator = new AdaptiveLinearInterpolator <Distribution>(new HyperBox <Distribution>(new FloatRange[] { inputRange }), new DistributionAdder());
                foreach (Datapoint datapoint in datapoints)
                {
                    interpolator.AddDatapoint(new AdaptiveInterpolation.Datapoint <Distribution>(datapoint.Input, Distribution.MakeDistribution(datapoint.Output, 0, datapoint.Weight)));
                }

                // ask the interpolator which input has the highest average output
                IEnumerable <double[]> representativePoints = interpolator.FindRepresentativePoints();
                if (representativePoints.Count() > 0)
                {
                    double[] bestInput = new double[1];
                    AdaptiveInterpolation.Distribution bestOutput = null;
                    foreach (double[] coordinates in representativePoints)
                    {
                        AdaptiveInterpolation.Distribution output = interpolator.Interpolate(coordinates);
                        if (bestOutput == null || output.Mean > bestOutput.Mean)
                        {
                            bestInput  = coordinates;
                            bestOutput = output;
                        }
                    }

                    // Check nearby regions for their outputs too
                    HyperBox <Distribution> inputNeighborhood = interpolator.FindNeighborhoodCoordinates(bestInput);
                    double inputNeighborhoodWidth             = inputNeighborhood.Coordinates[0].Width;
                    double lowerInput  = Math.Max(inputNeighborhood.Coordinates[0].LowCoordinate - inputNeighborhoodWidth, inputRange.LowCoordinate);
                    double higherInput = Math.Min(inputNeighborhood.Coordinates[0].HighCoordinate + inputNeighborhoodWidth, inputRange.HighCoordinate);

                    NeighborhoodInterpolation result = new NeighborhoodInterpolation();
                    result.Middle = new Interpolation(bestInput[0], bestOutput);
                    result.Left   = new Interpolation(lowerInput, interpolator.Interpolate(new double[] { lowerInput }));
                    result.Right  = new Interpolation(higherInput, interpolator.Interpolate(new double[] { higherInput }));

                    results.Add(result, activity);
                }
            }

            IEnumerable <ListItemStats <NeighborhoodInterpolation, Activity> > resultList = results.AllItems;

            if (resultList.Count() <= 0)
            {
                // This shouldn't be able to happen unless we disallow predicting the activity from itself
                this.SubLayout = new TextblockLayout("No activities found!");
            }
            else
            {
                int numWindowDays = (int)windowSize.TotalDays;
                GridLayout_Builder layoutBuilder = new Vertical_GridLayout_Builder().Uniform();
                if (resultList.Count() > 1)
                {
                    string title = "Activities that when done most strongly predict future participations in " + activityToPredict.Name;
                    layoutBuilder.AddLayout(new TextblockLayout(title));
                }
                else
                {
                    string title = "Predicting future participations in " + activityToPredict.Name;
                    layoutBuilder.AddLayout(new TextblockLayout(title));
                }

                string explanation = "A block of the form a->{b,c,d} means that when you have spent an average of <a> min/day on the given activity over the last " + numWindowDays + " days, " +
                                     "you have spent on average <c> min/day on " + activityToPredict.Name + " over the next " + numWindowDays + " days, with <b> and <d> marking -1 and +1 standard deviation, respectively";
                layoutBuilder.AddLayout(new TextblockLayout(explanation));

                int count = 0;
                foreach (ListItemStats <NeighborhoodInterpolation, Activity> result in resultList.Reverse())
                {
                    count++;
                    if (count > 3)
                    {
                        break;
                    }
                    Activity activity = result.Value;
                    NeighborhoodInterpolation neighborhood = result.Key;
                    layoutBuilder.AddLayout(new TextblockLayout("After " + activity.Name + ":"));
                    foreach (Interpolation interpolation in neighborhood.Items)
                    {
                        double inputSecondsPerWindow = interpolation.Input;
                        double inputMinutesPerDay    = inputSecondsPerWindow / windowSize.TotalDays / 60;

                        double avgOutputSecondsPerWindow = interpolation.Output.Mean;
                        double avgOutputMinutesPerDay    = avgOutputSecondsPerWindow / windowSize.TotalDays / 60;

                        double stddevOutputSecondsPerWindow = interpolation.Output.StdDev;
                        double stddevOutputMinutesPerDay    = stddevOutputSecondsPerWindow / windowSize.TotalDays / 60;

                        string itemLine = Math.Round(inputMinutesPerDay, 1) + " -> {" +
                                          Math.Round((avgOutputMinutesPerDay - stddevOutputMinutesPerDay), 1) + "," +
                                          Math.Round(avgOutputMinutesPerDay, 1) + "," +
                                          Math.Round((avgOutputMinutesPerDay + stddevOutputMinutesPerDay), 1) + "}";
                        layoutBuilder.AddLayout(new TextblockLayout(itemLine));
                    }
                }

                this.SubLayout = layoutBuilder.Build();
            }
        }