Click here to Skip to main content
15,887,405 members
Home / Discussions / C#
   

C#

 
GeneralRe: Ellipse Pin
WebMaster17-Oct-10 7:57
WebMaster17-Oct-10 7:57 
GeneralRe: Ellipse Pin
WebMaster17-Oct-10 8:05
WebMaster17-Oct-10 8:05 
GeneralRe: Ellipse Pin
Lamrin17-Oct-10 15:46
Lamrin17-Oct-10 15:46 
GeneralRe: Ellipse Pin
WebMaster18-Oct-10 5:16
WebMaster18-Oct-10 5:16 
GeneralRe: Ellipse Pin
WebMaster20-Oct-10 8:21
WebMaster20-Oct-10 8:21 
GeneralRe: Ellipse Pin
Lamrin23-Oct-10 6:24
Lamrin23-Oct-10 6:24 
GeneralRe: Ellipse Pin
WebMaster24-Oct-10 8:10
WebMaster24-Oct-10 8:10 
GeneralRe: Ellipse Pin
Lamrin25-Oct-10 5:15
Lamrin25-Oct-10 5:15 
Hi Wayne Macdaid,

The reason why your drop down pallete wipes whatever was drawn previously when it drops down is due to the peculiarity of GUI system of Windows.

As your probably know, though you create your form with all the controls in C# (or any in any language with GUI features), it the Windows operating system which actually draws everything in the background.

You know that Windows can open multiple windows on our screen. When you click any window, it becomes activated and comes to the forefront and whatever was in the front goes back. Actually there are no layers on a computer screen. But Windows only visually simulates. How ? Windows redraws the currently activated windows over whatever is on the screen thus overlapping whatever was on the screen. Now you can see this window above all other windows. When you move any window (let us call it Window1) over another (let us call it Window2), the Window1 is redrawn over the Window2 and some part of the Window2 get erased. But if you click any visible part of Window2 again, it becomes active and Windows OS redraws Window2 completely so that all parts of it is fully visible. Thus the Windows Operating System frequently redraws either completely or some part of each window as appropriate.

Now, in your case you draw something on your form (I presume). Then when pull down your drop down palette, Windows OS actually redraws the pallete in a bigger size (as specified by you) and thus some part of your form is erased. Now when you minimize your palette after choosing your color, the area previosly erased has to be redrawn by Windows OS. But Windows OS has nothing to remember what was in that space earlier. So it just paints the background color. In effect, what was there before you pulled the palette down is erased!

How can you prevent it ? I don't know what type of software you are writing. But suppose it is something like MS Paint, then whenever your draw any shape, save its details into a suitable data structure. Then, in the paint event of the form, read that details of each shape in the data structure and redraw it again. This way your drawings won't seem to disappear. For example, create a class in C# as follows :

  public class Shape<br />
   {<br />
      String ShapeName ; // 'Line','Circle','Rectangle' etc.<br />
   }<br />
<br />
   public class Line : Shape<br />
   {<br />
      Point StartPoint;<br />
      Point EndPoint;<br />
<br />
      public Line() : base()<br />
      {<br />
         ShapeName = "Line";<br />
         .<br />
         .<br />
         .<br />
      }<br />
   }<br />
<br />
   public class Circle : Shape<br />
   {<br />
      Point Centre;<br />
      int Radius;<br />
<br />
      public Circle()<br />
      {<br />
         ShapeName = "Circle";<br />
         Radius = 0;<br />
         Centre = new Point(0,0); // some default location<br />
      }<br />
   }<br />
<br />
   ArrayList ShapeList = new ArrayList();



Now add all shapes to the ShapeList whenever you create a shape. In 'Paint' event of the form (or any other control you are using), use the details of each shape in the ShapeList to redraw the shapes. That's all.

Well, I don't remember any section in MSDN suitable for you. But do a 'Google' search.

Happy coding! Big Grin | :-D
GeneralRe: Ellipse Pin
WebMaster25-Oct-10 9:27
WebMaster25-Oct-10 9:27 
QuestionOOB design - class fields Pin
Dell.Simmons15-Oct-10 13:41
Dell.Simmons15-Oct-10 13:41 
AnswerRe: OOB design - class fields Pin
ricmil4215-Oct-10 14:29
ricmil4215-Oct-10 14:29 
GeneralRe: OOB design - class fields Pin
Dell.Simmons15-Oct-10 14:34
Dell.Simmons15-Oct-10 14:34 
AnswerRe: OOB design - class fields Pin
Abhinav S15-Oct-10 22:25
Abhinav S15-Oct-10 22:25 
AnswerRe: OOB design - class fields Pin
Keith Barrow16-Oct-10 5:40
professionalKeith Barrow16-Oct-10 5:40 
AnswerRe: OOB design - class fields Pin
Nish Nishant16-Oct-10 6:27
sitebuilderNish Nishant16-Oct-10 6:27 
AnswerRe: OOB design - class fields Pin
Paul Michalik17-Oct-10 0:45
Paul Michalik17-Oct-10 0:45 
QuestionRead the 'raw' FileVersion and ProductVersion values from a file's version resource. Pin
Blake Miller15-Oct-10 13:02
Blake Miller15-Oct-10 13:02 
QuestionApplication Settings "Save Location" Pin
I Believe In GOD15-Oct-10 10:30
I Believe In GOD15-Oct-10 10:30 
AnswerRe: Application Settings "Save Location" Pin
Ian Shlasko15-Oct-10 10:34
Ian Shlasko15-Oct-10 10:34 
GeneralRe: Application Settings "Save Location" Pin
I Believe In GOD15-Oct-10 10:46
I Believe In GOD15-Oct-10 10:46 
GeneralRe: Application Settings "Save Location" Pin
AspDotNetDev15-Oct-10 12:29
protectorAspDotNetDev15-Oct-10 12:29 
QuestionHow to create a user control with parameters as tags Pin
kuul1315-Oct-10 10:17
kuul1315-Oct-10 10:17 
AnswerRe: How to create a user control with parameters as tags Pin
Not Active15-Oct-10 11:47
mentorNot Active15-Oct-10 11:47 
QuestionAsp.net Website Pin
MKC00215-Oct-10 2:59
MKC00215-Oct-10 2:59 
AnswerRe: Asp.net Website Pin
OriginalGriff15-Oct-10 3:05
mveOriginalGriff15-Oct-10 3:05 

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.