[EditorAttribute(typeof(MyFileNameEditor), typeof(UITypeEditor))]
-
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)"; } } }
-
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)"; } } }
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 toInvalidate()
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?