Beispiel #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_Conclusion(object se, EventArgs ee)
        {
            if (emotionHolder == null)
            {
                return;
            }

            topFlex.Children.Clear();

            List <CustomConclusion> custom = Customization.GetConclusion(emotionHolder.GetName(), subjectHolder.GetName());
            int count = (/*emotionHolder.conclusions.Count +*/ custom.Count);

            if (count > 9)
            {
                int      i       = 0;
                Button[] buttons = new Button[count];
                count--;
                counter = 0;
                foreach (CustomConclusion c in custom)
                {
                    strsize = c.GetConclusion().Length;
                    ff      = Math.Round((proportion / strsize), 1);
                    if (ff > 34)
                    {
                        ff = 34;
                    }
                    Button temp = new Button {
                        Text = c.GetConclusion(), 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_CustomConclusion(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 (CustomConclusion c in custom)
                {
                    strsize = c.GetConclusion().Length;
                    ff      = Math.Round((proportion / strsize), 1);
                    if (ff > 34)
                    {
                        ff = 34;
                    }
                    Button temp = new Button {
                        Text = c.GetConclusion(), 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_CustomConclusion(s, e);
                    topFlex.Children.Add(temp);
                    counter++;
                }
            }

            text.FontSize = 28;
            text.Text     = subjectHolder.GetName() + " " + emotionHolder.GetName();

            customConclusionHolder = null;
            canGoBack = true;
        }
Beispiel #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();

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

            border.BackgroundColor = col;                                       //sets border of top frame to 'col'
            string str = (se as Button).Text;

            emotionHolder = subjectHolder.GetEmotion(str);

            if (keepTut)
            {
                Tutorial.self.tutSetPageTwo(se, ee, tutFourText, 0.6, 0.05);
            }

            List <CustomConclusion> custom = Customization.GetConclusion(emotionHolder.GetName(), subjectHolder.GetName());
            int count = (/*emotionHolder.conclusions.Count +*/ custom.Count);

            if (count > 9)
            {
                int      i       = 0;
                Button[] buttons = new Button[count];
                count--;
                counter = 0;
                foreach (CustomConclusion c in custom)
                {
                    strsize = c.GetConclusion().Length;
                    ff      = Math.Round((proportion / strsize), 1);
                    if (ff > 34)
                    {
                        ff = 34;
                    }
                    Button temp = new Button {
                        Text = c.GetConclusion(), 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_CustomConclusion(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 (CustomConclusion c in custom)
                {
                    strsize = c.GetConclusion().Length;
                    ff      = Math.Round((proportion / strsize), 1);
                    if (ff > 34)
                    {
                        ff = 34;
                    }
                    Button temp = new Button {
                        Text = c.GetConclusion(), 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_CustomConclusion(s, e);
                    topFlex.Children.Add(temp);
                    counter++;
                }
            }

            text.Text = subjectHolder.GetName() + " " + emotionHolder.GetName();
            canGoBack = true;
        }