FolderWidget/frmMain.cs
/// <summary>
/// Changing the icon to specific image file
/// saves it in the main xml file
/// </summary>
Changing the icon to specific image file
saves it in the main xml file
Changing the icon to specific image file saves it in the main xml file
private void ChangeIcon_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog dlg = new OpenFileDialog())
            {
                dlg.Title = "Open Image";
                dlg.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png, *.ico, *.bmp) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png; *.ico;*.bmp";
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    Image img = null;
                    if (Path.GetExtension(dlg.FileName) == ".ico")
                    {
                        Icon icon = Icon.ExtractAssociatedIcon(dlg.FileName);
                        img = icon.ToBitmap();
                    }
                    else
                    {
                        img = Image.FromFile(dlg.FileName);
                    }
                    int id = clsFileManager.SaveIcon(ref m_iconsData, img);
                    string path = ((sender as MenuItem).GetContextMenu()).SourceControl.Tag.ToString();
                    var res = (m_iconsData.AsEnumerable().Where(dr => dr.Field<string>("Path") == path).FirstOrDefault()) as DataRow;
                    res["Icon"] = id;
                    clsFileManager.ReplaceXMLFile(m_iconsData);
                    this.Invoke((Action)(() =>
                    {
                        InitFormFilesAndButtons();
                    }));
                }
            }
        }
private void ChangeIcon_Click ( object sender , EventArgs e ) { using ( OpenFileDialog dlg = new OpenFileDialog ( ) ) { dlg . Title = " " ; dlg . Filter = " " ; if ( dlg . ShowDialog ( ) == DialogResult . OK ) { Image img = null ; if ( Path . GetExtension ( dlg . FileName ) == " " ) { Icon icon = Icon . ExtractAssociatedIcon ( dlg . FileName ) ; img = icon . ToBitmap ( ) ; } else { img = Image . FromFile ( dlg . FileName ) ; } int id = clsFileManager . SaveIcon ( ref m_iconsData , img ) ; string path = ( ( sender as MenuItem ) . GetContextMenu ( ) ) . SourceControl . Tag . ToString ( ) ; var res = ( m_iconsData . AsEnumerable ( ) . Where ( dr => dr . Field < string > ( " " ) == path ) . FirstOrDefault ( ) ) as DataRow ; res [ " " ] = id ; clsFileManager . ReplaceXMLFile ( m_iconsData ) ; this . Invoke ( ( Action ) ( ( ) => { InitFormFilesAndButtons ( ) ; } ) ) ; } } }
Changing the icon to specific image file
saves it in the main xml file
Changing the icon to specific image file saves it in the main xml file
sender
object
e
EventArgs