Post It Note
A sticky note for the desktop: a small, borderless, always-on-top window with a coloured title bar, a text area the user can type in, and a status bar – for reminders, comments on a record, or notes beside a document.
Assembly
| Assembly | Binarymission.WinForms.Controls.PostItNote.dll |
| Root namespace | Binarymission.WinForms.Controls.Containers |
| Target frameworks | .NET Framework 4.8, .NET 6 / 8 / 10 |
Overview
A note is a Form of its own. Create it in code with the window it belongs to,
set its text and look, and call Form.Show. It has no parameterless
constructor, so it is not dropped on a designer surface.
The parts of a note
- Title bar. The built-in title bar (
IsDefaultTitlebarVisible) is 28 logical pixels tall, with a command icon at the left (PostItNoteCommandBarInvokeRequested), a close icon at the right (PostItNoteCloseRequested) and an optionalPinin the middle. Turn it off for a thin 8-pixel strip instead, or supply your own withTitlebar. Any of them drags the note. - Text area. A rich text box holding
NoteText, inDefaultInputTextBoxFont. Hide it withIsDefaultInputTextBoxVisibleto put controls of your own on the note. - Status bar. One line of
StatusbarTextalong the bottom (IsStatusBarVisible), beside a gripper that resizes the note.
Behaviour
The close icon does not close the note: it raises PostItNoteCloseRequested, and your
handler decides – confirm, then call Form.Close. While
FollowsParentWindow is on, the note hides when its window is minimised or hidden and comes
back with it. InactiveOpacity fades notes that are not being worked in.
Appearance
NoteTheme sets the background and both title bars' colours in one go; set it first,
then adjust single colours. A new note starts with sample text in the text area and status bar –
replace both.
Getting started
A reminder note beside a customer record, removed when the user confirms its close icon.
using System;
using System.Drawing;
using System.Windows.Forms;
using Binarymission.WinForms.Controls.Containers;
private void OnAddNoteClick(object sender, EventArgs e)
{
PostItNote note = new PostItNote(this)
{
NoteTheme = PostItNoteTheme.Blue,
Pin = PostItNotePin.Red,
NoteText = "Call back about the overdue invoice INV-20431.",
StatusbarText = "Added " + DateTime.Now.ToString("d MMM, HH:mm"),
TitlebarTooltip = "Drag to move",
InactiveOpacity = 0.85,
Size = new Size(240, 200),
StartPosition = FormStartPosition.Manual,
Location = new Point(Right - 260, Top + 80)
};
note.PostItNoteCloseRequested += (s, args) =>
{
if (MessageBox.Show(note, "Remove this note?", "Notes", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
note.Close();
}
};
note.Show(this);
}API reference
Binarymission.WinForms.Controls.Containers
class PostItNote | A sticky note for the desktop: a small, borderless, always-on-top window with a coloured title bar, a text area the user can type in, and a status bar - for reminders, comments on a record, or notes beside a document. |
enum PostItNotePin | Specifies the coloured pin a PostItNote shows in the middle of its built-in title bar. |
enum PostItNoteTheme | Specifies the colour scheme of a PostItNote: its background and both title bars. |