aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Notifications/TaskItem.cs
blob: 110fbfa74d93945ecc9369cdc3e327d7b0cdad8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core;

namespace Tango.MachineStudio.Common.Notifications
{
    /// <summary>
    /// Represents a Machine Studio "work-bar" item.
    /// </summary>
    /// <seealso cref="Tango.Core.ExtendedObject" />
    /// <seealso cref="System.IDisposable" />
    public class TaskItem : ExtendedObject, IDisposable
    {
        private INotificationProvider _notificationProvider;

        /// <summary>
        /// Initializes a new instance of the <see cref="TaskItem"/> class.
        /// </summary>
        /// <param name="notificationProvider">The notification provider.</param>
        public TaskItem(INotificationProvider notificationProvider)
        {
            _notificationProvider = notificationProvider;
        }

        private String _message;
        /// <summary>
        /// Gets or sets the message.
        /// </summary>
        public String Message
        {
            get { return _message; }
            set { _message = value; RaisePropertyChangedAuto(); }
        }

        /// <summary>
        /// Removed this item from the queue.
        /// </summary>
        public void Pop()
        {
            _notificationProvider.PopTaskItem(this);
        }

        /// <summary>
        /// Pushes this item to the queue.
        /// </summary>
        public void Push()
        {
            _notificationProvider.PushTaskItem(this);
        }

        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            Pop();
        }
    }
}