示例#1
0
        private LayoutChoice_Set newTextBlock(string prefix, string indexString, string text, int indent)
        {
            Horizontal_GridLayout_Builder builder = new Horizontal_GridLayout_Builder();

            if (prefix.Length > 0)
            {
                TextblockLayout prefixBlock = new TextblockLayout(prefix, this.maxFontSize, false, false);
                prefixBlock.setTextColor(Color.FromRgba(0, 0, 0, 0));
                builder.AddLayout(prefixBlock);
            }

            double fontSize = this.maxFontSize;

            for (int i = 0; i < indent; i++)
            {
                fontSize = Math.Ceiling(fontSize * 4 / 5);
            }
            TextblockLayout indexLayout = new TextblockLayout(indexString, fontSize);

            indexLayout.AlignVertically(TextAlignment.Start);
            builder.AddLayout(indexLayout);

            TextblockLayout contentBlock = new TextblockLayout(text, fontSize);

            contentBlock.AlignVertically(TextAlignment.Start);
            builder.AddLayout(contentBlock);

            return(builder.BuildAnyLayout());
        }
        public ExperimentDifficultyEstimateLayout(SuggestedMetric suggestedMetric, Activity activity)
        {
            this.suggestedMetric = suggestedMetric;

            this.metricChooser = new ChooseMetric_View(false);
            this.metricChooser.SetActivity(activity);
            this.metricChooser.Choose(suggestedMetric.PlannedMetric.MetricName);

            this.difficultyBox              = new Editor();
            this.difficultyBox.Keyboard     = Keyboard.Numeric;
            this.difficultyBox.Placeholder  = this.defaultDifficulty.ToString();
            this.difficultyLayout           = new TitledControl("Difficulty:", new TextboxLayout(difficultyBox));
            this.difficultyBox.TextChanged += DifficultyBox_TextChanged;

            TextblockLayout nameLayout = new TextblockLayout(activity.Name);

            GridLayout evenGrid   = GridLayout.New(new BoundProperty_List(1), BoundProperty_List.Uniform(3), LayoutScore.Zero);
            GridLayout unevenGrid = GridLayout.New(new BoundProperty_List(1), new BoundProperty_List(3), LayoutScore.Get_UnCentered_LayoutScore(1));

            evenGrid.AddLayout(this.metricChooser);
            unevenGrid.AddLayout(this.metricChooser);

            evenGrid.AddLayout(nameLayout);
            unevenGrid.AddLayout(nameLayout);

            evenGrid.AddLayout(this.difficultyLayout);
            unevenGrid.AddLayout(this.difficultyLayout);


            this.SubLayout = new LayoutUnion(evenGrid, unevenGrid);
        }
示例#3
0
        private LayoutChoice_Set summarize(ProtoActivity protoActivity)
        {
            TextblockLayout option1 = new TextblockLayout(protoActivity.Text, true, 16);
            TextblockLayout option2 = new TextblockLayout(protoActivity.Text, 30);

            return(new LayoutUnion(option1, option2));
        }
        private void updateLayout()
        {
            TextblockLayout text = new TextblockLayout(this.GetText());

            text.setBackgroundColor(Color.Black);
            text.setTextColor(Color.White);
            this.progressContainer.SubLayout = text;
        }
示例#5
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();
        }
示例#6
0
        public ExportSuccessLayout(string filePath, PublicFileIo fileIo)
        {
            this.fileIo = fileIo;

            GridLayout      grid  = GridLayout.New(new BoundProperty_List(2), new BoundProperty_List(1), LayoutScore.Zero);
            TextblockLayout title = new TextblockLayout("Shared " + filePath, 16, false, true);

            grid.AddLayout(title);

            this.SubLayout = grid;
        }
        static TextblockLayout coloredRatio(double value, double neutralColorThreshold, double stddev)
        {
            Color  color = chooseColor(value, 1, neutralColorThreshold);
            string text  = "" + value;

            if (stddev != 0)
            {
                text += " +/- " + stddev;
            }
            TextblockLayout layout = new TextblockLayout(text, color);

            return(layout);
        }
示例#8
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();
        }
        private void SetupView()
        {
            LayoutChoice_Set instructions = new TextblockLayout("This this txt file contains most of what you've provided to " + this.persona.Name + ", and so it may become large.");
            ButtonLayout     buttonLayout = new ButtonLayout(this.exportButton, "Export");
            LayoutChoice_Set credits      = new CreditsButtonBuilder(this.layoutStack)
                                            .AddContribution(ActRecContributor.ANNI_ZHANG, new DateTime(2020, 04, 05), "Pointed out that exported data files could not be seen by users on iOS")
                                            .AddContribution(ActRecContributor.TOBY_HUANG, new DateTime(2021, 02, 16), "Pointed out that it was hard to find the exported files on ChromeOS")
                                            .Build();

            this.SetContent(new Vertical_GridLayout_Builder().Uniform()
                            .AddLayout(instructions)
                            .AddLayout(buttonLayout)
                            .AddLayout(credits)
                            .Build());
        }
示例#10
0
        public DateEntryView(string title, LayoutStack layoutStack, bool placeTitleAbove = true)
        {
            this.layoutStack                = layoutStack;
            this.chooseDate_button          = new Button();
            this.chooseDate_button.Clicked += ChooseDate_button_Clicked;
            this.title = title;
            LayoutChoice_Set titleLayout   = new TextblockLayout(title).AlignHorizontally(TextAlignment.Center).AlignVertically(TextAlignment.Center);
            LayoutChoice_Set contentLayout = ButtonLayout.WithoutBevel(this.chooseDate_button);

            if (placeTitleAbove)
            {
                this.SubLayout = new Vertical_GridLayout_Builder().Uniform()
                                 .AddLayout(titleLayout)
                                 .AddLayout(contentLayout)
                                 .Build();
            }
            else
            {
                this.SubLayout = new Horizontal_GridLayout_Builder().Uniform()
                                 .AddLayout(titleLayout)
                                 .AddLayout(contentLayout)
                                 .Build();
            }

            // Use a dateFormat of "yyyy-MM-ddTHH:mm:ss";
            this.dateFormat.Add(new DateCharacter('y', true));
            this.dateFormat.Add(new DateCharacter('y', true));
            this.dateFormat.Add(new DateCharacter('y', true));
            this.dateFormat.Add(new DateCharacter('y', true));
            this.dateFormat.Add(new DateCharacter('-', false));
            this.dateFormat.Add(new DateCharacter('M', true));
            this.dateFormat.Add(new DateCharacter('M', true));
            this.dateFormat.Add(new DateCharacter('-', false));
            this.dateFormat.Add(new DateCharacter('d', true));
            this.dateFormat.Add(new DateCharacter('d', true));
            this.dateFormat.Add(new DateCharacter('T', false));
            this.dateFormat.Add(new DateCharacter('H', true));
            this.dateFormat.Add(new DateCharacter('H', true));
            this.dateFormat.Add(new DateCharacter(':', false));
            this.dateFormat.Add(new DateCharacter('m', true));
            this.dateFormat.Add(new DateCharacter('m', true));
            this.dateFormat.Add(new DateCharacter(':', false));
            this.dateFormat.Add(new DateCharacter('s', true));
            this.dateFormat.Add(new DateCharacter('s', true));

            this.implView = new FullscreenDateEntryView(title, this.dateFormat, layoutStack);
        }
示例#11
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());
        }
示例#12
0
        private void showPosts()
        {
            List <AnalyzedPost>         posts       = new List <AnalyzedPost>(this.analyzedPosts);
            Vertical_GridLayout_Builder gridBuilder = new Vertical_GridLayout_Builder();

            gridBuilder.AddLayout(this.downloadStatus_container);

            this.sortPosts(posts);
            posts = this.withoutDuplicateSources(posts);

            int maxCountToShow = 30;

            if (posts.Count > maxCountToShow)
            {
                posts = posts.GetRange(0, maxCountToShow);
            }
            double previousScore = double.NegativeInfinity;

            foreach (AnalyzedPost scoredPost in posts)
            {
                double thisScore = scoredPost.Score;
                if (thisScore != previousScore)
                {
                    string          text            = "Score: " + thisScore;
                    TextblockLayout textBlockLayout = new TextblockLayout(text, 30);
                    textBlockLayout.setBackgroundColor(Color.Black);
                    textBlockLayout.setTextColor(Color.White);
                    gridBuilder.AddLayout(textBlockLayout);

                    previousScore = thisScore;
                }
                PostView postView = new PostView(scoredPost);
                postView.PostClicked += PostView_PostClicked;
                postView.PostStarred += PostView_PostStarred;
                gridBuilder.AddLayout(postView);
            }

            LayoutChoice_Set scrollLayout = ScrollLayout.New(gridBuilder.BuildAnyLayout());

            this.downloadsStatus.NumUrlsDownloadedButNotShown = 0;
            this.downloadsStatus.NumFailed = 0;
            this.update_numCompletedDownloads_status();

            this.resultsLayout.SubLayout = scrollLayout;
        }
        private void setupDrawing()
        {
            this.textA      = new Editor();
            this.textA.Text = this.protoA.Text;
            this.textB      = new Editor();
            this.textB.Text = this.protoB.Text;
            TextblockLayout description = new TextblockLayout("Split into two protoactivities, then go back");

            BoundProperty_List rowHeights = new BoundProperty_List(3);

            rowHeights.BindIndices(0, 2);
            GridLayout grid = GridLayout.New(rowHeights, new BoundProperty_List(1), LayoutScore.Zero);

            grid.AddLayout(ScrollLayout.New(new TextboxLayout(this.textA)));
            grid.AddLayout(description);
            grid.AddLayout(ScrollLayout.New(new TextboxLayout(this.textB)));
            this.SubLayout = grid;
        }
        public Confirm_BackupBeforeDeleteActivity_Layout(Activity activity, LayoutStack layoutStack)
        {
            this.activity = activity;
            TextblockLayout warning = new TextblockLayout("You have requested to delete " + activity.Name + ". We will first make a backup of all of your data, and then reload from that backup and exclude " +
                                                          "this activity. Would you like to continue?");
            Button okButton = new Button();

            okButton.Clicked += ConfirmDeletion;

            LayoutChoice_Set credits = new CreditsButtonBuilder(layoutStack)
                                       .AddContribution(ActRecContributor.TOBY_HUANG, new DateTime(2021, 02, 23), "Suggested supporting deletion of created activities that have never been used, in case of mistakes in creating them")
                                       .Build();

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

            this.SubLayout = builder.BuildAnyLayout();
        }
示例#15
0
        public ResetVersionNumberLayout()
        {
            this.label = new Label();
            TextblockLayout instructions = new TextblockLayout(this.label, 16, false, false);

            Button clearVersionButton = new Button();

            clearVersionButton.Clicked += ClearVersionButton_Clicked;
            clearVersionButton.Text     = "Clear Saved Version";

            Button resetVersionButton = new Button();

            resetVersionButton.Clicked += ResetVersionButton_Clicked;
            resetVersionButton.Text     = "Reset Saved Version to '1.0.0'";

            this.SubLayout = new Vertical_GridLayout_Builder().Uniform()
                             .AddLayout(instructions)
                             .AddLayout(new ButtonLayout(clearVersionButton))
                             .AddLayout(new ButtonLayout(resetVersionButton))
                             .Build();
        }
        static TextblockLayout signedColoredValue(double value, double neutralColorThreshold, double stddev)
        {
            string text;

            if (value > 0)
            {
                text = "+" + value;
            }
            else
            {
                text = "" + value;
            }
            if (stddev != 0)
            {
                text += " +/- " + stddev;
            }
            Color           textColor = chooseColor(value, 0, neutralColorThreshold);
            TextblockLayout layout    = new TextblockLayout(text, textColor);

            return(layout);
        }
        private void showErrors(PredictionErrors errors)
        {
            PlotView         plotView            = new PlotView();
            List <Datapoint> correctValues       = new List <Datapoint>();
            List <Datapoint> predictedValues     = new List <Datapoint>();
            List <Datapoint> predictedPlusStdDev = new List <Datapoint>();

            if (!double.IsInfinity(errors.MinAllowedValue))
            {
                plotView.MinY = errors.MinAllowedValue;
            }
            if (!double.IsInfinity(errors.MaxAllowedValue))
            {
                plotView.MaxY = errors.MaxAllowedValue;
            }
            DateTime referenceDate = new DateTime(2000, 1, 1);

            foreach (PredictionError error in errors.All)
            {
                double x = error.When.Subtract(referenceDate).TotalSeconds;
                correctValues.Add(new Datapoint(x, error.ActualMean, 1));
                predictedValues.Add(new Datapoint(x, error.Predicted.Mean, 1));
                predictedPlusStdDev.Add(new Datapoint(x, error.Predicted.Mean + error.Predicted.StdDev, 1));
            }
            plotView.AddSeries(correctValues, false);
            plotView.AddSeries(predictedValues, false);
            plotView.AddSeries(predictedPlusStdDev, false);

            ImageLayout     imageLayout = new ImageLayout(plotView, LayoutScore.Get_UsedSpace_LayoutScore(1));
            TextblockLayout legend      = new TextblockLayout("Prediction errors over time. Green: actual value. Blue: predicted value. White: prediction mean + stddev.");

            LayoutChoice_Set layout = new Vertical_GridLayout_Builder()
                                      .AddLayout(imageLayout)
                                      .AddLayout(legend)
                                      .BuildAnyLayout();

            this.layoutStack.AddLayout(layout, "errors");
        }
        public RelativeRatingEntryView() : base("")
        {
            this.TitleLayout.AlignVertically(TextAlignment.Center);
            this.mainDisplayGrid = GridLayout.New(new BoundProperty_List(2), new BoundProperty_List(1), LayoutScore.Zero);

            this.scaleBox              = new Editor();
            this.scaleBox.Keyboard     = Keyboard.Numeric;
            this.scaleBox.TextChanged += this.ScaleBlock_TextChanged;
            this.scaleBoxLayout        = new TextboxLayout(this.scaleBox);
            ContainerLayout scaleBoxHolder = new ContainerLayout(null, this.scaleBoxLayout, false);
            // The fact that the rating is relative to the previous participation is really important, so we put this text into its own text block.
            // Additionally, the timesBlock might be able to fit into the same line as the text box into which the user types the rating ratio.
            // Also, if there's enough space then we spell out the exact meaning more clearly
            LayoutChoice_Set conciseTimesBlock = new ScoreShifted_Layout(new TextblockLayout("x prev:").AlignVertically(TextAlignment.Center).AlignHorizontally(TextAlignment.Center), LayoutScore.Get_ReducedContent_Score(1));
            LayoutChoice_Set fullTimesBlock    = new TextblockLayout("times previous:").AlignVertically(TextAlignment.Center).AlignHorizontally(TextAlignment.Center);
            LayoutChoice_Set timesBlock        = new LayoutUnion(fullTimesBlock, conciseTimesBlock);

            LayoutChoice_Set horizontalBox = new Horizontal_GridLayout_Builder()
                                             .AddLayout(scaleBoxHolder)
                                             .AddLayout(timesBlock)
                                             .BuildAnyLayout();

            LayoutChoice_Set verticalBox = new Vertical_GridLayout_Builder()
                                           .AddLayout(scaleBoxHolder)
                                           .AddLayout(timesBlock)
                                           .BuildAnyLayout();

            this.Clear();
            this.mainDisplayGrid.AddLayout(new LayoutUnion(horizontalBox, verticalBox));

            // We try to use large font for the name layout and we also try to use as many clarifying words as possible
            this.fullNameLayout = new TextblockLayout();
            this.mainDisplayGrid.AddLayout(
                this.fullNameLayout
                );

            this.Placeholder("(Optional)");
        }
        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 EngineTesterView(ActivityRecommender recommender, LayoutStack layoutStack)
        {
            this.activityRecommender = recommender;
            this.layoutStack         = layoutStack;

            this.SetTitle("For Developers: Back-Testing");

            TextblockLayout explanationLayout = new TextblockLayout("This feature is incredibly slow (may take several minutes) and mostly intended for developers. "
                                                                    + "It does back-testing using all of your past data and computes the overall accuracy of the predictions that ActivityRecommender would make if it "
                                                                    + "were given all of the same data again (the intent is that you will change something about ActivityRecommender and then run this to see if "
                                                                    + "it made ActivityRecommender's predictions more accurate). Do you want to continue?");

            Button confirmButton = new Button();

            confirmButton.Text     = "Compute Overall Accuracy";
            confirmButton.Clicked += ConfirmButton_Clicked;

            LayoutChoice_Set gridLayout = new Vertical_GridLayout_Builder().Uniform()
                                          .AddLayout(explanationLayout)
                                          .AddLayout(new ButtonLayout(confirmButton))
                                          .Build();

            this.SetContent(gridLayout);
        }
        public Import_SpecificActivities_Layout(Inheritance inheritance, int numDescendants)
        {
            this.inheritance = inheritance;

            TextblockLayout title = new TextblockLayout(inheritance.ChildDescriptor.ActivityName + " (" + inheritance.ParentDescriptor.ActivityName + ")", 30);

            title.AlignVertically(TextAlignment.Center);

            Button selectAll_button = new Button();

            selectAll_button.Clicked += SelectAll_button_Clicked;
            Button customizeButton = new Button();

            customizeButton.Clicked += CustomizeButton_Clicked;
            Button dismissButton = new Button();

            dismissButton.Clicked += DismissButton_Clicked;
            GridLayout_Builder buttonsBuilder = new Horizontal_GridLayout_Builder().Uniform();

            if (numDescendants > 1)
            {
                buttonsBuilder.AddLayout(new ButtonLayout(selectAll_button, "I like all kinds! (" + numDescendants + " ideas)", 16));
                buttonsBuilder.AddLayout(new ButtonLayout(customizeButton, "I like this. Show me more!", 16));
            }
            else
            {
                buttonsBuilder.AddLayout(new ButtonLayout(customizeButton, "I like this!", 16));
            }

            buttonsBuilder.AddLayout(new ButtonLayout(dismissButton, "Not interested", 16));

            this.SubLayout = new Vertical_GridLayout_Builder()
                             .AddLayout(title)
                             .AddLayout(buttonsBuilder.Build())
                             .Build();
        }
示例#22
0
        public BrowseParticipations_Layout(ActivityDatabase activityDatabase, Engine engine, ScoreSummarizer scoreSummarizer, LayoutStack layoutStack)
        {
            this.activityDatabase = activityDatabase;
            this.engine           = engine;
            this.layoutStack      = layoutStack;
            this.scoreSummarizer  = scoreSummarizer;

            TextblockLayout helpLayout = new TextblockLayout("Browse participations");

            ActivityNameEntryBox categoryBox = new ActivityNameEntryBox("Category", activityDatabase, layoutStack, false, false);

            categoryBox.Placeholder("(Optional)");
            this.categoryBox = categoryBox;

            this.sinceDate_box = new DateEntryView("Since", layoutStack, false);
            this.sinceDate_box.Placeholder("(Optional)");

            this.displayRatings_box         = new VisiPlacement.CheckBox("No", "Yes");
            this.displayRatings_box.Checked = true;
            Thickness        buttonMargin          = new Thickness(0, 1);
            LayoutChoice_Set displayRatings_layout = new Horizontal_GridLayout_Builder()
                                                     .Uniform()
                                                     .AddLayout(new TextblockLayout("Show ratings?"))
                                                     .AddLayout(new MustBorderLayout(null, this.displayRatings_box, buttonMargin))
                                                     .BuildAnyLayout();

            this.requireComments_box         = new VisiPlacement.CheckBox("No", "Yes");
            this.requireComments_box.Checked = true;
            LayoutChoice_Set requireComments_layout = new Horizontal_GridLayout_Builder()
                                                      .Uniform()
                                                      .AddLayout(new TextblockLayout("Require comments?"))
                                                      .AddLayout(new MustBorderLayout(null, this.requireComments_box, buttonMargin))
                                                      .BuildAnyLayout();

            this.requireSuccessful_box = new VisiPlacement.SingleSelect(null, new List <string>()
            {
                "Any", "No Metric", "Successful", "Failed"
            });
            LayoutChoice_Set requireSuccessful_layout = new Horizontal_GridLayout_Builder()
                                                        .Uniform()
                                                        .AddLayout(new TextblockLayout("Require success status ="))
                                                        .AddLayout(new MustBorderLayout(null, this.requireSuccessful_box, buttonMargin))
                                                        .BuildAnyLayout();

            this.sortBy_box = new VisiPlacement.SingleSelect(null, new List <string>()
            {
                this.sortByFun_text, this.sortBy_netPresentHappiness_text, this.sortByEfficiency_text
            });
            LayoutChoice_Set sortBy_layout = new Horizontal_GridLayout_Builder()
                                             .Uniform()
                                             .AddLayout(new TextblockLayout("Sort by"))
                                             .AddLayout(new MustBorderLayout(null, this.sortBy_box, buttonMargin))
                                             .BuildAnyLayout();


            Button       browseTopParticipations_button = new Button();
            ButtonLayout browseTopParticipations_layout = new ButtonLayout(browseTopParticipations_button, "Top " + this.maxNumTopParticipationsToShow);

            browseTopParticipations_button.Clicked += BrowseTopParticipations_Button_Clicked;

            Button       browseExtremeParticipations_button = new Button();
            ButtonLayout browseExtremeParticipations_layout = new ButtonLayout(browseExtremeParticipations_button, "" + this.maxNumTopParticipationsToShow + " best/worst");

            browseExtremeParticipations_button.Clicked += BrowseExtremeParticipations_button_Clicked;


            Button       seeGoodRandomParticipation_button = new Button();
            ButtonLayout seeGoodRandomParticipation_layout = new ButtonLayout(seeGoodRandomParticipation_button, "A random, probably good one");

            seeGoodRandomParticipation_button.Clicked += SeeGoodRandomParticipation_Clicked;

            Button       seeRandomParticipations_button = new Button();
            ButtonLayout seeRandomParticipations_layout = new ButtonLayout(seeRandomParticipations_button, "" + this.maxNumRandomActivitiesToShow + " (uniformly) random");

            seeRandomParticipations_button.Clicked += SeeRandomParticipations_button_Clicked;

            this.SubLayout = new Vertical_GridLayout_Builder()
                             .AddLayout(helpLayout)
                             .AddLayout(categoryBox)
                             .AddLayout(sinceDate_box)
                             .AddLayout(displayRatings_layout)
                             .AddLayout(requireComments_layout)
                             .AddLayout(requireSuccessful_layout)
                             .AddLayout(sortBy_layout)
                             .AddLayout(
                new Horizontal_GridLayout_Builder()
                .Uniform()
                .AddLayout(browseTopParticipations_layout)
                .AddLayout(browseExtremeParticipations_layout)
                .AddLayout(seeGoodRandomParticipation_layout)
                .AddLayout(seeRandomParticipations_layout)
                .BuildAnyLayout()
                )
                             .Build();
            this.randomGenerator = new Random();
        }
示例#23
0
        public SuggestionView(ActivitiesSuggestion suggestion, bool isFirstSuggestion, Dictionary <ActivitySuggestion, bool> repeatingDeclinedSuggestion, LayoutStack layoutStack)
        {
            this.suggestion  = suggestion;
            this.layoutStack = layoutStack;

            bool allWorseThanAverage = true;

            foreach (ActivitySuggestion child in suggestion.Children)
            {
                if (!child.WorseThanRootActivity)
                {
                    allWorseThanAverage = false;
                }
            }

            GridLayout_Builder fullBuilder   = new Vertical_GridLayout_Builder();
            string             startTimeText = suggestion.Children[0].StartDate.ToString("HH:mm");

            bool badSuggestion = (allWorseThanAverage && suggestion.Skippable);

            if (badSuggestion)
            {
                fullBuilder.AddLayout(new TextblockLayout("Best ideas at " + startTimeText + ":", 24).AlignHorizontally(TextAlignment.Center));
            }
            else
            {
                fullBuilder.AddLayout(new TextblockLayout("At " + startTimeText + ":", 24).AlignHorizontally(TextAlignment.Center));
            }

            List <LayoutChoice_Set> specificFont_contentChoices = new List <LayoutChoice_Set>(); // list of layouts we might use, each with a different font size

            this.explainButtons = new Dictionary <Button, ActivitySuggestion>();
            this.doButtons      = new Dictionary <Button, ActivitySuggestion>();
            for (int mainFontSize = 20; mainFontSize >= 12; mainFontSize -= 8)
            {
                // grid containing the specific activities the user could do
                GridLayout activityOptionsGrid = GridLayout.New(new BoundProperty_List(3), BoundProperty_List.Uniform(suggestion.Children.Count), LayoutScore.Zero);

                for (int i = 0; i < suggestion.Children.Count; i++)
                {
                    ActivitySuggestion child = suggestion.Children[i];

                    // set up the options for the text
                    string          mainText  = this.summarize(child, repeatingDeclinedSuggestion[child]);
                    TextblockLayout mainBlock = new TextblockLayout(mainText, mainFontSize);
                    TextAlignment   horizontalAlignment;
                    TextAlignment   verticalAlignment;
                    if (i == 0)
                    {
                        horizontalAlignment = TextAlignment.Start;
                        if (suggestion.Children.Count == 1)
                        {
                            verticalAlignment = TextAlignment.Start;
                        }
                        else
                        {
                            verticalAlignment = TextAlignment.End;
                        }
                    }
                    else
                    {
                        if (i == suggestion.Children.Count - 1)
                        {
                            horizontalAlignment = TextAlignment.End;
                            verticalAlignment   = TextAlignment.Start;
                        }
                        else
                        {
                            horizontalAlignment = TextAlignment.Center;
                            verticalAlignment   = TextAlignment.Center;
                        }
                    }
                    mainBlock.AlignHorizontally(horizontalAlignment);
                    mainBlock.AlignVertically(verticalAlignment);
                    activityOptionsGrid.PutLayout(mainBlock, i, 0);

                    // set up the buttons
                    GridLayout_Builder buttonsBuilder = new Horizontal_GridLayout_Builder().Uniform();
                    double             buttonFontSize = mainFontSize * 0.9;
                    // make a doNow button if needed
                    if (isFirstSuggestion)
                    {
                        Button doNowButton = new Button();
                        doNowButton.Clicked        += DoNowButton_Clicked;
                        this.doButtons[doNowButton] = child;
                        ButtonLayout doButtonLayout = new ButtonLayout(doNowButton, "OK", buttonFontSize);
                        buttonsBuilder.AddLayout(doButtonLayout);
                    }
                    if (child.PredictedScoreDividedByAverage != null)
                    {
                        Button explainButton = new Button();
                        explainButton.Clicked += explainButton_Clicked;
                        this.explainButtons[explainButton] = child;
                        ButtonLayout explainLayout = new ButtonLayout(explainButton, "?", buttonFontSize);
                        buttonsBuilder.AddLayout(explainLayout);
                    }
                    activityOptionsGrid.PutLayout(buttonsBuilder.BuildAnyLayout(), i, 1);
                    if (child.ExpectedReaction != null)
                    {
                        TextblockLayout reactionLayout = new TextblockLayout(child.ExpectedReaction, buttonFontSize * 0.9);
                        reactionLayout.AlignHorizontally(horizontalAlignment);
                        reactionLayout.AlignVertically(verticalAlignment);
                        activityOptionsGrid.PutLayout(reactionLayout, i, 2);
                    }
                }

                LayoutChoice_Set optionsAtThisFontSize;
                if (badSuggestion)
                {
                    // If the suggestion is bad and we don't really want the user to do it, then we also show the user some convenient buttons for making more activities
                    GridLayout wrapper = GridLayout.New(new BoundProperty_List(1), BoundProperty_List.WithRatios(new List <double>()
                    {
                        suggestion.Children.Count, 1
                    }), LayoutScore.Zero);
                    wrapper.AddLayout(activityOptionsGrid);                            // activity suggestions
                    wrapper.AddLayout(this.make_otherActivities_layout(mainFontSize)); // layout for making new activities
                    optionsAtThisFontSize = wrapper;
                }
                else
                {
                    // If the suggestion isn't bad, then the options we give are just the activities being suggested
                    optionsAtThisFontSize = activityOptionsGrid;
                }
                specificFont_contentChoices.Add(optionsAtThisFontSize);
            }

            LayoutChoice_Set contentGrid = LayoutUnion.New(specificFont_contentChoices);

            // Add cancel buttons to the bottom
            this.cancelButton                         = new Button();
            this.cancelButton.Clicked                += cancelButton_Click;
            this.explainWhyYouCantSkipButton          = new Button();
            this.explainWhyYouCantSkipButton.Clicked += ExplainWhyYouCantSkipButton_Clicked;
            ButtonLayout cancelLayout;

            if (suggestion.Skippable)
            {
                cancelLayout = new ButtonLayout(this.cancelButton, "X");
            }
            else
            {
                cancelLayout = new ButtonLayout(this.explainWhyYouCantSkipButton, "!");
            }



            fullBuilder.AddLayout(contentGrid)
            .AddLayout(cancelLayout);

            this.SubLayout = fullBuilder.BuildAnyLayout();
        }
示例#24
0
        public ActivityNameEntryBox(string title, ActivityDatabase activityDatabase, LayoutStack layoutStack, bool createNewActivity = false, bool placeTitleAbove = true)
        {
            // some settings
            this.layoutStack               = layoutStack;
            this.AutoAcceptAutocomplete    = true;
            this.createNewActivity         = createNewActivity;
            this.activityDatabase          = activityDatabase;
            this.numAutocompleteRowsToShow = 1;

            // the box the user is typing in
            this.nameBox              = new Editor();
            this.nameBox.TextChanged += NameBox_TextChanged;
            this.nameBox_layout       = new TextboxLayout(this.nameBox);

            // "X"/"?" button for clearing text or getting help
            // We use one button for both purposes so that the layout doesn't relayout (and shift focus) when this button switches from one to the other
            this.sideButton          = new Button();
            this.sideButton.Clicked += SideButton_Clicked;
            this.sideButtonLayout    = new ButtonLayout(this.sideButton);

            // layouts controlling the alignment of the main text box and the side button
            this.sideLayout           = new ContainerLayout();
            this.sideLayout.SubLayout = this.sideButtonLayout;

            GridView   gridView = new GridView();
            GridLayout evenBox  = GridLayout.New(new BoundProperty_List(1), BoundProperty_List.WithRatios(new List <double>()
            {
                7, 1
            }), LayoutScore.Zero, 1, gridView);
            GridLayout unevenBox = GridLayout.New(new BoundProperty_List(1), new BoundProperty_List(2), LayoutScore.Get_UnCentered_LayoutScore(1), 1, gridView);

            evenBox.AddLayout(this.nameBox_layout);
            evenBox.AddLayout(this.sideLayout);
            unevenBox.AddLayout(this.nameBox_layout);
            unevenBox.AddLayout(this.sideLayout);
            this.nameBoxWithSideLayout = new LayoutUnion(evenBox, unevenBox);

            // the autocomplete above the text box
            this.autocompleteLayout = new TextblockLayout();
            this.autocompleteLayout.ScoreIfEmpty = false;

            // button that gives help with autocomplete
            this.helpWindow = new HelpWindowBuilder()
                              .AddMessage("This screen explains how to enter " + title + " in the previous screen. " +
                                          "If you haven't already created the activity that you want to enter here, you will have to go back and create it first in the Activities screen.")
                              .AddMessage("")
                              .AddMessage("To input an activity name, you may type it in using the letters on the keyboard.")
                              .AddMessage("While you do this, ActivityRecommender will try to guess which activity you mean, and " +
                                          "that autocomplete guess will appear above. If this autocomplete suggestion is what you want, then you can press " +
                                          "[enter] to use the autocomplete suggestion.")
                              .AddMessage("Autocomplete does not require you to type full words but it does require spaces between words.")
                              .AddMessage("Autocomplete does not require that you type letters using the correct case but it is more effective if you do.")
                              .AddMessage("Consider the following example:")
                              .AddMessage("If you have already entered an activity named \"Taking out the Garbage\", " +
                                          "here are some things you can type that might cause it to become the autocomplete suggestion:")
                              .AddMessage("Taking out the")
                              .AddMessage("Taking")
                              .AddMessage("out")
                              .AddMessage("Garbage")
                              .AddMessage("garbage")
                              .AddMessage("Taking o t G")
                              .AddMessage("T o t G")
                              .AddMessage("T")
                              .AddMessage("G")
                              .AddMessage("t")
                              .AddMessage("")
                              .AddMessage("Note, of course, that the longer and more unique your text, the more likely that it will be matched with the activity that you intend, rather than " +
                                          "with another activity, like for example, 'Talking on the Phone'")
                              .AddLayout(new CreditsButtonBuilder(layoutStack)
                                         .AddContribution(ActRecContributor.ANNI_ZHANG, new DateTime(2020, 6, 7), "Pointed out that completed ToDos should have a very low autocomplete priority")
                                         .Build()
                                         )
                              .Build();

            // help buttons that appear when the user types something invalid
            Button help_createNew_button = new Button();

            help_createNew_button.Clicked   += help_createNew_button_Clicked;
            this.autocomplete_longHelpLayout = new Horizontal_GridLayout_Builder().Uniform()
                                               .AddLayout(new ButtonLayout(help_createNew_button, "Create"))
                                               .AddLayout(new HelpButtonLayout(this.helpWindow, layoutStack))
                                               .Build();

            // the main layout that contains everything
            LayoutChoice_Set content;

            if (createNewActivity)
            {
                content = unevenBox;
            }
            else
            {
                GridLayout contentWithFeedback = GridLayout.New(new BoundProperty_List(2), new BoundProperty_List(1), LayoutScore.Get_UnCentered_LayoutScore(1));
                contentWithFeedback.AddLayout(this.responseLayout);
                contentWithFeedback.AddLayout(this.nameBoxWithSideLayout);

                content = contentWithFeedback;

                this.UpdateFeedback();
            }

            this.updateSideButton();

            TextblockLayout titleLayout = new TextblockLayout(title);

            titleLayout.AlignHorizontally(TextAlignment.Center);
            if (placeTitleAbove)
            {
                this.SubLayout = new Vertical_GridLayout_Builder()
                                 .AddLayout(titleLayout)
                                 .AddLayout(content)
                                 .Build();
            }
            else
            {
                GridLayout evenGrid   = GridLayout.New(new BoundProperty_List(1), BoundProperty_List.Uniform(2), LayoutScore.Zero);
                GridLayout unevenGrid = GridLayout.New(new BoundProperty_List(1), new BoundProperty_List(2), LayoutScore.Get_UnCentered_LayoutScore(1));
                evenGrid.AddLayout(titleLayout);
                unevenGrid.AddLayout(titleLayout);
                evenGrid.AddLayout(content);
                unevenGrid.AddLayout(content);
                this.SubLayout = new LayoutUnion(evenGrid, unevenGrid);
            }
        }