예제 #1
0
        static public void RenewProjects()
        {
            ProjectList.Clear();
            string[] filelist;
            string   workspace = MainClass.GetConfig("WORKSPACE");

            if (workspace == "")
            {
                QuickGTK.Error("I don't know where to look for projects! Please use the command GLOBALCONFIG WORKSPACE=/home/username/MyWorkSpace/ or something like that");
                return;
            }
            try
            {
                filelist = FileList.GetDir(workspace + "/Projects", 0, true, false);
            }
            catch
            {
                QuickGTK.Error("Reading the project folder failed! Has it been properly configured?");
                return;
            }
            foreach (string f in filelist)
            {
                if (qstr.Suffixed(f, ".prj"))
                {
                    ProjectList.AddItem(qstr.Left(f, f.Length - 4));
                }
            }
        }
예제 #2
0
        static void OnTxt(object sender, EventArgs e)
        {
            if (uneditable)
            {
                return;
            }
            if (!objlink.ContainsKey(sender))
            {
                QuickGTK.Error("INTERNAL ERROR!\n\nTextbox not properly bound to memory field!\n\nPlease report!"); return;
            }
            var field = objlink[sender];
            //var txtf = (sender as TextView);
            var    buf  = (sender as Entry); //(sender as TextBuffer );//txtf.Buffer;
            var    txt  = buf.Text;
            int    itxt = 0;
            double dtxt = 0;

            //QuickGTK.Info ($"Editing textfield: {field}");//debug
            switch (MyDataBase.fields[field].ToLower())
            {
            case "string":
                currentrec.value[field] = txt;
                break;

            case "int":
                if (txt != "" && txt != "-")
                {
                    try
                    {
                        itxt = Int32.Parse(txt);
                    } catch {
                        QuickGTK.Error($"'{txt}' is not a valid integer.");
                        itxt = 0;
                    }
                }
                currentrec.value[field] = $"{itxt}";
                break;

            case "double":
                if (txt != "" && txt != "-")
                {
                    try
                    {
                        dtxt = Double.Parse(txt);
                    }
                    catch
                    {
                        QuickGTK.Error($"'{txt}' is not a valid double.");
                        dtxt = 0;
                    }
                }
                currentrec.value[field] = $"{dtxt}";
                break;

            default:
                QuickGTK.Error($"Internal error!\n\nType {MyDataBase.fields[field].ToLower()} should never have bound itself to a textbox\n\nPlease report this!");
                break;
            }
            currentrec.MODIFIED = true;
        }
예제 #3
0
        static void OnGoForIt(object sender, EventArgs e)
        {
            var outdir = Data["Project"].Text;
            var prj    = System.IO.Path.GetFileName(outdir);
            var langs  = Languages.Buffer.Text.Split('\n');
            var gini   = new TGINI();

            gini.D("Author", Data["Author"].Text);
            gini.D("Copyright", Data["Author"].Text);
            gini.D("Notes", Data["License"].Text);
            gini.D("License", Data["License"].Text);
            gini.D("lzma", "YES");
            var outt = "[rem]\nEmpty now\n[tags]\n\n[scenario]\n\n";
            var li   = 0;

            if (langs.Length < 1)
            {
                QuickGTK.Error("At least one language is required to do the job!"); return;
            }
            foreach (string flang in langs)
            {
                li++;
                Console.WriteLine($"Creating language #{li}: {flang}");
                var lang = flang.Trim(); gini.D($"Lang{li}.Name", lang);
                var outj = outdir + "/" + lang + ".jcr"; gini.D($"Lang{li}.File", outj);
                var jo   = new TJCRCreate(outj, "lzma");
                jo.AddString(outt, "BASICENTRY", "lzma", Data["Author"].Text, Data["License"].Text);
                jo.Close();
            }
            Console.WriteLine("Creating project GINI");
            gini.SaveSource(outdir + "/" + prj + ".scenlang.gini");
            QuickGTK.Info("Project has been created.\nYou can now use the regular ScenLang tool and open project file:\n\n" + outdir + "/" + prj + ".scenlang.gini");
            Application.Quit();
        }
예제 #4
0
        override public string XClass(string cln)
        {
            var today = DateTime.Today;

            //classname = $"{qstr.md5($"Mydata_{MyDataBase.License}{today.DayOfWeek}") }_{ qstr.md5($"MyData_{today.DayOfWeek}")}";
            classname = $"MyDataClass_{cln}";
            var ret = new StringBuilder($"class MyData_{classname}\n");

            foreach (var dk in MyDataBase.defaults.Keys)
            {
                Console.WriteLine($"Default {dk} = {MyDataBase.defaults[dk]}");
            }
            foreach (var n in MyDataBase.fields.Keys)
            {
                var t  = MyDataBase.fields[n];
                var nu = n.ToUpper();
                switch (t)
                {
                case "info":
                case "strike":
                    break;     // Nothing I need here!

                case "string":
                case "mc":
                    ret.Append($"\tstring {n}");
                    if (MyDataBase.defaults.ContainsKey(nu))
                    {
                        ret.Append($" = \"{qstr.SafeString(MyDataBase.defaults[nu])}\"");
                    }
                    ret.Append("\n");
                    break;

                case "int":
                    ret.Append($"\tint {n}");
                    if (MyDataBase.defaults.ContainsKey(nu))
                    {
                        ret.Append($" = {qstr.ToInt(MyDataBase.defaults[nu])}");
                    }
                    ret.Append("\n");
                    break;

                case "bool":
                case "boolean":
                    ret.Append($"\tbool {n}");
                    if (MyDataBase.defaults.ContainsKey(nu))
                    {
                        ret.Append($" = {MyDataBase.defaults[nu].ToLower()}");
                    }
                    ret.Append("\n");
                    break;

                default:
                    QuickGTK.Error($"Unknown field type \"{n}\"! Field ignored and further exports will lead to errors in Neil!");
                    break;
                }
            }
            ret.Append("end\n");
            return($"{ret}");
        }
예제 #5
0
 static void Load_JCR6()
 {
     Assets = JCR6.Dir(Dirry.C("$AppDir$/jcr/Kobud.jcr"));
     if (Assets == null)
     {
         QuickGTK.Error(JCR6.JERROR);
         throw new Exception(JCR6.JERROR);
     }
 }
예제 #6
0
        static void AndACTION(object sender, EventArgs a)
        {
            var cmd = Prompt.Text;

            Prompt.Text = "";
            CommandHistory.AddItem(cmd);
            for (int i = 0; i < cmd.Length; ++i)
            {
                if (cmd[i] < 32 || cmd[i] > 126)
                {
                    QuickGTK.Error($"Non ASCII character found on position: {i} -> {cmd[i]}/{(int)cmd[i]}/{((int)cmd[i]).ToString("X")}");
                    return;
                }
            }
            CommandClass.DoCommand(cmd);
        }
예제 #7
0
 static void OnForceMod(object sender, EventArgs e)
 {
     if (sc_rec == "")
     {
         ButForceMod.Sensitive = false; return;
     }
     if (MyDataBase.Record.ContainsKey(sc_rec))
     {
         MyDataBase.Record[sc_rec].MODIFIED = true;
         //QuickGTK.Info($"Forcemodding {sc_rec}");
         ButForceMod.Sensitive = false;
     }
     else
     {
         QuickGTK.Error($"ForceModding {sc_rec} failed!");
     }
 }
예제 #8
0
        static public void SelectRecord(string recname)
        {
            uneditable = true;
            // declications
            var rec = MyDataBase.Record[recname];

            currentrec = rec;
            // Activate pages
            MainClass.Pages.Sensitive       = true;
            MainClass.ButForceMod.Sensitive = !rec.MODIFIED;
            MainClass.MenuBoxInput.Hide();
            MainClass.ButRemove.Sensitive = true;
            MainClass.ButRename.Sensitive = true;
            MainClass.ButDupe.Sensitive   = true;


            // Strings and other textbox related types
            foreach (string k in MainClass.DStrings.Keys)
            {
                if (!rec.value.ContainsKey(k))
                {
                    QuickGTK.Warn($"The {MyDataBase.fields[k]} {k} contains no data in this record! Creating data!");
                    //if (MyDataBase.fields[k] == "string") rec.value[k] = ""; else rec.value[k] = "0";
                    switch (MyDataBase.fields[k])
                    {
                    case "bool":
                        rec.value[k] = "FALSE";
                        break;

                    case "int":
                    case "double":
                        rec.value[k] = "0";
                        break;

                    default:
                        rec.value[k] = "";
                        break;
                    }
                }
                var tv = MainClass.DStrings[k];
                //tv.Buffer.Text = rec.value[k];
                tv.Text = rec.value[k];
            }

            // Booleans
            foreach (string k in MainClass.RBTbools.Keys)
            {
                var btrue  = MainClass.RBTbools[k];
                var bfalse = MainClass.RBFbools[k];
                if (!rec.value.ContainsKey(k))
                {
                    //QuickGTK.Warn($"{MyDataBase.fields[k]} contains no data in this record! Creating data!");
                    QuickGTK.Warn($"Boolean {k} contains no data in this record! Creating data!");
                    rec.value[k] = "FALSE";
                }
                btrue.Active  = rec.value[k].ToUpper() == "TRUE";
                bfalse.Active = rec.value[k].ToUpper() != "TRUE";
            }
            // mc
            foreach (string k in MainClass.mc.Keys)
            {
                var mc   = MainClass.mc[k];
                var mcid = MainClass.mcval2index;
                if (!rec.value.ContainsKey(k))
                {
                    QuickGTK.Warn($"{MyDataBase.fields[k]} contains no data in this record! Creating data!");
                    rec.value[k] = "";
                }
                if (!mcid.ContainsKey(k))
                {
                    QuickGTK.Warn("Empty mc list!");
                }
                else
                {
                    var mci   = mcid[k];
                    var value = rec.value[k];
                    if (value != "")
                    {
                        if (mci.ContainsKey(value))
                        {
                            mc.Active = mci[value];
                        }
                        else
                        {
                            QuickGTK.Error($"The value set for field '{k}' is '{value}', however that value is NOT listed!\n\nSetting ignored!");
                        }
                    }
                }
            }
            foreach (string k in MainClass.Dates.Keys)
            {
                if (!rec.value.ContainsKey(k))
                {
                    QuickGTK.Warn($"{MyDataBase.fields[k]} {k} contains no data in record '{recname}'! Creating data!");
                    rec.value[k] = "19/6/1975";
                }
                MainClass.Dates[k].Value = rec.value[k];
            }
            foreach (string k in MainClass.Times.Keys)
            {
                if (!rec.value.ContainsKey(k))
                {
                    QuickGTK.Warn($"{MyDataBase.fields[k]} {k} contains no data in record '{recname}'! Creating data!");
                    rec.value[k] = "01:02:03";
                }
                MainClass.Times[k].Value = rec.value[k];
            }
            foreach (string k in MainClass.Colors.Keys)
            {
                if (!rec.value.ContainsKey(k))
                {
                    QuickGTK.Warn($"{MyDataBase.fields[k]} {k} contains no data in record '{recname}'! Creating data!");
                    rec.value[k] = "255;255;255";
                }
                MainClass.Colors[k].Value = rec.value[k];
            }
            RunAllow();
            uneditable = false;
        }
예제 #9
0
        public static void RunAllow()
        {
            //var key = "";
            List <string> myList;

            string[] Boolean;
            var      v = "";
            //var presult = false;
            var work    = "";
            var OutCome = false;

            if (currentrec == null)
            {
                return;
            }
            var r = currentrec.value;

            if (r == null)
            {
                return;
            }
            //var t = "";
            var Blocked     = new List <string>();
            var Allow       = MyDataBase.Allow; // I'm lazy I know, I don't need YOU to tell me! :P
            var Fields      = MyDataBase.fields;
            var fieldonpage = MyDataBase.fieldonpage;
            var o           = false;

            foreach (string key in Allow.Keys)
            {
                myList  = Allow[key];//TList(MapValueForKey(Allow, key))
                Boolean = key.Split(' ');
                //'If (Len boolean)<>1 And Len(Boolean)<>3 Error "Misformed Allow condition"
                v = Boolean[0];
                if (qstr.Prefixed(v, "!"))
                {
                    v = qstr.Right(v, qstr.Len(v) - 1); o = true;
                }
                if (!Fields.ContainsKey(v))
                {
                    QuickGTK.Error($"Trying to check {v} for allowance. That field does not exist!\n\nAllow check aborted!");
                    return;
                }
                switch (Boolean.Length)
                {
                case 1:
                    switch (Fields[v])
                    {
                    case "string":
                    case "mc":
                    case "color":
                    case "date":
                    case "time":
                        OutCome = r[v] != "";
                        break;

                    case "bool": OutCome = r[v] == "TRUE"; break;

                    case "int":
                    case "double":
                        OutCome = qstr.ToInt(r[v]) != 0;
                        break;

                    case "":
                        error("Non-existent variable: " + v);
                        break;         // Unreachable, but required!

                    default:
                        error("Type \"" + Fields[v] + "\" is not (yet) compatible with the [ALLOW] conditional definitions");
                        break;
                    }
                    break;

                case 3:
                    switch (Boolean[1])
                    {
                    case "=":
                    case "==":
                        OutCome = r[v] == Boolean[2];         //'Print v +" = "+r.value(v)+" = "+boolean[2]+" >>> "+outcome
                        break;

                    case "{}":
                        OutCome = false;
                        foreach (string vvv in Boolean[2].Split(','))
                        {
                            OutCome = OutCome || r[v] == vvv;
                        }
                        break;

                    case "!=":
                    case "<>":
                    case "~=":
                    case "=/=":
                        OutCome = r[v] != Boolean[2];
                        break;

                    case "<":
                        switch (Fields[v])
                        {
                        case "int": OutCome = qstr.ToInt(r[v]) < qstr.ToInt(Fields[Boolean[2]]); break;

                        case "double": error("double not yet supported for > or < comparing "); break;

                        //Case "double"   outcome = r.value(v).todouble()<fields.value(boolean[2]).todouble()
                        default: error("Illegal type"); break;
                        }
                        break;

                    case ">":
                        switch (Fields[v])
                        {
                        case "int": OutCome = qstr.ToInt(r[v]) > qstr.ToInt(Fields[Boolean[2]]); break;

                        case "double": error("double not yet supported for > or < comparing "); break;

                        //Case "double"   outcome = r.value(v).todouble()<fields.value(boolean[2]).todouble()
                        default: error("Illegal type"); break;
                        }
                        break;

                    case "<=":
                        switch (Fields[v])
                        {
                        case "int": OutCome = qstr.ToInt(r[v]) <= qstr.ToInt(Fields[Boolean[2]]); break;

                        case "double": error("double not yet supported for > or < comparing "); break;

                        //Case "double"   outcome = r.value(v).todouble()<fields.value(boolean[2]).todouble()
                        default: error("Illegal type"); break;
                        }
                        break;

                    case ">=":
                        switch (Fields[v])
                        {
                        case "int": OutCome = qstr.ToInt(r[v]) > qstr.ToInt(Fields[Boolean[2]]); break;

                        case "double": error("double not yet supported for > or < comparing "); break;

                        //Case "double"   outcome = r.value(v).todouble()<fields.value(boolean[2]).todouble()
                        default: error("Illegal type"); break;
                        }
                        break;

                    default:
                        error("Unknown operator");
                        break;
                    }
                    break;

                default: error("Misformed Allow condition"); break;
                }
                if (o)
                {
                    OutCome = !OutCome;
                }
                bool oc;
                foreach (string wwork in Allow[key])
                {
                    work = wwork;
                    oc   = OutCome;
                    if (qstr.Prefixed(work, "!"))
                    {
                        work = qstr.RemPrefix(work, "!"); oc = !OutCome;
                    }
                    //'presult = outcome And (Not ListContains(banned,work))
                    if (qstr.Prefixed(work, "PREFIX:"))
                    {
                        foreach (string w in Fields.Keys)
                        {
                            if (qstr.RemPrefix(work, "PREFIX:") == w)
                            {
                                Dance(w, Blocked, oc);
                            }
                        }
                    }
                    else if (qstr.Prefixed(work, "PAGE:"))
                    {
                        //Print "Work with "+work+" >>> "+RemPrefix(work,"PAGE:")
                        foreach (string w in fieldonpage.Keys)
                        {
                            //'Print w+" = "+fieldonpage.value(w)+" "+remprefix(work,"PAGE:")+" "+Int(Trim(remprefix(work,"PAGE:"))=fieldonpage.value(w))
                            if (qstr.MyTrim(qstr.RemPrefix(work, "PAGE:")) == fieldonpage[w])
                            {
                                Dance(w, Blocked, oc);
                            }
                        }
                    }
                    else
                    {
                        Dance(work, Blocked, oc);
                    }
                }
            }
        }
예제 #10
0
        }// End Function

        static void error(string e)
        {
            QuickGTK.Error(e);
            throw new Exception(e); // Just to force the program to quit!
        }
예제 #11
0
 static void ThrowError(string error)
 {
     GUI.WriteLn($"ERROR:\t{error}");
     QuickGTK.Error($"!!ERROR!!\n\n{error}");
 }
예제 #12
0
파일: Export.cs 프로젝트: Tricky1975/Devlog
        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");
        }
예제 #13
0
        static void OnQIConfirm(object sender, EventArgs e)
        {
            var input = QI_Input.Text;
            var name  = input.ToUpper();

            MenuBoxInput.Hide();
            if (!QIValidName(name))
            {
                QuickGTK.Error("Invalid record name!\n\nRecord names may only contain letters, numbers and underscores!"); return;
            }
            if (MyDataBase.Record.ContainsKey(name))
            {
                if (!QuickGTK.Confirm($"A record named {name} already exists!\n\nIf you continue the old record will be destroyed and replaced by the new one!\n\nAre you sure?"))
                {
                    return;
                }
            }
            switch (want)
            {
            case "NEW":
                var newrec = new MyRecord();
                MyDataBase.Record[name] = newrec;
                foreach (string k in MyDataBase.fields.Keys)
                {
                    var uk = k.ToUpper();
                    newrec.value[k] = "";
                    switch (MyDataBase.fields[k])
                    {
                    case "int":
                    case "double":
                        newrec.value[k] = "0";
                        break;

                    case "bool":
                        newrec.value[k] = "FALSE";
                        break;

                    case "date":
                        newrec.value[k] = "19/6/1975";
                        break;

                    case "time":
                        newrec.value[k] = "00:00:00";
                        break;
                    }
                    if (MyDataBase.defaults.ContainsKey(uk))
                    {
                        newrec.value[k] = MyDataBase.defaults[uk];
                    }
                    Console.WriteLine($"Field: {MyDataBase.fields[k]} {k} = {newrec.value[k]}");
                }
                newrec.MODIFIED = true;
                MyDataBase.UpdateRecView();
                // TODO: New record should add default values if set.
                QuickGTK.Info($"Record {name} has been created!");
                break;

            case "DUPE":
                var rec = MyDataBase.Record[sc_rec];
                newrec = new MyRecord();
                MyDataBase.Record[name] = newrec;
                foreach (string k in MyDataBase.fields.Keys)
                {
                    newrec.value[k] = rec.value[k];
                }
                newrec.MODIFIED = true;
                MyDataBase.UpdateRecView();
                QuickGTK.Info($"Record {sc_rec} has been duplicated into {name}");
                break;

            case "RENAME":
                var crec = MyDataBase.Record[sc_rec];
                MyDataBase.Record.Remove(sc_rec);
                MyDataBase.Record[name] = crec;
                crec.MODIFIED           = true;
                MyDataBase.UpdateRecView();
                QuickGTK.Info($"Record {sc_rec} has been renamed to {name}\n\nWARNING!\nIf you've set MyData to record-by-record export files with the old name will remain!");
                break;

            default:
                QuickGTK.Error($"Internal error!\n\n\nInvalid input request --> {want}!");
                break;
            }
        }
예제 #14
0
        static public dvProject Get(string prjname)
        {
            try {
                if (LoadedProjects.ContainsKey(prjname))
                {
                    return(LoadedProjects[prjname]);
                }
                GUI.WriteLn($"Loading project: {prjname}");
                var ret = new dvProject();
                ret.myname = prjname;
                ret.myfile = $"{MainClass.WorkSpace}/Projects/{ret.myname}";
                try {
                    ret.Data = GINI.ReadFromFile($"{ret.myfile}.prj");
                } catch {
                    GUI.WriteLn($"ERROR:\tI could not read {ret.myfile}.prj");
                    QuickGTK.Error($"!!ERROR!!\n\nI could not read {ret.myfile}.prj");
                    return(null);
                } finally {
                    GUI.WriteLn("Complete!");
                }
                if (ret.Data == null)
                {
                    GUI.WriteLn($"ERROR:\tI could not read {ret.myfile}.prj");
                    QuickGTK.Error($"!!ERROR!!\n\nI could not read {ret.myfile}.prj");
                    return(null);
                }
                // Load Indexes
                var     bix = QuickStream.ReadFile($"{ret.myfile}.Index");
                byte    tag;
                dvIndex Index;
                GUI.WriteLn($"Loading indexes for project: {prjname}");
                while (!bix.EOF)
                {
                    //if (bix.EOF) { Console.WriteLine($"ERROR! Record {want} not found"); goto closure; } // I hate the "goto" command but in this particular case it's the safest way to go! (No I do miss the "defer" keyword Go has!)
                    tag = bix.ReadByte();
                    if (tag != 0)
                    {
                        GUI.WriteLn($"ERROR! Unknown index command tag {tag}!"); ret = null; goto closure;
                    }
                    Index        = new dvIndex();
                    Index.id     = bix.ReadInt();
                    Index.size   = bix.ReadLong();
                    Index.offset = bix.ReadLong();
                    if (ret.Indexes.ContainsKey(Index.id))
                    {
                        GUI.WriteLn($"WARNING!!! Duplicate index #{Index.id}. One of them will overwrite another");
                    }
                    ret.Indexes[Index.id] = Index;
                    //einde = offset + size;
                }                 //while (id != want);//(id < 0 || id < min || id > max);
                LoadedProjects[prjname] = ret;
                GUI.WriteLn($"Records:        {ret.CountRecords}");
                GUI.WriteLn($"Highest number: {ret.HighestRecordNumber}");
                ret.Data.CL("CDPREFIX");
                dvPrefix pref = null;
                foreach (string iline in ret.Data.List("CDPREFIX"))
                {
                    var line = iline.Trim();
                    if (line != "")
                    {
                        var p = line.IndexOf(':');
                        if (p < 0)
                        {
                            GUI.WriteLn("Invalid Prefix definition!");
                        }
                        else
                        {
                            var key   = line.Substring(0, p).Trim().ToUpper();
                            var value = line.Substring(p + 1).Trim();
                            if (key == "NEW")
                            {
                                pref = new dvPrefix();
                                ret.Prefixes[value] = pref;
                                GUI.WriteLn($"Prefix added:   {value}");
                            }
                            else if (pref == null)
                            {
                                GUI.WriteLn("Definition without prefix! Please check your prefix settings!");
                            }
                            else
                            {
                                pref.RawSet(key, value);
                                Console.WriteLine($"Prefix[\"{key}\"]=\"{value}\";");
                            }
                        }
                    }
                }
closure:
                bix.Close();
                return(ret);
            } catch (Exception E) {
                QuickGTK.Error(E.Message);
                return(null);
            }
        }