Beispiel #1
0
        private void addNewObjectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            NewIndex ni = new NewIndex(eds);

            if (ni.ShowDialog() == DialogResult.OK)
            {
                eds.dirty = true;

                ODentry od = new ODentry();

                od.objecttype      = ni.ot;
                od.index           = ni.index;
                od.StorageLocation = "RAM";
                od.defaultvalue    = "";
                od.accesstype      = EDSsharp.AccessType.rw;
                od.datatype        = ni.dt;
                od.parameter_name  = ni.name;

                if (od.objecttype == ObjectType.REC || od.objecttype == ObjectType.ARRAY)
                {
                    {
                        ODentry sod = new ODentry();

                        sod.objecttype      = ObjectType.VAR;
                        sod.subindex        = 0;
                        sod.index           = ni.index;
                        sod.StorageLocation = "RAM";
                        sod.defaultvalue    = String.Format("{0}", ni.nosubindexes);
                        sod.accesstype      = EDSsharp.AccessType.ro;
                        sod.datatype        = DataType.UNSIGNED8;
                        sod.parent          = od;

                        sod.parameter_name = "max sub-index";


                        od.subobjects.Add(0, sod);
                    }

                    for (int p = 0; p < ni.nosubindexes; p++)
                    {
                        ODentry sod = new ODentry();

                        sod.objecttype      = ObjectType.VAR;
                        sod.subindex        = (UInt16)(p + 1);
                        sod.index           = ni.index;
                        sod.StorageLocation = "RAM";
                        sod.defaultvalue    = "";
                        sod.accesstype      = EDSsharp.AccessType.rw;
                        sod.datatype        = ni.dt;
                        sod.parent          = od;

                        od.subobjects.Add((ushort)(p + 1), sod);
                    }
                }

                eds.ods.Add(od.index, od);

                //Now switch to it as well Bug #26

                updateselectedindexdisplay(od.index);
                selectedobject = eds.ods[od.index];
                validateanddisplaydata();


                populateindexlists();
            }
        }