Пример #1
0
        private void SetErrorStatus(string errorMessage)
        {
            //might not be on UI thread
            if (this.InvokeRequired || _errorMessageForm.InvokeRequired)
            {
                SetErrorStatusDelegate SetErrorStatusCallback = new SetErrorStatusDelegate(SetErrorStatus);
                this.Invoke(SetErrorStatusCallback, new object[] { errorMessage });
            }
            else
            {
                picStatus.Image = (_dpiScaleFactor > 1 ? HighDPIUtils.ScaleByDpi(Resources.ProgressError) : Resources.ProgressError);
                lblStatus.Text  = "Error";
                _deployStatus   = DeploymentStatus.Error;

                if (!String.IsNullOrEmpty(errorMessage) && String.IsNullOrEmpty(_errorMessageForm.ErrorMessage)) //just in case already shown
                {
                    _errorMessageForm.ErrorMessage   = errorMessage;
                    _errorMessageForm.StartPosition  = FormStartPosition.CenterParent;
                    _errorMessageForm.DpiScaleFactor = _dpiScaleFactor;
                    _errorMessageForm.ShowDialog();
                }

                btnStopProcessing.Enabled = false;
                btnClose.Enabled          = true;
                btnClose.Select();
            }
        }
Пример #2
0
        private void HandleDeploymentComplete(object sender, DeploymentCompleteEventArgs e)
        {
            switch (e.DeploymentStatus)
            {
            case DeploymentStatus.Success:
                picStatus.Image = (_dpiScaleFactor > 1 ? HighDPIUtils.ScaleByDpi(Resources.ProgressSuccess) : Resources.ProgressSuccess);
                lblStatus.Text  = "Success";
                _deployStatus   = DeploymentStatus.Success;
                break;

            case DeploymentStatus.Cancel:
                picStatus.Image = (_dpiScaleFactor > 1 ? HighDPIUtils.ScaleByDpi(Resources.ProgressCancel) : Resources.ProgressCancel);
                lblStatus.Text  = "Cancelled";
                _deployStatus   = DeploymentStatus.Cancel;
                break;

            case DeploymentStatus.Error:
                SetErrorStatus(e.ErrorMessage);
                break;

            default:
                break;
            }

            btnStopProcessing.Enabled = false;
            btnClose.Enabled          = true;
            //btnClose.Select();
        }
Пример #3
0
        /// <summary>
        /// Scales an ImageList which is already populated with an ImageStream. Scaling occurs on the object iteself.
        /// </summary>
        /// <param name="imageList">Target ImageList</param>
        public static void ScaleStreamedImageListByDpi(ImageList imageList)
        {
            // Need to store the images before setting ImageSize as this completely wipes the Images collection
            Dictionary <string, Image> originalImages = new Dictionary <string, Image>();

            for (int i = 0; i < imageList.Images.Count; i++)
            {
                originalImages.Add(imageList.Images.Keys[i], imageList.Images[i]);
            }

            // According to MSDN, setting a new size resets the Images collection
            imageList.ImageSize = HighDPIUtils.ScaleByDpi(imageList.ImageSize);
            foreach (KeyValuePair <string, Image> entry in originalImages)
            {
                imageList.Images.Add(entry.Key, entry.Value);
            }
        }