示例#1
0
        public async Task <List <CompuMethod> > GetCompuMethods(string data)
        {
            if (!A2LCollection.IsCompuMethodVTabsLoaded)
            {
                A2LCollection.CompuMethodVTab = await GetCompuMethodVTabs(data);
            }
            List <CompuMethod> CompuMethods = new List <CompuMethod>();

            foreach (string compuMethodStr in GetFirstInstanceTextBetween(data, CM_ST_START, CM_ST_END))
            {
                CompuMethod compMet = new CompuMethod();
                string[]    strSplt = compuMethodStr.Split('\n');
                compMet.Name          = strSplt[0].Cleanup();
                compMet.Description   = strSplt[1].Cleanup();
                compMet.Type          = strSplt[2].Cleanup().ToEnum <CompuMethodType>();
                compMet.DisplayFormat = strSplt[3].Cleanup();
                compMet.Unit          = strSplt[4].Cleanup();
                var coeffStr = GetStringAfter(compuMethodStr, "COEFFS").Cleanup().Split(' ');
                if (coeffStr.Length > 1)
                {
                    compMet.Coefficients = Array.ConvertAll <string, double>(coeffStr, item => double.Parse(item));
                }
                var compuTabRefStrIndex = CompuMethodVTabRef.IndexOf(GetStringAfter(compuMethodStr, "COMPU_TAB_REF").Cleanup());
                if (compuTabRefStrIndex != -1)
                {
                    compMet.CompuTableReference = A2LCollection.CompuMethodVTab[compuTabRefStrIndex];
                }
                CompuMethods.Add(compMet);
                CompuMethodRef.Add(compMet.Name);
            }
            A2LCollection.IsCompuMethodsLoaded = true;
            return(CompuMethods);
        }
示例#2
0
    protected void OnTreeViewGlobalKeyPress(object o, KeyPressEventArgs args)
    {
        TreeView  tv = (TreeView)o;
        TreeStore tm = (TreeStore)tv.Model;
        TreeIter  root;
        TreeIter  ti;
        TreePath  tp;

        tm.GetIterFirst(out root);
        TreeViewColumn tvc;

        tv.GetCursor(out tp, out tvc);
        tm.GetIter(out ti, tp);
        int          level = tm.GetPath(ti).Depth;
        AbstractData dat;

        if (1 == level)           // Project level
        {
            dat = GPrj;
        }
        else if (2 == tm.GetPath(ti).Depth)              // Groups, like Tasks
        {
            switch ((string)tm.GetValue(ti, 0))
            {
            case "StateMachines":
                dat = GPrj.StateMachines;
                if (args.Event.Key == Gdk.Key.KP_Add)
                {
                    StateMachine sm = new StateMachine();
                    this.GPrj.StateMachines.Add(sm);
                    ti = tm.AppendValues(TIstatemachines, sm.name);
                    tp = tm.GetPath(ti);
                    tv.ExpandToPath(tp);
                    tv.SetCursor(tp, tvc, true);
                    //esm.LoadData (sm);
                }
                else
                {
                }
                break;

            case "Tasks":
                dat = GPrj.Tasks;
                if (args.Event.Key == Gdk.Key.KP_Add)
                {
                    Task tsk = new Task();
                    this.GPrj.Tasks.Add(tsk);
                    ti = tm.AppendValues(TItasks, tsk.name);
                    tp = tm.GetPath(ti);
                    tv.ExpandToPath(tp);
                    tv.SetCursor(tp, tvc, true);
                    //etsk.LoadData (tsk);
                }
                else
                {
                }
                break;

            case "Processes":
                dat = GPrj.Processes;
                if (args.Event.Key == Gdk.Key.KP_Add)
                {
                    Process prc = new Process();
                    this.GPrj.Processes.Add(prc);
                    ti = tm.AppendValues(TIprocesses, prc.name);
                    tp = tm.GetPath(ti);
                    tv.ExpandToPath(tp);
                    tv.SetCursor(tp, tvc, true);
                    //eprc.LoadData (prc);
                }
                else
                {
                }
                break;

            case "Messages":
                dat = GPrj.Messages;
                if (args.Event.Key == Gdk.Key.KP_Add)
                {
                    Message msg = new Message();
                    this.GPrj.Messages.Add(msg);
                    ti = tm.AppendValues(TImessages, msg.name);
                    tp = tm.GetPath(ti);
                    tv.ExpandToPath(tp);
                    tv.SetCursor(tp, tvc, true);
                    //emsg.LoadData (msg);
                }
                else
                {
                }
                break;

            case "CompuMethods":
                dat = GPrj.CompuMethods;
                if (args.Event.Key == Gdk.Key.KP_Add)
                {
                    CompuMethod cpmd;
                    int         resp = SelectCompuMethodToCreate(this);
                    if (1 == resp)
                    {
                        cpmd = new RationalFunction();
                    }
                    else if (2 == resp)
                    {
                        cpmd = new VerbalTable();
                    }
                    else
                    {
                        return;
                    }
                    this.GPrj.CompuMethods.Add(cpmd);
                    ti = tm.AppendValues(TIcompumethods, cpmd.name);
                    tp = tm.GetPath(ti);
                    tv.ExpandToPath(tp);
                    tv.SetCursor(tp, tvc, true);
                    //ecpmd.LoadData (cpmd);
                }
                else
                {
                }
                break;

            case "Units":
                dat = GPrj.Units;
                if (args.Event.Key == Gdk.Key.KP_Add)
                {
                    EasyOS.Unit unt = new EasyOS.Unit();
                    this.GPrj.Units.Add(unt);
                    ti = tm.AppendValues(TIunits, unt.name);
                    tp = tm.GetPath(ti);
                    tv.ExpandToPath(tp);
                    tv.SetCursor(tp, tvc, true);
                    //eunt.LoadData (unt);
                }
                else
                {
                }
                break;

            default:
                break;
            }
            this.statusBarLabel1.Text = tp.ToString();
        }
        else if (3 == level)             // Item, like Task
        {
            TreeIter tiL2;
            tm.IterParent(out tiL2, ti);
            this.alignFrmEditor.Remove(this.alignFrmEditor.Child);
            string itemName = (string)tm.GetValue(ti, 0);
            switch ((string)tm.GetValue(tiL2, 0))
            {
            case "StateMachines":
                StateMachine sm = this.GPrj.StateMachines.FindWithName(itemName);
                if (args.Event.Key == Gdk.Key.KP_Add)
                {
                    sm = new StateMachine();
                    this.GPrj.StateMachines.Add(sm);
                    ti = tm.AppendValues(TIstatemachines, sm.name);
                    tp = tm.GetPath(ti);
                    tv.SetCursor(tp, tvc, true);
                    //esm.LoadData (sm);
                }
                else if (args.Event.Key == Gdk.Key.KP_Subtract)
                {
                    this.GPrj.StateMachines.Remove(sm);
                    tm.Remove(ref ti);
                }
                else
                {
                }
                break;

            case "Tasks":
                Task tsk = this.GPrj.Tasks.FindWithName(itemName);
                if (args.Event.Key == Gdk.Key.KP_Add)
                {
                    tsk = new Task();
                    this.GPrj.Tasks.Add(tsk);
                    ti = tm.AppendValues(TItasks, tsk.name);
                    tp = tm.GetPath(ti);
                    tv.SetCursor(tp, tvc, true);
                    //etsk.LoadData (tsk);
                }
                else if (args.Event.Key == Gdk.Key.KP_Subtract)
                {
                    this.GPrj.Tasks.Remove(tsk);
                    tm.Remove(ref ti);
                }
                else
                {
                }
                break;

            case "Processes":
                Process prc = this.GPrj.Processes.FindWithName(itemName);
                if (args.Event.Key == Gdk.Key.KP_Add)
                {
                    prc = new Process();
                    this.GPrj.Processes.Add(prc);
                    ti = tm.AppendValues(TIprocesses, prc.name);
                    tp = tm.GetPath(ti);
                    tv.SetCursor(tp, tvc, true);
                    //eprc.LoadData (prc);
                }
                else if (args.Event.Key == Gdk.Key.KP_Subtract)
                {
                    this.GPrj.Processes.Remove(prc);
                    tm.Remove(ref ti);
                }
                else
                {
                }
                break;

            case "Messages":
                Message msg = this.GPrj.Messages.FindWithName(itemName);
                if (args.Event.Key == Gdk.Key.KP_Add)
                {
                    msg = new Message();
                    this.GPrj.Messages.Add(msg);
                    ti = tm.AppendValues(TImessages, msg.name);
                    tp = tm.GetPath(ti);
                    tv.SetCursor(tp, tvc, true);
                    //emsg.LoadData (msg);
                }
                else if (args.Event.Key == Gdk.Key.KP_Subtract)
                {
                    this.GPrj.Messages.Remove(msg);
                    tm.Remove(ref ti);
                }
                else
                {
                }
                break;

            case "CompuMethods":
                CompuMethod cpmd = this.GPrj.CompuMethods.FindWithName(itemName);
                if (args.Event.Key == Gdk.Key.KP_Add)
                {
                    int resp = SelectCompuMethodToCreate(this);
                    if (1 == resp)
                    {
                        cpmd = new RationalFunction();
                    }
                    else if (2 == resp)
                    {
                        cpmd = new VerbalTable();
                    }
                    else
                    {
                        return;
                    }
                    this.GPrj.CompuMethods.Add(cpmd);
                    ti = tm.AppendValues(TIcompumethods, cpmd.name);
                    tp = tm.GetPath(ti);
                    tv.SetCursor(tp, tvc, true);
                    //ecpmd.LoadData (cpmd);
                }
                else if (args.Event.Key == Gdk.Key.KP_Subtract)
                {
                    this.GPrj.CompuMethods.Remove(cpmd);
                    tm.Remove(ref ti);
                }
                else
                {
                }
                break;

            case "Units":
                EasyOS.Unit unt = this.GPrj.Units.FindWithName(itemName);
                if (args.Event.Key == Gdk.Key.KP_Add)
                {
                    unt = new EasyOS.Unit();
                    this.GPrj.Units.Add(unt);
                    ti = tm.AppendValues(TIunits, unt.name);
                    tp = tm.GetPath(ti);
                    tv.SetCursor(tp, tvc, true);
                    //eunt.LoadData (unt);
                }
                else if (args.Event.Key == Gdk.Key.KP_Subtract)
                {
                    this.GPrj.Units.Remove(unt);
                    tm.Remove(ref ti);
                }
                else
                {
                }
                break;

            default:
                this.alignFrmEditor.Child = egrp;
                break;
            }
            this.statusBarLabel1.Text = tp.ToString();
        }
        else
        {
        }
    }
示例#3
0
    protected void OnTreeViewGlobalCursorChanged(object sender, EventArgs e)
    {
        TreeView  tv = (TreeView)sender;
        TreeStore tm = (TreeStore)tv.Model;
        TreeIter  root;
        TreeIter  ti;
        TreePath  tp;

        tm.GetIterFirst(out root);
        TreeViewColumn tvc;

        tv.GetCursor(out tp, out tvc);
        tm.GetIter(out ti, tp);
        this.lblFrmEditor.Text = (string)tm.GetValue(ti, 0);
        if (1 == tm.GetPath(ti).Depth)            // Project level
        {
            this.addAction.Sensitive    = false;
            this.deleteAction.Sensitive = false;
            this.alignFrmEditor.Remove(this.alignFrmEditor.Child);
            this.alignFrmEditor.Child = eprj;
            eprj.LoadData(GPrj);
        }
        else if (2 == tm.GetPath(ti).Depth)              // Sub levels, like Tasks
        {
            this.addAction.Sensitive    = true;
            this.deleteAction.Sensitive = false;
            this.alignFrmEditor.Remove(this.alignFrmEditor.Child);
            this.alignFrmEditor.Child = egrp;
            switch ((string)tm.GetValue(ti, 0))
            {
            case "StateMachines":
                egrp.LoadData(GPrj.StateMachines);
                break;

            case "Tasks":
                egrp.LoadData(GPrj.Tasks);
                break;

            case "Processes":
                egrp.LoadData(GPrj.Processes);
                break;

            case "Messages":
                egrp.LoadData(GPrj.Messages);
                break;

            case "CompuMethods":
                egrp.LoadData(GPrj.CompuMethods);
                break;

            case "Units":
                egrp.LoadData(GPrj.Units);
                break;

            default:
                break;
            }
        }
        else if (3 == tm.GetPath(ti).Depth)              // Sub levels, like Task
        {
            this.addAction.Sensitive    = true;
            this.deleteAction.Sensitive = true;
            TreeIter tiL2;
            tm.IterParent(out tiL2, ti);
            this.alignFrmEditor.Remove(this.alignFrmEditor.Child);
            string itemName = (string)tm.GetValue(ti, 0);
            switch ((string)tm.GetValue(tiL2, 0))
            {
            case "StateMachines":
                this.alignFrmEditor.Child = esm;
                StateMachine sm = this.GPrj.StateMachines.FindWithName(itemName);
                esm.LoadData(sm);
                PopTreeViewGlobalContextMenu(3, sm);
                break;

            case "Tasks":
                this.alignFrmEditor.Child = etsk;
                Task tsk = this.GPrj.Tasks.FindWithName(itemName);
                etsk.LoadData(tsk);
                PopTreeViewGlobalContextMenu(3, tsk);
                break;

            case "Processes":
                this.alignFrmEditor.Child = eprc;
                Process prc = this.GPrj.Processes.FindWithName(itemName);
                eprc.LoadData(prc);
                PopTreeViewGlobalContextMenu(3, prc);
                break;

            case "Messages":
                this.alignFrmEditor.Child = emsg;
                Message msg = this.GPrj.Messages.FindWithName(itemName);
                emsg.LoadData(msg);
                PopTreeViewGlobalContextMenu(3, msg);
                break;

            case "CompuMethods":
                this.alignFrmEditor.Child = ecpmd;
                CompuMethod cpmd = this.GPrj.CompuMethods.FindWithName(itemName);
                ecpmd.LoadData(cpmd);
                PopTreeViewGlobalContextMenu(3, cpmd);
                break;

            case "Units":
                this.alignFrmEditor.Child = eunt;
                EasyOS.Unit unt = this.GPrj.Units.FindWithName(itemName);
                eunt.LoadData(unt);
                PopTreeViewGlobalContextMenu(3, unt);
                break;

            default:
                this.alignFrmEditor.Child = egrp;
                break;
            }
        }
        else
        {
        }
    }