Example #1
0
        public App()
        {
            //TOOD: may want to move this and add a spinner if it causes too much lag
            GlobalData.Init();
            Customization.Reload();

            InitializeComponent();

            MainPage = new Oigo.MainPage();
        }
Example #2
0
        /// <summary>
        /// When the user presses Customization
        /// Only call from XAML
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Customize_Button_Clicked(object sender, EventArgs e)
        {
            if (Navigation.ModalStack.Count < 1)
            {
                if (!Customization.IsLoaded())
                {
                    await Navigation.PushModalAsync(new LoadingIndicator());

                    await Task.Run(() =>
                    {
                        Customization.Reload();
                    });

                    await Navigation.PopModalAsync(false);
                }

                //await Navigation.PushModalAsync(new Customization());
                await Navigation.PushModalAsync(new HelpMe(false));
            }
        }
Example #3
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);
                }
            }
        }