none
Get state images from file extensions ? RRS feed

  • Question

  • I am wondering if it is possible to get state images from a files extension. I am using a list view, I am getting large and small images (only difference is the size i.e. 16X16 or 32X32) from file extension.

    I need state image lists, as I want to view folders and files in a list view and distinguish them by the its states (i.e. hidden or not hidden or cut). I want to use "LVIS_CUT" to set an item if the user has set it for "Cut" operation.

    I don't know if it works, If the stateimage list is empty and I set the list view item state to "LVIS_CUT" should it work ? Any example?

    Thanks in Advance.

    SA

    Wednesday, February 3, 2016 6:49 PM

Answers

  • Hi SA,

    >>I need state image lists, as I want to view folders and files in a list view and distinguish them by the its states (i.e. hidden or not hidden or cut).

    If you want some code to do above operation,

      // check whether a file is hidden
      bool isHidden = ((File.GetAttributes(@"D:\File") & FileAttributes.Hidden) == FileAttributes.Hidden);

    About the Cut operation, as you said, you want to use "LVIS_CUT",  please check listview item cut style in .NET? for more details.

    private void MakeCutList(ImageList sourceList, Color background)
    {
       Brush overlay = new SolidBrush(Color.FromArgb(128, BackColor));
       Rectangle rect = new Rectangle(new Point(0, 0), sourceList.ImageSize);
    
       foreach (Image img in sourceList.Images)
       {
          Bitmap cutBmp = new Bitmap(img.Width, img.Height);
    
          using (Graphics g = Graphics.FromImage(cutBmp))
          {
             g.DrawImage(img, 0, 0);
             g.FillRectangle(overlay, rect);
          }
    
          sourceList.Images.Add(cutBmp);    
       }
    }

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, February 4, 2016 2:46 AM