BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Properties | List of all members
BrawlCrate.UI.RecentFileHandler Class Reference
Inheritance diagram for BrawlCrate.UI.RecentFileHandler:

Classes

class  FileMenuItem
 

Public Member Functions

 RecentFileHandler ()
 
 RecentFileHandler (IContainer container)
 
void AddFile (string fileName)
 
void Clear ()
 

Protected Member Functions

override void Dispose (bool disposing)
 

Properties

ToolStripMenuItem RecentFileToolStripItem [get, set]
 

Constructor & Destructor Documentation

◆ RecentFileHandler() [1/2]

BrawlCrate.UI.RecentFileHandler.RecentFileHandler ( )
inline
2545 {
2546 InitializeComponent();
2547
2548 Init();
2549 }

◆ RecentFileHandler() [2/2]

BrawlCrate.UI.RecentFileHandler.RecentFileHandler ( IContainer  container)
inline
2552 {
2553 container.Add(this);
2554
2555 InitializeComponent();
2556
2557 Init();
2558 }

Member Function Documentation

◆ AddFile()

void BrawlCrate.UI.RecentFileHandler.AddFile ( string  fileName)
inline
2566 {
2567 try
2568 {
2569 if (recentFileToolStripItem == null)
2570 {
2571 throw new OperationCanceledException("recentFileToolStripItem can not be null!");
2572 }
2573
2574 // check if the file is already in the collection
2575 int alreadyIn = GetIndexOfRecentFile(fileName);
2576 if (alreadyIn != -1) // remove it
2577 {
2578 Settings.Default.RecentFiles.RemoveAt(alreadyIn);
2579 if (recentFileToolStripItem.DropDownItems.Count > alreadyIn)
2580 {
2581 recentFileToolStripItem.DropDownItems.RemoveAt(alreadyIn);
2582 }
2583 }
2584 else if (alreadyIn == 0) // it´s the latest file so return
2585 {
2586 return;
2587 }
2588
2589 // insert the file on top of the list
2590 Settings.Default.RecentFiles.Insert(0, fileName);
2591 recentFileToolStripItem.DropDownItems.Insert(0, new FileMenuItem(fileName));
2592
2593 // remove any beyond the max size, if max size is reached
2594 while (Settings.Default.RecentFiles.Count > Settings.Default.RecentFilesMax)
2595 {
2596 Settings.Default.RecentFiles.RemoveAt(Settings.Default.RecentFilesMax);
2597 }
2598
2599 while (recentFileToolStripItem.DropDownItems.Count > Settings.Default.RecentFilesMax)
2600 {
2601 recentFileToolStripItem.DropDownItems.RemoveAt(Settings.Default.RecentFilesMax);
2602 }
2603
2604 // enable the menu item if it´s disabled
2605 if (!recentFileToolStripItem.Enabled)
2606 {
2607 recentFileToolStripItem.Enabled = true;
2608 }
2609
2610 // save the changes
2611 Settings.Default.Save();
2612 }
2613 catch
2614 {
2615 // ignored
2616 }
2617 }

◆ Clear()

void BrawlCrate.UI.RecentFileHandler.Clear ( )
inline
2683 {
2684 Settings.Default.RecentFiles.Clear();
2685 ReCreateItems();
2686 }

◆ Dispose()

override void BrawlCrate.UI.RecentFileHandler.Dispose ( bool  disposing)
inlineprotected
2503 {
2504 if (disposing)
2505 {
2506 components?.Dispose();
2507 }
2508
2509 base.Dispose(disposing);
2510 }

Property Documentation

◆ RecentFileToolStripItem

ToolStripMenuItem BrawlCrate.UI.RecentFileHandler.RecentFileToolStripItem
getset
2636 {
2637 get => recentFileToolStripItem;
2638 set
2639 {
2640 if (recentFileToolStripItem == value)
2641 {
2642 return;
2643 }
2644
2645 recentFileToolStripItem = value;
2646
2647 ReCreateItems();
2648 }
2649 }

The documentation for this class was generated from the following file: