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.

Afficher le fichier Open project: procfxgen/MGShaderEditor Class Usage Examples

Protected Properties

Свойство Type Description
maxEntries int
maxShortenPathLength int
mruStripMutex System.Threading.Mutex
numEntries int
recentFileMenuItem System.Windows.Forms.ToolStripMenuItem
registryKeyName string

Méthodes publiques

Méthode 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.)

Méthodes protégées

Méthode 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 méthode

public AddFile ( string filename ) : void
filename string
Résultat void

AddFile() public méthode

public AddFile ( string filename, string entryname ) : void
filename string
entryname string
Résultat void

AddFiles() public méthode

public AddFiles ( string filenames ) : void
filenames string
Résultat void

Disable() protected méthode

protected Disable ( ) : void
Résultat void

Enable() protected méthode

protected Enable ( ) : void
Résultat void

FindFilenameMenuIndex() public méthode

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

FindFilenameNumber() public méthode

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

FixupEntryname() public static méthode

public static FixupEntryname ( int number, string entryname ) : string
number int
entryname string
Résultat string

FixupPrefixes() protected méthode

protected FixupPrefixes ( int startNumber ) : void
startNumber int
Résultat void

GetFileAt() public méthode

public GetFileAt ( int number ) : string
number int
Résultat string

GetFiles() public méthode

public GetFiles ( ) : string[]
Résultat string[]

GetFilesFullEntrystring() public méthode

public GetFilesFullEntrystring ( ) : string[]
Résultat string[]

GetMenuIndex() public méthode

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

Init() protected méthode

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
Résultat void

LoadFromRegistry() public méthode

public LoadFromRegistry ( ) : void
Résultat void

LoadFromRegistry() public méthode

public LoadFromRegistry ( string keyName ) : void
keyName string
Résultat void

MruStripMenu() protected méthode

protected MruStripMenu ( ) : System
Résultat System

MruStripMenu() public méthode

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

MruStripMenu() public méthode

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
Résultat System

MruStripMenu() public méthode

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
Résultat System

MruStripMenu() public méthode

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
Résultat System

MruStripMenu() public méthode

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
Résultat System

MruStripMenu() public méthode

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
Résultat System

OnClick() protected méthode

protected OnClick ( object sender, System e ) : void
sender object
e System
Résultat void

RemoveAll() public méthode

public RemoveAll ( ) : void
Résultat void

RemoveFile() public méthode

public RemoveFile ( int number ) : void
number int
Résultat void

RemoveFile() public méthode

public RemoveFile ( string filename ) : void
filename string
Résultat void

RenameFile() public méthode

public RenameFile ( string oldFilename, string newFilename ) : void
oldFilename string
newFilename string
Résultat void

RenameFile() public méthode

public RenameFile ( string oldFilename, string newFilename, string newEntryname ) : void
oldFilename string
newFilename string
newEntryname string
Résultat void

SaveToRegistry() public méthode

public SaveToRegistry ( ) : void
Résultat void

SaveToRegistry() public méthode

public SaveToRegistry ( string keyName ) : void
keyName string
Résultat void

SetFiles() public méthode

public SetFiles ( string filenames ) : void
filenames string
Résultat void

SetFirstFile() protected méthode

protected SetFirstFile ( MruMenuItem menuItem ) : void
menuItem MruMenuItem
Résultat void

SetFirstFile() public méthode

public SetFirstFile ( int number ) : void
number int
Résultat void

ShortenPathname() static public méthode

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
Résultat string

Property Details

maxEntries protected_oe property

protected int maxEntries
Résultat int

maxShortenPathLength protected_oe property

protected int maxShortenPathLength
Résultat int

mruStripMutex protected_oe property

protected Mutex,System.Threading mruStripMutex
Résultat System.Threading.Mutex

numEntries protected_oe property

protected int numEntries
Résultat int

recentFileMenuItem protected_oe property

protected ToolStripMenuItem,System.Windows.Forms recentFileMenuItem
Résultat System.Windows.Forms.ToolStripMenuItem

registryKeyName protected_oe property

protected string registryKeyName
Résultat string