Ejemplo n.º 1
0
        /// <summary>
        /// Modify the due date or completion date depending on whether the
        /// task being modified is completed or active.
        /// </summary>
        /// <param name="sender">
        /// A <see cref="System.Object"/>
        /// </param>
        /// <param name="args">
        /// A <see cref="Gtk.EditedArgs"/>
        /// </param>
        void OnDateEdited(object sender, Gtk.EditedArgs args)
        {
            if (args.NewText == null) {
                Debug.WriteLine ("New date text null, not setting date");
                return;
            }

            Gtk.TreeIter iter;
            Gtk.TreePath path = new TreePath (args.Path);
            if (!Model.GetIter (out iter, path))
                return;

            //  2/11 - Today
            //  2/12 - Tomorrow
            //  2/13 - Wed
            //  2/14 - Thu
            //  2/15 - Fri
            //  2/16 - Sat
            //  2/17 - Sun
            // --------------
            //  2/18 - In 1 Week
            // --------------
            //  No Date
            // ---------------
            //  Choose Date...

            DateTime newDate = DateTime.MinValue;
            DateTime today = DateTime.Now;
            Task task = Model.GetValue (iter, 0) as Task;

            if (args.NewText.CompareTo (
                            today.ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("Today") ) == 0)
                newDate = today;
            else if (args.NewText.CompareTo (
                        today.AddDays(1).ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("Tomorrow") ) == 0)
                newDate = today.AddDays (1);
            else if (args.NewText.CompareTo (Catalog.GetString ("No Date")) == 0)
                newDate = DateTime.MinValue;
            else if (args.NewText.CompareTo (
                today.AddDays(7).ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("In 1 Week")	) == 0)
                newDate = today.AddDays (7);
            else if (args.NewText.CompareTo (Catalog.GetString ("Choose Date...")) == 0) {
                TaskCalendar tc = new TaskCalendar(task, this.Parent);
                tc.ShowCalendar();
                return;
            } else {
                for (int i = 2; i <= 6; i++) {
                    DateTime testDate = today.AddDays (i);
                    if (testDate.ToString(Catalog.GetString("M/d - ddd")).CompareTo (
                            args.NewText) == 0) {
                        newDate = testDate;
                        break;
                    }
                }
            }

            Console.WriteLine ("task.State {0}", task.State);

            // Modify the due date
            task.DueDate = newDate;
        }
Ejemplo n.º 2
0
        public DueDateColumn()
        {
            TreeViewColumn = new TreeViewColumn {
                Title = Catalog.GetString ("Due Date"),
                Sizing = TreeViewColumnSizing.Fixed,
                Alignment = 0f,
                FixedWidth = 90,
                Resizable = false,
                Clickable = true
            };

            var dueDateStore = new ListStore (typeof (string));
            var today = DateTime.Now;
            dueDateStore.AppendValues (
                today.ToString (Catalog.GetString ("M/d - ")) + Catalog.GetString ("Today"));
            dueDateStore.AppendValues (
                today.AddDays (1).ToString (Catalog.GetString ("M/d - ")) + Catalog.GetString ("Tomorrow"));
            dueDateStore.AppendValues (
                today.AddDays (2).ToString (Catalog.GetString ("M/d - ddd")));
            dueDateStore.AppendValues (
                today.AddDays (3).ToString (Catalog.GetString ("M/d - ddd")));
            dueDateStore.AppendValues (
                today.AddDays (4).ToString (Catalog.GetString ("M/d - ddd")));
            dueDateStore.AppendValues (
                today.AddDays (5).ToString (Catalog.GetString ("M/d - ddd")));
            dueDateStore.AppendValues (
                today.AddDays (6).ToString (Catalog.GetString ("M/d - ddd")));
            dueDateStore.AppendValues (
                today.AddDays (7).ToString (Catalog.GetString ("M/d - ")) + Catalog.GetString ("In 1 Week"));
            dueDateStore.AppendValues (Catalog.GetString ("No Date"));
            dueDateStore.AppendValues (Catalog.GetString ("Choose Date..."));

            var renderer = new CellRendererCombo {
                Editable = true,
                HasEntry = false,
                Model = dueDateStore,
                TextColumn = 0,
                Xalign = 0.0f
            };

            renderer.EditingStarted += (o, args) => {
                TreeIter iter;
                var path = new TreePath (args.Path);
                if (!model.GetIter (out iter, path))
                    return;

                var task = model.GetValue (iter, 0) as ITask;
                if (task == null)
                    return;

                taskBeingEdited = new TaskBeingEdited (task, iter, path);
                if (CellEditingStarted != null)
                    CellEditingStarted (this, new TaskRowEditingEventArgs (task, iter, path));
            };

            renderer.EditingCanceled += delegate { EndCellEditing (); };

            renderer.Edited += (o, args) => {
                TreeIter iter;
                var path = new TreePath (args.Path);
                var newText = args.NewText;
                if (newText != null && model.GetIter (out iter, path)) {

                    //  2/11 - Today
                    //  2/12 - Tomorrow
                    //  2/13 - Wed
                    //  2/14 - Thu
                    //  2/15 - Fri
                    //  2/16 - Sat
                    //  2/17 - Sun
                    // --------------
                    //  2/18 - In 1 Week
                    // --------------
                    //  No Date
                    // ---------------
                    //  Choose Date...

                    var newDate = DateTime.MinValue;
                    var tday = DateTime.Now;
                    var task = model.GetValue (iter, 0) as ITask;

                    if (newText == tday.ToString (Catalog.GetString ("M/d - ")) + Catalog.GetString ("Today"))
                        newDate = tday;
                    else if (newText == tday.AddDays (1).ToString (Catalog.GetString ("M/d - "))
                             + Catalog.GetString ("Tomorrow"))
                        newDate = tday.AddDays (1);
                    else if (newText == Catalog.GetString ("No Date"))
                        newDate = DateTime.MinValue;
                    else if (newText == tday.AddDays (7).ToString (Catalog.GetString ("M/d - "))
                             + Catalog.GetString ("In 1 Week"))
                        newDate = tday.AddDays (7);
                    else if (newText == Catalog.GetString ("Choose Date...")) {
                        var tc = new TaskCalendar (task, view.TreeView.Parent);
                        tc.ShowCalendar ();
                        return;
                    } else {
                        for (int i = 2; i <= 6; i++) {
                            DateTime testDate = tday.AddDays (i);
                            if (testDate.ToString (Catalog.GetString ("M/d - ddd")) == newText) {
                                newDate = testDate;
                                break;
                            }
                        }
                    }

                    Logger.Debug ("task.State {0}", task.State);

                    if (task.State != TaskState.Completed) {
                        // Modify the due date
                        task.DueDate = newDate;
                    }
                }
                EndCellEditing ();
            };

            TreeViewColumn.PackStart (renderer, true);
            TreeViewColumn.SetCellDataFunc (renderer, DueDateCellDataFunc);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Modify the due date or completion date depending on whether the
        /// task being modified is completed or active.
        /// </summary>
        /// <param name="sender">
        /// A <see cref="System.Object"/>
        /// </param>
        /// <param name="args">
        /// A <see cref="Gtk.EditedArgs"/>
        /// </param>
        void OnDateEdited(object sender, Gtk.EditedArgs args)
        {
            if (args.NewText == null)
            {
                Logger.Debug("New date text null, not setting date");
                return;
            }

            Gtk.TreeIter iter;
            Gtk.TreePath path = new TreePath(args.Path);
            if (!Model.GetIter(out iter, path))
            {
                return;
            }

            //  2/11 - Today
            //  2/12 - Tomorrow
            //  2/13 - Wed
            //  2/14 - Thu
            //  2/15 - Fri
            //  2/16 - Sat
            //  2/17 - Sun
            // --------------
            //  2/18 - In 1 Week
            // --------------
            //  No Date
            // ---------------
            //  Choose Date...

            DateTime newDate = DateTime.MinValue;
            DateTime today   = DateTime.Now;
            ITask    task    = Model.GetValue(iter, 0) as ITask;

            if (args.NewText.CompareTo(
                    today.ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("Today")) == 0)
            {
                newDate = today;
            }
            else if (args.NewText.CompareTo(
                         today.AddDays(1).ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("Tomorrow")) == 0)
            {
                newDate = today.AddDays(1);
            }
            else if (args.NewText.CompareTo(Catalog.GetString("No Date")) == 0)
            {
                newDate = DateTime.MinValue;
            }
            else if (args.NewText.CompareTo(
                         today.AddDays(7).ToString(Catalog.GetString("M/d - ")) + Catalog.GetString("In 1 Week")) == 0)
            {
                newDate = today.AddDays(7);
            }
            else if (args.NewText.CompareTo(Catalog.GetString("Choose Date...")) == 0)
            {
                TaskCalendar tc = new TaskCalendar(task, this.Parent);
                tc.ShowCalendar();
                return;
            }
            else
            {
                for (int i = 2; i <= 6; i++)
                {
                    DateTime testDate = today.AddDays(i);
                    if (testDate.ToString(Catalog.GetString("M/d - ddd")).CompareTo(
                            args.NewText) == 0)
                    {
                        newDate = testDate;
                        break;
                    }
                }
            }

            Console.WriteLine("task.State {0}", task.State);

            if (task.State == TaskState.Completed)
            {
                // Modify the completion date
                task.CompletionDate = newDate;
            }
            else
            {
                // Modify the due date
                task.DueDate = newDate;
            }
        }