Exemplo n.º 1
0
        public static string[] GetPathOfEachCard(string Group, int Stage)
        {
            string[]      all_cards = Globals.GetPathOfEachCard(Group);
            List <string> card_list = new List <string>();

            foreach (string c in all_cards)
            {
                try
                {
                    string     manifest_file = c + "\\manifest.man";
                    KeyValPair kv            = new KeyValPair(';', ':');
                    kv.Load(manifest_file);
                    int stg = int.Parse(kv.GetVal("stage"));
                    if (stg == Stage)
                    {
                        card_list.Add(c);
                    }
                }
                catch
                {
                    continue;
                }
            }
            return(card_list.ToArray());
        }
Exemplo n.º 2
0
        internal static string[] GetPathOfEachMissedCard(string GroupPath)
        {
            string[]      cards        = Globals.GetPathOfEachCard(GroupPath);
            List <string> missed_cards = new List <string>();

            foreach (string c in cards)
            {
                try
                {
                    MultiCalendar mc            = MultiCalendar.FromDateTime(DateTime.Now);
                    double        gdp_now       = mc.GetGdp();
                    string        manifest_file = c + "\\manifest.man";
                    KeyValPair    kv            = new KeyValPair(';', ':');
                    kv.Load(manifest_file);
                    double nv_gdp = double.Parse(kv.GetVal("next_visit"));
                    if (nv_gdp < gdp_now)
                    {
                        missed_cards.Add(c);
                    }
                }
                catch
                {
                    continue;
                }
            }
            return(missed_cards.ToArray());
        }
Exemplo n.º 3
0
        internal static string[] GetPathOfEachMissedCard()
        {
            string[] all_cards = Globals.GetPathOfEachCard();
            if (all_cards == null)
            {
                // MessageBox.Show("No cards found.");
                return(null);
            }
            List <string> pending_cards = new List <string>();

            foreach (string c in all_cards)
            {
                try
                {
                    MultiCalendar mc            = MultiCalendar.FromDateTime(DateTime.Now);
                    double        gdp_now       = mc.GetGdp();
                    string        manifest_file = c + "\\manifest.man";
                    KeyValPair    kv            = new KeyValPair(';', ':');
                    kv.Load(manifest_file);
                    double nv_gdp = double.Parse(kv.GetVal("next_visit"));
                    if (nv_gdp < gdp_now)
                    {
                        pending_cards.Add(c);
                    }
                }
                catch
                {
                    continue;
                }
            }
            return(pending_cards.ToArray());
        }
Exemplo n.º 4
0
        internal static string GetDefaultGroupPath()
        {
            KeyValPair kv = new KeyValPair(';', ':');
            string     settings_file_name = Globals.GetExecutablePath() + "Settings.stg";

            kv.Load(settings_file_name);
            string def_group = kv.GetVal("DefaultGroup");

            return(def_group);
        }
Exemplo n.º 5
0
        internal static void SetDefaultGroup(string DefaultCardGroupPath)
        {
            if (Directory.Exists(DefaultCardGroupPath) == false)
            {
                return;
            }

            KeyValPair kv = new KeyValPair(';', ':');
            string     settings_file_name = Globals.GetExecutablePath() + "Settings.stg";

            kv.Load(settings_file_name);
            kv.SetVal("DefaultGroup", DefaultCardGroupPath);
            kv.Save(settings_file_name);
        }
Exemplo n.º 6
0
 private int GetStage()
 {
     try
     {
         KeyValPair manifest = new KeyValPair(';', ':');
         manifest.Load(this.ManifestAbsFileName);
         string stg   = manifest.GetVal("stage");
         int    stage = int.Parse(stg);
         return(stage);
     }
     catch
     {
         return(0);
     }
 }
Exemplo n.º 7
0
 private double GetNextVisit()
 {
     try
     {
         KeyValPair manifest = new KeyValPair(';', ':');
         manifest.Load(this.ManifestAbsFileName);
         string nv         = manifest.GetVal("next_visit");
         double next_visit = double.Parse(nv);
         return(next_visit);
     }
     catch
     {
         return(0);
     }
 }
Exemplo n.º 8
0
        public static void OpenImageEditor(string ImageFile)
        {
            KeyValPair kv = new KeyValPair(';', ':');

            kv.Load(Globals.GetExecutablePath() + "settings.stg");
            string image_editor_path = kv.GetVal("ImageEditor");

            if (File.Exists(image_editor_path) == false)
            {
                return;
            }
            try
            {
                Process.Start(image_editor_path, ImageFile);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 9
0
 public static int GetShuldBuildHtmlDocs()
 {
     if (ShouldBuildHtmlDocs == -1)
     {
         KeyValPair kv = new KeyValPair(';', ':');
         string     settings_file_name = Globals.GetExecutablePath() + "Settings.stg";
         kv.Load(settings_file_name);
         string build_html_docs_str = kv.GetVal("BuildHtmlDocs");
         try
         {
             ShouldBuildHtmlDocs = int.Parse(build_html_docs_str);
         }
         catch
         {
             //MessageBox.Show("Building HTML documents is disabled.");
             ShouldBuildHtmlDocs = 0;
         }
     }
     return(ShouldBuildHtmlDocs);
 }
Exemplo n.º 10
0
        private void btnWrongAnswer_Click(object sender, RoutedEventArgs e)
        {
            if (CurrentCardIndex == -1)
            {
                return;
            }
            Card c = Cards[CurrentCardIndex];

            try
            {
                KeyValPair kv = new KeyValPair(';', ':');
                kv.Load(c.ManifestAbsFileName);
                int stage = Convert.ToInt32(kv.GetVal("stage"));
                stage = 0;
                kv.SetVal("stage", stage.ToString());
                MultiCalendar mc  = MultiCalendar.FromDateTime(DateTime.Now);
                double        gdp = mc.GetGdp();
                gdp += Math.Pow(2, stage);
                mc.SetGdp(gdp);
                kv.SetVal("next_visit", gdp.ToString());
                kv.Save(c.ManifestAbsFileName);
                string msg = string.Format("Stage -> {0}\r\nNext -> {1}", stage, mc.GetJalDate());

                string history = string.Format("\r\n[{0}] Wrong Answer. Stage: {1}", Globals.GetDateTimeStampSec(), stage);
                File.AppendAllText(c.HistoryAbsFileName, history);

                MessageBox.Show(msg);

                this.Cards.RemoveAt(CurrentCardIndex);
                Present();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to access manifest file\r\n" + ex.Message);
                System.Diagnostics.Process.Start(c.CardAbsPath);
            }
        }