コード例 #1
0
ファイル: ToDoItem.cs プロジェクト: aleksrutins/doit
        public static void ShowDetails(Window parent, ToDoListItem listItem)
        {
            var dlg = new ItemDisplay(listItem.tdItem);

            dlg.Parent     = parent;
            dlg.AttachedTo = parent;
            dlg.Show();
        }
コード例 #2
0
        private MainWindow(Builder builder) : base(builder.GetObject("MainWindow").Handle)
        {
            builder.Autoconnect(this);

            DeleteEvent             += Window_DeleteEvent;
            _addTask.Clicked        += AddTask;
            _tasks.ListRowActivated += (o, args) => {
                var row = (ToDoListItem)args.Row;
                ToDoListItem.ShowDetails(this, row);
            };
            flushBtn.Clicked += delegate {
                Util.SaveToDos();
            };
            refreshBtn.Clicked += delegate {
                Util.RefreshList(_tasks);
            };
            Util.RefreshList(_tasks);
        }
コード例 #3
0
ファイル: ToDoItem.cs プロジェクト: aleksrutins/doit
 public ItemDisplay(Builder builder, ToDoItem item) : base(builder.GetObject("ItemDisplay").Handle)
 {
     this.item = item;
     builder.Autoconnect(this);
     toDoName.Text           = item.name;
     description.Buffer.Text = item.description;
     completeBtn.Hide();
     if (item.done && item.doneOn.Value.Day != DateTime.Now.Day && item.days.IndexOf(DateTime.Now.DayOfWeek) != -1)
     {
         item.done = false;
         Util.SaveToDos();
     }
     if ((item.done && item.doneOn.Value.Day == DateTime.Now.Day) && item.days.IndexOf(DateTime.Now.DayOfWeek) != -1)
     {
         doneLabel.StyleContext.AddClass("done-label");
         doneLabel.Text = "Done";
         doneLabel.StyleContext.RemoveClass("notdone");
         doneLabel.StyleContext.AddClass("done");
     }
     else if (!item.done)
     {
         doneLabel.StyleContext.AddClass("done-label");
         doneLabel.StyleContext.RemoveClass("done");
         doneLabel.StyleContext.AddClass("notdone");
         doneLabel.Text = "Not done";
         completeBtn.Show();
     }
     foreach (var day in item.days)
     {
         var lbl = new Label(day.ToString());
         lbl.StyleContext.AddClass("day");
         if (DateTime.Now.DayOfWeek == day)
         {
             // Do it now!
             lbl.StyleContext.AddClass("doitnow");
         }
         daysBox.Add(lbl);
     }
     daysBox.ShowAll();
     Util.RefreshList(subtasks, ToDoList.fromArray(item.subtasks), subtaskRemoved);
     subtasks.ShowAll();
     if (item.days.Count == 0)
     {
         completeBtn.Hide();
     }
     addSubtaskBtn.Clicked += delegate {
         var res = Util.AddTask();
         if (res == null)
         {
             return;             // Cancelled
         }
         if (res.inheritDays)
         {
             res.days = item.days;
         }
         item.subtasks.Add(new ToDoItem {
             name        = res.dlg.name.Text,
             description = res.dlg.desc.Buffer.Text,
             days        = res.days
         });
         Util.SaveToDos();
         Util.RefreshList(subtasks, ToDoList.fromArray(item.subtasks), subtaskRemoved);
     };
     subtasks.ListRowActivated += (o, args) => {
         var row = (ToDoListItem)args.Row;
         ToDoListItem.ShowDetails(this, row);
     };
     saveDetailsBtn.Clicked += delegate {
         item.description = description.Buffer.Text;
         Util.SaveToDos();
     };
     completeBtn.Clicked += delegate {
         item.done   = true;
         item.doneOn = DateTime.Now;
         if (item.done && item.doneOn.Value.Day != DateTime.Now.Day && item.days.IndexOf(DateTime.Now.DayOfWeek) != -1)
         {
             item.done = false;
             Util.SaveToDos();
             completeBtn.Hide();
         }
         if ((item.done && item.doneOn.Value.Day == DateTime.Now.Day) && item.days.IndexOf(DateTime.Now.DayOfWeek) != -1)
         {
             doneLabel.StyleContext.AddClass("done-label");
             doneLabel.Text = "Done";
             doneLabel.StyleContext.RemoveClass("notdone");
             doneLabel.StyleContext.AddClass("done");
         }
         else if (item.done)
         {
             doneLabel.Text = "";
             doneLabel.StyleContext.RemoveClass("done-label");
         }
         else if (!item.done)
         {
             doneLabel.StyleContext.AddClass("done-label");
             doneLabel.StyleContext.RemoveClass("done");
             doneLabel.StyleContext.AddClass("notdone");
             doneLabel.Text = "Not done";
             completeBtn.Show();
         }
     };
     refreshSubtasksBtn.Clicked += delegate {
         Util.RefreshList(subtasks, ToDoList.fromArray(item.subtasks), subtaskRemoved);
     };
 }