Ejemplo n.º 1
0
 private eSet FindEventSet(eSet src, string nm)
 {
     while (src != null && src.nm != nm)
     {
         src = src.nxt;
     }
     return(src);
 }
Ejemplo n.º 2
0
        ssEvent pEvent(ssScanner scnr, ssForm f)
        {
            ssEvent e;

            try {
                scnr.GetStrSpDelim();
                eSet es = FindEventSet(subsets, scnr.S);
                if (es != null)
                {
                    e = es.e.nxt.copy();
                    if (!AtEventBoundry(scnr))
                    {
                        scnr.GetChar();
                    }
                }
                else
                {
                    e   = new ssEvent();
                    e.k = (Keys)keyconv.ConvertFromString(scnr.S);
                    scnr.GetStrSpDelim(); e.t = pType(scnr.S);
                    if (e.t == ssEventType.press)
                    {
                        scnr.GetStrSpDelim(); e.c = pChar(scnr.S);
                    }
                    if (!AtEventBoundry(scnr))
                    {
                        scnr.GetStrSpDelim(); e.a = pAction(scnr.S, ref e.cmdopt);
                    }
                    if (!AtEventBoundry(scnr))
                    {
                        scnr.GetStrSpDelim(); e.cont = bool.Parse(scnr.S);
                    }
                    if (e.cmdopt != ssEventCmdOption.none)
                    {
                        scnr.SetDelim("\n");
                        scnr.AllowComment    = false;
                        scnr.GetStr(); e.cmd = scnr.S;
                        scnr.AllowComment    = true;
                        scnr.SetDelim("");
                        if (!AtEventBoundry(scnr))
                        {
                            scnr.GetChar();
                        }
                    }
                }
            }
            catch (Exception ee) {
                scnr.SetDelim("");
                scnr.AllowComment = true;
                throw new ssException("error parsing event in events file" + "\r\n?" + ee.Message);
            }
            return(e);
        }
Ejemplo n.º 3
0
        eSet pSet(ssScanner scnr, ssForm f)
        {
            eSet es = null;
            eSet ss = null;

            for (;;)
            {
                switch (scnr.C)
                {
                case '=':
                case '<':
                    char c = scnr.C;
                    scnr.GetChar();
                    scnr.GetStrSpDelim();
                    eSet s = new eSet(null);
                    s.nm    = scnr.S;
                    s.e     = new ssEvent();
                    s.e.nxt = pEventTree(scnr, f);
                    if (c == '=')
                    {
                        s.nxt = es;
                        es    = s;
                    }
                    else
                    {
                        s.nxt   = subsets;
                        subsets = s;
                    }
                    break;

                case '\0':
                    return(es);

                default:
                    if (char.IsWhiteSpace(scnr.C))
                    {
                        scnr.GetChar();
                    }
                    else
                    {
                        throw new ssException("error parsing event set in events file");
                    }
                    break;
                }
            }
        }
Ejemplo n.º 4
0
        private eSet LoadEvents(ssForm f, string fnm)
        {
            eSet es = null;
            //ssEvent es = new ssEvent();

            int       cnt  = 0;
            ssScanner scnr = null;

            while (cnt < 2 && scnr == null)
            {
                try {
                    cnt++;
                    try {
                        scnr = new ssScanner(File.ReadAllText(fnm), true); // try local
                    }
                    catch {
                        fnm = System.IO.Path.GetDirectoryName(Application.ExecutablePath) +
                              System.IO.Path.DirectorySeparatorChar + fnm;
                        scnr = new ssScanner(File.ReadAllText(fnm), true); // try exe one
                    }
                    scnr.GetChar();
                }
                catch {
                    try {
                        if (cnt < 2)
                        {
                            f.Ed.MsgLn("creating default events file");
                            StreamWriter sw = new StreamWriter(fnm);
                            sw.WriteLine(defEvents);
                            sw.WriteLine("# Available commands:");
                            foreach (MethodInfo m in methods)
                            {
                                if (m.Name.Length > 2 && m.Name.Substring(0, 3) == "Cmd")
                                {
                                    sw.WriteLine(string.Format("#   {0}", m.Name));
                                }
                            }
                            sw.Close();
                        }
                        else
                        {
                            throw new ssException("no events file");
                        }
                    }
                    catch (Exception ee) {
                        f.Ed.Err("error writing default events file" + "\r\n" + ee.Message);
                    }
                }
            }

            try {
                es = pSet(scnr, f);
            }
            catch (Exception e) {
                if (f == f.Ed.Log.Frm)
                {
                    f.Ed.Err(e.Message + ": " + scnr.S);                    // Guard this so you don't get messages for every form created.
                }
            }
            return(es);
        }
Ejemplo n.º 5
0
 public eSet(eSet set)
 {
     nxt = set;
 }