Esempio n. 1
0
        private Size UpdatePictureBoxImage(IImageOwner imageOwner = null)
        {
            if (pictureBox.Image != null)
            {
                pictureBox.Image.Dispose();
                pictureBox.Image = null;
            }

            if (imageOwner == null || string.IsNullOrEmpty(imageOwner.Image))
            {
                return(Size.Empty);
            }

            using (var image = PersistenceManager.LoadImage(imageOwner.Image))
            {
                pictureBox.Image = image.ReduceToFit(pictureBox.ClientSize.Width, pictureBox.ClientSize.Height);
                return(image.Size);
            }
        }
Esempio n. 2
0
        private void UpdateButtonsState(IImageOwner selectedItem)
        {
            if (selectedItem == null)
            {
                btnAdd.Enabled    = true;
                btnUp.Enabled     = false;
                btnDown.Enabled   = false;
                btnDelete.Enabled = false;
                return;
            }

            var index = 0;
            var total = 0;

            switch (selectedItem)
            {
            case Project previewItem:
                index          = _portfolio.Projects.IndexOf(previewItem);
                total          = _portfolio.Projects.Count;
                btnAdd.Enabled = true;
                break;

            case ProjectItem portfolioItem:
                index          = portfolioItem.Parent.Items.IndexOf(portfolioItem);
                total          = portfolioItem.Parent.Items.Count;
                btnAdd.Enabled = false;
                break;
            }

            var isFirst = index == 0;
            var isLast  = index == total - 1;

            btnUp.Enabled     = !isFirst;
            btnDown.Enabled   = !isLast;
            btnDelete.Enabled = true;
        }