コード例 #1
0
        public static string CreateNewCard(string CardGroup)
        {
            try
            {
                string dir = GetExecutablePath();
                dir += @"Cards\";
                dir += CardGroup + @"\";
                dir += "C" + GetDateTimeStamp() + @"\";
                if (Directory.Exists(dir) == false)
                {
                    Directory.CreateDirectory(dir);
                }
                string history = string.Format("[{0}] Created. Stage: 0", Globals.GetDateTimeStampSec());
                File.WriteAllText(string.Format("{0}history.txt", dir), history);

                DateTime      now = DateTime.Now;
                MultiCalendar mc  = new MultiCalendar();
                mc.SetGregDate(now.Year, now.Month, now.Day);
                mc.SetTime(now.Hour, now.Minute, now.Second);
                double gdp = mc.GetGdp();

                KeyValPair kvp = new KeyValPair(';', ':');
                kvp.Add("next_visit", (gdp + 1).ToString());
                kvp.Add("next_visit_jal", mc.GetJalDate(DateSeparator: "") + "-" + mc.GetTime(TimeSeparator: ""));
                kvp.Add("next_visit_grg", mc.GetGregDate(DateSeparator: "") + "-" + mc.GetTime(TimeSeparator: ""));
                kvp.Add("stage", "0");
                kvp.Add("can_edit", "1");
                kvp.Add("last_modified", gdp.ToString());
                kvp.Add("crc", "0");
                string manifest_data = kvp.GetStrLines();

                //manifest_data += string.Format("next_visit={0}\r\n", gdp);
                //manifest_data += string.Format("stage={0}\r\n", 0);
                //manifest_data += string.Format("can_edit={0}\r\n", 1);
                //manifest_data += string.Format("last_modified={0}\r\n", gdp);
                //manifest_data += string.Format("crc={0}\r\n", 0);
                File.WriteAllText(string.Format("{0}manifest.man", dir), manifest_data);
                return(dir);
            }
            catch
            {
                return("");
            }
        }
コード例 #2
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);
            }
        }