OpenMRU.WinForm
1.3.0
dotnet add package OpenMRU.WinForm --version 1.3.0
NuGet\Install-Package OpenMRU.WinForm -Version 1.3.0
<PackageReference Include="OpenMRU.WinForm" Version="1.3.0" />
paket add OpenMRU.WinForm --version 1.3.0
#r "nuget: OpenMRU.WinForm, 1.3.0"
// Install OpenMRU.WinForm as a Cake Addin #addin nuget:?package=OpenMRU.WinForm&version=1.3.0 // Install OpenMRU.WinForm as a Cake Tool #tool nuget:?package=OpenMRU.WinForm&version=1.3.0
OpenMRU.WinForm
About
OpenMRU.WinForm is a part of OpenMRUSuite and contains WinForm GUI controls for "MRU (Most resently used) files" functionality. (Both menu-like control and control similar to one on VisualStudio start window)
Quick start
For to use controls from package, add them to your Toolbox palette by reference this package, then drag-and-drop MRUItemsControl to your form and initialize it with manager and localization.
For to use menu-like control, create ToolStripMenuItem item using visual editor, create MRUItemsMenu instance and initialize it with manager and localization. After that, attach MRUItemsMenu instance to certain ToolStripMenuItem item.
See code below for details (consider you have a form 'Form1', MRUItemsControl 'mruItemsControl1', Button 'ButtonOpen' and two ToolStripMenuItems 'recentFilesToolStripMenuItem' and 'recentcustomToolStripMenuItem' on it):
public partial class Form1 : Form
{
// link to manager.
private readonly MRUManager manager;
public Form1()
{
InitializeComponent();
// create IMRUItemStorage implementation using default xml-based storage from OpenMRU.Core
MRUItemFileStorage storage = new MRUItemFileStorage("demo_mru_storage.xml");
// create default manager from OpenMRU.Core
manager = new MRUManager();
// init manager with storage
manager.Initialize(storage);
// subscribe to 'item selected' event
manager.MRUItemSelected += Manager_MRUItemSelected;
// init GUI control with created manager and default (eng) localization
mruItemsControl1.Initialize(manager, new MRUGuiLocalization());
// init menu items
MRUItemsMenu itemsMenu = new MRUItemsMenu();
itemsMenu.Initialize(manager, new MRUGuiLocalization());
itemsMenu.AttachToMenu(recentFilesToolStripMenuItem);
// init menu items - custom appearance
MRUItemsMenu itemsMenu2 = new MRUItemsMenu();
itemsMenu2.Initialize(manager, new MRUGuiLocalization());
itemsMenu2.AttachToMenu(recentcustomToolStripMenuItem, "%FileName% - [%Path%] - [%AccessDate%]");
}
private void Manager_MRUItemSelected(string path)
{
MessageBox.Show("Select file from MRU: " + path);
}
// handle open file event
private void ButtonOpen_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == DialogResult.OK)
{
string path = ofd.FileName;
// add file that was selected by user to manager (begin track it and display on GUI)
manager.AddFile(path);
}
}
}
For customizing of presentation of menu items, use next patterns:
// string that represent appearance
// available placeholders:
// %FileName% - just file name (w/o path)
// %Path% - path to file (excluding file name)
// %FullFileName% - path to file + file name
// %AccessDate% - last access date of MRU item
// default is: %FullFileName%
Links
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net471 is compatible. net472 was computed. net48 was computed. net481 was computed. |
-
- OpenMRU.Core (>= 1.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
New features:
- get own images from MRU items;
- 'clear all' menu item;
- caption of 'last access date' group as menu separator;