示例#1
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));
        }
        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)");
        }