Click here to Skip to main content
15,899,475 members
Home / Discussions / C#
   

C#

 
GeneralRe: Copying a class Pin
Aryadip4-May-04 22:25
Aryadip4-May-04 22:25 
GeneralClickety Pin
Colin Angus Mackay4-May-04 22:57
Colin Angus Mackay4-May-04 22:57 
GeneralRe: Copying a class Pin
bouli5-May-04 5:37
bouli5-May-04 5:37 
GeneralComboBox borderstyle Pin
Gian4-May-04 22:08
Gian4-May-04 22:08 
GeneralRe: ComboBox borderstyle Pin
Jon G5-May-04 1:01
Jon G5-May-04 1:01 
GeneralRe: ComboBox borderstyle Pin
Gian5-May-04 2:54
Gian5-May-04 2:54 
GeneralRe: ComboBox borderstyle Pin
Heath Stewart5-May-04 4:07
protectorHeath Stewart5-May-04 4:07 
General"line between 2 points" control Pin
buto4-May-04 21:55
buto4-May-04 21:55 
Hello all

I have been trying for some time to write a good line control using C#. By this I mean a line control that can be used in graphical diagrams, graphic design programs and so on, to draw a line between two arbitrary points.

I believe this topic hasn´t been covered before, I´m trying to write an article on this but I have found a few problems which I can´t solve (I´m still new to .net and c#). Here it goes, I hope you guys can help me!

First, I inherit a control from System.Windows.Forms.Control. I override the OnPaint to draw a line between two corners of the control. This doesn´t work too well because you can´t see any of the controls that are behind the line´s control region. In other words, you get a nice white rectangular area encompassing the line and covering all that surrounds it.

Then I tried playing with various background colour settings. Interestingly, the "transparent" colours do not allow you to see what´s behind the control´s region - sure enough, it lets you define an alpha value for the background colour but you can´t see through it. Anyway, I also tried overriding OnPaintBackground, and playing with the control styles (UserPaint, SupportsTransparentBackColor, AllPaintingInWmPaint).

Lastly, I tried changing the control region of the line for a polygon that would more or less exactly encompass the actual line. So you only get a "white" area on a small polygon around the line instead of on a big rectangle. Guess what, although this looks quite nice there are occasions where windows doesn´t like it at all: when two of these lines are overlapping and are both moving at the same time, the system slows down a lot, and the rest of the controls aren´t correctly re-drawn.

As you can see, I´ve done my homework before asking. Can anyone give me a hand please? I just want a control to draw a line between two points :´(

Thanks in advance
-a.
GeneralRe: "line between 2 points" control Pin
Aryadip4-May-04 22:36
Aryadip4-May-04 22:36 
GeneralRe: "line between 2 points" control Pin
Anonymous_line5-May-04 0:08
sussAnonymous_line5-May-04 0:08 
GeneralRe: "line between 2 points" control Pin
Heath Stewart5-May-04 4:05
protectorHeath Stewart5-May-04 4:05 
Generalwant Ws2.lib & Ws2.dll Pin
Member 10154954-May-04 21:11
Member 10154954-May-04 21:11 
GeneralRe: want Ws2.lib & Ws2.dll Pin
Mike Dimmick5-May-04 1:46
Mike Dimmick5-May-04 1:46 
Generalrecognise assembly as managed code Pin
Aryadip4-May-04 20:27
Aryadip4-May-04 20:27 
GeneralRe: recognise assembly as managed code Pin
CWIZO4-May-04 20:36
CWIZO4-May-04 20:36 
GeneralRe: recognise assembly as managed code Pin
Aryadip4-May-04 22:17
Aryadip4-May-04 22:17 
GeneralRe: recognise assembly as managed code Pin
Mike Dimmick5-May-04 1:48
Mike Dimmick5-May-04 1:48 
GeneralRe: recognise assembly as managed code Pin
Heath Stewart5-May-04 4:03
protectorHeath Stewart5-May-04 4:03 
GeneralListView Column Header Not displayed correctly Pin
Alistair Leslie-Hughes4-May-04 20:24
sussAlistair Leslie-Hughes4-May-04 20:24 
GeneralRe: ListView Column Header Not displayed correctly Pin
Heath Stewart5-May-04 3:35
protectorHeath Stewart5-May-04 3:35 
GeneralAssign special key to operation Pin
Adam Amram4-May-04 18:24
Adam Amram4-May-04 18:24 
GeneralRe: Assign special key to operation Pin
Heath Stewart5-May-04 3:33
protectorHeath Stewart5-May-04 3:33 
GeneralSystem.Reflection.Emit vs System.CodeDom.Compiler.CodeDomProvider and CSharpCodeProvider Pin
benl4-May-04 18:14
benl4-May-04 18:14 
GeneralRe: System.Reflection.Emit vs System.CodeDom.Compiler.CodeDomProvider and CSharpCodeProvider Pin
Heath Stewart5-May-04 3:31
protectorHeath Stewart5-May-04 3:31 
GeneralMobile App Design Pin
MrJJKoolJ4-May-04 16:45
MrJJKoolJ4-May-04 16:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.