Exemplo n.º 1
0
            /// <summary>
            ///     Initializes a new instance of the <see cref="DropdownSelect" /> class.
            /// </summary>
            /// <param name="position">
            ///     The position of this item.
            /// </param>
            /// <param name="width">
            ///     The width of this item.
            /// </param>
            /// <param name="self">
            ///     This item's bounding area.
            /// </param>
            /// <param name="owner">
            ///     The owning dropdown for this item.
            /// </param>
            /// <param name="collection">
            ///     The collection containing this item.
            /// </param>
            public DropdownSelect(
                Point position,
                int width,
                Rectangle self,
                DropdownFormComponent owner,
                IComponentContainer collection)
            {
                this.MaxScroll  = Math.Max(0, owner.Values.Count - 10);
                this.Size       = Math.Min(10, owner.Values.Count);
                this.Value      = owner.Value;
                this.Owner      = owner;
                this.Collection = collection;
                this.Self       = self;
                this.Area       = new Rectangle(
                    position.X,
                    position.Y,
                    width,
                    Zoom2 + Game1.pixelZoom * Math.Min(7 * owner.Values.Count, 70));
                collection.GetAttachedMenu().GiveFocus(this);
                if (!collection.GetAttachedMenu().EventRegion.Contains(this.Area.X, this.Area.Y + this.Area.Height))
                {
                    // ReSharper disable once VirtualMemberCallInConstructor
                    this.MoveRegion(0, -(this.Area.Height + Zoom9));
                }

                var index = owner.Values.IndexOf(this.Value);

                this.ScrollOffset   = Math.Max(0, index - 9);
                this.KeyboardOffset = index;
            }
Exemplo n.º 2
0
            public DropdownSelect(Point position, int width, Rectangle self, DropdownFormComponent owner, IComponentContainer collection)
            {
                MaxScroll  = Math.Max(0, owner.Values.Count - 10);
                Size       = Math.Min(10, owner.Values.Count);
                Value      = owner.Value;
                Owner      = owner;
                Collection = collection;
                Self       = self;
                Area       = new Rectangle(position.X, position.Y, width, zoom2 + Game1.pixelZoom * Math.Min(7 * owner.Values.Count, 70));
                collection.GetAttachedMenu().GiveFocus(this);
                if (!collection.GetAttachedMenu().EventRegion.Contains(Area.X, Area.Y + Area.Height))
                {
                    Area.Y -= Area.Height + zoom9;
                }
                int index = owner.Values.IndexOf(Value);

                ScrollOffset   = Math.Max(0, index - 9);
                KeyboardOffset = index;
            }
Exemplo n.º 3
0
            public DropdownSelect(Point position, int width, Rectangle self, DropdownFormComponent owner, IComponentContainer collection)
            {
                this.MaxScroll  = Math.Max(0, owner.Values.Count - 10);
                this.Size       = Math.Min(10, owner.Values.Count);
                this.Value      = owner.Value;
                this.Owner      = owner;
                this.Collection = collection;
                this.Self       = self;
                this.Area       = new Rectangle(position.X, position.Y, width, zoom2 + Game1.pixelZoom * Math.Min(7 * owner.Values.Count, 70));
                collection.GetAttachedMenu().GiveFocus(this);
                if (this.Area.Y + this.Area.Height > Game1.viewport.Height)
                {
                    this.Area.Y -= this.Area.Height + zoom9;
                }
                int index = owner.Values.IndexOf(this.Value);

                this.ScrollOffset   = Math.Max(0, index - 9);
                this.KeyboardOffset = index;
            }