Exemple #1
0
        /// <summary>
        /// When user presses a conclusion button
        /// Only call from XAML
        /// </summary>
        /// <param name="se"></param>
        /// <param name="ee"></param>
        void Handle_Solution(object se, EventArgs ee)
        {
            //topFlex.Children.Clear();

            string str = (se as Button).Text;
            string tut = "";

            solution = HelpCustomization.GetSolution(str);

            String sentence = "When I am " + solution.GetEmotion().ToLower() + " " + solution.GetConnection() + " " + solution.GetSolution() + ".";

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

            if (MainPage.self.getKeepTut())
            {
                tut = tutEightText;
                Tutorial.self.tutSetPageFour(se, ee, tutNineText, 0.1, 0.05);
                topFlex.IsEnabled         = false;
                bottomFlex.IsEnabled      = true;
                CustomizeButton.IsEnabled = false;
                SpeakButton.IsEnabled     = false;
            }
            DisplayAlert(tut + "Solution", "When I am " + solution.GetEmotion().ToLower() + " " + solution.GetConnection() + " " + solution.GetSolution() + ".", "OK");
            canGoBack = true;
        }
        /// <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
                Solution newSolution = new Solution(emotion.Items[emotion.SelectedIndex].ToUpper(), conjunction.Text.Trim(), conclusion.Text.Trim());
                HelpCustomization.ReplaceCustomSolution(originalSolution, newSolution);
                HelpCustomization.Save();

                //Customization.Reload();
            }));
        }
Exemple #3
0
        /// <summary>
        /// Cusotm phrase listing screen
        /// </summary>
        public HelpCustomization()
        {
            emotionList = true;
            if (!loaded)
            {
                Reload();
            }
            else
            {
                ReloadItems();
            }

            InitializeComponent();
            self = this;
        }
Exemple #4
0
        /// <summary>
        /// Load the default list of Conclusions from the included Options.csv
        /// </summary>
        public static void Init()
        {
            if (File.Exists(Customization.customFilename))
            {
                Customization.Reload();

                foreach (CustomConclusion c in Customization.conclusions)
                {
                    AddPhrase(Time.Preset, c.GetSubject(), c.GetEmotion());
                }
            }
            else
            {
                //TODO: this needs to be changed to work with iOS
                string res = "Oigo.Droid.Options.csv";

                Stream s = IntrospectionExtensions.GetTypeInfo(typeof(GlobalData)).Assembly.GetManifestResourceStream(res);
                using (StreamReader reader = new StreamReader(s))
                {
                    string   line;
                    string   subject    = "";
                    string   emotion    = "";
                    string[] connection = new string[3];
                    string[] conclusion = new string[3];
                    string[] temp;

                    while ((line = reader.ReadLine()) != null)
                    {
                        if (line.StartsWith(".") || line.Replace(',', ' ').Trim().Length == 0)
                        {
                            continue;
                        }

                        temp = line.Trim().Split(',');
                        if (temp[0].Trim().Length > 0)
                        {
                            subject = temp[0].Trim();
                        }
                        if (temp[1].Trim().Length > 0)
                        {
                            emotion = temp[1].Trim();
                        }
                        if (temp[2].Trim().Length > 0)
                        {
                            connection[0] = temp[2].Trim();
                            connection[1] = temp[5].Trim();
                            connection[2] = temp[8].Trim();
                        }
                        if (temp[3].Trim().Length > 0)
                        {
                            conclusion[0] = temp[3].Trim();
                            conclusion[1] = temp[6].Trim();
                            conclusion[2] = temp[9].Trim();
                            for (int i = 0; i < 3; i++)
                            {
                                AddPhrase((Time)i, subject, emotion, connection[i], conclusion[i]);
                            }
                        }
                    }
                }
                Customization.Save();
            }

            if (File.Exists(HelpCustomization.customFilename))
            {
                HelpCustomization.Reload();
            }
            else
            {
                //TODO: this needs to be changed to work with iOS
                string res = "Oigo.Droid.Helpme.csv";

                Stream s = IntrospectionExtensions.GetTypeInfo(typeof(GlobalData)).Assembly.GetManifestResourceStream(res);
                using (StreamReader reader = new StreamReader(s))
                {
                    string   line;
                    string   subject    = "";
                    string   emotion    = "";
                    string   connection = "";
                    string   solution   = "";
                    string[] temp;

                    while ((line = reader.ReadLine()) != null)
                    {
                        if (line.StartsWith(".") || line.Replace(',', ' ').Trim().Length == 0)
                        {
                            continue;
                        }

                        temp = line.Trim().Split(',');
                        if (temp[0].Trim().Length > 0)
                        {
                            subject = temp[0].Trim();
                        }
                        if (temp[1].Trim().Length > 0)
                        {
                            emotion = temp[1].Trim();
                        }
                        if (temp[2].Trim().Length > 0)
                        {
                            connection = temp[2].Trim();
                        }
                        if (temp[3].Trim().Length > 0)
                        {
                            solution = temp[3].Trim();
                            HelpCustomization.solutions.Add(new Solution(emotion, connection, solution));
                        }
                    }
                }
                HelpCustomization.Save();
            }

            if (File.Exists(Tutorial.customFilename))
            {
                ;
            }
            else
            {
                string res = "Oigo.Droid.tutStart.txt";

                Stream s = IntrospectionExtensions.GetTypeInfo(typeof(GlobalData)).Assembly.GetManifestResourceStream(res);
                using (StreamReader sr = new StreamReader(s))
                {
                    string line;
                    line = sr.ReadLine();
                    File.WriteAllText(Tutorial.customFilename, line);
                }
            }
        }
Exemple #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_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;
        }
Exemple #6
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;
        }