Ejemplo n.º 1
0
        internal static void BuildHtmlDocs(FrmBuildHtmlDocument.ProcessInfo ProcessInfoHandler)
        {
            string[] all_cards_paths = Globals.GetPathOfEachCard();
            foreach (string card_path in all_cards_paths)
            {
                try
                {
                    BuildHtmlDocs(card_path, ProcessInfoHandler);
                }
                catch
                {
                    continue;
                }
            }

            string[] all_groups = Globals.GetPathOfEachGroup();
            if (all_groups != null)
            {
                foreach (string group in all_groups)
                {
                    try
                    {
                        BuildHtmlGroupInfo(group, ProcessInfoHandler);
                    }
                    catch
                    {
                        continue;
                    }
                }
            }
            BuildRootDocument(ProcessInfoHandler);
        }
Ejemplo n.º 2
0
        private static void BuildRootDocument(FrmBuildHtmlDocument.ProcessInfo ProcessInfoHandler)
        {
            if (ProcessInfoHandler != null)
            {
                ProcessInfoHandler("RememberIt.html");
            }

            string root_path = Globals.GetCardsPath();

            string[] group_paths = Globals.GetPathOfEachGroup();
            if (group_paths == null)
            {
                return;
            }

            byte[] file_bytes     = RememberItTemplate;
            string card_group_doc = ASCIIEncoding.ASCII.GetString(file_bytes);

            card_group_doc = card_group_doc.Replace("$groups", Globals.GetButtonsForGroups());

            file_bytes = ASCIIEncoding.ASCII.GetBytes(card_group_doc);

            if (file_bytes.Length <= 3)
            {
                return;
            }
            file_bytes[0] = 0xEF;
            file_bytes[1] = 0xBB;
            file_bytes[2] = 0xBF;
            string html_file_name = root_path + "/RememberIt.html";

            File.WriteAllBytes(html_file_name, file_bytes);

            Process.Start(html_file_name);
        }
Ejemplo n.º 3
0
        private static void BuildHtmlGroupInfo(string group, FrmBuildHtmlDocument.ProcessInfo ProcessInfoHandler)
        {
            if (ProcessInfoHandler != null)
            {
                ProcessInfoHandler(group);
            }

            string[] card_paths = Globals.GetPathOfEachCard(group);
            if (card_paths == null)
            {
                return;
            }

            byte[] file_bytes     = GroupTemplate;
            string card_group_doc = ASCIIEncoding.ASCII.GetString(file_bytes);

            card_group_doc = card_group_doc.Replace("$home", GetButton("Home", 100, 30, "../RememberIt.html"));
            card_group_doc = card_group_doc.Replace("$group_name", Globals.GetLastPartOfDir(group));
            card_group_doc = card_group_doc.Replace("$missed_cards", GetButtonsForMissedCards(group));
            card_group_doc = card_group_doc.Replace("$pending_cards", GetButtonsForPendingCards(group));
            card_group_doc = card_group_doc.Replace("$stage_0", GetButtonsForStage(group, 0));
            card_group_doc = card_group_doc.Replace("$stage_1", GetButtonsForStage(group, 1));
            card_group_doc = card_group_doc.Replace("$stage_2", GetButtonsForStage(group, 2));
            card_group_doc = card_group_doc.Replace("$stage_3", GetButtonsForStage(group, 3));
            card_group_doc = card_group_doc.Replace("$stage_4", GetButtonsForStage(group, 4));
            card_group_doc = card_group_doc.Replace("$stage_5", GetButtonsForStage(group, 5));
            file_bytes     = ASCIIEncoding.ASCII.GetBytes(card_group_doc);

            if (file_bytes.Length <= 3)
            {
                return;
            }
            file_bytes[0] = 0xEF;
            file_bytes[1] = 0xBB;
            file_bytes[2] = 0xBF;
            File.WriteAllBytes(group + "/Group.html", file_bytes);


            //foreach (string cp in card_paths)
            //{
            //    try
            //    {

            //    }
            //    catch
            //    {
            //        continue;
            //    }
            //}
        }
Ejemplo n.º 4
0
        public static void BuildHtmlDocs(string CardPath, FrmBuildHtmlDocument.ProcessInfo ProcessInfoHandler)
        {
            if (Globals.GetShuldBuildHtmlDocs() == 0)
            {
                return;
            }
            if (ProcessInfoHandler != null)
            {
                ProcessInfoHandler(CardPath);
            }

            Build(CardPath, "Q");
            Build(CardPath, "A");
            Build(CardPath, "R");
            Build(CardPath, "H");
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            FrmBuildHtmlDocument.ProcessInfo ProcessInfoHandler = null;
            Globals.BuildHtmlDocs(this.CardFolder, ProcessInfoHandler);
            CreateSnapshot();

            string q_dir = ctrlQuestion.WorkingFolder;

            if (Directory.Exists(q_dir) == false)
            {
                MessageBox.Show(string.Format("Unable to save content because directory '{0}' is missing.", q_dir));
                return;
            }
            if (Directory.GetFiles(q_dir).Length == 0)
            {
                MessageBox.Show(string.Format("Unable to save content because 'Question' content is empty."));
                tcCard.SelectedIndex = 0;
                return;
            }


            string a_dir = ctrlAnswer.WorkingFolder;

            if (Directory.Exists(a_dir) == false)
            {
                MessageBox.Show(string.Format("Unable to save content because directory '{0}' is missing.", a_dir));
                return;
            }
            if (Directory.GetFiles(a_dir).Length == 0)
            {
                MessageBox.Show(string.Format("Unable to save content because 'Answer' content is empty."));
                tcCard.SelectedIndex = 1;
                return;
            }


            this.save_is_pressed = true;
            this.external_ask_to_discard_is_in_process = false;
            if (this.OnClose != null)
            {
                this.OnClose(null, null);
            }
        }