Exemplo n.º 1
0
        public static string GetDateTimeStampSec()
        {
            MultiCalendar mc         = new MultiCalendar();
            DateTime      dt         = DateTime.Now;
            string        time_stamp = string.Format("{0}:{1}:{2}", Pad2(dt.Hour), Pad2(dt.Minute), Pad2(dt.Second));

            mc.SetGregDate(dt.Year, dt.Month, dt.Day);
            string date_time_stamp = mc.GetJalDate() + "-" + time_stamp;

            return(date_time_stamp);
        }
Exemplo n.º 2
0
        public static string GetDateTimeStamp()
        {
            MultiCalendar mc         = new MultiCalendar();
            DateTime      dt         = DateTime.Now;
            string        time_stamp = string.Format("{0}{1}{2}-{3}", Pad2(dt.Hour), Pad2(dt.Minute), Pad2(dt.Second), Pad3(dt.Millisecond));

            mc.SetGregDate(dt.Year, dt.Month, dt.Day);
            string date_time_stamp = mc.GetJalDate().Replace("/", "") + "-" + time_stamp;

            return(date_time_stamp);
        }
Exemplo n.º 3
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("");
            }
        }
Exemplo n.º 4
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);
            }
        }