Esempio n. 1
0
            public virtual int IndexOfKey(string key)
            {
                if (string.IsNullOrEmpty(key))
                {
                    return(-1);
                }

                if (IsValidIndex(lastAccessedIndex))
                {
                    if (WindowsFormsUtils.SafeCompareStrings(this[lastAccessedIndex].Name, key, true))
                    {
                        return(lastAccessedIndex);
                    }
                }

                for (int i = 0; i < Count; i++)
                {
                    if (!WindowsFormsUtils.SafeCompareStrings(this[i].Name, key, true))
                    {
                        continue;
                    }

                    lastAccessedIndex = i;
                    return(i);
                }

                lastAccessedIndex = -1;
                return(-1);
            }
Esempio n. 2
0
        public virtual int IndexOfKey(string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                return(-1);
            }

            for (int i = 0; i < Count; i++)
            {
                if (WindowsFormsUtils.SafeCompareStrings(items[i].Name, key, true))
                {
                    return(i);
                }
            }

            return(-1);
        }
Esempio n. 3
0
        private static ArrayList FindInternal(string key, bool searchAllChildren, TreeNodeCollection collection, ArrayList nodes)
        {
            if (collection == null || nodes == null)
            {
                return(null);
            }

            var collectionCount = collection.Count;

            for (int i = 0; i < collectionCount; i++)
            {
                var node = collection[i];
                if (node == null)
                {
                    continue;
                }

                if (WindowsFormsUtils.SafeCompareStrings(node.Name, key, true))
                {
                    nodes.Add(node);
                }
            }

            if (searchAllChildren)
            {
                for (int i = 0; i < collectionCount; i++)
                {
                    var node = collection[i];
                    if (node == null)
                    {
                        continue;
                    }

                    var nodeNodes = node.Nodes;
                    if (nodeNodes != null && nodeNodes.Count > 0)
                    {
                        nodes = FindInternal(key, true, nodeNodes, nodes);
                    }
                }
            }
            return(nodes);
        }
        protected override void SetBoundsCore(int argX, int argY, int argWidth, int argHeight, BoundsSpecified specified)
        {
            // Fix location
            var workingArea = Screen.PrimaryScreen.WorkingArea;
            var newBounds   = WindowsFormsUtils.ConstrainToBounds(workingArea, new Rectangle(argX, argY, argWidth, argHeight));

            ////var xFixed = argX != newBounds.X;

            // TODO: need some code to prevent child going outside of screen.

            /*if (OwnerItem != null)
             * {
             *  var parentDropDown = OwnerItem.Owner as ToolStripDropDown;
             *  if (parentDropDown != null && direction == ToolStripDropDownDirection.Right)
             *  {
             *      // TODO: need to add other direction. Should be ToolStripDropDownItem, but the problem is that
             *      // it's invoked after Graphics.MeasureString, which can only be done on paint thread.
             *      if (xFixed && newBounds.X + newBounds.Width - 2 >= parentDropDown.Location.X)
             *          newBounds = new Rectangle(parentDropDown.Location.X - argWidth + 2, newBounds.Y, newBounds.Width, newBounds.Height);
             *  }
             * }*/

            base.SetBoundsCore(newBounds.X, newBounds.Y, newBounds.Width, newBounds.Height, specified);
        }