SlideShare una empresa de Scribd logo
1 de 3
Public Class UndoRedoClass(Of T)

  Private UndoStack As Stack(Of T)

  Private RedoStack As Stack(Of T)



  Public CurrentItem As T

  Public Event UndoHappened As EventHandler(Of UndoRedoEventArgs)

  Public Event RedoHappened As EventHandler(Of UndoRedoEventArgs)



  Public Sub New()

    UndoStack = New Stack(Of T)

    RedoStack = New Stack(Of T)

  End Sub



  Public Sub Clear()

    UndoStack.Clear()

    RedoStack.Clear()

    CurrentItem = Nothing

  End Sub



  Public Sub AddItem(ByVal item As T)

    If CurrentItem IsNot Nothing Then UndoStack.Push(CurrentItem)

    CurrentItem = item

    RedoStack.Clear()

  End Sub
Public Sub Undo()

  RedoStack.Push(CurrentItem)

  CurrentItem = UndoStack.Pop()

  RaiseEvent UndoHappened(Me, New UndoRedoEventArgs(CurrentItem))

End Sub



Public Sub Redo()

  UndoStack.Push(CurrentItem)

  CurrentItem = RedoStack.Pop

  RaiseEvent RedoHappened(Me, New UndoRedoEventArgs(CurrentItem))

End Sub



Public Function CanUndo() As Boolean

  Return UndoStack.Count > 0

End Function



Public Function CanRedo() As Boolean

  Return RedoStack.Count > 0

End Function



Public Function UndoItems() As List(Of T)

  Return UndoStack.ToList

End Function



Public Function RedoItems() As List(Of T)
Return RedoStack.ToList

  End Function

End Class



Public Class UndoRedoEventArgs

  Inherits EventArgs



  Private _CurrentItem As Object

  Public ReadOnly Property CurrentItem() As Object

    Get

      Return _CurrentItem

    End Get

  End Property



  Public Sub New(ByVal currentItem As Object)

    _CurrentItem = currentItem

  End Sub

End Class

Más contenido relacionado

Destacado

Seyun hwang Resume plus (eng)
Seyun hwang Resume plus (eng)Seyun hwang Resume plus (eng)
Seyun hwang Resume plus (eng)Seyun Hwang
 
Physics powerpoint kromatografi
Physics powerpoint kromatografiPhysics powerpoint kromatografi
Physics powerpoint kromatografiVictoria Pardede
 
Resume plus (kor)
Resume plus (kor)Resume plus (kor)
Resume plus (kor)Seyun Hwang
 
Nasp 2014 Program - National Association of Settlement Purchasers
Nasp 2014 Program - National Association of Settlement PurchasersNasp 2014 Program - National Association of Settlement Purchasers
Nasp 2014 Program - National Association of Settlement PurchasersEinstein Structured Settlements
 
이산화탄소를 재활용한 수압차 발전방식 (제안서) : Korean
이산화탄소를 재활용한 수압차 발전방식 (제안서) : Korean이산화탄소를 재활용한 수압차 발전방식 (제안서) : Korean
이산화탄소를 재활용한 수압차 발전방식 (제안서) : KoreanSeyun Hwang
 

Destacado (11)

Na ruu karkes 19 juni2012
Na ruu karkes 19 juni2012Na ruu karkes 19 juni2012
Na ruu karkes 19 juni2012
 
Seyun hwang Resume plus (eng)
Seyun hwang Resume plus (eng)Seyun hwang Resume plus (eng)
Seyun hwang Resume plus (eng)
 
Physics powerpoint kromatografi
Physics powerpoint kromatografiPhysics powerpoint kromatografi
Physics powerpoint kromatografi
 
Resume plus (kor)
Resume plus (kor)Resume plus (kor)
Resume plus (kor)
 
Nasp 2014 Program - National Association of Settlement Purchasers
Nasp 2014 Program - National Association of Settlement PurchasersNasp 2014 Program - National Association of Settlement Purchasers
Nasp 2014 Program - National Association of Settlement Purchasers
 
이산화탄소를 재활용한 수압차 발전방식 (제안서) : Korean
이산화탄소를 재활용한 수압차 발전방식 (제안서) : Korean이산화탄소를 재활용한 수압차 발전방식 (제안서) : Korean
이산화탄소를 재활용한 수압차 발전방식 (제안서) : Korean
 
Renstra kemkes 2010 2014
Renstra kemkes 2010 2014Renstra kemkes 2010 2014
Renstra kemkes 2010 2014
 
Kerajaan singasari (1)
Kerajaan singasari (1)Kerajaan singasari (1)
Kerajaan singasari (1)
 
Sop ukp kkp
Sop ukp kkpSop ukp kkp
Sop ukp kkp
 
16 tenses
16 tenses16 tenses
16 tenses
 
Sop prl kkp
Sop prl kkpSop prl kkp
Sop prl kkp
 

Último

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 

Último (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

Document for redo undo in Visual Basic

  • 1. Public Class UndoRedoClass(Of T) Private UndoStack As Stack(Of T) Private RedoStack As Stack(Of T) Public CurrentItem As T Public Event UndoHappened As EventHandler(Of UndoRedoEventArgs) Public Event RedoHappened As EventHandler(Of UndoRedoEventArgs) Public Sub New() UndoStack = New Stack(Of T) RedoStack = New Stack(Of T) End Sub Public Sub Clear() UndoStack.Clear() RedoStack.Clear() CurrentItem = Nothing End Sub Public Sub AddItem(ByVal item As T) If CurrentItem IsNot Nothing Then UndoStack.Push(CurrentItem) CurrentItem = item RedoStack.Clear() End Sub
  • 2. Public Sub Undo() RedoStack.Push(CurrentItem) CurrentItem = UndoStack.Pop() RaiseEvent UndoHappened(Me, New UndoRedoEventArgs(CurrentItem)) End Sub Public Sub Redo() UndoStack.Push(CurrentItem) CurrentItem = RedoStack.Pop RaiseEvent RedoHappened(Me, New UndoRedoEventArgs(CurrentItem)) End Sub Public Function CanUndo() As Boolean Return UndoStack.Count > 0 End Function Public Function CanRedo() As Boolean Return RedoStack.Count > 0 End Function Public Function UndoItems() As List(Of T) Return UndoStack.ToList End Function Public Function RedoItems() As List(Of T)
  • 3. Return RedoStack.ToList End Function End Class Public Class UndoRedoEventArgs Inherits EventArgs Private _CurrentItem As Object Public ReadOnly Property CurrentItem() As Object Get Return _CurrentItem End Get End Property Public Sub New(ByVal currentItem As Object) _CurrentItem = currentItem End Sub End Class