OpenMRU.WinForm 1.3.0

Open MRU Siute (WinForm GUI controls)
Contains WinForm GUI controls for MRU items functionality

Install-Package OpenMRU.WinForm -Version 1.3.0
dotnet add package OpenMRU.WinForm --version 1.3.0
<PackageReference Include="OpenMRU.WinForm" Version="1.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OpenMRU.WinForm --version 1.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: OpenMRU.WinForm, 1.3.0"
For F# scripts that support #r syntax, copy this into the source code to reference the package.

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

https://github.com/dmsobeshchanskiy/OpenMRUSuite

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

https://github.com/dmsobeshchanskiy/OpenMRUSuite

Release Notes

New features:
- get own images from MRU items;
- 'clear all' menu item;
- caption of 'last access date' group as menu separator;

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.3.0 92 10/18/2020
1.2.0 189 10/1/2020
1.1.0 99 9/21/2020
1.0.0 111 9/12/2020