void ReleaseDesignerOutlets()
 {
     if (ButtonQuery != null)
     {
         ButtonQuery.Dispose();
         ButtonQuery = null;
     }
     if (ImageCollection != null)
     {
         ImageCollection.Dispose();
         ImageCollection = null;
     }
     if (LabelResults != null)
     {
         LabelResults.Dispose();
         LabelResults = null;
     }
     if (ProgressBar != null)
     {
         ProgressBar.Dispose();
         ProgressBar = null;
     }
     if (TextFieldSearch != null)
     {
         TextFieldSearch.Dispose();
         TextFieldSearch = null;
     }
 }
Exemple #2
0
        private void Scale(ref float absFactor, ImageCollection raw, ref ImageCollection scaled)
        {
            scaled?.Dispose();

            if (Math.Abs(absFactor - 1) < 0.01f)
            {
                scaled = raw;
                this.currentScaleFactor = 1;
                return;
            }

            var rawSize = raw.ImageSize;
            var newSize = new Size((int)(rawSize.Width * absFactor), (int)(rawSize.Height * absFactor));

            scaled           = new ImageCollection();
            scaled.ImageSize = newSize;
            foreach (Image img in raw.Images)
            {
                scaled.AddImage(ScaleImage(img, absFactor));
            }
        }
        /// <summary>
        /// Opens a form that allows to select image of image collection
        /// and returns image collection and selected index.
        /// </summary>
        /// <param name="filename">The filename of image file.</param>
        /// <param name="selectedIndex">Selected index.</param>
        /// <returns>Image collection.</returns>
        public static ImageCollection SelectImageFromFile(string filename, out int selectedIndex)
        {
            selectedIndex = -1;

            // create image collection
            ImageCollection images = new ImageCollection();

            DocumentPasswordForm.EnableAuthentication(images);
            try
            {
                try
                {
                    // add an image file to the image collection
                    images.Add(filename);
                }
                catch (Exception e)
                {
                    DemosTools.ShowErrorMessage(e);
                    return(null);
                }

                selectedIndex = 0;


                // if image file contains more than 1 image
                if (images.Count > 1)
                {
                    // create a dialog that allows to select image from multipage image file
                    using (SelectImageForm selectImageForm =
                               new SelectImageForm(images))
                    {
                        // show the dialog
                        DialogResult result = selectImageForm.ShowDialog();
                        // if image is selected
                        if (result == DialogResult.OK)
                        {
                            // get the selected index
                            selectedIndex = selectImageForm.SelectedImageIndex;
                        }
                        else
                        {
                            selectedIndex = -1;
                        }
                    }
                }
            }
            finally
            {
                DocumentPasswordForm.DisableAuthentication(images);

                // if image is not selected
                if (selectedIndex == -1)
                {
                    // clear and dispose images from the image collection
                    images.ClearAndDisposeItems();

                    // dispose image collection
                    images.Dispose();
                }
            }
            return(images);
        }
        void ReleaseDesignerOutlets()
        {
            if (Avatar != null)
            {
                Avatar.Dispose();
                Avatar = null;
            }

            if (BottomConstraint != null)
            {
                BottomConstraint.Dispose();
                BottomConstraint = null;
            }

            if (BottomRuler2 != null)
            {
                BottomRuler2.Dispose();
                BottomRuler2 = null;
            }

            if (IconBox != null)
            {
                IconBox.Dispose();
                IconBox = null;
            }

            if (ImageCollection != null)
            {
                ImageCollection.Dispose();
                ImageCollection = null;
            }

            if (Input != null)
            {
                Input.Dispose();
                Input = null;
            }

            if (InputBoxHieghtConstraint != null)
            {
                InputBoxHieghtConstraint.Dispose();
                InputBoxHieghtConstraint = null;
            }

            if (MentionUser != null)
            {
                MentionUser.Dispose();
                MentionUser = null;
            }

            if (PickImage != null)
            {
                PickImage.Dispose();
                PickImage = null;
            }

            if (TakeImage != null)
            {
                TakeImage.Dispose();
                TakeImage = null;
            }
        }