C# Class JWC.MruStripMenu

Represents a most recently used (MRU) menu.
This class shows the MRU list in a popup menu. To display the MRU list "inline" use .

The class will optionally load the last set of files from the registry on construction and store them when instructed by the main program.

Internally, this class uses zero-based numbering for the items. The displayed numbers, however, will start with one.

Datei anzeigen Open project: procfxgen/MGShaderEditor Class Usage Examples

Protected Properties

Property Type Description
maxEntries int
maxShortenPathLength int
mruStripMutex System.Threading.Mutex
numEntries int
recentFileMenuItem System.Windows.Forms.ToolStripMenuItem
registryKeyName string

Public Methods

Method Description
AddFile ( string filename ) : void
AddFile ( string filename, string entryname ) : void
AddFiles ( string filenames ) : void
FindFilenameMenuIndex ( string filename ) : int

Returns the menu index of the passed filename.

FindFilenameNumber ( string filename ) : int

Returns the entry number matching the passed filename.

FixupEntryname ( int number, string entryname ) : string
GetFileAt ( int number ) : string
GetFiles ( ) : string[]
GetFilesFullEntrystring ( ) : string[]
GetMenuIndex ( int number ) : int

Returns the menu index for a specified MRU item number.

LoadFromRegistry ( ) : void
LoadFromRegistry ( string keyName ) : void
MruStripMenu ( ToolStripMenuItem recentFileMenuItem, ClickedHandler clickedHandler ) : System

Initializes a new instance of the MruMenu class.

MruStripMenu ( ToolStripMenuItem recentFileMenuItem, ClickedHandler clickedHandler, int maxEntries ) : System

Initializes a new instance of the MruMenu class.

MruStripMenu ( ToolStripMenuItem recentFileMenuItem, ClickedHandler clickedHandler, string registryKeyName ) : System

Initializes a new instance of the MruMenu class.

MruStripMenu ( ToolStripMenuItem recentFileMenuItem, ClickedHandler clickedHandler, string registryKeyName, bool loadFromRegistry ) : System

Initializes a new instance of the MruMenu class.

MruStripMenu ( ToolStripMenuItem recentFileMenuItem, ClickedHandler clickedHandler, string registryKeyName, bool loadFromRegistry, int maxEntries ) : System

Initializes a new instance of the MruMenu class.

MruStripMenu ( ToolStripMenuItem recentFileMenuItem, ClickedHandler clickedHandler, string registryKeyName, int maxEntries ) : System

Initializes a new instance of the MruMenu class.

RemoveAll ( ) : void
RemoveFile ( int number ) : void
RemoveFile ( string filename ) : void
RenameFile ( string oldFilename, string newFilename ) : void
RenameFile ( string oldFilename, string newFilename, string newEntryname ) : void
SaveToRegistry ( ) : void
SaveToRegistry ( string keyName ) : void
SetFiles ( string filenames ) : void
SetFirstFile ( int number ) : void
ShortenPathname ( string pathname, int maxLength ) : string

Shortens a pathname for display purposes.

Shortens a pathname by either removing consecutive components of a path and/or by removing characters from the end of the filename and replacing then with three elipses (...)

In all cases, the root of the passed path will be preserved in it's entirety.

If a UNC path is used or the pathname and maxLength are particularly short, the resulting path may be longer than maxLength.

This method expects fully resolved pathnames to be passed to it. (Use Path.GetFullPath() to obtain this.)

Protected Methods

Method Description
Disable ( ) : void
Enable ( ) : void
FixupPrefixes ( int startNumber ) : void
Init ( ToolStripMenuItem recentFileMenuItem, ClickedHandler clickedHandler, string registryKeyName, bool loadFromRegistry, int maxEntries ) : void
MruStripMenu ( ) : System
OnClick ( object sender, System e ) : void
SetFirstFile ( MruMenuItem menuItem ) : void

Method Details

AddFile() public method

public AddFile ( string filename ) : void
filename string
return void

AddFile() public method

public AddFile ( string filename, string entryname ) : void
filename string
entryname string
return void

AddFiles() public method

public AddFiles ( string filenames ) : void
filenames string
return void

Disable() protected method

protected Disable ( ) : void
return void

Enable() protected method

protected Enable ( ) : void
return void

FindFilenameMenuIndex() public method

Returns the menu index of the passed filename.
public FindFilenameMenuIndex ( string filename ) : int
filename string The filename to search for.
return int

FindFilenameNumber() public method

Returns the entry number matching the passed filename.
public FindFilenameNumber ( string filename ) : int
filename string The filename to search for.
return int

FixupEntryname() public static method

public static FixupEntryname ( int number, string entryname ) : string
number int
entryname string
return string

FixupPrefixes() protected method

protected FixupPrefixes ( int startNumber ) : void
startNumber int
return void

GetFileAt() public method

public GetFileAt ( int number ) : string
number int
return string

GetFiles() public method

public GetFiles ( ) : string[]
return string[]

GetFilesFullEntrystring() public method

public GetFilesFullEntrystring ( ) : string[]
return string[]

GetMenuIndex() public method

Returns the menu index for a specified MRU item number.
public GetMenuIndex ( int number ) : int
number int The MRU item number.
return int

Init() protected method

protected Init ( ToolStripMenuItem recentFileMenuItem, ClickedHandler clickedHandler, string registryKeyName, bool loadFromRegistry, int maxEntries ) : void
recentFileMenuItem System.Windows.Forms.ToolStripMenuItem
clickedHandler ClickedHandler
registryKeyName string
loadFromRegistry bool
maxEntries int
return void

LoadFromRegistry() public method

public LoadFromRegistry ( ) : void
return void

LoadFromRegistry() public method

public LoadFromRegistry ( string keyName ) : void
keyName string
return void

MruStripMenu() protected method

protected MruStripMenu ( ) : System
return System

MruStripMenu() public method

Initializes a new instance of the MruMenu class.
public MruStripMenu ( ToolStripMenuItem recentFileMenuItem, ClickedHandler clickedHandler ) : System
recentFileMenuItem System.Windows.Forms.ToolStripMenuItem
clickedHandler ClickedHandler
return System

MruStripMenu() public method

Initializes a new instance of the MruMenu class.
public MruStripMenu ( ToolStripMenuItem recentFileMenuItem, ClickedHandler clickedHandler, int maxEntries ) : System
recentFileMenuItem System.Windows.Forms.ToolStripMenuItem
clickedHandler ClickedHandler
maxEntries int
return System

MruStripMenu() public method

Initializes a new instance of the MruMenu class.
public MruStripMenu ( ToolStripMenuItem recentFileMenuItem, ClickedHandler clickedHandler, string registryKeyName ) : System
recentFileMenuItem System.Windows.Forms.ToolStripMenuItem
clickedHandler ClickedHandler
registryKeyName string
return System

MruStripMenu() public method

Initializes a new instance of the MruMenu class.
public MruStripMenu ( ToolStripMenuItem recentFileMenuItem, ClickedHandler clickedHandler, string registryKeyName, bool loadFromRegistry ) : System
recentFileMenuItem System.Windows.Forms.ToolStripMenuItem
clickedHandler ClickedHandler
registryKeyName string
loadFromRegistry bool
return System

MruStripMenu() public method

Initializes a new instance of the MruMenu class.
public MruStripMenu ( ToolStripMenuItem recentFileMenuItem, ClickedHandler clickedHandler, string registryKeyName, bool loadFromRegistry, int maxEntries ) : System
recentFileMenuItem System.Windows.Forms.ToolStripMenuItem
clickedHandler ClickedHandler
registryKeyName string
loadFromRegistry bool
maxEntries int
return System

MruStripMenu() public method

Initializes a new instance of the MruMenu class.
public MruStripMenu ( ToolStripMenuItem recentFileMenuItem, ClickedHandler clickedHandler, string registryKeyName, int maxEntries ) : System
recentFileMenuItem System.Windows.Forms.ToolStripMenuItem
clickedHandler ClickedHandler
registryKeyName string
maxEntries int
return System

OnClick() protected method

protected OnClick ( object sender, System e ) : void
sender object
e System
return void

RemoveAll() public method

public RemoveAll ( ) : void
return void

RemoveFile() public method

public RemoveFile ( int number ) : void
number int
return void

RemoveFile() public method

public RemoveFile ( string filename ) : void
filename string
return void

RenameFile() public method

public RenameFile ( string oldFilename, string newFilename ) : void
oldFilename string
newFilename string
return void

RenameFile() public method

public RenameFile ( string oldFilename, string newFilename, string newEntryname ) : void
oldFilename string
newFilename string
newEntryname string
return void

SaveToRegistry() public method

public SaveToRegistry ( ) : void
return void

SaveToRegistry() public method

public SaveToRegistry ( string keyName ) : void
keyName string
return void

SetFiles() public method

public SetFiles ( string filenames ) : void
filenames string
return void

SetFirstFile() protected method

protected SetFirstFile ( MruMenuItem menuItem ) : void
menuItem MruMenuItem
return void

SetFirstFile() public method

public SetFirstFile ( int number ) : void
number int
return void

ShortenPathname() static public method

Shortens a pathname for display purposes.
Shortens a pathname by either removing consecutive components of a path and/or by removing characters from the end of the filename and replacing then with three elipses (...)

In all cases, the root of the passed path will be preserved in it's entirety.

If a UNC path is used or the pathname and maxLength are particularly short, the resulting path may be longer than maxLength.

This method expects fully resolved pathnames to be passed to it. (Use Path.GetFullPath() to obtain this.)

static public ShortenPathname ( string pathname, int maxLength ) : string
pathname string
maxLength int
return string

Property Details

maxEntries protected_oe property

protected int maxEntries
return int

maxShortenPathLength protected_oe property

protected int maxShortenPathLength
return int

mruStripMutex protected_oe property

protected Mutex,System.Threading mruStripMutex
return System.Threading.Mutex

numEntries protected_oe property

protected int numEntries
return int

recentFileMenuItem protected_oe property

protected ToolStripMenuItem,System.Windows.Forms recentFileMenuItem
return System.Windows.Forms.ToolStripMenuItem

registryKeyName protected_oe property

protected string registryKeyName
return string