コード例 #1
0
ファイル: PlanningView.cs プロジェクト: chergert/adroit
        void HandleTaskCompletedToggled(object o, ToggledArgs args)
        {
            TreeIter iter;
            var path = new TreePath (args.Path);

            if (m_store.GetIter (out iter, path)) {
                var item = (Task)m_store.Adapter.GetValue (iter, 0);
                if (item != null) {
                    var completed = !(o as CellRendererToggle).Active;

                    var command = new EditTaskCommand () {
                        Task = item,
                        Property = "Completed",
                        Value = completed,
                        Storage = m_storage
                    };

                    var commands = ServiceManager.Get<CommandService> ().Commands;
                    commands.Do (command);
                }
            }
        }
コード例 #2
0
ファイル: PlanningView.cs プロジェクト: chergert/adroit
        protected virtual void OnRemoveAttachmentButtonClicked(object sender, System.EventArgs e)
        {
            var paths = m_tasksIconView.SelectedItems;
            var model = m_tasksIconView.Model as ListStore;

            TreeIter iter;
            Array.Reverse (paths);

            foreach (TreePath path in paths) {
                if (model.GetIter (out iter, path)) {
                    model.Remove (ref iter);
                }
            }

            List<string> filenames = new List<string> ();

            if (model.GetIterFirst (out iter)) {
                do {
                    filenames.Add ((string)model.GetValue (iter, 2));
                } while (model.IterNext (ref iter));
            }

            var command = new EditTaskCommand () {
                Property = "Attachments",
                Value = filenames.ToArray (),
                Task = SelectedTask,
                Storage = m_storage
            };

            command.Done += delegate { this.UpdateAttachments (); };
            command.Undone += delegate { this.UpdateAttachments (); };

            var commands = ServiceManager.Get<CommandService> ().Commands;
            commands.Do (command);
        }
コード例 #3
0
ファイル: PlanningView.cs プロジェクト: chergert/adroit
        void BuildProjectColumns()
        {
            m_projectsTreeView.RowSeparatorFunc = delegate (TreeModel model, TreeIter iter) {
                var project = (Project)model.GetValue (iter, 0);
                return (project == null);
            };

            var column = new TreeViewColumn ();
            column.Title = Catalog.GetString ("Projects");
            column.Alignment = 0.5f;

            var cpix = new CellRendererPixbuf ();
            column.PackStart (cpix, false);
            column.SetCellDataFunc (cpix, (TreeCellDataFunc) ProjectIconCellDataFunc);

            var ctext = new CellRendererText ();
            ctext.Ellipsize = Pango.EllipsizeMode.End;
            ctext.Editable = true;
            ctext.Edited += OnProjectTitleEdited;
            ctext.EditingStarted += delegate {
                this.OnEditingStarted (ctext);
            };
            ctext.EditingCanceled += delegate {
                this.OnEditingStopped ();
            };
            column.PackStart (ctext, true);
            column.SetCellDataFunc (ctext, (TreeCellDataFunc) ProjectTitleCellDataFunc);

            m_projectsTreeView.RowSeparatorFunc = ProjectRowSeparatorFunc;
            m_projectsTreeView.AppendColumn (column);

            var targetEntries = new TargetEntry[] {
                new TargetEntry ("application/adroit-task", TargetFlags.App, 0),
            };

            this.m_projectsTreeView.EnableModelDragDest (targetEntries, Gdk.DragAction.Default | Gdk.DragAction.Move);
            this.m_projectsTreeView.DragDataReceived += delegate(object o, DragDataReceivedArgs args) {
                var tree = o as Gtk.TreeView;

                TreeViewDropPosition pos;
                TreePath path;

                if (tree.GetDestRowAtPos (args.X, args.Y, out path, out pos)) {
                    TreeIter iter;
                    tree.Model.GetIter (out iter, path);
                    var project = tree.Model.GetValue (iter, 0) as Project;
                    if (project == null)
                        return;

                    var model = m_tasksTreeView.Model;
                    var taskId = BitConverter.ToInt32 (args.SelectionData.Data, 0);

                    model.Foreach (delegate (TreeModel m, TreePath p, TreeIter i) {
                        var task = m.GetValue (i, 0) as Task;

                        if (task != null && task.Id == taskId) {
                            var command = new EditTaskCommand () {
                                Task = task,
                                Property = "ProjectId",
                                Value = project.Id,
                                Storage = m_storage
                            };
                            var commands = ServiceManager.Get<CommandService> ().Commands;
                            commands.Do (command);
                            return true;
                        }
                        return false;
                    });
                }
            };
        }
コード例 #4
0
ファイル: PlanningView.cs プロジェクト: chergert/adroit
        protected virtual void OnAddAttachmentButtonClicked(object sender, System.EventArgs e)
        {
            var task = SelectedTask;

            if (task == null)
                return;

            var dialog = new FileChooserDialog (Catalog.GetString ("Add Attachment"),
                                                (Gtk.Window)this.Toplevel,
                                                FileChooserAction.Open,
                                                Gtk.Stock.Cancel, Gtk.ResponseType.Cancel,
                                                Gtk.Stock.Ok, Gtk.ResponseType.Ok);
            int response = dialog.Run ();

            List<string> filenames = new List<string> ();

            if (response == (int)Gtk.ResponseType.Ok) {
                if (task.Attachments != null)
                    filenames.AddRange (task.Attachments);
                filenames.AddRange (dialog.Filenames);

                var command = new EditTaskCommand () {
                    Storage = m_storage,
                    Task = task,
                    Property = "Attachments",
                    Value = filenames.ToArray ()
                };

                command.Done += delegate {
                    this.UpdateAttachments ();
                };

                command.Undone += delegate {
                    this.UpdateAttachments ();
                };

                var commands = ServiceManager.Get<CommandService> ().Commands;
                commands.Do (command);
            }

            dialog.Destroy ();
        }
コード例 #5
0
ファイル: PlanningView.cs プロジェクト: chergert/adroit
        public void MarkSelectedTask()
        {
            TreeIter iter;
            TreeModel model;

            if (m_tasksTreeView.Selection.GetSelected (out model, out iter)) {
                var item = (Task) model.GetValue (iter, 0);
                var command = new EditTaskCommand () {
                    Task = item,
                    Property = "Completed",
                    Value = !item.Completed,
                    Storage = m_storage
                };
                var commands = ServiceManager.Get<CommandService> ().Commands;
                commands.Do (command);
            }
        }
コード例 #6
0
ファイル: PlanningView.cs プロジェクト: chergert/adroit
 public void FlagSelectedTask(TreeIter iter)
 {
     var item = (Task) m_tasksTreeView.Model.GetValue (iter, 0);
     var flag = TaskFlag.None;
     switch (item.Flag) {
     case TaskFlag.Black:
         flag = TaskFlag.Blue;
         break;
     case TaskFlag.Blue:
         flag = TaskFlag.Green;
         break;
     case TaskFlag.Green:
         flag = TaskFlag.Red;
         break;
     case TaskFlag.Red:
         flag = TaskFlag.Yellow;
         break;
     case TaskFlag.Yellow:
         flag = TaskFlag.None;
         break;
     default:
         flag = TaskFlag.Black;
         break;
     }
     var command = new EditTaskCommand () {
         Task = item,
         Storage = m_storage,
         Property = "Flag",
         Value = flag
     };
     var commands = ServiceManager.Get<CommandService> ().Commands;
     commands.Do (command);
 }
コード例 #7
0
ファイル: PlanningView.cs プロジェクト: chergert/adroit
        void OnTaskTitleEdited(object sender, EditedArgs args)
        {
            try {
                TreeIter iter;
                TreePath path = new TreePath (args.Path);
                if (m_tasksTreeView.Model.GetIter (out iter, path)) {
                    var item = (Task)m_tasksTreeView.Model.GetValue (iter, 0);
                    if (item != null) {
                        var command = new EditTaskCommand () {
                            Task     = item,
                            Property = "Title",
                            Value    = args.NewText,
                            Storage  = this.m_storage
                        };

                        var commands = ServiceManager.Get<CommandService> ().Commands;
                        commands.Do (command);

                        /* select the next column for editing */
                        var column = m_tasksTreeView.Columns[4];
                        m_tasksTreeView.SetCursor (path, column, true);
                    }
                }
            }
            finally {
                this.OnEditingStopped ();
            }
        }
コード例 #8
0
ファイル: PlanningView.cs プロジェクト: chergert/adroit
        void OnTaskNextActionEdited(object sender, EditedArgs args)
        {
            try {
                TreeIter iter;
                TreePath path = new TreePath (args.Path);
                if (m_store.GetIter (out iter, path)) {
                    var item = (Task)m_store.Adapter.GetValue (iter, 0);
                    if (item != null) {
                        var command = new EditTaskCommand () {
                            Task     = item,
                            Property = "NextAction",
                            Value    = args.NewText,
                            Storage  = this.m_storage
                        };

                        var commands = ServiceManager.Get<CommandService> ().Commands;
                        commands.Do (command);
                    }
                }
            }
            finally {
                this.OnEditingStopped ();
            }
        }