Ejemplo n.º 1
0
        /// <summary>
        /// When user presses button to go to conclusion list
        /// Only call from XAML
        /// </summary>
        /// <param name="se"></param>
        /// <param name="ee"></param>
        void Handle_Goto_Solution(object se, EventArgs ee)
        {
            List <Solution> custom = HelpCustomization.GetSolutions(emotion);
            int             count  = custom.Count;

            if (custom.Count > 9)
            {
                int      i       = 0;
                Button[] buttons = new Button[custom.Count];
                count--;
                counter = 0;

                foreach (Solution c in custom)
                {
                    strsize = c.GetSolution().Length;
                    ff      = Math.Round((proportion / strsize), 1);
                    if (ff > 34)
                    {
                        ff = 34;
                    }
                    Button temp = new Button {
                        Text = c.GetSolution(), Padding = 5, FontSize = ff
                    };
                    AbsoluteLayout.SetLayoutBounds(temp, new Rectangle(0.5 * (counter % 3), 0.5 * (counter / 3), 0.33, 0.33));
                    AbsoluteLayout.SetLayoutFlags(temp, AbsoluteLayoutFlags.All);
                    temp.Clicked += (s, e) => Handle_Solution(s, e);
                    buttons[i++]  = temp;
                    counter++;
                    if (counter >= 7)
                    {
                        counter = 0;
                    }
                }

                i = 0;

                if (page > 0)
                {
                    Button temp = new Button {
                        Text = "<-", Padding = 10, FontSize = 26
                    };
                    AbsoluteLayout.SetLayoutBounds(temp, new Rectangle(0.5, 1, 0.33, 0.33));
                    AbsoluteLayout.SetLayoutFlags(temp, AbsoluteLayoutFlags.All);
                    temp.Clicked += (s, e) => Handle_Page_Decrease(s, e);
                    topFlex.Children.Add(temp);
                }
                else
                {
                    topFlex.Children.Add(buttons[i++ + (page * 7)]);
                }

                topFlex.Children.Add(buttons[i++ + (page * 7)]);

                if (page < (custom.Count / 7))
                {
                    Button temp = new Button {
                        Text = "->", Padding = 10, FontSize = 26
                    };
                    AbsoluteLayout.SetLayoutBounds(temp, new Rectangle(1, 1, 0.33, 0.33));
                    AbsoluteLayout.SetLayoutFlags(temp, AbsoluteLayoutFlags.All);
                    temp.Clicked += (s, e) => Handle_Page_Increase(s, e);
                    topFlex.Children.Add(temp);
                }

                for (; i < 7; i++)
                {
                    if (i + (page * 7) >= buttons.Length)
                    {
                        break;
                    }
                    topFlex.Children.Add(buttons[i + (page * 7)]);
                }
            }
            else
            {
                counter = 0;
                foreach (Solution c in custom)
                {
                    strsize = c.GetSolution().Length;
                    ff      = Math.Round((proportion / strsize), 1);
                    if (ff > 34)
                    {
                        ff = 34;
                    }
                    Button temp = new Button {
                        Text = c.GetSolution(), Padding = 5, FontSize = ff
                    };
                    AbsoluteLayout.SetLayoutBounds(temp, new Rectangle(0.5 * (counter % 3), 0.5 * (counter / 3), 0.33, 0.33));
                    AbsoluteLayout.SetLayoutFlags(temp, AbsoluteLayoutFlags.All);
                    temp.Clicked += (s, e) => Handle_Solution(s, e);
                    topFlex.Children.Add(temp);
                    counter++;
                }
            }

            text.FontSize = 28;
            text.Text     = emotion;

            //text.Text = subjectHolder.GetName() + " " + emotionHolder.GetName();
            canGoBack = true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// When user presses an emotion button
        /// Only call from XAML
        /// </summary>
        /// <param name="se"></param>
        /// <param name="ee"></param>
        void Handle_Emotion(object se, EventArgs ee)
        {
            topFlex.Children.Clear();

            if (MainPage.self.getKeepTut())
            {
                Tutorial.self.tutSetPageFour(se, ee, tutSevenText, 0.3, 0.05);
            }

            emotion = (se as Button).Text;
            Color col = ((se as Button).Parent as StackLayout).BackgroundColor; //gets color of emotion button

            border.BackgroundColor = col;                                       //sets border of top frame to 'col'

            //emotion = emotion.ToUpper();
            List <Solution> custom = HelpCustomization.GetSolutions(emotion);
            int             count  = custom.Count;

            if (count > 9)
            {
                int      i       = 0;
                Button[] buttons = new Button[count];
                count--;
                counter = 0;
                foreach (Solution c in custom)
                {
                    strsize = c.GetSolution().Length;
                    ff      = Math.Round((proportion / strsize), 1);
                    if (ff > 34)
                    {
                        ff = 34;
                    }
                    Button temp = new Button {
                        Text = c.GetSolution(), Padding = 5, FontSize = ff
                    };
                    AbsoluteLayout.SetLayoutBounds(temp, new Rectangle(0.5 * (counter % 3), 0.5 * (counter / 3), 0.33, 0.33));
                    AbsoluteLayout.SetLayoutFlags(temp, AbsoluteLayoutFlags.All);
                    temp.Clicked += (s, e) => Handle_Solution(s, e);
                    buttons[i++]  = temp;
                    counter++;
                    if (counter >= 7)
                    {
                        counter = 0;
                    }
                }

                i = 0;

                if (page > 0)
                {
                    Button temp = new Button {
                        Text = "<-", Padding = 10, FontSize = 26
                    };
                    AbsoluteLayout.SetLayoutBounds(temp, new Rectangle(0.5, 1, 0.33, 0.33));
                    AbsoluteLayout.SetLayoutFlags(temp, AbsoluteLayoutFlags.All);
                    temp.Clicked += (s, e) => Handle_Page_Decrease(s, e);
                    topFlex.Children.Add(temp);
                }
                else
                {
                    topFlex.Children.Add(buttons[i++ + (page * 7)]);
                }

                topFlex.Children.Add(buttons[i++ + (page * 7)]);

                if (page < (count / 7))
                {
                    Button temp = new Button {
                        Text = "->", Padding = 10, FontSize = 26
                    };
                    AbsoluteLayout.SetLayoutBounds(temp, new Rectangle(1, 1, 0.33, 0.33));
                    AbsoluteLayout.SetLayoutFlags(temp, AbsoluteLayoutFlags.All);
                    temp.Clicked += (s, e) => Handle_Page_Increase(s, e);
                    topFlex.Children.Add(temp);
                }

                for (; i < 7; i++)
                {
                    if (i + (page * 7) >= buttons.Length)
                    {
                        break;
                    }
                    topFlex.Children.Add(buttons[i + (page * 7)]);
                }
            }
            else
            {
                counter = 0;
                foreach (Solution c in custom)
                {
                    strsize = c.GetSolution().Length;
                    ff      = Math.Round((proportion / strsize), 1);
                    if (ff > 34)
                    {
                        ff = 34;
                    }
                    Button temp = new Button {
                        Text = c.GetSolution(), Padding = 5, FontSize = ff
                    };
                    AbsoluteLayout.SetLayoutBounds(temp, new Rectangle(0.5 * (counter % 3), 0.5 * (counter / 3), 0.33, 0.33));
                    AbsoluteLayout.SetLayoutFlags(temp, AbsoluteLayoutFlags.All);
                    temp.Clicked += (s, e) => Handle_Solution(s, e);
                    topFlex.Children.Add(temp);
                    counter++;
                }
            }

            text.FontSize = 28;
            text.Text     = emotion;
            //text.Text = subjectHolder.GetName() + " " + emotionHolder.GetName();
            canGoBack = true;
        }