示例#1
0
        public static void UpdateEntries(int start, int einde)
        {
            if (start > einde)
            {
                WriteLn("HUH? I cannot update the entries when the start value is lower than the end value");
                return;
            }
            var cp = CurrentProject; if (cp == null)
            {
                return;
            }
            var ls = new ListStore(typeof(string), typeof(string), typeof(string), typeof(string), typeof(string));

            //var bt = QOpen.ReadFile(cp.EntryFile);
            //while (!bt.EOF){
            for (int i = einde; i >= start; i--)
            {
                var e = new dvEntry(cp, i, true);                //(bt, start, einde);
                if (e == null)
                {
                    break;
                }
                if (e.Loaded)
                {
                    ls.AppendValues($"{i}", e.Tag, e.Pure, e.Date, e.Time);
                }
            }
            //bt.Close();
            Entries.Model = ls;
        }
示例#2
0
        static void AddEntry(string junk)
        {
            var p = junk.IndexOf(' '); if (p < 0)
            {
                GUI.WriteLn("ADD: Syntax error!"); return;
            }
            var tag     = junk.Substring(0, p).ToUpper().Trim();
            var content = junk.Substring(p + 1).Trim();
            var cp      = CurrentProject;

            if (cp == null)
            {
                GUI.WriteLn("ADD: No project!"); return;
            }
            if (!cp.GotTag(tag))
            {
                GUI.WriteLn($"ADD: Tag {tag} does not exist!"); return;
            }
            // Prefix handling
            var MustSave = false;

            foreach (string id in cp.Prefixes.Keys)
            {
                var pf = cp.Prefixes[id];
                pf.CD--;
                //GUI.WriteLn($"Prefix {id} CD at: {pf.CD}/{pf.Reset}");
                if (pf.CD <= 0)
                {
                    content = $"{pf.Prefix} {content}"; pf.CD += Math.Abs(pf.Reset); MustSave = true;
                }
            }
            if (MustSave)
            {
                cp.SaveMe();
            }
            var e = new dvEntry(cp, tag, content);

            GUI.WriteLn($"Added entry #{e.RecID}");
            GUI.UpdateEntries(cp.HighestRecordNumber - 200, cp.HighestRecordNumber);
            GUI.UpdatePrefix();
            // Autopush
            cp.autopush--;
            if (cp.autopush < 0)
            {
                DoCommand("GEN");
                DoCommand("PUSH");
                cp.autopush = 10;
                cp.SaveMe();
            }
            else if (cp.autopush == 0)
            {
                GUI.WriteLn("Next addition will trigger the autopush");
            }
            else
            {
                GUI.WriteLn($"Auto-Push after {cp.autopush+1} more additions");
            }
        }
示例#3
0
 static public void Init()
 {
     MKL.Lic("Development Log - Command.cs", "GNU General Public License 3");
     MKL.Version("Development Log - Command.cs", "20.07.24");
     Commands["ANNOY"]        = Annoy;
     Commands["BYE"]          = Bye;
     Commands["SAY"]          = delegate(string yeah) { GUI.WriteLn(yeah, true); };
     Commands["F**K"]         = delegate { Annoy("Did your mother never teach you not to say such words?"); };
     Commands["YULERIA"]      = delegate { Annoy("Yuleria's rule of revenge:\nAn amateur kills people! A professional makes them suffer!"); };
     Commands["GLOBALCONFIG"] = GlobalConfig;
     Commands["USE"]          = delegate(string useme) { GUI.Use(useme); };
     Commands["SYSVARS"]      = delegate { if (CurrentProject == null)
                                           {
                                               GUI.WriteLn("No project!"); return;
                                           }
                                           foreach (string v in CurrentProject.Data.Vars())
                                           {
                                               GUI.WriteLn(v);
                                           }
     };
     Commands["VARS"] = delegate { if (CurrentProject == null)
                                   {
                                       GUI.WriteLn("No project!"); return;
                                   }
                                   foreach (string v in CurrentProject.Data.Vars())
                                   {
                                       if (qstr.Prefixed(v, "VAR."))
                                       {
                                           GUI.WriteLn(v);
                                       }
                                   }
     };
     Commands["LET"]    = LetVar;
     Commands["NEWTAG"] = NewTag;
     Commands["ADDTAG"] = NewTag;
     Commands["ADD"]    = AddEntry;
     Commands["GEN"]    = delegate { Export.Gen(); };
     Commands["ABOUT"]  = delegate {
         GUI.WriteLn($"This tool has been created and copyrighted by Jeroen P. Broks\nIs has been released under the terms of the GPL version 3\n\nCompiled on the next source files:\n\n{MKL.All()}");
     };
     Commands["CLH"]    = delegate { GUI.ClearHistory(); };
     Commands["CLS"]    = delegate { GUI.ClearConsole(); };
     Commands["PUSH"]   = delegate { GUI.WriteLn("Thanks to Ziggo I cannot push yet, but that comes later!"); };
     Commands["GO"]     = Go;
     Commands["UNLINK"] = Delete;
     Commands["DELETE"] = Delete;
     Commands["KILL"]   = Delete;
     Commands["RM"]     = Delete;
     Commands["REMOVE"] = Delete;
     Commands["DEL"]    = Delete;
     Commands["CREATE"] = Create;
     Commands["SAVE"]   = delegate { if (CurrentProject != null)
                                     {
                                         CurrentProject.SaveMe(); GUI.WriteLn("Saved!");
                                     }
                                     else
                                     {
                                         Annoy("No Project!");
                                     } };
     Commands["TAKE"] = Take;
     Commands["EDIT"] = delegate(string num) {
         if (CurrentProject == null)
         {
             Annoy("No Project!"); return;
         }
         var e = new dvEntry(CurrentProject, qstr.ToInt(num), true);
         if (e == null)
         {
             Annoy("Entry couldn't be accessed!"); return;
         }
         GUI.SetPrompt($"MODIFY {num} {e.Tag} {e.Pure}");
     };
     Commands["MODIFY"] = delegate(string str) {
         var args = str.Split(' ');
         if (CurrentProject == null)
         {
             Annoy("No Project!"); return;
         }
         if (args.Length < 3)
         {
             Annoy("Modify syntax error!"); return;
         }
         var num = qstr.ToInt(args[0]);
         var e   = new dvEntry(CurrentProject, num, true);
         if (e == null)
         {
             Annoy("Entry couldn't be accessed!"); return;
         }
         var tag = args[1].ToUpper();
         if (!CurrentProject.GotTag(tag))
         {
             Annoy($"There's no tag: {tag}"); return;
         }
         var sb = new System.Text.StringBuilder();
         e.Tag = tag;
         for (int i = 2; i < args.Length; ++i)
         {
             sb.Append($"{args[i]} ");
         }
         e.Pure = sb.ToString().Trim();
         GUI.UpdateEntries(CurrentProject.HighestRecordNumber - 200, CurrentProject.HighestRecordNumber);
     };
 }
示例#4
0
        static public void Gen()
        {
            string template;
            var    cp = CurrentProject; if (cp == null)

            {
                GUI.WriteLn("GEN: No project!"); return;
            }

            try {
                System.IO.Directory.CreateDirectory(OutDir);
            } catch (Exception e) {
                GUI.WriteLn($"GEN: {e.Message}");
                return;
            }
            int    pages        = cp.CountRecords / 200;
            int    page         = 1;
            int    pcountdown   = 200;
            bool   justnewpaged = false;
            string olddate      = "____OLD____";

            string[] iconext = { "png", "gif", "svg", "jpg" };
            if (cp.CountRecords % 200 > 0)
            {
                pages++;
            }
            try{
                template = QuickStream.LoadString(cp.Template.Trim());
            } catch {
                QuickGTK.Error($"Template {cp.Template} could not be properly loaded!");
                GUI.WriteLn($"GEN:Template {cp.Template} could not be properly loaded!");
                return;
            }
            GUI.Write("Exporting...");
            var pageline = "";

            for (int p = 1; p <= pages; p++)
            {
                if (page == p)
                {
                    pageline += $"<big><big>{p}</big></big> ";
                }
                else
                {
                    pageline += $"<a href='{cp.PrjName}_DevLog_Page_{p}.html'>{p}</a> ";
                }
            }
            pageline = pageline.Trim();
            var content = new System.Text.StringBuilder($"<table style=\"width:{cp.GetDataDefaultInt("EXPORT.TABLEWIDTH", 1200)}\">\n");

            content.Append($"<tr><td colspan=3 align=center>{pageline}</td></tr>\n");
            for (int i = cp.HighestRecordNumber; i > 0; i--)
            {
                //if (i % 6 == 0) { GUI.Write("."); Console.Write($".{i}."); }
                justnewpaged = false;
                var rec = new dvEntry(cp, i, true);
                if (rec.Loaded)
                {
                    if (rec.Date != olddate)
                    {
                        content.Append($"<tr><td align=center colspan=3 style='font-size:30pt;'>- = {rec.Date} = -</td></tr>\n");
                    }
                    olddate = rec.Date;
                    string headstyle    = cp.Data.C($"HEAD.{rec.Tag.ToUpper()}");
                    string contentstyle = cp.Data.C($"INHD.{rec.Tag.ToUpper()}");
                    content.Append($"<tr valign=top><td align=left><a id='dvRec_{rec.RecID}'></a>{rec.Time}</td><td style=\"{headstyle}\">{rec.Tag}</td><td style='width: { cp.GetDataDefaultInt("EXPORT.CONTENTWIDTH", 800)}; {contentstyle}'><div style=\"width: { cp.GetDataDefaultInt("EXPORT.CONTENTWIDTH", 800)}; overflow-x:auto;\">");
                    var alticon = cp.Data.C($"ICON.{rec.Tag.ToUpper()}").Trim();
                    if (alticon == "")
                    {
                        var icon    = $"{OutDir}/Icons/{rec.Tag.ToLower()}";
                        var neticon = $"Icons/{rec.Tag.ToLower()}";
                        neticon = neticon.Replace("#", "%23");
                        icon    = icon.Replace("#", "hashtag");
                        foreach (string pfmt in iconext)
                        {
                            var iconfile = $"{icon}.{pfmt}";
                            iconfile = iconfile.Replace("#", "%23");
                            if (System.IO.File.Exists(iconfile))
                            {
                                content.Append($"<img style='float:{cp.GetDataDefault("EXPORT.ICONFLOATPOSITION", "Right")}; height:{cp.GetDataDefaultInt("EXPORT.ICONHEIGHT", 50)}' src='{neticon}.{pfmt}' alt='{rec.Tag}'>"); break;
                            }
                        }
                    }
                    else
                    {
                        //content.Append($"<img style='float:{cp.GetDataDefault("EXPORT.ICONFLOATPOSITION", "Right")}; height:{cp.GetDataDefaultInt("EXPORT.ICONHEIGHT", 50)};'  src='{alticon}' alt='{rec.Tag}'>");
                        content.Append($"<img style='float:{cp.GetDataDefault("EXPORT.ICONFLOATPOSITION", "Right")};' height='{cp.GetDataDefaultInt("EXPORT.ICONHEIGHT", 50)}' src='{alticon}' alt='{rec.Tag}'>");
                    }
                    content.Append($"{rec.Text}</div></td></tr>\n");
                    pcountdown--;
                    if (pcountdown <= 0)
                    {
                        pcountdown   = 200;
                        justnewpaged = true;
                        content.Append($"<tr><td colspan=3 align=center>{pageline}</td></tr>\n</table>\n\n");
                        QuickStream.SaveString($"{OutDir}/{cp.PrjName}_DevLog_Page_{page}.html", template.Replace("@CONTENT@", content.ToString()));
                        page++;
                        pageline = "";
                        for (int p = 1; p <= pages; p++)
                        {
                            if (page == p)
                            {
                                pageline += $"<big><big>{p}</big></big> ";
                            }
                            else
                            {
                                pageline += $"<a href='{cp.PrjName}_DevLog_Page_{p}.html'>{p}</a> ";
                            }
                        }
                        content = new System.Text.StringBuilder($"<table style=\"width:{cp.GetDataDefaultInt("EXPORT.TABLEWIDTH", 1200)}\">\n");
                        content.Append($"<tr><td colspan=3 align=center>{pageline}</td></tr>\n");
                    }
                }
            }
            if (!justnewpaged)
            {
                content.Append($"<tr><td colspan=3 align=center>{pageline}</td></tr>\n</table>");
                QuickStream.SaveString($"{OutDir}/{cp.PrjName}_DevLog_Page_{page}.html", template.Replace("@CONTENT@", content.ToString()));
            }
            GUI.WriteLn(" Done");
            Console.WriteLine(" GENERATED");
        }