Ejemplo n.º 1
0
        public void Add(SurfaceBoxRenderer addMe, bool alwaysOnTop)
        {
            SurfaceBoxRenderer[] startList   = alwaysOnTop ? this.topList : this.list;
            SurfaceBoxRenderer[] listPlusOne = new SurfaceBoxRenderer[startList.Length + 1];

            for (int i = 0; i < startList.Length; ++i)
            {
                listPlusOne[i] = startList[i];
            }

            listPlusOne[listPlusOne.Length - 1] = addMe;

            if (alwaysOnTop)
            {
                this.topList = listPlusOne;
            }
            else
            {
                this.list = listPlusOne;
            }

            Invalidate();
        }
Ejemplo n.º 2
0
        public void Add(SurfaceBoxRenderer addMe, bool alwaysOnTop)
        {
            SurfaceBoxRenderer[] startList = alwaysOnTop ? this.topList : this.list;
            SurfaceBoxRenderer[] listPlusOne = new SurfaceBoxRenderer[startList.Length + 1];

            for (int i = 0; i < startList.Length; ++i)
            {
                listPlusOne[i] = startList[i];
            }

            listPlusOne[listPlusOne.Length - 1] = addMe;

            if (alwaysOnTop)
            {
                this.topList = listPlusOne;
            }
            else
            {
                this.list = listPlusOne;
            }

            Invalidate();
        }
        public void Remove(SurfaceBoxRenderer removeMe)
        {
            if (this.list.Length == 0 && this.topList.Length == 0)
            {
                throw new InvalidOperationException("zero items left, can't remove anything");
            }
            else
            {
                bool found = false;

                if (this.list.Length > 0)
                {
                    SurfaceBoxRenderer[] listSubOne = new SurfaceBoxRenderer[this.list.Length - 1];
                    bool foundHere = false;
                    int dstIndex = 0;

                    for (int i = 0; i < this.list.Length; ++i)
                    {
                        if (this.list[i] == removeMe)
                        {
                            if (foundHere)
                            {
                                throw new ArgumentException("removeMe appeared multiple times in the list");
                            }
                            else
                            {
                                foundHere = true;
                            }
                        }
                        else
                        {
                            if (dstIndex == this.list.Length - 1)
                            {
                                // was not found
                            }
                            else
                            {
                                listSubOne[dstIndex] = this.list[i];
                                ++dstIndex;
                            }
                        }
                    }

                    if (foundHere)
                    {
                        this.list = listSubOne;
                        found = true;
                    }
                }

                if (this.topList.Length > 0)
                {
                    SurfaceBoxRenderer[] topListSubOne = new SurfaceBoxRenderer[this.topList.Length - 1];
                    int topDstIndex = 0;
                    bool foundHere = false;

                    for (int i = 0; i < this.topList.Length; ++i)
                    {
                        if (this.topList[i] == removeMe)
                        {
                            if (found || foundHere)
                            {
                                throw new ArgumentException("removeMe appeared multiple times in the list");
                            }
                            else
                            {
                                foundHere = true;
                            }
                        }
                        else
                        {
                            if (topDstIndex == this.topList.Length - 1)
                            {
                                // was not found
                            }
                            else
                            {
                                topListSubOne[topDstIndex] = this.topList[i];
                                ++topDstIndex;
                            }
                        }
                    }

                    if (foundHere)
                    {
                        this.topList = topListSubOne;
                        found = true;
                    }
                }

                if (!found)
                {
                    throw new ArgumentException("removeMe was not found", "removeMe");
                }

                Invalidate();
            }
        }
Ejemplo n.º 4
0
        public void Remove(SurfaceBoxRenderer removeMe)
        {
            if (this.list.Length == 0 && this.topList.Length == 0)
            {
                throw new InvalidOperationException("zero items left, can't remove anything");
            }
            else
            {
                bool found = false;

                if (this.list.Length > 0)
                {
                    SurfaceBoxRenderer[] listSubOne = new SurfaceBoxRenderer[this.list.Length - 1];
                    bool foundHere = false;
                    int  dstIndex  = 0;

                    for (int i = 0; i < this.list.Length; ++i)
                    {
                        if (this.list[i] == removeMe)
                        {
                            if (foundHere)
                            {
                                throw new ArgumentException("removeMe appeared multiple times in the list");
                            }
                            else
                            {
                                foundHere = true;
                            }
                        }
                        else
                        {
                            if (dstIndex == this.list.Length - 1)
                            {
                                // was not found
                            }
                            else
                            {
                                listSubOne[dstIndex] = this.list[i];
                                ++dstIndex;
                            }
                        }
                    }

                    if (foundHere)
                    {
                        this.list = listSubOne;
                        found     = true;
                    }
                }

                if (this.topList.Length > 0)
                {
                    SurfaceBoxRenderer[] topListSubOne = new SurfaceBoxRenderer[this.topList.Length - 1];
                    int  topDstIndex = 0;
                    bool foundHere   = false;

                    for (int i = 0; i < this.topList.Length; ++i)
                    {
                        if (this.topList[i] == removeMe)
                        {
                            if (found || foundHere)
                            {
                                throw new ArgumentException("removeMe appeared multiple times in the list");
                            }
                            else
                            {
                                foundHere = true;
                            }
                        }
                        else
                        {
                            if (topDstIndex == this.topList.Length - 1)
                            {
                                // was not found
                            }
                            else
                            {
                                topListSubOne[topDstIndex] = this.topList[i];
                                ++topDstIndex;
                            }
                        }
                    }

                    if (foundHere)
                    {
                        this.topList = topListSubOne;
                        found        = true;
                    }
                }

                if (!found)
                {
                    throw new ArgumentException("removeMe was not found", "removeMe");
                }

                Invalidate();
            }
        }