Beispiel #1
0
        private void addButton_Click(object sender, EventArgs e)
        {
            var task = new MirrorTask();

            using (TaskDialog dialog = new TaskDialog(task))
            {
                if (dialog.ShowDialog(this) != DialogResult.Yes)
                {
                    return;
                }
            }

            if (!TrySaveTask(task))
            {
                return;
            }

            AddListViewItem(task);

            // select the newly added item
            listView1.SelectedIndices.Clear();
            listView1.SelectedIndices.Add(listView1.Items.Count - 1);
        }
Beispiel #2
0
        private void editButton_Click(object sender, EventArgs e)
        {
            MirrorTask task = SelectedTask;

            if (task == null)
            {
                return;
            }

            using (var dialog = new TaskDialog(task))
            {
                if (dialog.ShowDialog(this) != DialogResult.Yes)
                {
                    return;
                }
            }

            if (!TrySaveTask(task))
            {
                return;
            }

            UpdateListViewItem(task);
        }
Beispiel #3
0
        /// <summary>
        /// Creates a new history form.
        /// </summary>
        public TaskHistoryForm(MirrorTask task)
        {
            if (task == null)
            {
                throw new ArgumentNullException("task");
            }

            InitializeComponent();

            var entries = Log.LoadEntries(task.Guid);

            foreach (var entry in entries)
            {
                var item = new ListViewItem();

                item.Tag = entry;

                if (entry.Type == EventLogEntryType.Information)
                {
                    item.ImageIndex = 0;
                }
                else if (entry.Type == EventLogEntryType.Warning)
                {
                    item.ImageIndex = 1;
                }
                else
                {
                    item.ImageIndex = 2;
                }

                item.SubItems.Add(entry.TimeStamp.ToString("g"));
                item.SubItems.Add(entry.Message);

                listView1.Items.Add(item);
            }
        }