コード例 #1
0
 public bool LoadData(CompuMethod dat)
 {
     currentCM                  = dat;
     this.entryName.Text        = dat.name;
     this.entryDescription.Text = dat.description;
     if (dat is RationalFunction)
     {
         currentRF = (RationalFunction)dat;
         this.notebook1.GetNthPage(0).ShowAll();
         this.notebook1.GetNthPage(1).HideAll();
         this.entryNumerator.Text    = currentRF.Numerators [0].ToString();
         this.entryNumerator1.Text   = currentRF.Numerators [1].ToString();
         this.entryDenominator.Text  = currentRF.Denominators [0].ToString();
         this.entryDenominator1.Text = currentRF.Denominators [1].ToString();
     }
     else if (dat is VerbalTable)
     {
         currentVT = (VerbalTable)dat;
         this.notebook1.GetNthPage(0).HideAll();
         this.notebook1.GetNthPage(1).ShowAll();
         lsVT.Clear();
         foreach (var item in ((VerbalTable)dat).items)
         {
             this.lsVT.AppendValues(item.Key, item.Value);
         }
         this.buttonDelete.Sensitive = false;
     }
     else
     {
     }
     return(true);
 }
コード例 #2
0
        public static RationalFunction ParseFromXml(XmlNode node, RationalFunction ret = null)
        {
            if (null == ret)
            {
                ret = new RationalFunction();
            }
            ret = (RationalFunction)AbstractData.ParseFromXml(node, ret);
            XmlNode cnode = null;

            cnode = node.SelectSingleNode("Numerators");
            if (null != cnode)
            {
                XmlNodeList dnodes = cnode.SelectNodes("vt");
                for (int i = 0; i < dnodes.Count; i++)
                {
                    ret.Numerators [i] = Convert.ToDouble(dnodes.Item(i).InnerText);
                }
            }
            cnode = node.SelectSingleNode("Denominators");
            if (null != cnode)
            {
                XmlNodeList dnodes = cnode.SelectNodes("vt");
                for (int i = 0; i < dnodes.Count; i++)
                {
                    ret.Denominators [i] = Convert.ToDouble(dnodes.Item(i).InnerText);
                }
            }
            return(ret);
        }
コード例 #3
0
        public static List <CompuMethod> CreateBaseCompuMethods()
        {
            List <CompuMethod> ret = new List <CompuMethod> ();

            ret.AddRange(RationalFunction.CreateBaseRationalFunctions());
            ret.AddRange(VerbalTable.CreateBaseVerbalTables());
            return(ret);
        }
コード例 #4
0
        public static RationalFunction CreateOneToTen()
        {
            RationalFunction ret = new RationalFunction();

            ret.name            = "OneToTen";
            ret.description     = "Rational function one to ten";
            ret.Numerators [0]  = 0;
            ret.Numerators [1]  = 10;
            ret.Denominators[0] = 1;
            ret.Denominators[1] = 0;
            return(ret);
        }
コード例 #5
0
        public static CompuMethod ParseFromXml(XmlNode node, CompuMethod ret = null)
        {
            switch (node.Name)
            {
            case "RationalFunction":
                return(RationalFunction.ParseFromXml(node, ret));

                break;

            case "VerbalTable":
                return(VerbalTable.ParseFromXml(node, ret));

                break;

            default:
                return(ret);

                break;
            }
        }
コード例 #6
0
        public static Group <T> ParseFromXml(XmlNode node, Group <T> ret = null)
        {
            if (null == ret)
            {
                ret = new Group <T> ();
            }
            ret.elements.Clear();
            XmlNode cnode = null;

            cnode = node.SelectSingleNode("name");
            if (null != cnode)
            {
                ret.name = cnode.InnerText;
            }
            cnode = node.SelectSingleNode("description");
            if (null != cnode)
            {
                ret.description = cnode.InnerText;
            }
            XmlNodeList cnodelist;

            if (typeof(T).Name.Equals("CompuMethod"))
            {
                cnodelist = node.SelectNodes("RationalFunction");
                for (int i = 0; i < cnodelist.Count; i++)
                {
                    Group <CompuMethod> .GAdd(RationalFunction.ParseFromXml(cnodelist.Item(i)));
                }
                cnodelist = node.SelectNodes("VerbalTable");
                for (int i = 0; i < cnodelist.Count; i++)
                {
                    Group <CompuMethod> .GAdd(VerbalTable.ParseFromXml(cnodelist.Item(i)));
                }
            }
            else
            {
                cnodelist = node.SelectNodes(typeof(T).Name);
                for (int i = 0; i < cnodelist.Count; i++)
                {
                    switch (typeof(T).Name)
                    {
                    case "Unit":
                        Group <Unit> .GAdd(Unit.ParseFromXml(cnodelist.Item(i)));

                        break;

                    case "Message":
                        Group <Message> .GAdd(Message.ParseFromXml(cnodelist.Item(i)));

                        break;

                    case "Process":
                        Group <Process> .GAdd(Process.ParseFromXml(cnodelist.Item(i)));

                        break;

                    case "Task":
                        Group <Task> .GAdd(Task.ParseFromXml(cnodelist.Item(i)));

                        break;

                    case "StateMachine":
                        Group <StateMachine> .GAdd(StateMachine.ParseFromXml(cnodelist.Item(i)));

                        break;

                    default:
                        break;
                    }
                }
            }

            return(ret);
        }