Exemplo n.º 1
0
        public void LoadPackages(PackageQueryResult packages, PackageCategory category)
        {
            _packages.SuspendLayout();

            _packages.Controls.Clear();

            foreach (var package in packages.Packages)
            {
                var control = new PackageControl(package, category);

                _packages.Controls.Add(control);

                control.IsSelectedChanged += control_IsSelectedChanged;
                control.ButtonClick       += control_ButtonClick;
            }

            if (_packages.Controls.Count > 0)
            {
                ((PackageControl)_packages.Controls[0]).IsSelected = true;
            }

            _packages.ResumeLayout();

            _selectedPage = packages.Page;

            _pager.SuspendLayout();

            _leftButton.Visible  = packages.Page > 0;
            _rightButton.Visible = packages.Page < packages.PageCount - 1;

            int start = Math.Max(packages.Page - 2, 0);
            int end   = Math.Min(packages.PageCount - 1, start + 4);

            var buttons = new[]
            {
                _page1Button,
                _page2Button,
                _page3Button,
                _page4Button,
                _page5Button
            };

            int visibleCount = (end - start) + 1;

            for (int i = 0; i < 5; i++)
            {
                buttons[i].Visible = i < visibleCount;
            }

            for (int i = start, buttonIndex = 0; i <= end; i++, buttonIndex++)
            {
                buttons[buttonIndex].Font = packages.Page == i ? _boldFont : Font;
                buttons[buttonIndex].Text = (i + 1).ToString();
                buttons[buttonIndex].Tag  = i;
            }

            _pager.ResumeLayout();
        }
Exemplo n.º 2
0
        public void LoadPackages(PackageQueryResult packages, PackageCategory category)
        {
            _packages.SuspendLayout();

            _packages.Controls.Clear();

            foreach (var package in packages.Packages)
            {
                var control = new PackageControl(package, category);

                _packages.Controls.Add(control);

                control.IsSelectedChanged += control_IsSelectedChanged;
                control.ButtonClick += control_ButtonClick;
            }

            if (_packages.Controls.Count > 0)
                ((PackageControl)_packages.Controls[0]).IsSelected = true;

            _packages.ResumeLayout();

            _selectedPage = packages.Page;

            _pager.SuspendLayout();

            _leftButton.Visible = packages.Page > 0;
            _rightButton.Visible = packages.Page < packages.PageCount - 1;

            int start = Math.Max(packages.Page - 2, 0);
            int end = Math.Min(packages.PageCount - 1, start + 4);

            var buttons = new[]
            {
                _page1Button,
                _page2Button,
                _page3Button,
                _page4Button,
                _page5Button
            };

            int visibleCount = (end - start) + 1;

            for (int i = 0; i < 5; i++)
            {
                buttons[i].Visible = i < visibleCount;
            }

            for (int i = start, buttonIndex = 0; i <= end; i++, buttonIndex++)
            {
                buttons[buttonIndex].Font = packages.Page == i ? _boldFont : Font;
                buttons[buttonIndex].Text = (i + 1).ToString();
                buttons[buttonIndex].Tag = i;
            }

            _pager.ResumeLayout();
        }