Exemple #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());
        }
Exemple #2
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 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());
        }
        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");
        }
Exemple #5
0
        public override SpecificLayout GetBestLayout(LayoutQuery query)
        {
            if (this.text == null)
            {
                if (this.textProvider == null)
                {
                    this.text = "Reading logs on this platform is not supported. Sorry";
                }
                else
                {
                    this.text = textProvider.Get().ReadToEnd();
                }

                Vertical_GridLayout_Builder builder = new Vertical_GridLayout_Builder();
                // Split text into multiple text blocks so that if roudning error occurs in text measurement, the errors are spaced evenly.
                // There could be 50 pages of text, and we don't want 2% rounding error to add a completely blank page at the end
                List <string> lines            = new List <string>(this.text.Split(new char[] { '\n' }));
                int           numLinesPerBlock = 10;
                for (int i = 0; i < lines.Count; i += numLinesPerBlock)
                {
                    int           maxIndex     = Math.Min(i + numLinesPerBlock, lines.Count);
                    List <string> currentLines = lines.GetRange(i, maxIndex - i);
                    string        currentText  = string.Join("\n", currentLines);
                    builder.AddLayout(new TextblockLayout(currentText, 16, false, true));
                }

                this.SubLayout = ScrollLayout.New(builder.BuildAnyLayout());
            }
            return(base.GetBestLayout(query));
        }
Exemple #6
0
 private void update()
 {
     if (this.protoActivity_database.ProtoActivities.Count() < 1)
     {
         this.SubLayout = new TextblockLayout("No protoactivities!");
     }
     else
     {
         GridLayout_Builder   builder         = new Vertical_GridLayout_Builder().Uniform();
         List <ProtoActivity> protoActivities = new List <ProtoActivity>(protoActivity_database.ProtoActivities);
         protoActivities.Reverse();
         if (this.startIndex < 0)
         {
             this.startIndex = 0;
         }
         if (startIndex >= protoActivities.Count)
         {
             startIndex = protoActivities.Count - 1;
         }
         int endIndex = Math.Min(startIndex + this.pageCount, protoActivities.Count);
         if (this.startIndex > 0)
         {
             builder.AddLayout(this.prevButtonLayout);
         }
         for (int i = startIndex; i < endIndex; i++)
         {
             builder.AddLayout(this.summarize(protoActivities[i]));
         }
         if (endIndex < protoActivities.Count)
         {
             builder.AddLayout(this.nextButtonLayout);
         }
         this.SubLayout = ScrollLayout.New(builder.BuildAnyLayout());
     }
 }
        private LayoutChoice_Set plot()
        {
            // sort activities by their discovery date
            // make a plot
            PlotView         plotView             = new PlotView();
            List <Datapoint> activitiesDatapoints = this.getDatapoints(this.activityDatabase.AllActivities);

            plotView.AddSeries(activitiesDatapoints, false);
            List <Datapoint> categoriesDatapoints = this.getDatapoints(this.activityDatabase.AllCategories);

            plotView.AddSeries(categoriesDatapoints, false);
            // add tick marks for years
            if (activitiesDatapoints.Count > 0)
            {
                plotView.XAxisSubdivisions = TimeProgression.AbsoluteTime.GetNaturalSubdivisions(activitiesDatapoints[0].Input, activitiesDatapoints[activitiesDatapoints.Count - 1].Input);
            }

            // add description
            string           todayText = DateTime.Now.ToString("yyyy-MM-dd");
            LayoutChoice_Set result    = new Vertical_GridLayout_Builder()
                                         .AddLayout(new TextblockLayout("Number of activities over time"))
                                         .AddLayout(new ImageLayout(plotView, LayoutScore.Get_UsedSpace_LayoutScore(1)))
                                         .AddLayout(new TextblockLayout("You have " + activitiesDatapoints.Count + " activities, " + categoriesDatapoints.Count + " of which are categories. Today is " + todayText))
                                         .BuildAnyLayout();

            return(result);
        }
Exemple #8
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());
        }
Exemple #9
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());
        }
Exemple #10
0
        private void initialize(bool showRatings)
        {
            List <Participation> participations = new List <Participation>(this.participations);

            if (!showRatings)
            {
                this.orderRandomly(participations);
            }

            Vertical_GridLayout_Builder gridBuilder = new Vertical_GridLayout_Builder();

            foreach (Participation participation in participations)
            {
                ParticipationView v = new ParticipationView(participation, this.scoreSummarizer, this.layoutStack, this.engine, showRatings);
                v.AddParticipationComment += Child_AddParticipationComment;
                gridBuilder.AddLayout(v);
            }
            if (!showRatings)
            {
                Button showRatings_button = new Button();
                showRatings_button.Clicked += ShowRatings_button_Clicked;
                showRatings_button.Text     = "Show Ratings";
                ButtonLayout showRatings_layout = new ButtonLayout(showRatings_button);
                gridBuilder.AddLayout(showRatings_layout);
            }
            this.SubLayout = ScrollLayout.New(gridBuilder.BuildAnyLayout());
        }
Exemple #11
0
        private void UpdateLayout_From_Suggestions()
        {
            List <LayoutChoice_Set> layouts = new List <LayoutChoice_Set>();

            // show feedback if there is any
            if (this.messageLayout.ModelledText != "")
            {
                layouts.Add(messageLayout);
            }
            // show suggestions if there are any
            bool addDoNowButton = true;

            if (this.suggestions.Count > 0)
            {
                foreach (ActivitiesSuggestion suggestion in this.suggestions)
                {
                    Dictionary <ActivitySuggestion, bool> repeatingDeclinedSuggestion = new Dictionary <ActivitySuggestion, bool>();
                    foreach (ActivitySuggestion child in suggestion.Children)
                    {
                        if (this.previousDeclinedSuggestion != null && this.previousDeclinedSuggestion.CanMatch(child.ActivityDescriptor))
                        {
                            repeatingDeclinedSuggestion[child] = true;
                        }
                        else
                        {
                            repeatingDeclinedSuggestion[child] = false;
                        }
                    }
                    layouts.Add(this.makeLayout(suggestion, addDoNowButton, repeatingDeclinedSuggestion));
                    addDoNowButton = false;
                }
            }
            // Show an explanation about how multiple suggestions work (they're in chronological order) if there's room
            // Also be sure to save room for the suggestion buttons
            if (layouts.Count <= this.maxNumSuggestions - 2)
            {
                if (this.suggestions.Count > 0)
                {
                    this.askWhatIsNext_layout.setText("What's after that?");
                    layouts.Add(this.askWhatIsNext_layout);
                }
            }

            // show the button for getting more suggestions if there's room
            if (this.suggestions.Count < this.maxNumSuggestions)
            {
                layouts.Add(this.requestSuggestion_layout);
            }
            // show help and experiments if there are no suggestions visible
            if (this.suggestions.Count < 1)
            {
                layouts.Add(this.bottomLayout);
            }

            LayoutChoice_Set even   = new Vertical_GridLayout_Builder().Uniform().AddLayouts(layouts).BuildAnyLayout();
            LayoutChoice_Set uneven = new ScoreShifted_Layout(new Vertical_GridLayout_Builder().AddLayouts(layouts).BuildAnyLayout(), LayoutScore.Get_UnCentered_LayoutScore(1));

            this.SetContent(new LayoutUnion(even, uneven));
        }
        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());
        }
Exemple #13
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);
        }
 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();
 }
Exemple #15
0
        public PostView(AnalyzedPost post)
        {
            this.post = post;
            Vertical_GridLayout_Builder mainBuilder  = new Vertical_GridLayout_Builder();
            Vertical_GridLayout_Builder titleBuilder = new Vertical_GridLayout_Builder();

            // post title
            foreach (AnalyzedString component in post.TitleComponents)
            {
                Label label = new Label();
                if (component.Score > 0)
                {
                    label.TextColor = Color.Green;
                }
                else
                {
                    if (component.Score < 0)
                    {
                        label.TextColor = Color.Red;
                    }
                    else
                    {
                        label.TextColor = Color.White;
                    }
                }
                label.BackgroundColor = Color.Black;
                TextblockLayout textBlockLayout = new TextblockLayout(label, 16, false, true);
                textBlockLayout.setText(component.Text);
                titleBuilder.AddLayout(textBlockLayout);
            }
            this.starButton = new Button();
            this.updateStarButton();
            this.starButton.Clicked += SaveButton_Clicked;

            GridLayout topGrid = GridLayout.New(new BoundProperty_List(1), BoundProperty_List.WithRatios(new List <double>()
            {
                5, 1
            }), LayoutScore.Zero);

            topGrid.AddLayout(titleBuilder.BuildAnyLayout());
            topGrid.AddLayout(new ButtonLayout(this.starButton));
            mainBuilder.AddLayout(topGrid);

            this.linkLayout = new TextblockLayout(post.Interaction.Post.Source, 16, false, true);
            this.linkLayout.setBackgroundColor(Color.Black);
            this.updateLinkColor();
            mainBuilder.AddLayout(this.linkLayout);

            Button openButton = new Button();

            mainBuilder.AddLayout(new ButtonLayout(openButton, "Open", 16));
            openButton.Clicked += OpenButton_Clicked;

            this.SubLayout = mainBuilder.BuildAnyLayout();
        }
Exemple #16
0
        public LayoutChoice_Set Build()
        {
            Vertical_GridLayout_Builder gridBuilder = new Vertical_GridLayout_Builder().Uniform();

            foreach (string name in this.layoutNames)
            {
                LayoutChoice_Set subLayout = this.Get_ButtonLayout_By_Name(name);
                gridBuilder.AddLayout(subLayout);
            }
            return(gridBuilder.BuildAnyLayout());
        }
        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());
            }
        }
Exemple #18
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()));
        }
Exemple #19
0
        public Confirm_BackupBeforeRecalculateEfficiency_Layout()
        {
            TextblockLayout warning = new TextblockLayout("You have requested to recalculate your efficiency using ActivityRecommender's latest algorithm. We will first " +
                                                          "make a backup of your data, and then reload from that backup and recalculate efficiency. Would you like to continue?");
            Button okButton = new Button();

            okButton.Clicked += Confirm;
            GridLayout_Builder builder = new Vertical_GridLayout_Builder()
                                         .AddLayout(warning)
                                         .AddLayout(new ButtonLayout(okButton, "Back up your data"));

            this.SubLayout = builder.BuildAnyLayout();
        }
        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 LayoutChoice_Set makeContent()
        {
            this.chooseFile_button          = new Button();
            this.chooseFile_button.Clicked += ChooseFile;
            ButtonLayout chooseLayout = new ButtonLayout(this.chooseFile_button, "Select file");

            GridLayout_Builder builder = new Vertical_GridLayout_Builder()
                                         .Uniform()
                                         .AddLayout(new TextblockLayout("The file to import should be of the form created by the Export feature " +
                                                                        "(and the name of file should start with \"ActivityData\")"));

            builder.AddLayout(chooseLayout);

            return(builder.BuildAnyLayout());
        }
        public New_ParticipationComment_Layout(Participation participation, LayoutStack layoutStack)
        {
            this.participation = participation;
            this.textBox       = new Editor();
            this.layoutStack   = layoutStack;
            Button saveButton = new Button();

            saveButton.Clicked += SaveButton_Clicked;
            GridLayout_Builder builder = new Vertical_GridLayout_Builder()
                                         .AddLayout(new TextblockLayout("Comment"))
                                         .AddLayout(new TextboxLayout(textBox))
                                         .AddLayout(new ButtonLayout(saveButton, "Save"));

            this.SubLayout = builder.BuildAnyLayout();
        }
Exemple #23
0
        private void explainSuggestionQuality()
        {
            Vertical_GridLayout_Builder builder = new Vertical_GridLayout_Builder();

            builder.AddLayout(new TextblockLayout("Why:", this.maxFontSize));
            builder.AddLayout(new TextblockLayout("Suggestion quality: " + Math.Round(explanation.SuggestionValue, 3), this.maxFontSize));
            int childIndex = 0;

            foreach (Justification child in this.explanation.Reasons)
            {
                builder.AddLayouts(this.renderJustification(child, 0, this.explanation.Suggestion.ActivityDescriptor, childIndex));
                childIndex++;
            }
            this.suggestionQuality_container.SubLayout = builder.BuildAnyLayout();
        }
        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();
        }
Exemple #25
0
        public ExperimentSuggestionLayout(SuggestedMetric suggestion)
        {
            this.CancelButton.Clicked  += CancelButton_Clicked;
            this.JustifyButton.Clicked += JustifyButton_Clicked;

            GridLayout grid = new Vertical_GridLayout_Builder().Uniform()
                              .AddLayout(new TextblockLayout(suggestion.ActivityDescriptor.ActivityName))
                              .AddLayout(new TextblockLayout("(" + suggestion.PlannedMetric.MetricName + ")"))
                              .AddLayout(new Horizontal_GridLayout_Builder().Uniform()
                                         .AddLayout(new ButtonLayout(this.CancelButton, "X"))
                                         .AddLayout(new ButtonLayout(this.JustifyButton, "?"))
                                         .Build())
                              .Build();

            this.SubLayout = grid;
        }
Exemple #26
0
        private LayoutChoice_Set makeSublayout()
        {
            TextblockLayout title    = new TextblockLayout("Export Protoactivities");
            TextblockLayout subtitle = new TextblockLayout("This feature exports a file containing all of your protoactivies. You can send them to your friends!");

            Button button = new Button();

            button.Clicked += Button_Clicked;
            ButtonLayout buttonLayout = new ButtonLayout(button, "Export");

            GridLayout_Builder builder = new Vertical_GridLayout_Builder()
                                         .AddLayout(title)
                                         .AddLayout(subtitle)
                                         .AddLayout(buttonLayout);

            return(builder.BuildAnyLayout());
        }
Exemple #27
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());
     }
 }
Exemple #28
0
        public NewInheritanceLayout(ActivityDatabase activityDatabase, LayoutStack layoutStack)
        {
            this.activityDatabase = activityDatabase;
            this.layoutStack      = layoutStack;

            this.SetTitle("Relate Two Existing Activities");

            GridLayout bottomGrid = GridLayout.New(new BoundProperty_List(2), BoundProperty_List.Uniform(2), LayoutScore.Zero);

            this.childNameBox = new ActivityNameEntryBox("Activity Name", activityDatabase, layoutStack);
            this.childNameBox.AutoAcceptAutocomplete = false;
            bottomGrid.AddLayout(this.childNameBox);

            this.parentNameBox = new ActivityNameEntryBox("Parent Name", activityDatabase, layoutStack);
            this.parentNameBox.AutoAcceptAutocomplete = false;
            bottomGrid.AddLayout(this.parentNameBox);

            this.okButton          = new Button();
            this.okButton.Clicked += OkButton_Clicked;
            bottomGrid.AddLayout(new ButtonLayout(this.okButton, "OK"));


            LayoutChoice_Set helpWindow = (new HelpWindowBuilder()).AddMessage("This screen is for you to enter activities, to use as future suggestions.")
                                          .AddMessage("The text box on the left is where you type the activity name.")
                                          .AddMessage("The text box on the right is where you type another activity that you want to make be a parent of the given activity.")
                                          .AddMessage("For example, you might specify that Gaming is a child activity of the Fun activity. Grouping activities like this is helpful for two reasons. It gives " +
                                                      "ActivityRecommender more understanding about the relationships between activities and can help it to notice trends. It also means that you can later request a suggestion " +
                                                      "from within Activity \"Fun\" and ActivityRecommender will know what you mean, and might suggest \"Gaming\".")
                                          .AddMessage("If you haven't created the parent activity yet, you'll have to create it first. The only activity that exists at the beginning is the built-in activity " +
                                                      "named \"Activity\".")
                                          .AddMessage("While typing you can press Enter to fill in the autocomplete suggestion.")
                                          .Build();

            HelpButtonLayout helpLayout = new HelpButtonLayout(helpWindow, layoutStack);

            bottomGrid.AddLayout(helpLayout);

            this.feedbackLayout = new TextblockLayout();

            GridLayout mainGrid = new Vertical_GridLayout_Builder()
                                  .AddLayout(this.feedbackLayout)
                                  .AddLayout(bottomGrid)
                                  .Build();

            this.SetContent(mainGrid);
        }
Exemple #29
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();
        }
Exemple #30
0
        private void showResults(Activities_HappinessContributions contributions, DateTime start, DateTime end)
        {
            // title
            string title = "" + (contributions.Best.Count + contributions.Worst.Count) + " Activities adding or subtracting the most happiness from " + start + " to " + end;

            BoundProperty_List heights = new BoundProperty_List(4);

            heights.BindIndices(1, 3);
            GridLayout grid = GridLayout.New(heights, new BoundProperty_List(1), LayoutScore.Zero);

            grid.AddLayout(new TextblockLayout(title));

            // contents
            GridLayout_Builder topBuilder = new Vertical_GridLayout_Builder().Uniform();

            // Show the top activities from best to worst
            for (int i = 0; i < contributions.Best.Count; i++)
            {
                ActivityHappinessContribution item = contributions.Best[i];
                topBuilder.AddLayout(this.renderContribution("top " + (i + 1) + ": ", item, start));
            }
            grid.AddLayout(ScrollLayout.New(topBuilder.BuildAnyLayout()));

            // Use the help button as the divider between the best and worst activities
            LayoutChoice_Set helpWindow = new HelpWindowBuilder()
                                          .AddMessage("Activities that you like more than average are accompanied by positive numbers.")
                                          .AddMessage("Activities that you like less than average are accompanied by negative numbers.")
                                          .AddMessage("Activities that you participated in for more total time are accompanied by numbers that are further from 0.")
                                          .AddMessage("Specifically, each of these numbers is calculated by looking at all of the participations in that activity during this time, " +
                                                      "computing the difference between the happiness of that participation and your overall average happiness, " +
                                                      "multiplying each by the duration of its participation, and adding up the results.")
                                          .Build();

            grid.AddLayout(new HelpButtonLayout("?", helpWindow, this.layoutStack));

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

            // Show the bottom activities, also from best to worst
            for (int i = contributions.Worst.Count - 1; i >= 0; i--)
            {
                bottomBuilder.AddLayout(this.renderContribution("bottom " + (i + 1) + ": ", contributions.Worst[i], start));
            }
            grid.AddLayout(bottomBuilder.BuildAnyLayout());

            this.layoutStack.AddLayout(grid, "Significant Activities");
        }