Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. [EditorAttribute(typeof(MyFileNameEditor), typeof(UITypeEditor))]

[EditorAttribute(typeof(MyFileNameEditor), typeof(UITypeEditor))]

Scheduled Pinned Locked Moved C#
designquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Susuko
    wrote on last edited by
    #1

    i've created a contro with this property, i let the user can select an image for the control. During the design time, it works. But when i compile and try it on another pc i the image is not loaded. So what i've to do after i load the image? [EditorAttribute(typeof(MyFileNameEditor), typeof(UITypeEditor))] [Category("Image state"), Description("Mouse over image")] //[DefaultValue("")] public string MouseMovePath { get { return MouseMove_path; } set { try { MouseMove_path = value; FileStream fs = new FileStream(MouseMove_path, FileMode.Open, FileAccess.Read); move = Image.FromStream(fs); fs.Close(); this.Invalidate(); } catch { MouseMove_path = "(none)"; } } }

    O 1 Reply Last reply
    0
    • S Susuko

      i've created a contro with this property, i let the user can select an image for the control. During the design time, it works. But when i compile and try it on another pc i the image is not loaded. So what i've to do after i load the image? [EditorAttribute(typeof(MyFileNameEditor), typeof(UITypeEditor))] [Category("Image state"), Description("Mouse over image")] //[DefaultValue("")] public string MouseMovePath { get { return MouseMove_path; } set { try { MouseMove_path = value; FileStream fs = new FileStream(MouseMove_path, FileMode.Open, FileAccess.Read); move = Image.FromStream(fs); fs.Close(); this.Invalidate(); } catch { MouseMove_path = "(none)"; } } }

      O Offline
      O Offline
      Office Lineman
      wrote on last edited by
      #2

      I don't see how this would work properly. Your Image is being loaded from a FileStream that you're immediately closing with fs.Close(). An underlying stream has to be open for as long as the Image is in use. The next call to Invalidate() makes it try to refresh the image... but it can't, so I would expect an error thrown at that point. -- I've killed again, haven't I?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups