Пример #1
0
    static void Main(string[] args)
    {
        using (DataSequence ds = new DataSequence())
        {
            ds.PushBack(3.14);
            Console.WriteLine(ds);

            ds.PushBack(2.71);
            ds.PushBack(100);
            Console.WriteLine(ds);

            ds.PopBack();
            Console.WriteLine(ds);

            ds.PopBack();
            ds.PopBack();
            Console.WriteLine(ds);

            try
            {
                ds.PopBack();
            }
            catch (Exception e)
            {
            }
        }

        Util.Pause();
    }
Пример #2
0
        List <DataSequence> getData(string fileName)
        {
            List <DataSequence> result = new List <DataSequence>();
            string row = "";

            using (StreamReader sr = new StreamReader(fileName))
            {
                for (int rowNumber = 0; null != ((row = sr.ReadLine())); rowNumber++)
                {
                    if (rowNumber % 1000 == 0)
                    {
                        Console.WriteLine(rowNumber);
                    }
                    DataSequence sequence = new DataSequence();
                    sequence.Steps = new List <DataStep>();
                    for (int i = 0; i < row.Length; i++)
                    {
                        DataStep step = new DataStep(FieldLetterTranslator.traslateToField(row[i]), FieldLetterTranslator.traslateToField((i + 1 < row.Length) ? row[i + 1] : '$'));
                        if (step.Input != null && step.TargetOutput != null)
                        {
                            sequence.Steps.Add(step);
                        }
                    }
                    result.Add(sequence);
                }
            }
            return(result);
        }
Пример #3
0
        protected DataInsertingEventArgs OnInserting(object data, string scope)
        {
            var args = new DataInsertingEventArgs(this.Name, DataDictionary <TEntity> .GetDataDictionary(data), scope);

            //尝试递增注册的递增键值
            DataSequence.Increments(this, (DataDictionary <TEntity>)args.Data);

            this.OnInserting(args);
            return(args);
        }
Пример #4
0
    static void Main(string[] args)
    {
        using (DataSequence dataSeq = new DataSequence())
        {
            dataSeq.PushBack(1.0);
            dataSeq.PushBack(3.14);
            dataSeq.PushBack(2.0);

            foreach (double v in dataSeq)
            {
                Console.WriteLine(v);
            }

            dataSeq.PopBack();

            foreach (double v in dataSeq)
            {
                Console.WriteLine(v);
            }

            dataSeq[0] = 2.71828;
            Console.WriteLine(dataSeq[0]);

            double[] data = dataSeq.GetData();
            foreach (double v in data)
            {
                Console.WriteLine(v);
            }
        }

        DataSequence dataSeq2 = new DataSequence(10);

        Debug.Assert(dataSeq2.Size == 10);
        try
        {
            dataSeq2[10] = 100.0;
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
        }

        dataSeq2.PushBack(100.0);
        UInt32 size = dataSeq2.Size;

        for (UInt32 i = 0; i < size; ++i)
        {
            Console.WriteLine(dataSeq2[i]);
        }

        Util.Pause();
    }
        static List <DataSequence> GetSequences(NNValue[] inputs, NNValue[] outputs)
        {
            List <DataSequence> dataSequences = new List <DataSequence>();

            for (int i = 0; i < inputs.Length; i++)
            {
                DataStep     dataStep     = new DataStep(inputs[i], outputs[i]);
                DataSequence dataSequence = new DataSequence();
                dataSequence.Steps.Add(dataStep);
                dataSequences.Add(dataSequence);
            }

            return(dataSequences);
        }
Пример #6
0
        public int Insert(object data, string scope, object state)
        {
            if (data == null)
            {
                return(0);
            }

            //将当前插入数据实体对象转换成数据字典
            var dictionary = DataDictionary <TEntity> .GetDataDictionary(data);

            //尝试递增注册的递增键值
            DataSequence.Increments(this, dictionary);

            return(this.OnInsert(dictionary, scope, state));
        }
Пример #7
0
        public DataService(Zongsoft.Services.IServiceProvider serviceProvider)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            _serviceProvider = serviceProvider;
            _dataAccess      = serviceProvider.ResolveRequired <IDataAccess>();

            //获取当前数据搜索键
            _searchKey = (DataSearchKeyAttribute)Attribute.GetCustomAttribute(this.GetType(), typeof(DataSearchKeyAttribute), true);

            //注册数据递增键序列号
            DataSequence.Register(this);
        }
Пример #8
0
        public int InsertMany(IEnumerable data, string scope, object state)
        {
            if (data == null)
            {
                return(0);
            }

            //将当前插入数据实体集合对象转换成数据字典集合
            var dictionares = DataDictionary <TEntity> .GetDataDictionaries(data);

            foreach (var dictionary in dictionares)
            {
                //尝试递增注册的递增键值
                DataSequence.Increments(this, dictionary);
            }

            return(this.OnInsertMany(dictionares, scope, state));
        }
Пример #9
0
        private List <DataSequence> CreateSequences(string xFilename, string yFilename)
        {
            double[][] x = LoadCsv(xFilename);
            double[][] y = LoadCsv(yFilename);

            // Create sequences
            List <DataSequence> sequences = new List <DataSequence>();
            DataSequence        ds        = new DataSequence();

            sequences.Add(ds);
            ds.Steps = new List <DataStep>();

            for (int i = 0; i < x.Length; ++i)
            {
                ds.Steps.Add(new DataStep(x[i], y[i]));
            }

            return(sequences);
        }
Пример #10
0
        /// <summary>
        ///     Sets the network statistics for a given direction for the current frame.
        /// </summary>
        /// <param name="frameData">The network statistics.</param>
        /// <param name="direction">The direction of those statistics.</param>
        public void SetFrameStats(NetFrameStats frameData, Direction direction)
        {
            // First we need to zero out the data before processing the _sparse_ data in the NetFrameStats.
            foreach (var pair in Data)
            {
                pair.Value.Clear(nextFrameIndex, direction);
            }

            foreach (var pair in frameData.Messages)
            {
                if (!Data.TryGetValue(pair.Key, out var data))
                {
                    data = new DataSequence(sequenceLength);
                }

                data.AddFrame(nextFrameIndex, pair.Value, direction);
                Data[pair.Key] = data;
            }
        }
Пример #11
0
        public static List <DataSequence> GetDataSequences(List <int[]> dataInp, List <int[]> dataOutp)
        {
            List <DataSequence> lds = new List <DataSequence>();

            for (int i = 0; i < dataInp.Count; i++)
            {
                DataSequence sequence = new DataSequence();
                sequence.Steps = new List <DataStep>();

                for (int j = 0; j < dataInp[i].Length; j++)
                {
                    DataStep ds = new DataStep(GetValue(dataInp[i][j], 11));
                    sequence.Steps.Add(ds);
                }


                for (int j = 0; j < dataOutp[i].Length; j++)
                {
                    DataStep ds;

                    if (j == 0)
                    {
                        ds = new DataStep(GetValue(10, 11), GetValue(dataOutp[i][j]));
                    }
                    else
                    {
                        ds = new DataStep(GetValue(dataOutp[i][j - 1], 11), GetValue(dataOutp[i][j]));
                    }

                    sequence.Steps.Add(ds);
                }

                lds.Add(sequence);
            }

            return(lds);
        }
Пример #12
0
        private void recursiveCreateDataList(object dl, XElement el)
        {
            Data nd = new Data();

            switch (el.Attribute("Type").Value)
            {
            case "structure":
                nd = new Data();
                DataSequence sd = new DataSequence();
                sd.initValue();
                nd.selectStructure(sd);
                if (dl is List <Data> )
                {
                    (dl as List <Data>).Add(nd);
                }
                else if (dl is Data)
                {
                    if ((dl as Data).isStructureSelected())
                    {
                        (dl as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        Logger.getLogger().LogError("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    Logger.getLogger().LogError("Error: Invalid parent data type !");
                }
                break;

            case "boolean":
                nd = new Data();
                nd.selectBoolean(el.Attribute("Value").Value == "True" ? true : false);

                if (el.Attribute("Desc") != null)
                {
                    nd.Description = el.Attribute("Desc").Value;
                }

                if (dl is List <Data> )
                {
                    (dl as List <Data>).Add(nd);
                }
                else if (dl is Data)
                {
                    if ((dl as Data).isStructureSelected())
                    {
                        (dl as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        Logger.getLogger().LogError("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    Logger.getLogger().LogError("Error: Invalid parent data type !");
                }
                break;

            case "integer":
                nd = new Data();
                nd.selectInteger(Convert.ToInt32(el.Attribute("Value").Value));

                if (el.Attribute("Desc") != null)
                {
                    nd.Description = el.Attribute("Desc").Value;
                }

                if (dl is List <Data> )
                {
                    (dl as List <Data>).Add(nd);
                }
                else if (dl is Data)
                {
                    if ((dl as Data).isStructureSelected())
                    {
                        (dl as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        Logger.getLogger().LogError("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    Logger.getLogger().LogError("Error: Invalid parent data type !");
                }
                break;

            case "bit_string":
                nd = new Data();
                StringToDataConverter Converter = new StringToDataConverter();
                BitString             bs        = Converter.ConvertToBitstring(el.Attribute("Value").Value);

                if (el.Attribute("Desc") != null)
                {
                    nd.Description = el.Attribute("Desc").Value;
                }

                if (bs != null)
                {
                    nd.selectBitstring(bs);
                }
                else
                {
                    nd.selectBitstring(new BitString(new byte[] { 0 }));
                    nd.Bitstring.TrailBitsCnt = 8;
                }
                if (dl is List <Data> )
                {
                    (dl as List <Data>).Add(nd);
                }
                else if (dl is Data)
                {
                    if ((dl as Data).isStructureSelected())
                    {
                        (dl as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        Logger.getLogger().LogError("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    Logger.getLogger().LogError("Error: Invalid parent data type !");
                }
                break;

            default:
                break;
            }

            if (el.HasElements)
            {
                foreach (XElement ndcn in el.Elements())
                {
                    recursiveCreateDataList(nd, ndcn);
                }
            }
        }
Пример #13
0
        private void recursiveCreateGvl(object dl, XElement el, List <string> nst)
        {
            Data nd = new Data();

            switch (el.Attribute("Type").Value)
            {
            case "structure":
                nd = new Data();
                DataSequence sd = new DataSequence();
                sd.initValue();
                nd.selectStructure(sd);
                if (dl is List <Data> )
                {
                    (dl as List <Data>).Add(nd);
                }
                else if (dl is Data)
                {
                    if ((dl as Data).isStructureSelected())
                    {
                        (dl as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        Logger.getLogger().LogError("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    Logger.getLogger().LogError("Error: Invalid parent data type !");
                }
                break;

            case "boolean":
                nd = new Data();
                nd.selectBoolean(el.Attribute("Value").Value == "True" ? true : false);
                //nd.ValueChanged += new EventHandler(_ValueChanged);

                if (el.Attribute("Desc") != null)
                {
                    nd.Description = el.Attribute("Desc").Value;
                }

                if (dl is List <Data> )
                {
                    (dl as List <Data>).Add(nd);
                }
                else if (dl is Data)
                {
                    if ((dl as Data).isStructureSelected())
                    {
                        (dl as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        Logger.getLogger().LogError("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    Logger.getLogger().LogError("Error: Invalid parent data type !");
                }
                break;

            case "integer":
                nd = new Data();
                nd.selectInteger(Convert.ToInt32(el.Attribute("Value").Value));
                //nd.ValueChanged += new EventHandler(_ValueChanged);

                if (el.Attribute("Desc") != null)
                {
                    nd.Description = el.Attribute("Desc").Value;
                }

                if (dl is List <Data> )
                {
                    (dl as List <Data>).Add(nd);
                }
                else if (dl is Data)
                {
                    if ((dl as Data).isStructureSelected())
                    {
                        (dl as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        Logger.getLogger().LogError("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    Logger.getLogger().LogError("Error: Invalid parent data type !");
                }
                break;

            /*
             * case "float":
             * nd = new Data();
             * nd.selectFloatingpoint(new FloatingPoint(new byte[] { 0 }));
             * nd.ValueChanged += new EventHandler(_ValueChanged);
             * if (dl is List<Data>)
             *  (dl as List<Data>).Add(nd);
             * else if (dl is Data)
             * {
             *  if ((dl as Data).isStructureSelected())
             *      (dl as Data).Structure.Value.Add(nd);
             *  else
             *      MessageBox.Show("Error: Invalid parent data type !");
             * }
             * else
             *  MessageBox.Show("Error: Invalid parent data type !");
             * break;
             */
            case "bit_string":
                nd = new Data();
                StringToDataConverter Converter = new StringToDataConverter();
                BitString             bs        = Converter.ConvertToBitstring(el.Attribute("Value").Value);
                if (bs != null)
                {
                    nd.selectBitstring(bs);
                }
                else
                {
                    nd.selectBitstring(new BitString(new byte[] { 0 }));
                    nd.Bitstring.TrailBitsCnt = 8;
                }

                if (el.Attribute("Desc") != null)
                {
                    nd.Description = el.Attribute("Desc").Value;
                }

                //nd.ValueChanged += new EventHandler(_ValueChanged);
                if (dl is List <Data> )
                {
                    (dl as List <Data>).Add(nd);
                }
                else if (dl is Data)
                {
                    if ((dl as Data).isStructureSelected())
                    {
                        (dl as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        Logger.getLogger().LogError("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    Logger.getLogger().LogError("Error: Invalid parent data type !");
                }
                break;

            default:
                if (!nst.Contains(el.Attribute("Type").Value))
                {
                    nst.Add(el.Attribute("Type").Value);
                }
                break;
            }

            if (el.HasElements)
            {
                foreach (XElement ndcn in el.Elements())
                {
                    recursiveCreateGvl(nd, ndcn, nst);
                }
            }
        }
        //Search Button
        private void button2_Click(object sender, EventArgs e)
        {
            string     tempMakeModelID  = "[Make Model ID]";
            string     tempColorID      = "[Color ID]";
            string     tempMile         = "Mileage";
            string     tempPrice        = "Price";
            List <int> MakeModelIDsList = new List <int>();
            int        numofIDs         = -1;

            if (makeTxtBox.Text == "" && modelTxtBox.Text == "" && priceMinBox.Value == 0 && priceMaxBox.Value == 0 && colorTxtBox.Text == "" && carLotTxtBox.Text == "" && carMileage.Value == 0)
            {
                con = new SqlConnection(@"Data Source=(local)\SQLEXPRESS;Initial Catalog=Car Dealership;Integrated Security=True");
                con.Open();
                cmd = new SqlCommand("SELECT * FROM CarID", con);
                //Working one
                //SqlDataAdapter sqlDa = new SqlDataAdapter("SELECT * FROM CarID WHERE[Make Model ID] = " + "[Make Model ID]" + " AND [Color ID] = " + "[Color ID]" + " AND Mileage = " + tempMile + " AND Price = " + tempPrice + "", con);

                SqlDataAdapter sqlDa = new SqlDataAdapter("SELECT * FROM CarID WHERE[Make Model ID]=[Make Model ID] and [Color ID]=[Color ID] and Mileage=Mileage and (Price = Price AND Price!=0)", con);


                //SqlDataAdapter sqlDa = new SqlDataAdapter("SELECT * FROM CarID,LotCarID WHERE[Make Model ID] = " + "[Make Model ID]" + " AND [Color ID] = " + "[Color ID]" + " AND Mileage = " + tempMile + " AND Price = " + tempPrice + " AND CarID.[Car ID] = LotCarID.[Car ID]", con);

                DataTable dtbl = new DataTable();
                sqlDa.Fill(dtbl);
                dataGridView1.DataSource = dtbl;

                cmd.ExecuteNonQuery();
                con.Close();
            }
            else if (makeTxtBox.Text != "" && modelTxtBox.Text == "")
            {
                con = new SqlConnection(@"Data Source=(local)\SQLEXPRESS;Initial Catalog=Car Dealership;Integrated Security=True");
                con.Open();

                //Getting all the MakeModel Ids based on selected Make
                string Sql = "SELECT [Make Model ID] FROM MakeModelID WHERE([Make] = '" + makeTxtBox.Text + "')";

                SqlCommand    cmd = new SqlCommand(Sql, con);
                SqlDataReader DR  = cmd.ExecuteReader();


                while (DR.Read())
                {
                    MakeModelIDsList.Add(DR.GetInt32(0));
                    numofIDs++;
                }
                DR.Close();


                ///Getting ColorID
                if (colorTxtBox.Text != "")
                {
                    cmd         = new SqlCommand("Select [Color ID] FROM ColorID WHERE ([Color] = '" + colorTxtBox.Text + "')", con);
                    tempColorID = cmd.ExecuteScalar().ToString();
                }
                else
                {
                    tempColorID = "[Color ID]";
                }

                if (priceMaxBox.Value == 0)
                {
                    priceMaxBox.Value = 1000000;
                }

                if (carMileage.Value == 0)
                {
                    carMileage.Value = 1000000;
                }
                con.Close();

                ArrayList sequence = new ArrayList();
                try
                {
                    int i = 0;
                    con = new SqlConnection();
                    con.ConnectionString = (@"Data Source=(local)\SQLEXPRESS;Initial Catalog=Car Dealership;Integrated Security=True");
                    cmd            = new SqlCommand();
                    cmd.Connection = con;
                    con.Open();
                    while (i <= numofIDs)
                    {
                        // Working one
                        //cmd.CommandText = "SELECT* FROM CarID WHERE[Make Model ID] = " + MakeModelIDsList[i] + " AND[Color ID] = " + tempColorID + " AND(Mileage <= " + carMileage.Value + ") AND(Price BETWEEN " + priceMinBox.Value + " AND " + priceMaxBox.Value + ")";
                        cmd.CommandText = "SELECT * FROM CarID WHERE[Make Model ID] = " + MakeModelIDsList[i] + " AND[Color ID] = " + tempColorID + " AND(Mileage <= " + carMileage.Value + ") AND(Price BETWEEN " + priceMinBox.Value + " AND " + priceMaxBox.Value + " AND Price!=0)";

                        SqlDataReader reader = cmd.ExecuteReader();
                        while (reader.Read())
                        {
                            DataSequence d = new DataSequence();
                            d.ID          = (int)reader[0];
                            d.MakeModelID = (int)reader[1];
                            d.VIN         = (int)reader[2];
                            d.ColorID     = (int)reader[3];
                            d.Mileage     = (int)reader[4];
                            d.Price       = (int)reader[5];
                            d.Picture     = reader[6].ToString();
                            sequence.Add(d);
                        }
                        i++;
                        reader.Close();
                    }
                    dataGridView1.DataSource = sequence;
                }
                finally
                {
                    con.Close();
                }
            }
            else
            {
                con = new SqlConnection(@"Data Source=(local)\SQLEXPRESS;Initial Catalog=Car Dealership;Integrated Security=True");
                con.Open();
                //Getting Make Model ID
                if (makeTxtBox.Text != "" && modelTxtBox.Text != "")
                {
                    cmd             = new SqlCommand("Select [Make Model ID] FROM MakeModelID WHERE ([Make] = '" + makeTxtBox.Text + "') AND ([Model] = '" + modelTxtBox.Text + "')", con);
                    tempMakeModelID = cmd.ExecuteScalar().ToString();
                }

                ///Getting ColorID
                if (colorTxtBox.Text != "")
                {
                    cmd         = new SqlCommand("Select [Color ID] FROM ColorID WHERE ([Color] = '" + colorTxtBox.Text + "')", con);
                    tempColorID = cmd.ExecuteScalar().ToString();
                }
                else
                {
                    tempColorID = "[Color ID]";
                }

                if (priceMaxBox.Value == 0)
                {
                    priceMaxBox.Value = 1000000;
                }

                if (carMileage.Value == 0)
                {
                    carMileage.Value = 1000000;
                }
                cmd = new SqlCommand("SELECT * FROM CarID", con);

                //SqlDataAdapter sqlDa = new SqlDataAdapter("SELECT * FROM CarID WHERE[Make Model ID] = " + tempMakeModelID + " AND [Color ID] = " + tempColorID + " AND (Mileage <= " + carMileage.Value + ") AND (Price BETWEEN " + priceMinBox.Value + " AND " + priceMaxBox.Value + ")", con);
                SqlDataAdapter sqlDa = new SqlDataAdapter("SELECT * FROM CarID WHERE[Make Model ID] = " + tempMakeModelID + " AND [Color ID] = " + tempColorID + " AND (Mileage <= " + carMileage.Value + ") AND (Price BETWEEN " + priceMinBox.Value + " AND " + priceMaxBox.Value + " AND Price!=0)", con);
                DataTable      dtbl  = new DataTable();
                sqlDa.Fill(dtbl);
                dataGridView1.DataSource = dtbl;

                cmd.ExecuteNonQuery();
                con.Close();
            }
        }
Пример #15
0
        void OnAddDataClick(object sender, EventArgs e)
        {
            switch ((sender as ToolStripItem).Text)
            {
            case "Add Structure":
                Data         nd = new Data();
                DataSequence sd = new DataSequence();
                sd.initValue();
                nd.selectStructure(sd);
                if ((sender as ToolStripItem).Tag is List <Data> )
                {
                    ((sender as ToolStripItem).Tag as List <Data>).Add(nd);
                }
                else if (((sender as ToolStripItem).Tag is NodeGData))
                {
                    if ((((sender as ToolStripItem).Tag as NodeGData).Tag is Data) && ((((sender as ToolStripItem).Tag as NodeGData).Tag as Data).isStructureSelected()))
                    {
                        (((sender as ToolStripItem).Tag as NodeGData).Tag as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        MessageBox.Show("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    MessageBox.Show("Error: Invalid parent data type !");
                }
                break;

            case "Add Boolean":
                nd = new Data();
                nd.selectBoolean(false);
                nd.ValueChanged += new EventHandler(_ValueChanged);
                if ((sender as ToolStripItem).Tag is List <Data> )
                {
                    ((sender as ToolStripItem).Tag as List <Data>).Add(nd);
                }
                else if (((sender as ToolStripItem).Tag is NodeGData))
                {
                    if ((((sender as ToolStripItem).Tag as NodeGData).Tag is Data) && ((((sender as ToolStripItem).Tag as NodeGData).Tag as Data).isStructureSelected()))
                    {
                        (((sender as ToolStripItem).Tag as NodeGData).Tag as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        MessageBox.Show("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    MessageBox.Show("Error: Invalid parent data type !");
                }
                break;

            case "Add Integer":
                nd = new Data();
                nd.selectInteger(0);
                nd.ValueChanged += new EventHandler(_ValueChanged);
                if ((sender as ToolStripItem).Tag is List <Data> )
                {
                    ((sender as ToolStripItem).Tag as List <Data>).Add(nd);
                }
                else if (((sender as ToolStripItem).Tag is NodeGData))
                {
                    if ((((sender as ToolStripItem).Tag as NodeGData).Tag is Data) && ((((sender as ToolStripItem).Tag as NodeGData).Tag as Data).isStructureSelected()))
                    {
                        (((sender as ToolStripItem).Tag as NodeGData).Tag as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        MessageBox.Show("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    MessageBox.Show("Error: Invalid parent data type !");
                }
                break;

            case "Add Float":
                nd = new Data();
                nd.selectFloatingpoint(new FloatingPoint(new byte[] { 0 }));
                nd.ValueChanged += new EventHandler(_ValueChanged);
                if ((sender as ToolStripItem).Tag is List <Data> )
                {
                    ((sender as ToolStripItem).Tag as List <Data>).Add(nd);
                }
                else if (((sender as ToolStripItem).Tag is NodeGData))
                {
                    if ((((sender as ToolStripItem).Tag as NodeGData).Tag is Data) && ((((sender as ToolStripItem).Tag as NodeGData).Tag as Data).isStructureSelected()))
                    {
                        (((sender as ToolStripItem).Tag as NodeGData).Tag as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        MessageBox.Show("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    MessageBox.Show("Error: Invalid parent data type !");
                }
                break;

            case "Add Bitstring":
                nd = new Data();
                nd.selectBitstring(new BitString());
                nd.ValueChanged += new EventHandler(_ValueChanged);
                if ((sender as ToolStripItem).Tag is List <Data> )
                {
                    ((sender as ToolStripItem).Tag as List <Data>).Add(nd);
                }
                else if (((sender as ToolStripItem).Tag is NodeGData))
                {
                    if ((((sender as ToolStripItem).Tag as NodeGData).Tag is Data) && ((((sender as ToolStripItem).Tag as NodeGData).Tag as Data).isStructureSelected()))
                    {
                        (((sender as ToolStripItem).Tag as NodeGData).Tag as Data).Structure.Value.Add(nd);
                    }
                    else
                    {
                        MessageBox.Show("Error: Invalid parent data type !");
                    }
                }
                else
                {
                    MessageBox.Show("Error: Invalid parent data type !");
                }
                break;

            case "Delete":

                if (((sender as ToolStripItem).Tag is NodeGData))
                {
                    listViewGoose_Clear();

                    if ((((sender as ToolStripItem).Tag as NodeGData).Tag is Data))
                    {
                        (((sender as ToolStripItem).Tag as NodeGData).Tag as Data).ValueChanged -= new EventHandler(_ValueChanged);
                        _dataList.Remove((((sender as ToolStripItem).Tag as NodeGData).Tag as Data));
                    }
                }
                break;

            default:
                break;
            }

            updateTree();
        }