Click here to Skip to main content
16,005,121 members
Home / Discussions / C#
   

C#

 
QuestionHow to view a RPT file in my application Pin
i.rabek25-Jun-07 1:26
i.rabek25-Jun-07 1:26 
Questiongetting id of row Pin
tauras8125-Jun-07 1:23
tauras8125-Jun-07 1:23 
AnswerRe: getting id of row Pin
kubben25-Jun-07 2:07
kubben25-Jun-07 2:07 
QuestionCatch Dr.Watson Window Pin
realmontanakid25-Jun-07 1:13
realmontanakid25-Jun-07 1:13 
Questioncan u figure y dis xception is comin Pin
samreengr825-Jun-07 1:01
samreengr825-Jun-07 1:01 
AnswerRe: can u figure y dis xception is comin Pin
Luc Pattyn25-Jun-07 1:24
sitebuilderLuc Pattyn25-Jun-07 1:24 
GeneralRe: can u figure y dis xception is comin Pin
samreengr825-Jun-07 1:38
samreengr825-Jun-07 1:38 
AnswerRe: can u figure y dis xception is comin Pin
Pete O'Hanlon25-Jun-07 1:39
mvePete O'Hanlon25-Jun-07 1:39 
Y u fl u nd to tlk in txtspk? It's very annoying.

Your code looks slightly suspect to me. Let's break it down, section by section:
if (bmpUNDOLEVEL[ucount] != null)//array of bitmaps
  bmpUNDOLEVEL[ucount] = null;
bmpUNDOLEVEL[ucount] = new Bitmap(origBitmap);
ucount++;
if (ucount == 20)
ShiftUndoLevel();
Why are you doing it this way? Why do you add the record in and then reorder your undo stack? Surely you would be better off reordering the stack and then performing the bitmap assignment.

Second, I would recode your undo stack to use a List<Bitmap> instead of an array list. Then, your code would look something like this:
private List<Bitmap> bmpUndoLevel = new List<Bitmap>();
private void AddToUndo(Bitmap bmp)
{
  if (ucount == 19) 
    ShiftUndoLevel();
  else
     ucount ++;
  bmpUndoLevel.Add(bmp);
}

private void undoBtn_Click(object sender, EventArgs e)
{
  if (ucount == 0) throw new ArgumentOutOfRangeException("ucount");
  origBitmap = (Bitmap)bmpUndoLevel[--ucount];
  panel3.Invalidate();
  if (ucount == 0)
    undoBtn.Enabled = false;
}

private void ShiftUndoLevel()
{
  // This gets rid of the top item from the list.
  bmpUndoLevel.RemoveAt(0);
}
Note that this isn't the complete code, but it should give you a starter for what to look at. BTW - repeatedly creating new Bitmaps is not the best way to manage them. Old ones need to be disposed.

Please visit http://www.readytogiveup.com/ and do something special today.
Deja View - the feeling that you've seen this post before.

QuestionC# - Display forms Dynamically Pin
robbie.t25-Jun-07 0:42
robbie.t25-Jun-07 0:42 
AnswerRe: C# - Display forms Dynamically Pin
giddy_guitarist27-Jun-07 4:44
giddy_guitarist27-Jun-07 4:44 
QuestionC# - Display forms Dynamically Pin
robbie.t25-Jun-07 0:41
robbie.t25-Jun-07 0:41 
AnswerRe: C# - Display forms Dynamically Pin
Christian Graus25-Jun-07 0:56
protectorChristian Graus25-Jun-07 0:56 
GeneralRe: C# - Display forms Dynamically Pin
robbie.t25-Jun-07 1:02
robbie.t25-Jun-07 1:02 
GeneralRe: C# - Display forms Dynamically Pin
Urs Enzler25-Jun-07 1:36
Urs Enzler25-Jun-07 1:36 
GeneralRe: C# - Display forms Dynamically Pin
robbie.t25-Jun-07 2:10
robbie.t25-Jun-07 2:10 
GeneralRe: C# - Display forms Dynamically Pin
Urs Enzler25-Jun-07 2:14
Urs Enzler25-Jun-07 2:14 
GeneralRe: C# - Display forms Dynamically Pin
robbie.t25-Jun-07 2:26
robbie.t25-Jun-07 2:26 
GeneralRe: C# - Display forms Dynamically Pin
Urs Enzler25-Jun-07 2:38
Urs Enzler25-Jun-07 2:38 
GeneralRe: C# - Display forms Dynamically Pin
robbie.t25-Jun-07 2:54
robbie.t25-Jun-07 2:54 
GeneralRe: C# - Display forms Dynamically Pin
Urs Enzler25-Jun-07 2:59
Urs Enzler25-Jun-07 2:59 
GeneralRe: C# - Display forms Dynamically Pin
robbie.t25-Jun-07 3:04
robbie.t25-Jun-07 3:04 
QuestionHow to keep the Window in WorkArea Pin
MarkPhB25-Jun-07 0:39
MarkPhB25-Jun-07 0:39 
QuestionC# Parallel Port Programming Pin
mercenary0125-Jun-07 0:26
mercenary0125-Jun-07 0:26 
AnswerRe: C# Parallel Port Programming Pin
Hesham Yassin25-Jun-07 0:59
Hesham Yassin25-Jun-07 0:59 
GeneralRe: C# Parallel Port Programming Pin
mercenary0125-Jun-07 1:01
mercenary0125-Jun-07 1:01 

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.