Esempio n. 1
0
        //--------------------------------------
        // IMAGE HANDLERS
        //--------------------------------------

        // Adding icon by button
        private void cmdAddGroupIcon_Click(object sender, EventArgs e)
        {
            resetSelection();

            lblErrorIcon.Visible = false;                      //resetting error msg

            OpenFileDialog openFileDialog = new OpenFileDialog // ask user to select img as group icon
            {
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
                Title            = "Select Group Icon",
                CheckFileExists  = true,
                CheckPathExists  = true,
                DefaultExt       = "img",
                Filter           = "Image files and exec (*.jpg, *.jpeg, *.jpe, *.jfif, *.png, *.exe, *.ico) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png; *.ico; *.exe",
                FilterIndex      = 2,
                RestoreDirectory = true,
                ReadOnlyChecked  = true,
                DereferenceLinks = false,
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                String imageExtension = Path.GetExtension(openFileDialog.FileName).ToLower();

                handleIcon(openFileDialog.FileName, imageExtension);
            }
        }
Esempio n. 2
0
        private void cmdAddGroupIcon_Click(object sender, EventArgs e)
        {
            lblErrorIcon.Visible = false;                      //resetting error msg

            OpenFileDialog openFileDialog = new OpenFileDialog // ask user to select img as group icon
            {
                //InitialDirectory = @"C:\",
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),

                Title            = "Select Group Icon",
                CheckFileExists  = true,
                CheckPathExists  = true,
                DefaultExt       = "img",
                Filter           = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png",
                FilterIndex      = 2,
                RestoreDirectory = true,
                ReadOnlyChecked  = true,
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                cmdAddGroupIcon.BackgroundImage = Image.FromFile(openFileDialog.FileName);
                lblAddGroupIcon.Text            = "Change group icon";
            }
        }
        private void BtnAddGroupIcon_MouseUp(object sender, MouseButtonEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog  // ask user to select img as group icon
            {
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
                Title            = "Select group icon",
                CheckFileExists  = true,
                CheckPathExists  = true,
                Filter           = "Image files and exe|*.png;*.jpg;*.jpeg;*.jpe;*.jfif;*.ico;*.exe;*.lnk",
                DereferenceLinks = false
            };

            if (openFileDialog.ShowDialog() == true)
            {
                LblErrorIcon.Visibility = Visibility.Hidden; //hide error msg

                string imageExtension = Path.GetExtension(openFileDialog.FileName).ToLower();

                // Checks if the file being dropped is an .ico/.exe/.lnk in which type icons need to be extracted / processed
                if (specialImageExt.Contains(imageExtension))
                {
                    ImgGroupIcon.Source = HandleSpecialImageExtensions(openFileDialog.FileName, imageExtension);
                }
                else
                {
                    ImgGroupIcon.Source = new BitmapImage(new Uri(openFileDialog.FileName));
                }
            }
        }
Esempio n. 4
0
        private void cmdAddGroupIcon_Click(object sender, EventArgs e)
        {
            lblErrorIcon.Visible = false;                      //resetting error msg

            OpenFileDialog openFileDialog = new OpenFileDialog // ask user to select img as group icon
            {
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
                Title            = "Select Group Icon",
                CheckFileExists  = true,
                CheckPathExists  = true,
                DefaultExt       = "img",
                Filter           = "Image files and exec (*.jpg, *.jpeg, *.jpe, *.jfif, *.png, *.exe, *.ico) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png; *.ico; *.exe",
                FilterIndex      = 2,
                RestoreDirectory = true,
                ReadOnlyChecked  = true,
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                String imageExtension = Path.GetExtension(openFileDialog.FileName).ToLower();

                if (specialImageExt.Contains(imageExtension))
                {
                    if (imageExtension == ".lnk")
                    {
                        cmdAddGroupIcon.BackgroundImage = handleLnkExt(openFileDialog.FileName);
                    }
                    else
                    {
                        cmdAddGroupIcon.BackgroundImage = Icon.ExtractAssociatedIcon(openFileDialog.FileName).ToBitmap();
                    }
                }
                else
                {
                    cmdAddGroupIcon.BackgroundImage = Image.FromFile(openFileDialog.FileName);
                }
                lblAddGroupIcon.Text = "Change group icon";
            }
        }