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
H

Herbertmunch

@Herbertmunch
About
Posts
8
Topics
6
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • GDI+ Invalidate() artifacts
    H Herbertmunch

    thanks " What you'll want to do is just to invalidate an area slightly larger than your rectangle.." I came to the same conclusion, but its just a bit nasty for my liking! I cant remember ever encountering this problem before, which is strange. it makes no sense at all why this occurs. Surely nothing should be displayed in an area that hasnt been invalidated. Why is this 1 pixel wide artifact occuring? Is this a bug with GDI+?

    --------------------------- Chris.

    C# graphics winforms help question

  • GDI+ Invalidate() artifacts
    H Herbertmunch

    Thanks very much for replying. "Also, the call to e.Graphics.FillRectangle(Brushes.White, r) in the OnPaint method will need to be adjusted to fill the clip region (can't remember the property name off hand, but should be easy enough to find)." Yeah i realised i had done that! r instead of e.ClipRectangle property, but it doesnt actually make any difference any way. "You need to keep track of the area that was under the original rectangle and invalidate the union of the old rectangle and the new one.." Thats what the first invalidate does! When you call invalidate, it wont invalidate immediately. If you were to call refresh() then it would go straight to the paint code, but this way it just carries on executing the next instruction. I then set the new location and invalidate this as well. this way both the old and new rects are included in the clipping rect, which is filled in the Paint routine (with the corrected code).

    --------------------------- Chris.

    C# graphics winforms help question

  • GDI+ Invalidate() artifacts
    H Herbertmunch

    Hi all, Could someone please explain to me why the following code doesnt work? Rectangle r = new Rectangle(0, 0, 100, 100); Pen p = Pens.Black; private void Form1_Load(object sender, EventArgs e) { this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint,true); //a.AddLine(new Point(10, 10), new Point(100, 10)); } protected override void OnMouseMove(MouseEventArgs e) { //Invalidate old location Invalidate(r); r.Location = e.Location; //Invalidate new location Invalidate(r); } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); //Clear clipping rect e.Graphics.FillRectangle(Brushes.White, r); //Draw invalidated region e.Graphics.DrawRectangle(p, r); //Method will draw the right and bottom side out of clipping rect } When i run it, the rectangles bottom and right hand side are drawn outside the clipping rectangle. I thought that if something was drawn outside the clipping rectangle, it would be discarded. However this doesnt seem to be the case here. when i move the mouse, I move the rectangles location also. Before i change the location of the rect, i invalidate it, and then invalidate again once change has been made. In the drawing routine i wipe the clipping rect with background colour, but for some reason artifacts ouside the clipping area remain. The end result of the mouse move is an artifact trail, similar to a mouse trail and exactly like what happens, when you win at ms solitare. It would appear that im not invalidating the right area, but i dont understand why! I have done a fair bit of graphics programming before, and have never experienced any problem like this. If im invalidating the old bounds before changing them for the new bounds, it should be removing the old screen. If i change the drawing code to make sure that the rectangle is drawn inside the clipping rect, the problem doesnt happen. But I just cant understand why the problem occurs anyway. Surely invalidate should cause the overlapping line to be removed? Here is the code that has been modified not to overdraw the clipping region: protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e);

    C# graphics winforms help question

  • Control Properties
    H Herbertmunch

    Does anyone know if its possible to use a custom class as a property for a custom control? i.e When you set the forms location in the property editor, it has a little cross next to it, which is essentially the a Point Class. Point.X Point.Y I have tried to do this but it just grays out my property if i use a non standard class. I combatted this by inheriting from ComponentModel.Component, which enabled me to type in the fields but the propertys set code doesnt get called for some reason. Thanks for your help!

    Visual Basic help question

  • Cast not valid
    H Herbertmunch

    When trying to use Ctype to convert an object to a custom class, i have encountered a problem. Even though when i call the getType method , im told that both the object that im trying to convert and the destination variable are the same type, however when i call the ctype function, i get a Specified Cast not valid message. Any Ideas? Thanks for your help!

    Visual Basic help question

  • SOAP FORMATTER
    H Herbertmunch

    hI ALL, My problem is this: Im writting a control that reads a list of graphics from an embedded text file. This file is generated by soap formatter. The Soap F. serialises a class that holds info. My program then uses soap to deserialise the file, back into the orig class and reads the info and loads the embedded pictures into variables This all works fine at runtime, but when you add the control to a form in design time it returns an error : Cast not valid. I can Deserialise it back into a object type though. i.e Dim SoapF as new soapformatter Dim MemoryStream as memoryStream Dim obj as Object Dim tstClass as TestClass 'This works at designtime/runtime : obj = soapf.deserialise(MemoryStream,Object) 'This works at runtime (but i need it to work all the time!) : tstClass = soapf.deserialise(MemoryStream,TestClass) Any Ideas? __________________ Thanks for your help!

    Visual Basic help wcf graphics design hardware

  • Problem With Embedded Resources Inside A user Control
    H Herbertmunch

    HI all! When designing a control, i embedded some pictures into the project. But when i try to access them i get no joy! the thing is the code i use works fine on just a standard project, but when i try it in the control, no stream is returned! The namespace im using is correct, and ive even tried putting the resourses in both the usercontrol project and the test project! Heres the code i use for standard projects: Public Function GetEmbeddedImage(ByVal AppForm As Object, ByVal strImageName As String) As Bitmap Dim Exec_Assem As [Assembly] = AppForm.GetType.Assembly.GetEntryAssembly Dim myNameSpace As String = Exec_Assem.GetName.Name.ToString Dim PicStream As Stream Dim BMP As Bitmap PicStream = Exec_Assem.GetManifestResourceStream(myNameSpace + "." + strImageName) BMP = New Bitmap(PicStream) GetEmbeddedImage = BMP.Clone() BMP.Dispose() PicStream.Close() End Function :((:((:confused: the only differnce in code i use when calling from the usercontrol is : GetEntryAssembly Instead of which i use GetExecuting Assembly as this returns the user control assembly instead of the test project assembly. Thanks for your help!

    Visual Basic help graphics hardware

  • Transparency Issues
    H Herbertmunch

    Hi All! Sorry for the cryptic explanation that follows! My problem is : i have created a gradient on a form, and then I have put a custom control that i created that just basically implements a picturebox control. The control is a checkbox control that uses graphics that i made in photoshop, saved as a png file, which incorperates transparency. The problem is that my control doesnt maintain transparency over this freshly created GDI+ gradient, however if i was to put the control over a picture say in a picture box that i had loaded from file then it works! When i do it over the GDI+ stuff, i see a (grey windows default coloured) box around my Checkbox! :laugh::eek: If that lot makes any sense to any one i would appr. any help anyone can offer! Thanks for your help!

    Visual Basic graphics help winforms adobe
  • Login

  • Don't have an account? Register

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