Esempio n. 1
0
        public void Add(TKey key, TValue value)
        {
            if (itemNumber >= length)
            {
                ReHash();
            }

            int hashCode     = key.GetHashCode();
            int Index2Insert = hashCode % length;

            KeyValuePair <TKey, TValue> pair = new KeyValuePair <TKey, TValue>(key, value);

            if (head[Index2Insert] == null)
            {
                //insert a new linked list into the array
                System.Collections.Generic.LinkedList <KeyValuePair <TKey, TValue> > linkedList = new System.Collections.Generic.LinkedList <KeyValuePair <TKey, TValue> >();
                head[Index2Insert] = linkedList;
                head[Index2Insert].AddFirst(pair);
            }
            else
            {
                //insert the value into the already there linked list
                if (head[Index2Insert].Contains(pair))
                {
                    throw new Exception("you inserted a duplicate and that is not allowed");
                }
                else
                {
                    head[Index2Insert].AddFirst(pair);
                }
            }

            itemNumber++;
        }
    /// <summary>
    /// Converts the given end node and path node information
    /// to a path from the start node to the end node
    /// </summary>
    /// <param name="path">path to convert</param>
    /// <returns>string for path</returns>
    private string ConvertPathToString(GraphNode <int> endNode, Dictionary <GraphNode <int>, PathNodeInfo <int> > pathNodes)
    {
        //Build linked list for path in correct order
        System.Collections.Generic.LinkedList <GraphNode <int> > path =
            new System.Collections.Generic.LinkedList <GraphNode <int> >();

        path.AddFirst(endNode);
        GraphNode <int> previous = pathNodes[endNode].Previous;

        while (previous != null)
        {
            path.AddFirst(previous);
            previous = pathNodes[previous].Previous;
        }

        //Build and return string
        StringBuilder pathString = new StringBuilder();

        System.Collections.Generic.LinkedListNode <GraphNode <int> > currentNode = path.First;
        int nodeCount = 0;

        while (currentNode != null)
        {
            nodeCount++;
            pathString.Append(currentNode.Value.Value);
            if (nodeCount < path.Count)
            {
                pathString.Append(" ");
            }

            currentNode = currentNode.Next;
        }

        return(pathString.ToString());
    }
Esempio n. 3
0
        static long GetDirectoriesSize(
            String strCurDir,
            System.Collections.Generic.LinkedList <DirInfo> parentList)
        {
            String[] strFiles = Directory.GetFiles(strCurDir, "*.*");
            long     aSize    = 0;

            foreach (String s in strFiles)
            {
                FileInfo info = new FileInfo(s);
                aSize += info.Length;
            }


            DirInfo infoCur = new DirInfo();

            infoCur.dirName = strCurDir;
            infoCur.curSize = aSize;
            System.Collections.Generic.LinkedListNode <DirInfo> infoMine = parentList.AddLast(infoCur);


            String[] strDirectories = Directory.GetDirectories(strCurDir);
            foreach (String sDirs in strDirectories)
            {
                aSize += GetDirectoriesSize(sDirs, infoMine.Value.listChild);
            }

            //Console.WriteLine("{0} size({1,0:N0}) Bytes", strCurDir, aSize);
            //infoMine.Value.aSize = aSize;
            infoMine.Value.aSize = aSize;

            return(aSize);
        }
Esempio n. 4
0
		public static Board BuildNewBoard()
		{
			var blockLists = new System.Collections.Generic.List<System.Collections.Generic.LinkedList<Block>>();

			for (int counter = 0; counter < maxNumberOfLists; counter++)
			{
				var linkedList = new System.Collections.Generic.LinkedList<Block>();

				int numberOfBlocksInTheList = randomNumberGenerator.Next(3, 6);

				for (int listCounter = 0; listCounter < numberOfBlocksInTheList; listCounter++)
				{
					var block = GetNewRandomBlock();
					linkedList.AddFirst(block);
				}

				for (int listCounter = numberOfBlocksInTheList; listCounter < 9; listCounter++)
				{
					var block = new Block();
					linkedList.AddLast(block);
				}

					blockLists.Add(linkedList);
			}

			Board board = new Board()
			{
				BlockLists = blockLists,
				inDanger = false,
				active = true
			};

			return board;
		}
Esempio n. 5
0
		public static Board BuildNewBoard()
		{
			int numberOfBlocksInTheList = 3;
			var blockLists = new System.Collections.Generic.List<System.Collections.Generic.LinkedList<Block>>();

			for (int counter = 0; counter < maxNumberOfLists; counter++)
			{
				var linkedList = new System.Collections.Generic.LinkedList<Block>();

				for (int listCounter = 0; listCounter < numberOfBlocksInTheList; listCounter++)
				{
					var block = GetNewRandomBlock();
					linkedList.AddFirst(block);
				}

				blockLists.Add(linkedList);
			}

			Board board = new Board()
			{
				BlockLists = blockLists
			};

			return board;
		}
Esempio n. 6
0
 static void PrintQueue(System.Collections.Generic.LinkedList <int> jediIDList)
 {
     foreach (var item in jediIDList)
     {
         Console.WriteLine(item.ToString());
     }
 }
Esempio n. 7
0
        public static void SetQueue(List <Jedi> jediListComplete)
        {
            Console.WriteLine("Press enter");
            Console.WriteLine("Type which Queue function you would like to see: enqueue, dequeue");

            var QueueClass = new Queue.List.Queue <int>();//New Queue class

            int[] JediIDList = jediListComplete.Select(x => x.ID).ToArray();
            var   QueueItems = new System.Collections.Generic.LinkedList <int>(JediIDList);

            QueueClass._items = QueueItems;


            switch (Console.ReadLine())
            {
            case "enqueue":
                Jedi newJedi = Jedi.NewJedi();
                QueueClass.Enqueue(newJedi.ID);
                PrintQueue(QueueClass._items);
                Console.ReadLine();
                break;

            case "dequeue":
                QueueClass.Dequeue();
                PrintQueue(QueueClass._items);
                Console.ReadLine();
                break;

            default:
                break;
            }
        }
Esempio n. 8
0
        protected override void OnSubscribe(Instrument instrument)
        {
            // Get size of bar.
            barSize = (long)Global[barSizeCode];

            // Get spread instrument.
            spread = instrument;

            // Add legs instruments to bar factory.
            foreach (Leg leg in spread.Legs)
            {
                BarFactory.Add(leg.Instrument, BarType.Time, barSize);
            }

            // Remove instruments from strategy.
            Instruments.Clear();

            // Add legs instruments to strategy.
            foreach (Leg leg in spread.Legs)
            {
                AddInstrument(leg.Instrument);
            }

            processors = new System.Collections.Generic.LinkedList <OrderProcessor>();
            groups     = new Dictionary <Instrument, Group[]>();

            AddGroups();
        }
Esempio n. 9
0
        static LinkedList <String> GenerateBinaryRepresentationList(int n)
        {
            LinkedQueue <StringBuilder> q = new LinkedQueue <StringBuilder>();

            LinkedList <String> output = new System.Collections.Generic.LinkedList <String>();

            if (n < 1)
            {
                return(output);
            }

            q.Push(new StringBuilder("1"));

            while (n-- > 0)
            {
                StringBuilder sb = q.Pop();
                //add to output list  "not sure Addafter or Addlast"
                output.AddLast(sb.ToString());

                //copy
                StringBuilder sbc = new StringBuilder(sb.ToString());

                //left
                sb.Append('0');
                q.Push(sb);
                //right
                sbc.Append('1');
                q.Push(sbc);
            }
            return(output);
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            var l = new System.Collections.Generic.LinkedList <int>();

            var n       = int.Parse(Console.ReadLine());
            var numbers = new DSAImplementations.LinkedList <int>();

            numbers.AddFirst(1);
            for (int i = 2; i <= n; i++)
            {
                numbers.AddLast(i);
            }

            var swap = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

            // find the separator node and while there put all the elements before it in an array
            for (var i = 0; i < swap.Count; i++)
            {
                // find separator node
                var separatorNode = new NodeLL <int>(default(int));
                var separator     = swap[i];
                var current       = numbers.Head;
                while (current.Value != separator)
                {
                    current = current.Next;
                }
                separatorNode = current;

                if (separatorNode.Next == null)
                {
                    numbers.AddFirst(separatorNode);
                }
                else if (separatorNode.Prev == null)
                {
                    numbers.AddLast(separatorNode.Value);
                }
                else
                {
                    // set the head to the first number after the separator
                    // it points to all the numbers
                    numbers.Head = separatorNode.Next;
                    var last = numbers.FindLast();
                    var temp = separatorNode.Prev;
                    last.Next          = separatorNode;
                    separatorNode.Prev = last;
                    last = temp;
                    while (temp != null)
                    {
                        separatorNode.Next = temp;
                        temp = temp.Prev;
                    }

                    last.Next = null;
                }

                Console.WriteLine(numbers.ToString());
            }
        }
Esempio n. 11
0
            internal Enumerator(System.Collections.Generic.LinkedList <T> linkedList)
            {
                if (linkedList == null)
                {
                    throw new GameException("Linked list is invalid.");
                }

                m_Enumerator = linkedList.GetEnumerator();
            }
Esempio n. 12
0
 public void Write <T>(string name, System.Collections.Generic.LinkedList <T> list)
 {
     this.StartElement(name);
     foreach (T current in list)
     {
         this.Write <T>(current.GetType().Name, current);
     }
     this.EndElement();
 }
 public OrderedSet(IEnumerable <T> source)
 {
     list = new System.Collections.Generic.LinkedList <T>();
     map  = new Dictionary <T, LinkedListNode <T> >();
     foreach (var item in source)
     {
         var node = list.AddLast(item);
         map.Add(item, node);
     }
 }
Esempio n. 14
0
        /// <summary>
        /// Get all the account options names
        /// </summary>
        public System.Collections.Generic.LinkedList <String> GetOptionsNames()
        {
            System.Collections.Generic.LinkedList <String> options = new System.Collections.Generic.LinkedList <String>();

            foreach (KeyValuePair <String, String> option in this._options)
            {
                options.AddLast(option.Key);
            }
            return(options);
        }
Esempio n. 15
0
        public System.Collections.Generic.LinkedList <T> toSystemLinkedList()
        {
            var returnList = new System.Collections.Generic.LinkedList <T>();

            foreach (T element in this)
            {
                returnList.AddLast(element);
            }
            return(returnList);
        }
Esempio n. 16
0
        /// <summary>
        /// Get all the user accounts
        /// </summary>
        public System.Collections.Generic.LinkedList <Account> GetAccounts()
        {
            System.Collections.Generic.LinkedList <Account> accounts = new System.Collections.Generic.LinkedList <Account>();

            foreach (KeyValuePair <int, Account> account in this._accounts)
            {
                accounts.AddLast(account.Value);
            }
            return(accounts);
        }
Esempio n. 17
0
        public PopularityList(int minPoolSize, int maxPoolSize, ListCanExpand listCanExpandDelegate)
        {
            this.minPoolSize           = minPoolSize;
            this.maxPoolSize           = maxPoolSize;
            this.currentPoolSize       = this.minPoolSize;
            this.listCanExpandDelegate = listCanExpandDelegate;

            this.sortedList = new SortedList <TKey, LinkedListNode <KeyValuePair <TKey, TValue> > >();
            //this.sortedList = new Dictionary<TKey, LinkedListNode<KeyValuePair<TKey, TValue>>>();
            this.linkedList = new LinkedList <KeyValuePair <TKey, TValue> >();
        }
Esempio n. 18
0
        public void GedraagtMijnLinkedListZichNetZoAlsDieVanDotNet()
        {
            var ours = new LinkedList <int> {
                1, 2, 3, 4
            };
            var theirs = new System.Collections.Generic.LinkedList <int>();

            theirs.AddAfter(theirs.AddAfter(theirs.AddAfter(theirs.AddFirst(1), 2), 3), 4);

            Assert.Equal(theirs, ours);
        }
Esempio n. 19
0
 public Client(string server, int port, string userName, string password, string alias = null)
 {
     this.server   = server;
     this.port     = port;
     this.userName = userName;
     this.password = password;
     this.alias    = alias;
     _connEvnt     = new List <WaitConnect>();
     _reqs         = new LinkedList <ClRequest>();
     root          = new DTopic(this);
 }
Esempio n. 20
0
 public SioClient(string url, Action<Event, INotMsg> cb) {
   _url = url;
   _callback = cb;
   _respCnt = 0;
   _reqs = new LinkedList<Request>();
   _st = State.Connecting;
   _rccnt = 1;
   _verbose = true;
   _reconn = new System.Threading.Timer(CheckState, null, 100, -1);
   Connect();
 }
        /// <summary> Creates a new <c>MultipleTermPositions</c> instance.
        ///
        /// </summary>
        /// <exception cref="System.IO.IOException">
        /// </exception>
        public MultipleTermPositions(IndexReader indexReader, Term[] terms)
        {
            var termPositions = new System.Collections.Generic.LinkedList <TermPositions>();

            for (int i = 0; i < terms.Length; i++)
            {
                termPositions.AddLast(indexReader.TermPositions(terms[i]));
            }

            _termPositionsQueue = new TermPositionsQueue(termPositions);
            _posList            = new IntQueue();
        }
Esempio n. 22
0
        /// <summary>
        /// Paint the triangles defined by the points
        /// </summary>
        /// <param name="points"></param>
        private LinkedList <Triangle> makeTriangles(LinkedList <Pair <double, double> > points)
        {
            if (points == null || points.Count == 0)
            {
                return(null);
            }

            CPoint2D[]            vertices  = new CPoint2D[points.Count];
            LinkedList <Triangle> triangles = new System.Collections.Generic.LinkedList <Triangle>();

            int index = 0;

            foreach (Pair <double, double> p in points)
            {
                vertices[index] = new CPoint2D(p.X, p.Y);
                index++;
            }

            CPolygonShape cutPolygon = new CPolygonShape(vertices);

            cutPolygon.CutEar();

            debugOut("Numer of polygons: " + cutPolygon.NumberOfPolygons);

            CPoint2D[] corners;

            for (int numPoly = 0; numPoly < cutPolygon.NumberOfPolygons; numPoly++)
            {
                #region find upper and lower
                corners = cutPolygon.Polygons(numPoly);

                Pair <double, double>[] corns = new Pair <double, double> [3];
                for (int cornIndex = 0; cornIndex < 3; cornIndex++)
                {
                    CPoint2D coern = corners[cornIndex];
                    corns[cornIndex] = new Pair <double, double>(coern.X, coern.Y);
                }

                Pair <Pair <double, double>, Pair <double, double> > pairResult = findUpperAndLower(new LinkedList <Pair <double, double> >(corns));

                Pair <double, double> upper = pairResult.X;
                Pair <double, double> lower = pairResult.Y;

                Triangle inside = new Triangle(corns, upper, lower);

                debugOut(inside.ToString());

                triangles.AddLast(inside);
                #endregion
            }
            return(triangles);
        }
Esempio n. 23
0
        public DataContext(
            IDictionaryFactory dictionaryFactory,
            DataContextFactory dataContextFactory,
            IDataDependencyFactory dataDependencyFactory,
            IIdManager idManager)
        {
            _dataContextFactory    = dataContextFactory;
            _dataDependencyFactory = dataDependencyFactory;
            _properties            = new System.Collections.Generic.LinkedList <PropertyEntry>();
#if DEBUG
            _id = idManager.GetUniqueId();
#endif
        }
Esempio n. 24
0
 public LinkedListNode <T> Insert(T value)
 {
     if (this.linkedList_0 == null)
     {
         this.linkedList_0     = new System.Collections.Generic.LinkedList <T>();
         this.linkedListNode_0 = this.linkedList_0.AddLast(value);
     }
     else
     {
         this.linkedListNode_0 = this.linkedListNode_0 != null?this.linkedList_0.AddAfter(this.linkedListNode_0, value) : this.linkedList_0.AddLast(value);
     }
     return(this.linkedListNode_0);
 }
Esempio n. 25
0
 public void Read(string name, ref System.Collections.Generic.LinkedList <string> list)
 {
     if (this.StartElement(name))
     {
         list = new System.Collections.Generic.LinkedList <string>();
         for (int i = 0; i < this.Count; i++)
         {
             string value = "";
             this.Read(i, ref value);
             list.AddLast(value);
         }
         this.EndElement();
     }
 }
Esempio n. 26
0
        public void PerfTestSequentialRead()
        {
            var systemList       = new System.Collections.Generic.List <int>(BenchmarkData);
            var systemLinkedList = new System.Collections.Generic.LinkedList <int>(BenchmarkData);

            var testedLinkedList = new SingleList <int>();

            foreach (var number in BenchmarkData)
            {
                testedLinkedList.Add(number);
            }

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            for (int i = 0; i < BenchmarkData.Length; i++)
            {
                var it = systemList[i];
            }
            stopwatch.Stop();
            var systemListDuration = stopwatch.ElapsedMilliseconds;

            stopwatch.Restart();
            foreach (var item in systemLinkedList)
            {
                var it = item;
            }
            stopwatch.Stop();
            var systemLinkedListDuration = stopwatch.ElapsedMilliseconds;

            stopwatch.Restart();
            for (int i = 0; i < BenchmarkData.Length; i++)
            {
                var it = testedLinkedList[i];
            }
            stopwatch.Stop();
            var linkedListIterated = stopwatch.ElapsedMilliseconds;

            stopwatch.Restart();
            //Tested this for comparison, it's about three times faster
            foreach (var item in testedLinkedList)
            {
                var it = item;
            }
            stopwatch.Stop();
            var linkedListEnumerated = stopwatch.ElapsedMilliseconds;

            output.WriteLine($"'Enumerator' {linkedListEnumerated} | Indexer | {linkedListIterated}| " +
                             $"System.List {systemListDuration}| System.LinkedList {systemLinkedListDuration}");
        }
        static void Main(string[] args)
        {
            // +-----+------+
            // |  3  | null +
            // +-----+------+
            Node first = new Node {
                Value = 3
            };

            // +-----+------+    +-----+------+
            // |  3  | null +    |  5  | null +
            // +-----+------+    +-----+------+
            Node middle = new Node {
                Value = 5
            };

            // +-----+------+    +-----+------+
            // |  3  |  *---+--->|  5  | null +
            // +-----+------+    +-----+------+
            first.Next = middle;

            // +-----+------+    +-----+------+   +-----+------+
            // |  3  |  *---+--->|  5  | null +   |  7  | null +
            // +-----+------+    +-----+------+   +-----+------+
            Node last = new Node {
                Value = 7
            };

            // +-----+------+    +-----+------+   +-----+------+
            // |  3  |  *---+--->|  5  |  *---+-->|  7  | null +
            // +-----+------+    +-----+------+   +-----+------+
            middle.Next = last;

            // now iterate over each node and print the value
            PrintNodes(first);
            Console.ReadKey();


            #region .NetFrmaework LinkedList is DoublyLinkedList
            System.Collections.Generic.LinkedList <int> list = new System.Collections.Generic.LinkedList <int>();
            list.AddLast(3);
            list.AddLast(5);
            list.AddLast(7);

            foreach (int value in list)
            {
                Console.WriteLine(value);
            }
            #endregion
        }
Esempio n. 28
0
        public bool BuildSampleGraphAdjacenyList()
        {
            try {
                ArrayVerteicesAdjacencyList = new int[10];
                AdjacencyList = new System.Collections.Generic.LinkedList <int> [10];
                for (int i = 0; i < 10; i++)
                {
                    ArrayVerteicesAdjacencyList[i] = ++i;
                }
                for (int i = 0; i < 10; i++)
                {
                    AdjacencyList[i] = new System.Collections.Generic.LinkedList <int>();
                }
                AdjacencyList[0].AddFirst(1);
                AdjacencyList[0].AddLast(2);
                AdjacencyList[0].AddLast(3);

                AdjacencyList[1].AddFirst(0);
                AdjacencyList[1].AddLast(4);

                AdjacencyList[2].AddLast(0);
                AdjacencyList[2].AddLast(5);

                AdjacencyList[3].AddLast(0);
                AdjacencyList[3].AddLast(4);
                AdjacencyList[3].AddLast(5);
                AdjacencyList[3].AddLast(7);

                AdjacencyList[4].AddLast(1);
                AdjacencyList[4].AddLast(3);
                AdjacencyList[4].AddLast(6);

                AdjacencyList[5].AddLast(2);
                AdjacencyList[5].AddLast(3);
                AdjacencyList[5].AddLast(6);

                AdjacencyList[6].AddLast(4);
                AdjacencyList[6].AddLast(5);
                AdjacencyList[6].AddLast(8);
                AdjacencyList[6].AddLast(9);
                return(true);
            }
            catch (IndexOutOfRangeException ior) {
                System.Console.WriteLine(ior.Message);
                System.Console.WriteLine(ior.StackTrace);
                return(false);
            }
        }
Esempio n. 29
0
        Transform[] GeneratePoints(Transform root)
        {
            var points = new System.Collections.Generic.LinkedList <Transform>();

            foreach (var node in root.GetComponentsInChildren <Transform>())
            {
                if (node.childCount == 0 && node != root)
                {
                    points.AddLast(node);
                }
            }
            var result = new Transform[points.Count];

            points.CopyTo(result, 0);
            return(result);
        }
Esempio n. 30
0
        public void AllLinkedList()
        {
            //1 - Remove Duplicate
            //RemoveDuplicate();

            //2 Return Kth to Last
            // KthtoLast();

            //3 Delete Given Node
            //copy content from next node and set the pointer to next to next ///simple enough

            //4 Partition

            //6 Palindrom

            LinkedList <int> l = new System.Collections.Generic.LinkedList <int>();
        }
Esempio n. 31
0
        static void Main()
        {
            var linked = new System.Collections.Generic.LinkedList <int>();
            var node   = new LinkedListNode <int>(1);

            linked.AddFirst(node);
            var x = linked.AddAfter(node, 5);

            var list = new LinkedList <int>()
            {
                1, 2, 3, 4
            };

            list.Print();
            list.Print();
            list.FindFirst(4);
            Console.Read();
        }
Esempio n. 32
0
        protected override void OnSubscribe(Instrument instrument)
        {
            spread            = instrument;
            futureInstrument  = spread.Legs[1].Instrument;
            currentInstrument = spread.Legs[0].Instrument;

            // Remove instruments from strategy.
            Instruments.Clear();

            // Add legs instruments to strategy.
            foreach (Leg leg in spread.Legs)
            {
                AddInstrument(leg.Instrument);
            }

            processors = new System.Collections.Generic.LinkedList <OrderProcessor>();

            //	AddGroups();
        }
Esempio n. 33
0
        public void Add(K key, V value)
        {
            int hash = Hash(key);

            if (data == null)
            {
                Resize(hash + 1);
            }
            else if (data.Length <= hash)
            {
                Resize(hash + 1);
            }
            if (data[hash] == null)
            {
                data[hash] = new System.Collections.Generic.LinkedList <Pair>();
            }
            data[hash].AddFirst(new Pair(key, value));
            Count++;
        }
Esempio n. 34
0
        /// <summary>
        /// Paint the triangles defined by the points
        /// </summary>
        /// <param name="points"></param>
        private LinkedList<Triangle> makeTriangles(LinkedList<Pair<double, double>> points)
        {
            if (points == null ||points.Count == 0)
                return null;

            CPoint2D[] vertices = new CPoint2D[points.Count];
            LinkedList<Triangle> triangles = new System.Collections.Generic.LinkedList<Triangle>();

            int index = 0;
            foreach (Pair<double, double> p in points) {
                vertices[index] = new CPoint2D(p.X, p.Y);
                index++;
            }

            CPolygonShape cutPolygon =  new CPolygonShape(vertices);
            cutPolygon.CutEar();

            debugOut("Numer of polygons: "  + cutPolygon.NumberOfPolygons);

            CPoint2D[] corners;

            for(int numPoly = 0; numPoly < cutPolygon.NumberOfPolygons; numPoly++) {
                #region find upper and lower
                corners = cutPolygon.Polygons(numPoly);

                Pair<double, double>[] corns = new Pair<double, double>[3];
                for(int cornIndex = 0; cornIndex < 3; cornIndex++) {
                    CPoint2D coern = corners[cornIndex];
                    corns[cornIndex] = new Pair<double, double>(coern.X, coern.Y);
                }

                Pair<Pair<double, double>, Pair<double, double>> pairResult = findUpperAndLower(new LinkedList<Pair<double, double>>(corns));

                Pair<double, double> upper = pairResult.X;
                Pair<double, double> lower = pairResult.Y;

                Triangle inside = new Triangle(corns, upper, lower);

                debugOut(inside.ToString());

                triangles.AddLast(inside);
                #endregion
            }
            return triangles;
        }
Esempio n. 35
0
        void exportBrush(object sender, EventArgs e)
        {
            try {
                FileDialog fileDia = new SaveFileDialog();
                fileDia.Filter = filter;
                fileDia.DefaultExt = saveFormat;

                if (fileDia.ShowDialog() == DialogResult.OK) {
                    getValuesFromFormControls();
                    string filename = fileDia.FileName;
                    LinkedList<textureData> textures = new System.Collections.Generic.LinkedList<textureData>();
                    foreach (textureData tex in textureList.Items) {
                        textures.AddLast(tex);
                    }
                    data.exportBrushData(filename, textures, grassTextures.selectedTextures);

                }
            } catch (Exception e2) {
                Console.WriteLine(e2);
            }
        }
Esempio n. 36
0
 public Snake()
 {
     _Waits = new Queue<SnakeBody>();
     _Bodys = new LinkedList<SnakeBody>();
     _Bodys.AddLast(new SnakeBody());
 }
Esempio n. 37
0
 public AnEntityWithCollection()
 {
     Collection = new System.Collections.Generic.LinkedList<String>();
 }
Esempio n. 38
0
 public AnEntityWithComplexCollection()
 {
     Collection = new System.Collections.Generic.LinkedList<AnEntity>();
 }
Esempio n. 39
0
        // On error or failure, returns null.
        private static string locate_fxc_on_disk()
        {
            try
            {
                long EndTime = DateTime.Now.Ticks + MAX_LOCATE_TIME;

                // Paths to process
                System.Collections.Generic.LinkedList<string> PathQueue = new System.Collections.Generic.LinkedList<string>();
                // Path already processed in form Key=Path, Value="1"
                System.Collections.Specialized.StringDictionary Processed = new System.Collections.Specialized.StringDictionary();

                // Add default paths
                // - Program files
                PathQueue.AddLast(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));
                // - Hard disks
                foreach (DriveInfo Drive in DriveInfo.GetDrives())
                    if (Drive.DriveType == DriveType.Fixed)
                        PathQueue.AddLast(Drive.RootDirectory.Name);

                // Processing loop - berform breadth first search (BFS) algorithm
                while (PathQueue.Count > 0)
                {
                    // Get directory to process
                    string Dir = PathQueue.First.Value;
                    PathQueue.RemoveFirst();
                    // Already processed
                    if (Processed.ContainsKey(Dir))
                        continue;
                    // Add to processed
                    Processed.Add(Dir, "1");

                    try
                    {
                        // Look for fxc.exe file
                        string[] FxcFiles = Directory.GetFiles(Dir, "fxc.exe");
                        if (FxcFiles.Length > 0)
                            return FxcFiles[0];

                        // Look for subdirectories
                        foreach (string SubDir in Directory.GetDirectories(Dir))
                        {
                            // Interesting directory - add at the beginning of the queue
                            if (DirectoryIsInteresting(SubDir))
                                PathQueue.AddFirst(SubDir);
                            // Not interesting - add at the end of the queue
                            else
                                PathQueue.AddLast(SubDir);
                        }
                    }
                    catch (Exception ) { }

                    // Time out
                    if (DateTime.Now.Ticks >= EndTime)
                        return null;
                }

                // Not found
                return null;
            }
            catch (Exception )
            {
                return null;
            }
        }
Esempio n. 40
0
        private void Uploadfile(HttpContext context)
        {
            int i = 0;
            System.Collections.Generic.LinkedList<ViewDataUploadFilesResult> r = new System.Collections.Generic.LinkedList<ViewDataUploadFilesResult>();
            string[] files = null;
            string savedFileName = string.Empty;

            System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();

            try
            {

                if (context.Request.Files.Count >= 1)
                {

                    int maximumFileSize = Convert.ToInt32(ConfigurationManager.AppSettings["UploadFilesMaximumFileSize"].ToString());

                    context.Response.ContentType = "text/plain";
                    for (i = 0; i <= context.Request.Files.Count - 1; i++)
                    {
                        HttpPostedFile hpf = null;
                        string FileName = null;
                        hpf = context.Request.Files[i];

                        if (HttpContext.Current.Request.Browser.Browser.ToUpper() == "IE")
                        {
                            files = hpf.FileName.Split(Convert.ToChar("\\\\"));
                            FileName = files[files.Length - 1];
                        }
                        else
                        {
                            FileName = hpf.FileName;
                        }

                        if (hpf.ContentLength >= 0 & (hpf.ContentLength <= maximumFileSize * 1000 | maximumFileSize == 0))
                        {

                            savedFileName = StorageRoot(context);

                            savedFileName = savedFileName + FileName;

                            hpf.SaveAs(savedFileName);

                            r.AddLast(new ViewDataUploadFilesResult(FileName, hpf.ContentLength, hpf.ContentType, savedFileName));

                            dynamic uploadedFiles = r.Last;
                            dynamic jsonObj = js.Serialize(uploadedFiles);
                            context.Response.Write(jsonObj.ToString());

                        }
                        else
                        {

                            // File to Big (using IE without ActiveXObject enabled
                            if (hpf.ContentLength > maximumFileSize * 1000)
                            {
                                r.AddLast(new ViewDataUploadFilesResult(FileName, hpf.ContentLength, hpf.ContentType, string.Empty, "maxFileSize"));

                            }

                            dynamic uploadedFiles = r.Last;
                            dynamic jsonObj = js.Serialize(uploadedFiles);
                            context.Response.Write(jsonObj.ToString());

                        }
                    }

                }

            }
            catch (Exception ex)
            {
                string msg = ex.Message;
                throw;
            }
        }
Esempio n. 41
0
        public void bw_receive_DoWork(object sender, DoWorkEventArgs e)
        {
            byte[] buffer = new byte[4];
            byte[] data = null;
            string usernameTemp;
            bool check_addMessage = false;
            while (socket.Connected)
            {
                try
                {

                    stream.Read(buffer, 0, 4);
                    CommandType_ cmt = (CommandType_)BitConverter.ToInt32(buffer, 0);
                    if (cmt == CommandType_.Message)
                    {

                        string cmdMetaData = "";
                        buffer = new byte[4];
                        //đọc nội dung tin nhắn
                        stream.Read(buffer, 0, 4);
                        int lenght = BitConverter.ToInt32(buffer, 0);
                        byte[] metaBuffer = new byte[lenght];
                        stream.Read(metaBuffer, 0, lenght);
                        cmdMetaData = Encoding.ASCII.GetString(metaBuffer);
                        //đọc font
                        stream.Read(buffer, 0, 4);
                        lenght = BitConverter.ToInt32(buffer, 0);
                        metaBuffer = new byte[lenght];
                        stream.Read(metaBuffer, 0, lenght);
                        MemoryStream s = new MemoryStream(metaBuffer);
                        BinaryFormatter bf = new BinaryFormatter();
                        Font temp = new Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular);
                        temp = (Font)bf.Deserialize(s);
                        Chat chatForm = null;
                        _frmMain.Invoke(new Action(delegate()
                        {
                            if ((chatForm = IsShow("Server")) == null)
                            {
                                chatForm = new Chat(this, "Server");
                                chatForm.Text = "Server";
                                chatForm.Show();
                                listFormChat.Add(chatForm);
                            }
                        }));
                        chatForm.Receive("Server", cmdMetaData, temp);
                    }//end message

                    if (cmt == CommandType_.LoadMessage)
                    {
                        buffer = new byte[4];
                        stream.Read(buffer, 0, 4);
                        int count = BitConverter.ToInt16(buffer, 0);
                        if (count > 0)
                        {
                            buffer = new byte[4];
                            stream.Read(buffer, 0, 4);
                            int lengh = BitConverter.ToInt32(buffer, 0);
                            data = new byte[lengh];
                            stream.Read(data, 0, lengh);
                            usernameTemp = Encoding.ASCII.GetString(data);
                            LinkedList<MessageText> listmessageTemp = new System.Collections.Generic.LinkedList<MessageText>();
                            for (int i = 0; i < count; i++)
                            {
                                buffer = new byte[4];
                                stream.Read(buffer, 0, 4);
                                lengh = BitConverter.ToInt32(buffer, 0);
                                data = new byte[lengh];
                                stream.Read(data, 0, lengh);
                                string content = Encoding.ASCII.GetString(data);

                                stream.Read(buffer, 0, 4);
                                int lenght = BitConverter.ToInt32(buffer, 0);
                                data = new byte[lenght];
                                stream.Read(data, 0, lenght);
                                MemoryStream s = new MemoryStream(data);
                                s.Position = 0;
                                BinaryFormatter bf = new BinaryFormatter();
                                Font temp = new Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular);
                                temp = (Font)bf.Deserialize(s);

                                buffer = new byte[4];
                                stream.Read(buffer, 0, 4);
                                int type = BitConverter.ToInt16(buffer, 0);
                                MessageText mst = new MessageText(content, temp, type);

                                listmessageTemp.AddLast(mst);

                            }
                            foreach (var s in listmessageTemp)
                            {
                                IsShow(usernameTemp).listmessage.AddFirst(s);
                            }
                            IsShow(usernameTemp).update_message(true);

                        }
                    }
                    if (cmt == CommandType_.MessageFriend)
                    {
                        buffer = new byte[4];
                        stream.Read(buffer, 0, 4);
                        int lengh = BitConverter.ToInt32(buffer, 0);
                        data = new byte[lengh];
                        stream.Read(data, 0, lengh);
                        usernameTemp = Encoding.ASCII.GetString(data);

                        //đọc nội dung tin nhắn
                        string cmdMetaData = "";
                        buffer = new byte[4];
                        stream.Read(buffer, 0, 4);
                        int lenght = BitConverter.ToInt32(buffer, 0);
                        byte[] metaBuffer = new byte[lenght];
                        stream.Read(metaBuffer, 0, lenght);
                        cmdMetaData = Encoding.UTF8.GetString(metaBuffer);
                        //đọc font
                        stream.Read(buffer, 0, 4);
                        lenght = BitConverter.ToInt32(buffer, 0);
                        metaBuffer = new byte[lenght];
                        stream.Read(metaBuffer, 0, lenght);
                        //convert byte sang font
                        MemoryStream s = new MemoryStream(metaBuffer);
                        BinaryFormatter bf = new BinaryFormatter();
                        Font temp = new Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular);
                        temp = (Font)bf.Deserialize(s);
                        Chat chatForm = null;
                        _frmMain.Invoke(new Action(delegate()
                        {
                            if ((chatForm = IsShow(usernameTemp)) == null)
                            {
                                chatForm = new Chat(this, usernameTemp);
                                chatForm.Text = usernameTemp;
                                //Command cmd = new Command(CommandType_.LoadMessage, usernameTemp, 0);
                                // this.SendCommand(cmd);
                                chatForm.Show();
                                listFormChat.Add(chatForm);
                            }
                        }));
                        chatForm.Receive(usernameTemp, cmdMetaData, temp);
                    }
                    if (cmt == CommandType_.LoginSuccess)
                    {
                        stream.Read(buffer, 0, 4);
                        int stt = BitConverter.ToInt32(buffer, 0);

                        byte[] dataPicture;
                        //đọc tên username
                        stream.Read(buffer, 0, 4);
                        int lenght = BitConverter.ToInt32(buffer, 0);
                        data = new byte[lenght];
                        stream.Read(data, 0, lenght);
                        string username = Encoding.ASCII.GetString(data);
                        this._userName = username;

                        //nhận email
                        stream.Read(buffer, 0, 4);
                        lenght = BitConverter.ToInt32(buffer, 0);
                        data = new byte[lenght];
                        stream.Read(data, 0, lenght);
                        string email = Encoding.ASCII.GetString(data);

                        //đọc avatar
                        Image image;
                        stream.Read(buffer, 0, 4);
                        lenght = BitConverter.ToInt32(buffer, 0);
                        dataPicture = new byte[lenght];
                        ReadBigData(stream, lenght, ref dataPicture);
                        MemoryStream mem = new MemoryStream(dataPicture);
                        image = Image.FromStream(mem);

                        //đọc status
                        stream.Read(buffer, 0, 4);
                        lenght = BitConverter.ToInt32(buffer, 0);
                        data = new byte[lenght];
                        ReadBigData(stream, lenght, ref data);
                        string status = Encoding.UTF8.GetString(data);

                        //Đăng nhập thành công
                        //Khởi tạo form chính
                        //dangnhapForm.KillThreard();
                        if (_frmMain == null)
                        {
                            dangnhapForm.Invoke(new Action(delegate()
                            {

                                {
                                    _frmMain = new Form1(dangnhapForm, 1, this._userName, email, image, status, this);
                                    _frmMain.Text = "Frozen";
                                    _frmMain.Show();
                                    dangnhapForm.Hide();
                                }
                            }));

                        }
                        Command cmd = new Command(CommandType_.ListFriend, this._userName);
                        this.SendCommand(cmd);
                        //load list friend
                        //đọc thông tin list Friend
                        //Thread.Sleep(2000);
                        //--Đọc số lượng friend của user

                    }//End LoginSuccess
                    if (cmt == CommandType_.ListFriend)
                    {
                        stream.Read(buffer, 0, 4);
                        int _CountTemp;
                        _CountTemp = BitConverter.ToInt32(buffer, 0);
                        _frmMain.listFriend = new List<FriendList>();
                        for (int i = 0; i < _CountTemp; i++)
                        {
                            //đọc useer friend
                            //int a = _abc;
                            stream.Read(buffer, 0, 4);
                            int lenght = BitConverter.ToInt32(buffer, 0);
                            data = new byte[lenght];
                            stream.Read(data, 0, lenght);
                            string usernameFriend = Encoding.ASCII.GetString(data);

                            //đọc avatar friend
                            Image _avatarFriend;
                            stream.Read(buffer, 0, 4);
                            lenght = BitConverter.ToInt32(buffer, 0);
                            byte[] dataPicture = new byte[lenght];
                            ReadBigData(stream, lenght, ref dataPicture);
                            MemoryStream memTemp = new MemoryStream(dataPicture);
                            _avatarFriend = Image.FromStream(memTemp);

                            stream.Read(buffer, 0, 4);
                            lenght = BitConverter.ToInt32(buffer, 0);
                            data = new byte[lenght];
                            ReadBigData(stream, lenght, ref data);
                            string _status = Encoding.UTF8.GetString(data);

                            //đọc trạng thái của friend này
                            stream.Read(buffer, 0, 4);
                            CommandType_ status = (CommandType_)BitConverter.ToInt32(buffer, 0);
                            FriendList friendTemp;
                            if (status == CommandType_.Online)
                            {
                                friendTemp = new FriendList(usernameFriend, _avatarFriend, true, _status);
                            }
                            else
                            {
                                friendTemp = new FriendList(usernameFriend, _avatarFriend, false, _status);
                            }
                            _frmMain.listFriend.Add(friendTemp);
                        }
                        _frmMain.update_listFriend(true);
                    }
                    if (cmt == CommandType_.Found)
                    {
                        stream.Read(buffer, 0, 4);
                        int lenght = BitConverter.ToInt32(buffer, 0);
                        data = new byte[lenght];
                        stream.Read(data, 0, lenght);
                        string username = Encoding.ASCII.GetString(data);

                        stream.Read(buffer, 0, 4);
                        lenght = BitConverter.ToInt32(buffer, 0);
                        data = new byte[lenght];
                        stream.Read(data, 0, lenght);
                        string email = Encoding.ASCII.GetString(data);

                        byte[] dataPicture;
                        //đọc avatar
                        Image image;
                        stream.Read(buffer, 0, 4);
                        lenght = BitConverter.ToInt32(buffer, 0);
                        dataPicture = new byte[lenght];
                        ReadBigData(stream, lenght, ref dataPicture);
                        MemoryStream mem = new MemoryStream(dataPicture);
                        image = Image.FromStream(mem);
                        ff_Form.Found(username, email, image);
                    }
                    if (cmt == CommandType_.NotFound)
                    {
                        ff_Form.Notfound();
                    }
                    if (cmt == CommandType_.NameExists)
                    {
                        MessageCustom.Show("Tài khoản bạn đã được đang nhập bởi người khác!", "Thông báo", new Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))));
                        dangnhapForm.ChangePanel();
                    }
                    if (cmt == CommandType_.Failure)
                    {
                        MessageCustom.Show("Tài khoản hoặc mật khẩu không đúng!", "Error", new Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))));
                        dangnhapForm.ChangePanel();
                    }
                    if (cmt == CommandType_.RegisterFailure)
                    {
                        MessageCustom.Show("Tài khoản hoặc tên người dùng đã tồn tại!", "Thông báo", new Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))));
                    }
                    if (cmt == CommandType_.RegisterSuccess)
                    {
                        MessageCustom.Show("Đăng kí thành công!", "Thông báo", new Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))));
                    }
                    if (cmt == CommandType_.Online)
                    {
                        stream.Read(buffer, 0, 4);
                        int lenght = BitConverter.ToInt32(buffer, 0);
                        data = new byte[lenght];
                        stream.Read(data, 0, lenght);
                        string usernameFriend = Encoding.ASCII.GetString(data);
                        foreach (var s in _frmMain.listFriend)
                        {
                            if (s._userFriend == usernameFriend)
                            {
                                s.Status = true;
                            }
                        }
                        _frmMain.update_listFriend(true);
                    }
                    if (cmt == CommandType_.Offline)
                    {
                        stream.Read(buffer, 0, 4);
                        int lenght = BitConverter.ToInt32(buffer, 0);
                        data = new byte[lenght];
                        stream.Read(data, 0, lenght);
                        string usernameFriend = Encoding.ASCII.GetString(data);
                        foreach (var s in _frmMain.listFriend)
                        {
                            if (s._userFriend == usernameFriend)
                            {
                                s.Status = false;
                            }
                        }
                        _frmMain.update_listFriend(true);
                    }
                    //load toàn bộ thông báo
                    if (cmt == CommandType_.LoadNotice)
                    {
                        stream.Read(buffer, 0, 4);
                        int count = BitConverter.ToInt32(buffer, 0);
                        for (int i = 0; i < count; i++)
                        {

                            stream.Read(buffer, 0, 4);
                            int _stt = BitConverter.ToInt32(buffer, 0);

                            stream.Read(buffer, 0, 4);
                            int lenght = BitConverter.ToInt32(buffer, 0);
                            data = new byte[lenght];
                            stream.Read(data, 0, lenght);
                            string _userPrimary = Encoding.ASCII.GetString(data);

                            stream.Read(buffer, 0, 4);
                            lenght = BitConverter.ToInt32(buffer, 0);
                            data = new byte[lenght];
                            stream.Read(data, 0, lenght);
                            string _userReference = Encoding.ASCII.GetString(data);

                            stream.Read(buffer, 0, 4);
                            lenght = BitConverter.ToInt32(buffer, 0);
                            data = new byte[lenght];
                            stream.Read(data, 0, lenght);
                            string _type = Encoding.ASCII.GetString(data);

                            stream.Read(buffer, 0, 4);
                            lenght = BitConverter.ToInt32(buffer, 0);
                            data = new byte[lenght];
                            stream.Read(data, 0, lenght);
                            string _content = Encoding.ASCII.GetString(data);

                            stream.Read(buffer, 0, 4);
                            lenght = BitConverter.ToInt32(buffer, 0);
                            data = new byte[lenght];
                            stream.Read(data, 0, lenght);
                            string _time = Encoding.ASCII.GetString(data);
                            Notice_List noticeTemp = new Notice_List(_stt, _userPrimary, _userReference, _type, _time);
                            Notice_frm.listNotice.Add(noticeTemp);
                        }
                        Notice_frm.update_Notice(false);
                    }
                    if (cmt == CommandType_.DeleteNoticeSuccess)
                    {
                        Notice_frm.update_Notice(true);
                    }
                    if (cmt == CommandType_.AddNoticeSuccess)
                    {
                        ff_Form.AddNoticeSuccess();
                    }
                    if (cmt == CommandType_.AddNoticeFailure)
                    {
                        ff_Form.AddNoticeFailure();
                    }
                    if (cmt == CommandType_.AddFriendFailure)
                    {
                        ff_Form.AddFriendFailure();
                    }
                }
                catch
                {
                    if (_check)
                    {
                        MessageCustom.Show("Server đang bảo trì !", "Thông báo", new Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))));
                        socket.Close();
                        dangnhapForm.Client = null;
                    }
                }
            }//end while
        }
Esempio n. 42
0
        protected override void OnSubscribe(Instrument instrument)
        {
            // Get size of bar.
            barSize = (long)Global[barSizeCode];

            // Get spread instrument.
            spread = instrument;

            // Add legs instruments to bar factory.
            foreach (Leg leg in spread.Legs)
                BarFactory.Add(leg.Instrument, BarType.Time, barSize);

            // Remove instruments from strategy.
            Instruments.Clear();

            // Add legs instruments to strategy.
            foreach (Leg leg in spread.Legs)
                AddInstrument(leg.Instrument);

            processors = new System.Collections.Generic.LinkedList<OrderProcessor>();
            groups = new Dictionary<Instrument, Group[]>();

            AddGroups();
        }
Esempio n. 43
0
        /// <summary>
        /// Prepares to show the top models for one store.
        /// <para>A new hidden row is inserted below the current row in the grid.</para>
        /// <para>That row will have only one cell, spanned to the entire row.</para>
        /// <para>Inside the new row, a panel is inserted as a simple HTML 'fieldset', just to show a border and some header.</para>
        /// <para>Inside the fieldset, a new panel is inserted. That panel will be filled with details when the user click the button.</para>
        /// </summary>
        /// <param name="gridViewRow">One row from the main grid</param>
        /// <param name="storeRow">One store</param>
        private void InsertModelsRow(GridViewRow gridViewRow, BO.Store storeRow)
        {
            // Gets the index for the new row

            Table htmlTab = gridStores.Controls[0] as Table;

            int newRowIndex = htmlTab.Rows.GetRowIndex(gridViewRow) + 1;

            // Creates two panels : external and internal

            // External panel : A simple <fieldset>
            System.Web.UI.WebControls.Panel externalPanel = new Panel();
            externalPanel.EnableViewState = false;
            externalPanel.GroupingText = "Top models";
            externalPanel.ID = String.Format(CultureInfo.InvariantCulture, "pModelE_{0}", newRowIndex);
            externalPanel.CssClass = "expand-painel";

            // Internal panel : A <div> as a container for top models
            System.Web.UI.WebControls.Panel internalPanel = new Panel();
            internalPanel.EnableViewState = false;
            internalPanel.ID = String.Format(CultureInfo.InvariantCulture, "pModel_{0}", newRowIndex);

            externalPanel.Controls.Add(internalPanel);

            // Inserts the panels in one cell

            TableCell cell = new TableCell();
            //cell.HorizontalAlign = HorizontalAlign.Left;
            cell.BorderStyle = BorderStyle.None;
            cell.Controls.Add(externalPanel);
            cell.ColumnSpan = VisibleColumns;

            // Inserts the cell in a collection of cell (only one cell)

            TableCell[] cells = new TableCell[1];

            cells[0] = cell;

            // Inserts one row under the current row

            GridViewRow newRow = new GridViewRow(
                newRowIndex,
                newRowIndex,
                DataControlRowType.DataRow,
                DataControlRowState.Normal);

            newRow.ID = String.Format(CultureInfo.InvariantCulture, "linM_{0}", newRowIndex);

            newRow.Style.Add(HtmlTextWriterStyle.Display, "none");

            // Inserts the cell in the new row

            newRow.Cells.AddRange(cells);

            // Inserts the new row in the controls collection of the table (grid)

            htmlTab.Controls.AddAt(newRowIndex, newRow);

            // contextKey = CustomerId + radSimulatedData.Checked, separated by '-'
            string contextKey = String.Format(CultureInfo.InvariantCulture,
                "{0}-{1}",
                storeRow.CustomerId,
                (radSimulatedData.Checked ? 1 : 0));

            // Locates the button and prepares the 'onclick' event

            Image btn = gridViewRow.FindControl("imgModel") as Image;

            btn.Attributes["onClick"] = String.Format(CultureInfo.InvariantCulture,
                "ExpandModels('{0}', '{1}', '{2}', '{3}');",
                contextKey,
                newRow.ClientID,
                internalPanel.ClientID,
                btn.ClientID);

            // Insert the ID into the buttons list

            if (_Buttons == null)
                _Buttons = new System.Collections.Generic.LinkedList<string>();

            _Buttons.AddLast(btn.ClientID);
        }