Example #1
0
 /// <summary>
 /// Replace a conclusion with a new one
 /// </summary>
 /// <param name="originalConclusion">Conclusion to replace, or null if adding new conclusion</param>
 /// <param name="newConclusion">Conclusion to replace/add</param>
 public static void ReplaceCustomConclusion(CustomConclusion originalConclusion, CustomConclusion newConclusion)
 {
     if (originalConclusion != null)
     {
         conclusions.Remove(originalConclusion);
     }
     conclusions.Add(newConclusion);
 }
        /// <summary>
        /// await-able Task to save changes to the previously selected item/new item
        /// </summary>
        /// <returns></returns>
        private Task Save()
        {
            return(Task.Run(() =>
            {
                //Customization.conclusions
                CustomConclusion newConclusion = new CustomConclusion(subject.Items[subject.SelectedIndex], emotion.Items[emotion.SelectedIndex], conjunction.Text.Trim(), conclusion.Text.Trim());
                Customization.ReplaceCustomConclusion(originalConclusion, newConclusion);
                Customization.Save();

                //Customization.Reload();
            }));
        }
        /// <summary>
        /// Modify custom phrase screen
        /// </summary>
        /// <param name="c">The conclusion to modify, or null if new conclusion</param>
        public CustomizationCustomize(CustomConclusion c)
        {
            originalConclusion = c;

            InitializeComponent();

            if (c != null)
            {
                if (c.GetSubject().ToLower().StartsWith('i'))
                {
                    subject.SelectedIndex = 1;
                }
                else
                {
                    subject.SelectedIndex = 0;
                }

                emotion.SelectedIndex = emotion.Items.IndexOf(c.GetEmotion().ToLower());

                conjunction.Text = c.GetConjunction();
                conclusion.Text  = c.GetConclusion();
            }
        }
Example #4
0
        /// <summary>
        /// When user presses a custom conclusion button
        /// Only call from XAML
        /// </summary>
        /// <param name="se"></param>
        /// <param name="ee"></param>
        void Handle_CustomConclusion(object se, EventArgs ee)
        {
            string str = (se as Button).Text;
            string tut = "";

            customConclusionHolder = Customization.GetItem(str);

            string sentence = subjectHolder.GetName() + " " + emotionHolder.GetName() + " " + customConclusionHolder.GetConjunction() + " " + customConclusionHolder.GetConclusion() + (subjectHolder.GetName().ToLower().StartsWith("i") ? "." : "?");

            text.FontSize = CalculateFontSize(sentence);
            text.Text     = sentence;

            if (keepTut)
            {
                tut = "Your full sentence is displayed here:\r\n";
                Tutorial.self.tutSetPageTwo(se, ee, tutFiveText, 0.1, 0.05);
                topFlex.IsEnabled    = false;
                BackButton.IsEnabled = true;
            }

            DisplayAlert("Sentence", tut + subjectHolder.GetName() + " " + emotionHolder.GetName() + " " + customConclusionHolder.GetConjunction() + " " + customConclusionHolder.GetConclusion() + (subjectHolder.GetName().ToLower().StartsWith("i") ? "." : "?"), "OK");
            canGoBack = true;
        }
Example #5
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;
        }