Пример #1
0
        public PackageControl(PackageMetadata package, PackageCategory category)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            SetStyle(ControlStyles.Selectable | ControlStyles.ResizeRedraw, true);
            TabStop = false;

            Package = package;

            InitializeComponent();

            _icon.Image                =
                _icon.ErrorImage       =
                    _icon.InitialImage =
                        NeutralResources.NuGetPackage;

            HookMouseEvents(this);

            if (!String.IsNullOrEmpty(package.IconUrl))
            {
                PackageImageCache.LoadImage(package.IconUrl, _icon);
            }

            _title.Text       = Normalize(package.Title);
            _description.Text = Normalize(package.Description);

            bool isCorePackage = package.State.HasFlag(PackageState.CorePackage);

            switch (category)
            {
            case PackageCategory.Installed:
                if (package.State.HasFlag(PackageState.Disabled))
                {
                    AddButton(Labels.Enable, PackageControlButton.Enable, 0, !isCorePackage);
                }
                else
                {
                    AddButton(Labels.Disable, PackageControlButton.Disable, 0, !isCorePackage);
                }

                AddButton(Labels.Uninstall, PackageControlButton.Uninstall, 1, !isCorePackage && !package.State.HasFlag(PackageState.UninstallPending));
                break;

            case PackageCategory.Online:
                bool installedOrPending =
                    package.State.HasFlag(PackageState.Installed) ||
                    package.State.HasFlag(PackageState.InstallPending);

                AddButton(Labels.Install, PackageControlButton.Install, 0, !installedOrPending);
                break;

            case PackageCategory.Updates:
                AddButton(Labels.Update, PackageControlButton.Update, 0, !package.State.HasFlag(PackageState.UpdatePending));
                break;
            }
        }
Пример #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();
        }
Пример #3
0
        private void _selector_SelectedIndexChanged(object sender, EventArgs e)
        {
            var category = ((SelectionItem <PackageCategory>)_selector.SelectedItem).Value;

            if (category == _lastCategory)
            {
                return;
            }

            _lastCategory = category;

            LoadCategory(category);
        }
Пример #4
0
        public PackageControl(PackageMetadata package, PackageCategory category)
        {
            if (package == null)
                throw new ArgumentNullException("package");

            SetStyle(ControlStyles.Selectable | ControlStyles.ResizeRedraw, true);
            TabStop = false;

            Package = package;

            InitializeComponent();

            _icon.Image =
            _icon.ErrorImage =
            _icon.InitialImage =
                NeutralResources.NuGetPackage;

            HookMouseEvents(this);

            if (!String.IsNullOrEmpty(package.IconUrl))
                PackageImageCache.LoadImage(package.IconUrl, _icon);

            _title.Text = Normalize(package.Title);
            _description.Text = Normalize(package.Description);

            bool isCorePackage = package.State.HasFlag(PackageState.CorePackage);

            switch (category)
            {
                case PackageCategory.Installed:
                    if (package.State.HasFlag(PackageState.Disabled))
                        AddButton(Labels.Enable, PackageControlButton.Enable, 0, !isCorePackage);
                    else
                        AddButton(Labels.Disable, PackageControlButton.Disable, 0, !isCorePackage);

                    AddButton(Labels.Uninstall, PackageControlButton.Uninstall, 1, !isCorePackage && !package.State.HasFlag(PackageState.UninstallPending));
                    break;

                case PackageCategory.Online:
                    bool installedOrPending =
                        package.State.HasFlag(PackageState.Installed) ||
                        package.State.HasFlag(PackageState.InstallPending);

                    AddButton(Labels.Install, PackageControlButton.Install, 0, !installedOrPending);
                    break;

                case PackageCategory.Updates:
                    AddButton(Labels.Update, PackageControlButton.Update, 0, !package.State.HasFlag(PackageState.UpdatePending));
                    break;
            }
        }
Пример #5
0
 private void Send(PackageCategory category, IMessage msg = null)
 {
     //var seq = Interlocked.Increment(ref _seq);
     //var completionSource = new TaskCompletionSource<SocketResult>();
     //_taskCompletionSources.TryAdd(seq, completionSource);
     _socket.Send(new SocketPackage {
         Seq = 0, Category = category, Content = msg == null ? ByteString.Empty : msg.ToByteString()
     }.ToByteArray());
     //completionSource.Task.ContinueWith(t =>
     //{
     //    //var res = t.Result;
     //    //Console.WriteLine("received {0},{1},{2} {3}", res.Category, res.Code, res.Message, DateTime.Now);
     //});
 }
Пример #6
0
        private void LoadCategory(PackageCategory category)
        {
            switch (category)
            {
            case PackageCategory.Installed:
                LoadInstalledPackages();
                break;

            case PackageCategory.Online:
                LoadOnlinePackages();
                break;

            case PackageCategory.Updates:
                LoadPackagesForUpdate();
                break;
            }
        }
Пример #7
0
 public bool TryGetCategory(string packageId, out PackageCategory category) => _packages.TryGetValue(packageId, out category);
Пример #8
0
 public SICategory(PackageCategory category, SIStorageServiceClient siService, string restriction)
 {
     _category    = category;
     _restriction = restriction;
     _siService   = siService;
 }
Пример #9
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();
        }
Пример #10
0
        private void _selector_SelectedIndexChanged(object sender, EventArgs e)
        {
            var category = ((SelectionItem<PackageCategory>)_selector.SelectedItem).Value;

            if (category == _lastCategory)
                return;

            _lastCategory = category;

            LoadCategory(category);
        }
Пример #11
0
        private void LoadCategory(PackageCategory category)
        {
            switch (category)
            {
                case PackageCategory.Installed:
                    LoadInstalledPackages();
                    break;

                case PackageCategory.Online:
                    LoadOnlinePackages();
                    break;

                case PackageCategory.Updates:
                    LoadPackagesForUpdate();
                    break;
            }
        }