Skip to content

Instantly share code, notes, and snippets.

@Willy-Kimura
Last active November 17, 2017 13:46
Show Gist options
  • Save Willy-Kimura/1a2d8bad2c0ba276f88c75c608f14ce7 to your computer and use it in GitHub Desktop.
Save Willy-Kimura/1a2d8bad2c0ba276f88c75c608f14ce7 to your computer and use it in GitHub Desktop.
Custom TaskItem control class.
// Custom TaskItem Class.
public class TaskItem
{
// This adds a new TaskItem control.
public void Add(TaskLabels task_label, bool show_separator, string task_subject, string task_title, string task_subtitle)
{
// Set the texts for the three Task values.
subject.Text = task_subject;
title.Text = task_title;
subtitle.Text = task_subtitle;
// If the TaskLabel option is set as "Important", then set the appropriate visual cues.
// Likewise, if the TaskLabel option is set as "Finished", then set the appropriate visual cue.
if (task_label == TaskLabels.Important) {
indicator.Visible = true;
subject.ForeColor = Color.FromArgb(243, 49, 85);
indicator.LineColor = Color.FromArgb(243, 49, 85);
} else if (task_label == TaskLabels.Finished) {
title.Font = new Font(subject.Font.FontFamily, 9.75, FontStyle.Strikeout);
}
// If the user has disabled viewing an item's separator, which is hereby optional, then hide it.
if (show_separator == false) {
separator.Visible = false;
}
}
// This provides a list of TaskLabel options.
public enum TaskLabels
{
General = 0,
Intermediate = 1,
Important = 2,
Finished = 3
}
// On TaskItem MouseHover, some visual effects will be previewed.
private void TaskItem_MouseHover(object sender, EventArgs e)
{
this.BackColor = Color.FromArgb(223, 218, 251);
edit.Show();
delete.Show();
}
// On TaskItem MouseLeave, some visual effects will be previewed.
private void TaskItem_MouseLeave(object sender, EventArgs e)
{
this.BackColor = Color.White;
edit.Hide();
delete.Hide();
}
// TaskItem event builders.
public TaskItem()
{
MouseLeave += TaskItem_MouseLeave;
MouseHover += TaskItem_MouseHover;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment