public TreePath(TreePath parent, object node)
		{
			_path=new object[parent.FullPath.Length+1];
			for(int i=0; i<_path.Length-1; i++)
				_path[i]=parent.FullPath[i];
			_path[_path.Length-1]=node;
		}
		/// <summary>
		/// Returns node at specified path
		/// </summary>
		public override object GetNodeAtPath (TreePath aPath)
		{
			if (Items == null)
				return (null);
			if (aPath.Indices.Length == 0)
				return (null);
			return (Items.Rows[aPath.Indices[0]]);
		}
示例#3
0
 public TaskRowEditingEventArgs(ITask task, TreeIter iter, TreePath path)
 {
     if (task == null)
         throw new ArgumentNullException ("task");
     ITask = task;
     if (path == null)
         throw new ArgumentNullException ("path");
     Path = path;
     Iter = iter;
 }
示例#4
0
 public TaskBeingEdited(ITask task, TreeIter iter, TreePath path)
 {
     if (path == null)
         throw new ArgumentNullException ("path");
     if (task == null)
         throw new ArgumentNullException ("task");
     Task = task;
     Iter = iter;
     Path = path;
 }
		/// <summary>
		/// Searches for node in Items
		/// </summary>
		public override TreePath PathFromNode (object aNode)
		{
			TreePath tp = new TreePath();
			if ((aNode == null) || (Items == null) || (Items.Rows.Count == 0))
				return (tp);

			int idx = Items.Rows.IndexOf(aNode as DataRow);
			if (idx >= 0)
				tp.AppendIndex (idx);
			return (tp);
		}
 private void AdjustCursorForCurrentPage()
 {
     int page = gamesBook.CurrentPage;
     TreePath path =
         new TreePath (new int[]{ page });
     gamesList.Selection.SelectPath (path);
 }
示例#7
0
        void OnTaskToggled(object o, ToggledArgs args)
        {
            Logger.Debug ("OnTaskToggled");
            TreeIter iter;
            var path = new TreePath (args.Path);
            if (!model.GetIter (out iter, path))
                return; // Do nothing

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

            // remove any timer set up on this task
            var timerCol = (TimerColumn)view.GetColumn (typeof (TimerColumn));
            var tmr = timerCol.GetTimer (task);
            if (tmr != null)
                tmr.Cancel ();

            if (task.State == TaskState.Active) {
                bool showCompletedTasks = preferences.GetBool (PreferencesKeys.ShowCompletedTasksKey);

                // When showCompletedTasks is true, complete the tasks right
                // away.  Otherwise, set a timer and show the timer animation
                // before marking the task completed.
                if (showCompletedTasks) {
                    task.Complete ();
                    var statusMsg = Catalog.GetString ("Task Completed");
                    TaskWindow.ShowStatus (statusMsg, 5000);
                } else {
                    var timer = timerCol.CreateTimer (task);
                    timer.TimerStopped += (s, e) => {
                        if (!e.Canceled)
                            e.Task.Complete ();
                    };
                    timer.Tick += (s, e) => {
                        var statusMsg = string.Format (
                            Catalog.GetString ("Completing Task In: {0}"), e.CountdownTick);
                        TaskWindow.ShowStatus (statusMsg, 2000);
                    };
                    timer.Start ();
                }
            } else {
                var statusMsg = Catalog.GetString ("Action Canceled");
                TaskWindow.ShowStatus (statusMsg, 5000);
                task.Activate ();
            }
        }
示例#8
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;
            }
        }
示例#9
0
        bool TemplateCategoriesTreeViewSelection(TreeSelection selection, TreeModel model, TreePath path, bool path_currently_selected)
        {
            TreeIter iter;

            if (model.GetIter(out iter, path))
            {
                var category = model.GetValue(iter, TemplateCategoryColumn) as TemplateCategory;
                if (category?.IsTopLevel == true)                   // don't allow selection for top level categories
                {
                    return(false);
                }
            }

            return(true);
        }
 private void ClearHighlighting()
 {
     if (last_row < 0 || last_col < 0)
         return;
     int idx;
     MoveDetails details;
     TreePath path =
         new TreePath (new int[]{ last_row });
     TreeIter lastiter;
     store.GetIter (out lastiter, path);
     idx = last_col ==
         WHITE_MOVE_COL ?
         WHITE_MOVE_DETAILS_COL :
         BLACK_MOVE_DETAILS_COL;
     details =
         (MoveDetails) store.
         GetValue (lastiter, idx);
     idx = last_col;
     store.SetValue (lastiter, idx,
             GetMove (details));
     last_col = last_row = -1;
 }
示例#11
0
 public new bool RowDropPossible(TreePath path, SelectionData sel)
 {
     return(path.Depth == 2);
 }
 public void DecomposeTree(AbstractTree parentNode, AbstractTree node, TreeBranch branch, TreePath path)
 {
     if (!path.IsAdded)
     {
         Possibilities.Add(path);
         path.IsAdded = true;
     }
     // Recursive browse
     if (node is TreeConnector) {
             TreeConnector treeConnector = (TreeConnector)node;
             if (treeConnector.Connection == "&")
             {
                 DecomposeTree(treeConnector, treeConnector.LeftTree, TreeBranch.Left, path);
                 DecomposeTree(treeConnector, treeConnector.RightTree, TreeBranch.Right, path);
             }
             else if (treeConnector.Connection == "|")
             {
                 // In this case, parentNode is a TreeOperator
                 if (parentNode != null)
                 {
                     // Left distribution
                     TreePath clonedPathLeftDistribution = (TreePath)path.Clone();
                     TreeConnector parentTreeConnectorLeftDistribution = (TreeConnector)parentNode.Clone();
                     // Right distribution
                     TreePath clonedPathRightDistribution = (TreePath)path.Clone();
                     TreeConnector parentTreeConnectorRightDistribution = (TreeConnector)parentNode.Clone();
                     if (branch == TreeBranch.Left)
                     {
                         parentTreeConnectorLeftDistribution.LeftTree = treeConnector.LeftTree;
                         parentTreeConnectorRightDistribution.LeftTree = treeConnector.RightTree;
                     }
                     else if (branch == TreeBranch.Right)
                     {
                         parentTreeConnectorLeftDistribution.RightTree = treeConnector.LeftTree;
                         parentTreeConnectorRightDistribution.RightTree = treeConnector.RightTree;
                     }
                     // Remove obsolete path
                     Possibilities.Remove(path);
                     // Browse recursively distributed tree ; the path must be different (by ref) if the parent operator is 'OR'
                     DecomposeTree(
                         parentTreeConnectorLeftDistribution,
                         parentTreeConnectorLeftDistribution.LeftTree,
                         TreeBranch.Left,
                         parentTreeConnectorLeftDistribution.Connection == "|"
                             ? (TreePath)clonedPathLeftDistribution.Clone()
                             : clonedPathLeftDistribution
                     );
                     DecomposeTree(
                         parentTreeConnectorLeftDistribution,
                         parentTreeConnectorLeftDistribution.RightTree,
                         TreeBranch.Right,
                         clonedPathLeftDistribution
                     );
                     DecomposeTree(
                         parentTreeConnectorRightDistribution,
                         parentTreeConnectorRightDistribution.LeftTree,
                         TreeBranch.Left,
                         parentTreeConnectorLeftDistribution.Connection == "|"
                             ? (TreePath)clonedPathRightDistribution.Clone()
                             : clonedPathRightDistribution
                     );
                     DecomposeTree(
                         parentTreeConnectorRightDistribution,
                         parentTreeConnectorRightDistribution.RightTree,
                         TreeBranch.Right,
                         clonedPathRightDistribution
                     );
                 }
                 // The operator is the root of the tree; we simply divide the path
                 else
                 {
                     TreePath clonedLeftPath = (TreePath)path.Clone();
                     TreePath clonedRightPath = (TreePath)path.Clone();
                     // Remove obsolete path
                     Possibilities.Remove(path);
                     DecomposeTree(treeConnector, treeConnector.LeftTree, TreeBranch.Left, clonedLeftPath);
                     DecomposeTree(treeConnector, treeConnector.RightTree, TreeBranch.Right, clonedRightPath);
                 }
             }
             break;
     }
     // Leaf
     else if (node is TreeValue) {
         TreeValue treeValue = (TreeValue)node;
         path.Add(treeValue);
     }
 }
            public void Prepend(ArrayList moves)
            {
                TreeIter iter;
                int end = moves.Count;
                int nrows = (moves.Count + 1) / 2;
                if (store.GetIterFirst (out iter))
                  {
                      int movenumber =
                          (int) store.GetValue (iter,
                                    0);
                      bool black_move =
                          store.GetValue (iter,
                                  WHITE_MOVE_DETAILS_COL)
                          == null;
                      end = (movenumber - 1) * 2;

                      nrows = movenumber - 1;
                      if (black_move)
                        {
                            end++;
                        }

                      // create the required number of rows
                      int j;
                      for (j = 0; j < nrows; j++)
                        {
                            store.Insert (j);
                            total_rows++;
                        }
                      if (last_row >= 0)
                          last_row += j;
                  }

                int row = 0;
                int i = 0;

                foreach (MoveDetails md in moves)
                {
                    TreePath path =
                        new TreePath (new int[]{ row
                                  });
                    if (i >= end)
                        break;
                    if (i % 2 == 0)
                      {
                          store.GetIter (out iter,
                                 path);
                          store.SetValue (iter, 0,
                                  md.
                                  movenumber);
                          store.SetValue (iter,
                                  WHITE_MOVE_COL,
                                  GetMove
                                  (md));
                          store.SetValue (iter,
                                  WHITE_MOVE_DETAILS_COL,
                                  md);
                      }
                    else
                      {
                          store.GetIter (out iter,
                                 path);
                          store.SetValue (iter,
                                  BLACK_MOVE_COL,
                                  GetMove
                                  (md));
                          store.SetValue (iter,
                                  BLACK_MOVE_DETAILS_COL,
                                  md);
                          row++;
                      }
                    i++;
                }

                if (total_rows > 0)
                    ScrollToCell (new TreePath (new int[]
                                    {
                                    total_rows
                                    - 1}
                              ),
                              GetColumn
                              (WHITE_MOVE_COL), false,
                              0, 0);
            }
示例#14
0
 public string[] GetParentTreePath() => TreePath.Take(TreePath.Length - 1).ToArray();
示例#15
0
文件: Tree.cs 项目: cederlof/Wyam
 public object[] GetParentTreePath() => TreePath.Take(TreePath.Length - 1).ToArray();
示例#16
0
        public RenderablesList(string file_name)
        {
            m_unit_file = new UnitFile(file_name);

            m_renderables_names = new List <string> (m_unit_file.renderables_names());
            m_renderables       = new List <Renderable> (m_unit_file.renderables());

            Console.Write(m_renderables_names[0]);
            m_renderables_store = new ListStore(typeof(string), typeof(string), typeof(string), typeof(string), typeof(bool));

            TreeView tree = new TreeView();

            this.Add(tree);

            TreeViewColumn nameColumn = new TreeViewColumn();

            nameColumn.Title     = "Name";
            nameColumn.Alignment = 0.5f;

            TreeViewColumn nodeColumn = new TreeViewColumn();

            nodeColumn.Title     = "Node";
            nodeColumn.Alignment = 0.5f;

            TreeViewColumn typeColumn = new TreeViewColumn();

            typeColumn.Title     = "Type";
            typeColumn.Alignment = 0.5f;

            TreeViewColumn resourceColumn = new TreeViewColumn();

            resourceColumn.Title     = "Resource";
            resourceColumn.Alignment = 0.5f;

            TreeViewColumn visibleColumn = new TreeViewColumn();

            visibleColumn.Title     = "Visible";
            visibleColumn.Alignment = 0.5f;

            // Assign the model to the TreeView
            tree.Model = m_renderables_store;

            CellRendererText nameCell = new CellRendererText();

            nameCell.Editable = true;
            nameCell.Edited  += delegate(object o, EditedArgs e) {
                TreePath path = new TreePath(e.Path);
                TreeIter iter;
                m_renderables_store.GetIter(out iter, path);
                int i = path.Indices[0];

                string r = e.NewText;
                m_renderables_names[i] = r;
                m_renderables_store.SetValue(iter, 0, r);
            };
            nameColumn.PackStart(nameCell, true);

            CellRendererText nodeCell = new CellRendererText();

            nodeCell.Editable = true;
            nodeCell.Edited  += delegate(object o, EditedArgs e) {
                TreePath path = new TreePath(e.Path);
                TreeIter iter;
                m_renderables_store.GetIter(out iter, path);
                int i = path.Indices[0];

                Renderable r = m_renderables[i];
                r.node = e.NewText;
                m_renderables_store.SetValue(iter, 1, r.node);
            };
            nodeColumn.PackStart(nodeCell, true);

            CellRendererText typeCell = new CellRendererText();

            typeCell.Editable = true;
            typeCell.Edited  += delegate(object o, EditedArgs e) {
                TreePath path = new TreePath(e.Path);
                TreeIter iter;
                m_renderables_store.GetIter(out iter, path);
                int i = path.Indices[0];

                Renderable r = m_renderables[i];
                r.type = e.NewText;
                m_renderables_store.SetValue(iter, 2, r.type);
            };
            typeColumn.PackStart(typeCell, true);

            CellRendererText resourceCell = new CellRendererText();

            resourceCell.Editable = true;
            resourceCell.Edited  += delegate(object o, EditedArgs e) {
                TreePath path = new TreePath(e.Path);
                TreeIter iter;
                m_renderables_store.GetIter(out iter, path);
                int i = path.Indices[0];

                Renderable r = m_renderables[i];
                r.resource = e.NewText;
                m_renderables_store.SetValue(iter, 3, r.resource);
            };
            resourceColumn.PackStart(resourceCell, true);

            CellRendererToggle visibleCell = new CellRendererToggle();

            visibleCell.Activatable = true;
            visibleCell.Toggled    += delegate(object o, ToggledArgs e) {
                TreePath path = new TreePath(e.Path);
                TreeIter iter;
                m_renderables_store.GetIter(out iter, path);
                int i = path.Indices[0];

                Renderable r   = m_renderables[i];
                bool       old = (bool)m_renderables_store.GetValue(iter, 4);
                r.visible = !old;
                m_renderables_store.SetValue(iter, 4, !old);
            };
            visibleColumn.PackStart(visibleCell, true);

            // Add the columns to the TreeView
            nameColumn.AddAttribute(nameCell, "text", 0);
            nodeColumn.AddAttribute(nodeCell, "text", 1);
            typeColumn.AddAttribute(typeCell, "text", 2);
            resourceColumn.AddAttribute(resourceCell, "text", 3);
            visibleColumn.AddAttribute(visibleCell, "active", 4);

            tree.AppendColumn(nameColumn);
            tree.AppendColumn(nodeColumn);
            tree.AppendColumn(typeColumn);
            tree.AppendColumn(resourceColumn);
            tree.AppendColumn(visibleColumn);

            create_model();

            // Show the window and everything on it
            ShowAll();
        }
示例#17
0
 /// <summary>
 /// Determines if a <see cref="TreePath"/> describes a leaf node.
 /// </summary>
 /// <param name="treePath">The path.</param>
 /// <returns><c>True</c> if the paht points to a leaf node.</returns>
 public override bool IsLeaf(TreePath treePath)
 {
     return(treePath.LastNode is ObjectFieldValue);
 }
示例#18
0
 public new bool DragDataGet(TreePath path, SelectionData sel)
 {
     logger.Debug("DragDataGet path={0}", path);
     return(Tree.SetRowDragData(sel, this, path));
 }
示例#19
0
 public static void SerializeNullable(TreePath? value, TextWriter sw)
 {
     if (value == null)
         sw.Write("null");
     else
         Serialize(value.Value, sw);
 }
示例#20
0
        protected override void Render(Drawable window, Widget widget, Gdk.Rectangle background_area, Gdk.Rectangle cell_area, Gdk.Rectangle expose_area, CellRendererState flags)
        {
            if (isDisposed)
            {
                return;
            }
            if (diffMode)
            {
                if (path.Equals(selctedPath))
                {
                    selectedLine = -1;
                    selctedPath  = null;
                }

                int w, maxy;
                window.GetSize(out w, out maxy);
                if (DrawLeft)
                {
                    cell_area.Width += cell_area.X - leftSpace;
                    cell_area.X      = leftSpace;
                }
                var treeview = widget as FileTreeView;
                var p        = treeview != null? treeview.CursorLocation : null;

                cell_area.Width -= RightPadding;

                window.DrawRectangle(widget.Style.BaseGC(Gtk.StateType.Normal), true, cell_area.X, cell_area.Y, cell_area.Width - 1, cell_area.Height);

                Gdk.GC normalGC  = widget.Style.TextGC(StateType.Normal);
                Gdk.GC removedGC = new Gdk.GC(window);
                removedGC.Copy(normalGC);
                removedGC.RgbFgColor = baseRemoveColor.AddLight(-0.3);
                Gdk.GC addedGC = new Gdk.GC(window);
                addedGC.Copy(normalGC);
                addedGC.RgbFgColor = baseAddColor.AddLight(-0.3);
                Gdk.GC infoGC = new Gdk.GC(window);
                infoGC.Copy(normalGC);
                infoGC.RgbFgColor = widget.Style.Text(StateType.Normal).AddLight(0.2);

                Cairo.Context ctx = CairoHelper.Create(window);

                // Rendering is done in two steps:
                // 1) Get a list of blocks to render
                // 2) render the blocks

                int y = cell_area.Y + 2;

                // cline keeps track of the current source code line (the one to jump to when double clicking)
                int       cline        = 1;
                bool      inHeader     = true;
                BlockInfo currentBlock = null;

                List <BlockInfo> blocks = new List <BlockInfo> ();

                for (int n = 0; n < lines.Length; n++, y += lineHeight)
                {
                    string line = lines [n];
                    if (line.Length == 0)
                    {
                        currentBlock = null;
                        y           -= lineHeight;
                        continue;
                    }

                    char tag = line [0];

                    if (line.StartsWith("---", StringComparison.Ordinal) ||
                        line.StartsWith("+++", StringComparison.Ordinal))
                    {
                        // Ignore this part of the header.
                        currentBlock = null;
                        y           -= lineHeight;
                        continue;
                    }
                    if (tag == '@')
                    {
                        int l = ParseCurrentLine(line);
                        if (l != -1)
                        {
                            cline = l - 1;
                        }
                        inHeader = false;
                    }
                    else if (tag != '-' && !inHeader)
                    {
                        cline++;
                    }

                    BlockType type;
                    switch (tag)
                    {
                    case '-': type = BlockType.Removed; break;

                    case '+': type = BlockType.Added; break;

                    case '@': type = BlockType.Info; break;

                    default: type = BlockType.Unchanged; break;
                    }

                    if (currentBlock == null || type != currentBlock.Type)
                    {
                        if (y > maxy)
                        {
                            break;
                        }

                        // Starting a new block. Mark section ends between a change block and a normal code block
                        if (currentBlock != null && IsChangeBlock(currentBlock.Type) && !IsChangeBlock(type))
                        {
                            currentBlock.SectionEnd = true;
                        }

                        currentBlock = new BlockInfo()
                        {
                            YStart          = y,
                            FirstLine       = n,
                            Type            = type,
                            SourceLineStart = cline,
                            SectionStart    = (blocks.Count == 0 || !IsChangeBlock(blocks[blocks.Count - 1].Type)) && IsChangeBlock(type)
                        };
                        blocks.Add(currentBlock);
                    }
                    // Include the line in the current block
                    currentBlock.YEnd     = y + lineHeight;
                    currentBlock.LastLine = n;
                }

                // Now render the blocks

                // The y position of the highlighted line
                int selectedLineRowTop = -1;

                BlockInfo lastCodeSegmentStart = null;
                BlockInfo lastCodeSegmentEnd   = null;

                foreach (BlockInfo block in blocks)
                {
                    if (block.Type == BlockType.Info)
                    {
                        // Finished drawing the content of a code segment. Now draw the segment border and label.
                        if (lastCodeSegmentStart != null)
                        {
                            DrawCodeSegmentBorder(infoGC, ctx, cell_area.X, cell_area.Width, lastCodeSegmentStart, lastCodeSegmentEnd, lines, widget, window);
                        }
                        lastCodeSegmentStart = block;
                    }

                    lastCodeSegmentEnd = block;

                    if (block.YEnd < 0)
                    {
                        continue;
                    }

                    // Draw the block background
                    DrawBlockBg(ctx, cell_area.X + 1, cell_area.Width - 2, block);

                    // Get all text for the current block
                    StringBuilder sb = new StringBuilder();
                    for (int n = block.FirstLine; n <= block.LastLine; n++)
                    {
                        string s = ProcessLine(lines [n]);
                        if (n > block.FirstLine)
                        {
                            sb.Append('\n');
                        }
                        if (block.Type != BlockType.Info && s.Length > 0)
                        {
                            sb.Append(s, 1, s.Length - 1);
                        }
                        else
                        {
                            sb.Append(s);
                        }
                    }

                    // Draw a special background for the selected line

                    if (block.Type != BlockType.Info && p.HasValue && p.Value.X >= cell_area.X && p.Value.X <= cell_area.Right && p.Value.Y >= block.YStart && p.Value.Y <= block.YEnd)
                    {
                        int    row  = (p.Value.Y - block.YStart) / lineHeight;
                        double yrow = block.YStart + lineHeight * row;
                        double xrow = cell_area.X + LeftPaddingBlock;
                        int    wrow = cell_area.Width - 1 - LeftPaddingBlock;
                        if (block.Type == BlockType.Added)
                        {
                            ctx.SetSourceColor(baseAddColor.AddLight(0.1).ToCairoColor());
                        }
                        else if (block.Type == BlockType.Removed)
                        {
                            ctx.SetSourceColor(baseRemoveColor.AddLight(0.1).ToCairoColor());
                        }
                        else
                        {
                            ctx.SetSourceColor(widget.Style.Base(Gtk.StateType.Prelight).AddLight(0.1).ToCairoColor());
                            xrow -= LeftPaddingBlock;
                            wrow += LeftPaddingBlock;
                        }
                        ctx.Rectangle(xrow, yrow, wrow, lineHeight);
                        ctx.Fill();
                        selectedLine       = block.SourceLineStart + row;
                        selctedPath        = path;
                        selectedLineRowTop = (int)yrow;
                    }

                    // Draw the line text. Ignore header blocks, since they are drawn as labels in DrawCodeSegmentBorder

                    if (block.Type != BlockType.Info)
                    {
                        layout.SetMarkup("");
                        layout.SetText(sb.ToString());
                        Gdk.GC gc;
                        switch (block.Type)
                        {
                        case BlockType.Removed: gc = removedGC; break;

                        case BlockType.Added: gc = addedGC; break;

                        case BlockType.Info: gc = infoGC; break;

                        default: gc = normalGC; break;
                        }
                        window.DrawLayout(gc, cell_area.X + 2 + LeftPaddingBlock, block.YStart, layout);
                    }

                    // Finally draw the change symbol at the left margin

                    DrawChangeSymbol(ctx, cell_area.X + 1, cell_area.Width - 2, block);
                }

                // Finish the drawing of the code segment
                if (lastCodeSegmentStart != null)
                {
                    DrawCodeSegmentBorder(infoGC, ctx, cell_area.X, cell_area.Width, lastCodeSegmentStart, lastCodeSegmentEnd, lines, widget, window);
                }

                // Draw the source line number at the current selected line. It must be done at the end because it must
                // be drawn over the source code text and segment borders.
                if (selectedLineRowTop != -1)
                {
                    DrawLineBox(normalGC, ctx, ((Gtk.TreeView)widget).VisibleRect.Right - 4, selectedLineRowTop, selectedLine, widget, window);
                }

                ((IDisposable)ctx).Dispose();
                removedGC.Dispose();
                addedGC.Dispose();
                infoGC.Dispose();
            }
            else
            {
                // Rendering a normal text row
                int y = cell_area.Y + (cell_area.Height - height) / 2;
                window.DrawLayout(widget.Style.TextGC(GetState(widget, flags)), cell_area.X, y, layout);
            }
        }
		/// <summary>
		/// Returns node at specified path
		/// </summary>
		public override object GetNodeAtPath (TreePath aPath)
		{
			if (DataSource == null)
				return (null);
			if (aPath.Indices.Length == 0)
				return (null);
			return (GetItemAtIndex (aPath.Indices[0]));
		}
		/// <summary>
		/// Searches for node in Items
		/// </summary>
		public override TreePath PathFromNode (object aNode)
		{
			TreePath tp = new TreePath();
			return (tp);
		}
            private bool FindMoveRow(int movenumber,
						  out TreePath path,
						  out TreeIter iter)
            {
                iter = TreeIter.Zero;
                if (total_rows <= 0)
                  {
                      path = null;
                      return false;
                  }

                path = new TreePath (new int[]
                             {
                             total_rows - 1});
                do
                  {
                      store.GetIter (out iter, path);
                      int number =
                          (int) store.GetValue (iter,
                                    0);
                      if (number == movenumber)
                          return true;
                      if (number < movenumber)
                          return false;
                  }
                while (path.Prev ());

                return false;
            }
示例#24
0
        void OnTaskToggled(object o, ToggledArgs args)
        {
            Logger.Debug ("OnTaskToggled");
            TreeIter iter;
            var path = new TreePath (args.Path);
            if (!model.GetIter (out iter, path))
                return; // Do nothing

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

            string statusMsg;
            if (task.State == TaskState.Active) {
                task.Complete ();
                statusMsg = Catalog.GetString ("Task Completed");
            } else {
                statusMsg = Catalog.GetString ("Action Canceled");
                task.Activate ();
            }
            TaskWindow.ShowStatus (statusMsg, 5);
        }
示例#25
0
        public PriorityColumn()
        {
            TreeViewColumn = new TreeViewColumn {
                Title = Catalog.GetString ("Priority"),
                Sizing = TreeViewColumnSizing.Fixed,
                Alignment = 0.5f,
                FixedWidth = 30,
                Resizable = false,
                Clickable = true
            };

            var priorityStore = new ListStore (typeof (string));
            priorityStore.AppendValues (Catalog.GetString ("1")); // High
            priorityStore.AppendValues (Catalog.GetString ("2")); // Medium
            priorityStore.AppendValues (Catalog.GetString ("3")); // Low
            priorityStore.AppendValues (Catalog.GetString ("-")); // None

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

            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);
                if (model.GetIter (out iter, path)) {
                    TaskPriority newPriority;
                    var newText = args.NewText;
                    if (newText == Catalog.GetString ("3"))
                        newPriority = TaskPriority.Low;
                    else if (newText == Catalog.GetString ("2"))
                        newPriority = TaskPriority.Medium;
                    else if (newText == Catalog.GetString ("1"))
                        newPriority = TaskPriority.High;
                    else
                        newPriority = TaskPriority.None;

                    // Update the priority if it's different
                    var task = model.GetValue (iter, 0) as ITask;
                    if (task.Priority != newPriority)
                        task.Priority = newPriority;
                }
                EndCellEditing ();
            };

            TreeViewColumn.PackStart (renderer, true);
            TreeViewColumn.SetCellDataFunc (renderer, TaskPriorityCellDataFunc);
        }
示例#26
0
 public new bool RowDraggable(TreePath path)
 {
     return(path.Depth == 2);
 }
示例#27
0
        private TreeViewColumn NextColumn(TreePath path, TreeViewColumn column, bool prev, out TreePath next)
        {
            TreeViewColumn[] columns = d_treeview.Columns;

            int idx = Array.IndexOf(columns, column);

            next = null;

            if (idx < 0)
            {
                return(null);
            }

            next = path.Copy();

            if (!prev && idx == columns.Length - 1)
            {
                next.Next();
                idx = 0;
            }
            else if (prev && idx == 0)
            {
                if (!next.Prev())
                {
                    return(null);
                }

                idx = columns.Length - 1;
            }
            else if (!prev)
            {
                ++idx;
            }
            else
            {
                --idx;
            }

            return(columns[idx]);
        }
示例#28
0
        /*
         * Método que realiza la misma función que el método OnTreeviewNeighboursRowActivated. BOTON CONEXIÓN
         * */
        protected void OnConnectionPngAction1Activated(object sender, EventArgs e)
        {
            TreeIter t;
            TreePath p = treeviewNeighbours.Selection.GetSelectedRows()[0];

            this._infoNeighboursView.GetIter(out t, p);

            string vecino = (string)this._infoNeighboursView.GetValue(t, 0);

            //Comprobamos que está el usuario y si la tupla que tiene es del mismo (tipoBBDD,nombreBBDD)
            if (!this._messages.ContainsKey(vecino))
            {
                this._connectionDialog = new ConnectionDialog(this._user.Nombre, vecino, null, null, this._claves);

                this._connectionDialog.Run();


                switch (this._connectionDialog.TypeOutPut)
                {
                case Constants.CANCEL:

                    break;

                case Constants.MENSAJE_CONEXION:
                    Dictionary <string, PipeMessage> messageC = new Dictionary <string, PipeMessage>();
                    messageC.Add(Constants.CONNECTION, this._connectionDialog.Connection);
                    Tuple <string, string, Dictionary <string, PipeMessage> > tupl =
                        new Tuple <string, string, Dictionary <string, PipeMessage> >(null, null, messageC);

                    if (!this._messages.ContainsKey(vecino))
                    {
                        List <Tuple <string, string, Dictionary <string, PipeMessage> > > lista = new List <Tuple <string, string, Dictionary <string, PipeMessage> > >();
                        lista.Add(tupl);

                        this._messages.Add(vecino, lista);
                    }
                    else
                    {
                        this._messages[vecino].Add(tupl);
                    }

                    if (!this._keyPairClients.ContainsKey(vecino))
                    {
                        Tuple <RsaKeyParameters, SymmetricAlgorithm> tup = new Tuple <RsaKeyParameters, SymmetricAlgorithm>(this._connectionDialog.Connection.PublicKey, this._connectionDialog.Connection.SymmetricKey);
                        this._keyPairClients.Add(vecino, tup);
                    }

                    this._neighbours.SaveNeighbourDatabases(this._connectionDialog.Connection.MessageResponse);

                    AddValuesDatabasesNeighbours();

                    MostrarSolicitudConexion(this._connectionDialog.Connection.MessageRequest);
                    MostrarConexion(this._connectionDialog.Connection.MessageResponse);
                    IncrementarConexionesActivas();

                    break;

                case Constants.ERROR_CONNECTION:
                    MostrarError(this._connectionDialog.TypeOutPut);
                    break;
                }
            }
        }
示例#29
0
        /*
         * Método evento para solicitar consulta BBDD. BOTON SELECT
         * */
        protected void OnSelectPngActionActivated(object sender, EventArgs e)
        {
            TreeIter t;
            TreePath p = treeviewDatabases.Selection.GetSelectedRows()[0];

            this._infoBBDDView.GetIter(out t, p);


            string usuarioDestino = (string)this._infoBBDDView.GetValue(t, 0);
            string tipoBBDD       = (string)this._infoBBDDView.GetValue(t, 1);
            string nombreBBDD     = (string)this._infoBBDDView.GetValue(t, 2);

            //Comprobamos que está el usuario y si la tupla que tiene es del mismo (tipoBBDD,nombreBBDD)
            if (this._messages.ContainsKey(usuarioDestino))
            {
                Tuple <string, string, Dictionary <string, PipeMessage> > tupla = DevuelveTupla(usuarioDestino, tipoBBDD, nombreBBDD);

                if (tupla != null)
                {
                    int index = this._messages[usuarioDestino].IndexOf(tupla);

                    if (ComprobarTuplaConSchema(usuarioDestino, tipoBBDD, nombreBBDD))
                    {
                        PipeMessage pipeConexion = null;
                        if (this._messages[usuarioDestino][index].Item3.ContainsKey(Constants.CONNECTION))
                        {
                            pipeConexion = this._messages[usuarioDestino][index].Item3[Constants.CONNECTION];
                        }
                        else
                        {
                            Tuple <string, string, Dictionary <string, PipeMessage> > tuplaAuxiliar = DevuelveTupla(usuarioDestino, null, null);

                            int indexAuxiliar = this._messages[usuarioDestino].IndexOf(tuplaAuxiliar);
                            pipeConexion = this._messages[usuarioDestino][indexAuxiliar].Item3[Constants.CONNECTION];
                        }
                        PipeMessage pipeSchema = this._messages[usuarioDestino][index].Item3[Constants.SCHEMA];

                        this._connectionDialog = new ConnectionDialog(this._user.Nombre,
                                                                      usuarioDestino, tipoBBDD, nombreBBDD, pipeConexion, pipeSchema, this._claves);
                    }
                }
            }

            this._connectionDialog.Run();

            switch (this._connectionDialog.TypeOutPut)
            {
            case Constants.CANCEL:

                break;

            case Constants.MENSAJE_CONSULTA:
                Tuple <string, string, Dictionary <string, PipeMessage> > tupla = DevuelveTupla(usuarioDestino, tipoBBDD, nombreBBDD);

                int index = this._messages[usuarioDestino].IndexOf(tupla);
                if (this._messages[usuarioDestino][index].Item3.ContainsKey(Constants.SELECT))
                {
                    this._messages[usuarioDestino][index].Item3[Constants.SELECT] = this._connectionDialog.Select;
                }
                else
                {
                    this._messages[usuarioDestino][index].Item3.Add(Constants.SELECT, this._connectionDialog.Select);
                }

                MostrarSolicitudConsulta(this._connectionDialog.Select.MessageRequest);
                MostrarResultadoConsulta(this._connectionDialog.Select.MessageRequest, this._connectionDialog.Select.MessageResponse);

                break;

            case Constants.ERROR_CONNECTION:
                MostrarError(this._connectionDialog.TypeOutPut);
                break;
            }
        }
示例#30
0
 /// <summary>
 /// Gets a <see cref="FileReference"/> from a given path in the tree.
 /// </summary>
 /// <param name="gameContext">The game context for the reference.</param>
 /// <param name="path">The path in the tree.</param>
 /// <returns>The FileReference pointed to by the given TreePath.</returns>
 public FileReference GetReferenceByPath(IGameContext gameContext, TreePath path)
 {
     GetIter(out var iter, path);
     return(GetReferenceByIter(gameContext, iter));
 }
示例#31
0
        /*
         * Método evento para solicitar esquema BBDD. BOTON ESQUEMA
         * */
        protected void OnSchemaPngActionActivated(object sender, EventArgs e)
        {
            TreeIter t;
            TreePath p = treeviewDatabases.Selection.GetSelectedRows()[0];

            this._infoBBDDView.GetIter(out t, p);

            string usuarioDestino = (string)this._infoBBDDView.GetValue(t, 0);
            string tipoBBDD       = (string)this._infoBBDDView.GetValue(t, 1);
            string nombreBBDD     = (string)this._infoBBDDView.GetValue(t, 2);

            //Comprobamos que está el usuario y si la tupla que tiene es del mismo (tipoBBDD,nombreBBDD)
            if (this._messages.ContainsKey(usuarioDestino))
            {
                Tuple <string, string, Dictionary <string, PipeMessage> > tupla = DevuelveTupla(usuarioDestino, tipoBBDD, nombreBBDD);

                if (tupla == null)
                {
                    Tuple <string, string, Dictionary <string, PipeMessage> > firstTupla = DevuelvePrimeraTupla(usuarioDestino);
                    int index = this._messages[usuarioDestino].IndexOf(firstTupla);

                    PipeMessage pipeConexion = this._messages[usuarioDestino][index].Item3[Constants.CONNECTION];

                    this._connectionDialog = new ConnectionDialog(this._user.Nombre, usuarioDestino, tipoBBDD, nombreBBDD, pipeConexion, this._claves);
                }
                else
                {
                    int index = this._messages[usuarioDestino].IndexOf(tupla);

                    if (!ComprobarTuplaConSchema(usuarioDestino, tipoBBDD, nombreBBDD))
                    {
                        PipeMessage pipeConexion = this._messages[usuarioDestino][index].Item3[Constants.CONNECTION];

                        this._connectionDialog = new ConnectionDialog(this._user.Nombre, usuarioDestino, tipoBBDD, nombreBBDD, pipeConexion, this._claves);
                    }
                }
            }

            this._connectionDialog.Run();

            switch (this._connectionDialog.TypeOutPut)
            {
            case Constants.CANCEL:

                break;

            case Constants.MENSAJE_ESQUEMA:

                if (!ComprobarTuplaConSchema(usuarioDestino, tipoBBDD, nombreBBDD))
                {
                    Tuple <string, string, Dictionary <string, PipeMessage> > tuplaa = DevuelveTupla(usuarioDestino, tipoBBDD, nombreBBDD);

                    if (tuplaa != null)
                    {
                        //Añadimos un nuevo pipeMessage a la tupla existente
                        int indexx = this._messages[usuarioDestino].IndexOf(tuplaa);
                        this._messages[usuarioDestino][indexx].Item3.Add(Constants.SCHEMA, this._connectionDialog.Schema);
                    }
                    else
                    {
                        Tuple <string, string, Dictionary <string, PipeMessage> > tuplaDiferente = DevuelvePrimeraTupla(usuarioDestino);

                        //Añadimos una nueva tupla
                        Dictionary <string, PipeMessage> diccionarioNuevo = new Dictionary <string, PipeMessage>();
                        //diccionarioNuevo.Add(Constants.CONNECTION, tuplaDiferente.Item3[Constants.CONNECTION]);
                        diccionarioNuevo.Add(Constants.SCHEMA, this._connectionDialog.Schema);
                        Tuple <string, string, Dictionary <string, PipeMessage> > tuplaNueva = new Tuple <string, string, Dictionary <string, PipeMessage> >(tipoBBDD, nombreBBDD, diccionarioNuevo);
                        this._messages[usuarioDestino].Add(tuplaNueva);
                    }
                }

                MostrarSolicitudEsquema(this._connectionDialog.Schema.MessageRequest);
                MostrarEsquema(this._connectionDialog.Schema.MessageResponse);
                break;

            case Constants.ERROR_CONNECTION:
                MostrarError(this._connectionDialog.TypeOutPut);
                break;
            }
        }
示例#32
0
 bool IsIterSelected(TreePath selPath, TreeIter iter)
 {
     return(selPath != null && store.GetPath(iter).Equals(selPath));
 }
示例#33
0
        /// <summary>
        /// Sets the active document as selected by the user
        /// </summary>
        private bool HandleDocumentSelected(TreeSelection selection, TreeModel model, TreePath path, bool path_currently_selected)
        {
            int index = path.Indices[0];

            if (!path_currently_selected && index != PintaCore.Workspace.ActiveDocumentIndex)
            {
                PintaCore.Workspace.SetActiveDocument(index);
            }

            return(true);
        }
示例#34
0
        private void Redraw(Cairo.Context cr)
        {
            // Clear the background
            cr.Rectangle(0, 0, Allocation.Width, Allocation.Height);
            Gdk.CairoHelper.SetSourceColor(cr, Style.Base(State));
            cr.Fill();

            if (model == null)
            {
                if (hadj != null)
                {
                    hadj.Upper = hadj.Lower = 0;
                    hadj.Change();
                }

                if (vadj != null)
                {
                    vadj.Upper = 0;
                    vadj.Change();
                }
                return;
            }

            if (rows == 0 || cols == 0)
            {
                return;
            }

            Gdk.Rectangle background_area = cell_size;
            background_area.Width  += padding;
            background_area.Height += padding;

            TreeIter iter;

            if (model.GetIterFirst(out iter))
            {
                do
                {
                    TreePath path = model.GetPath(iter);

                    int x, y;
                    GetCellPosition(path.Indices[0], out x, out y);

                    if (hadj != null &&
                        (x + cell_size.Width < hadj.Value ||
                         x > hadj.Value + hadj.PageSize))
                    {
                        continue;
                    }

                    if (vadj != null &&
                        (y + cell_size.Height < vadj.Value ||
                         y > vadj.Value + vadj.PageSize))
                    {
                        continue;
                    }

                    if (data_func != null)
                    {
                        data_func(this, renderer, model, iter);
                    }

                    cell_size.X = x;
                    cell_size.Y = y;

                    if (hadj != null)
                    {
                        cell_size.X -= (int)hadj.Value;
                    }

                    if (vadj != null)
                    {
                        cell_size.Y -= (int)vadj.Value;
                    }

                    background_area.X = cell_size.X - (padding / 2);
                    background_area.Y = cell_size.Y - (padding / 2);

                    cr.Rectangle(background_area.X, background_area.Y,
                                 background_area.Width, background_area.Height);
                    cr.Clip();

                    renderer.Render(cr, this, background_area,
                                    cell_size, GetCellState(path));

                    cr.ResetClip();
                } while (model.IterNext(ref iter));
            }

            if (have_rubberband_selection)
            {
                int hadj_val = (hadj != null) ? (int)hadj.Value : 0;
                int vadj_val = (vadj != null) ? (int)vadj.Value : 0;

                cr.Rectangle(sel_rect.X - hadj_val + 0.5f, sel_rect.Y - vadj_val + 0.5f,
                             sel_rect.Width, sel_rect.Height);

                Cairo.Color sel_cairo_color = CairoHelper.GetCairoColor(Style.Background(StateType.Selected));



                //cr.Color = sel_cairo_color;
                cr.SetSourceRGBA(sel_cairo_color.R, sel_cairo_color.G, sel_cairo_color.B, sel_cairo_color.A);

                cr.LineWidth = 1.0f;
                cr.StrokePreserve();

                sel_cairo_color.A = 0.3f;
                //cr.Color = sel_cairo_color;
                cr.SetSourceRGBA(sel_cairo_color.R, sel_cairo_color.G, sel_cairo_color.B, sel_cairo_color.A);

                cr.Fill();
            }
        }
            public void Remove(ObservingGamePage page)
            {
                // remove page
                int num = gamesBook.PageNum (page);
                // unobserve
                TreePath path =
                    new TreePath (new int[]{ num });
                TreeIter iter;
                gamesStore.GetIter (out iter, path);
                gamesStore.Remove (ref iter);

                if (page.NeedsUnobserve)
                    client.CommandSender.
                        SendCommand ("unobserve " +
                                 page.GameId);
                gamesBook.RemovePage (num);
                currentGames.Remove (page.GameId);
                AdjustCursorForCurrentPage ();
                if (GamePageRemovedEvent != null)
                    GamePageRemovedEvent (this,
                                  EventArgs.
                                  Empty);
            }
示例#36
0
 private bool PathIsValid(TreePath path)
 {
     return(PathIsValid(path, n_cells));
 }
            public void Update(MoveDetails details)
            {
                if (!currentGames.
                    ContainsKey (details.gameNumber))
                  {
                      AddGamePage (details);
                      return;
                  }

                ObservingGamePage info = (ObservingGamePage)
                    currentGames[details.gameNumber];
                info.Update (details);
                int num = gamesBook.PageNum (info);
                if (num == gamesBook.CurrentPage)
                    return;

                TreePath path =
                    new TreePath (new int[]{ num });
                TreeIter iter;
                gamesStore.GetIter (out iter, path);
                string text =
                    (string) gamesStore.GetValue (iter,
                                      1);
                string markup =
                    String.Format ("<b>{0}</b>", text);
                gamesStore.SetValue (iter, 0, markup);
            }
示例#38
0
        private void OnDataRowDeleted(object o, RowDeletedArgs args)
        {
            if (model == null || args.Path == null)
            {
                return;
            }

            bool sel_paths_changed = false;

            // Don't update the real n_cells, as doing this will
            // throw off ScrollToPath if called before SizeAllocate
            // is run
            int n_cells = model.IterNChildren();

            for (int i = 0; i < selected_paths.Count; i++)
            {
                TreePath path = (TreePath)selected_paths[i];

                int cmp = path.Compare(args.Path);
                if (cmp == 0)
                {
                    selected_paths.RemoveAt(i);
                    i--;
                    sel_paths_changed = true;
                    continue;
                }

                // decrement each path that follows the one we
                // just deleted
                if (cmp > 0)
                {
                    path.Prev();
                    selected_paths[i] = path;
                    continue;
                }
            }

            if (sel_paths_changed && SelectionChanged != null)
            {
                SelectionChanged(this, new EventArgs());
            }

            if (focused_path != null &&
                focused_path.Equals(args.Path))
            {
                focused_path = focused_path.Copy();

                // try to advance the focus forward
                focused_path.Next();

                if (!PathIsValid(focused_path, n_cells) &&
                    !focused_path.Prev())
                {
                    focused_path = null;
                }
            }

            if (selection_anchor != null &&
                selection_anchor.Equals(args.Path))
            {
                selection_anchor = null;
            }

            QueueResize();
        }
示例#39
0
 public static void Serialize(TreePath value, TextWriter sw)
 {
     sw.Write('"');
     sw.Write(value.ToString());
     sw.Write('"');
 }
示例#40
0
 public bool PathIsSelected(TreePath path)
 {
     return(selected_paths.Contains(path));
 }
示例#41
0
        public TaskNameColumn()
        {
            TreeViewColumn = new TreeViewColumn {
                Title = Catalog.GetString ("Task Name"),
                Sizing = TreeViewColumnSizing.Autosize,
                Expand = true,
                Resizable = true
            };

            // TODO: Add in code to determine how wide we should make the name
            // column.
            // TODO: Add in code to readjust the size of the name column if the
            // user resizes the Task Window.
            //column.FixedWidth = 250;

            var renderer = new CellRendererText { Editable = true };

            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);
                if (model.GetIter (out iter, path)) {
                    var task = model.GetValue (iter, 0) as ITask;
                    if (task == null)
                        return;

                    var newText = args.NewText;
                    // Attempt to derive due date information from text.
                    if (preferences.GetBool (PreferencesKeys.ParseDateEnabledKey) &&
                        task.State == TaskState.Active &&
                        task.DueDate == DateTime.MinValue) {

                        string parsedTaskText;
                        DateTime parsedDueDate;
                        TaskParser.Instance.TryParse (newText, out parsedTaskText, out parsedDueDate);

                        if (parsedDueDate != DateTime.MinValue)
                            task.DueDate = parsedDueDate;
                        newText = parsedTaskText;
                    }

                    task.Text = newText;
                }
                EndCellEditing ();
            };

            TreeViewColumn.PackStart (renderer, true);
            TreeViewColumn.SetCellDataFunc (renderer, TaskNameTextCellDataFunc);
        }
示例#42
0
 public void ScrollToPath(TreePath path)
 {
     ScrollToPath(path, false, 0f, 0f);
 }
		/// <summary>
		/// Searches for node in Items
		/// </summary>
		public override TreePath PathFromNode (object aNode)
		{
			TreePath tp = new TreePath();
			if ((aNode == null) || (DataSource == null) || (GetItemCount() == 0))
				return (tp);

			int idx = GetItemIndex (aNode);
			if (idx >= 0)
				tp.AppendIndex (idx);
			return (tp);
		}
示例#44
0
 public void ScrollToPath(TreePath path, float row_align, float col_align)
 {
     ScrollToPath(path, true, row_align, col_align);
 }
            private void WhiteMove(MoveDetails details)
            {
                TreeIter iter;
                TreePath path;
                if (FindMoveRow
                    (details.movenumber, out path, out iter))
                  {
                      store.SetValue (iter,
                              WHITE_MOVE_COL,
                              GetMove (details));
                      store.SetValue (iter,
                              WHITE_MOVE_DETAILS_COL,
                              details);
                  }
                else
                  {
                      iter = store.AppendValues (details.
                                     movenumber,
                                     GetMove
                                     (details),
                                     null,
                                     details,
                                     null);
                      path = new TreePath (new int[]
                                   {
                                   total_rows});
                      total_rows++;
                  }

                blacksMoveNext = true;
                if (!autoAppend)
                    return;
                SetHighlighted (iter, path.Indices[0],
                        WHITE_MOVE_COL);

                ScrollToCell (path,
                          GetColumn (WHITE_MOVE_COL),
                          false, 0, 0);
            }
示例#46
0
        protected override bool OnKeyPressEvent(Gdk.EventKey ev)
        {
            if (model == null)
            {
                return(false);
            }

            int      r, c;
            TreePath tmp;

            // Lame workaround for GtkBinding not being bound
            switch (ev.Key)
            {
            // Activate keycodes
            case Gdk.Key.space:
            case Gdk.Key.Return:
            case Gdk.Key.ISO_Enter:
            case Gdk.Key.KP_Enter:
                // Remove this when we can use OnActivate ()
                if (focused_path == null)
                {
                    return(false);
                }

                if ((ev.State & Gdk.ModifierType.ControlMask) == 0)
                {
                    UnselectAll();
                }

                if (selected_paths.Contains(focused_path))
                {
                    UnselectPath(focused_path);
                }
                else
                {
                    SelectPath(focused_path);
                }

                if (ItemActivated != null)
                {
                    ItemActivatedArgs activated_args = new ItemActivatedArgs();
                    activated_args.Args = new object[] { focused_path };
                    ItemActivated(this, activated_args);
                }

                return(true);

            case Gdk.Key.a:
                // if control down, select all
                if (selection_mode == SelectionMode.Multiple &&
                    (ev.State & Gdk.ModifierType.ControlMask) > 0)
                {
                    SelectAll();
                }
                return(true);

            case Gdk.Key.A:
                // if control down and shift down, unselect all
                if (selection_mode == SelectionMode.Multiple &&
                    (ev.State & Gdk.ModifierType.ControlMask) > 0 &&
                    (ev.State & Gdk.ModifierType.ShiftMask) > 0)
                {
                    UnselectAll();
                }
                return(true);

            case Gdk.Key.Up:
            case Gdk.Key.KP_Up:
                // Move focus or selection up
                if (layout_mode == LayoutMode.Vertical ||
                    layout_mode == LayoutMode.Grid)
                {
                    // find out the currently focused r and c
                    GetRowAndColForPath(focused_path, out r, out c);

                    // decrement the row by 1
                    if (r > 0)
                    {
                        r--;

                        // find the path at new r, c
                        if (GetPathAtRowAndCol(r, c, out tmp))
                        {
                            focused_path = tmp;
                        }
                    }
                }
                break;

            case Gdk.Key.Down:
            case Gdk.Key.KP_Down:
                // move down
                if (layout_mode == LayoutMode.Vertical ||
                    layout_mode == LayoutMode.Grid)
                {
                    // find out the currently focused r and c
                    GetRowAndColForPath(focused_path, out r, out c);

                    // increment the row by 1
                    r++;

                    // find the path at new r, c
                    if (GetPathAtRowAndCol(r, c, out tmp))
                    {
                        focused_path = tmp;
                    }
                }
                break;

            case Gdk.Key.Left:
            case Gdk.Key.KP_Left:
                // move left
                if (layout_mode == LayoutMode.Horizontal ||
                    layout_mode == LayoutMode.Grid)
                {
                    tmp = focused_path.Copy();

                    // don't wrap around
                    if (tmp.Prev())
                    {
                        focused_path = tmp;
                    }
                }
                break;

            case Gdk.Key.Right:
            case Gdk.Key.KP_Right:
                // move right
                if (layout_mode == LayoutMode.Horizontal ||
                    layout_mode == LayoutMode.Grid)
                {
                    tmp = focused_path.Copy();
                    tmp.Next();

                    if (PathIsValid(tmp))
                    {
                        focused_path = tmp;
                    }
                }
                break;

            case Gdk.Key.Home:
            case Gdk.Key.KP_Home:
                // select and focus the first item, dropping
                // current selection
                tmp = TreePath.NewFirst();

                // verify that the path is valid
                if (PathIsValid(tmp))
                {
                    selected_paths.Clear();
                    focused_path = tmp;
                    SelectPath(focused_path);
                }
                return(true);

            case Gdk.Key.End:
            case Gdk.Key.KP_End:
                // select and focus the first item, dropping
                // current selection
                tmp = new TreePath(new int[] { n_cells - 1 });

                // verify that the path is valid
                if (PathIsValid(tmp))
                {
                    selected_paths.Clear();
                    focused_path = tmp;
                    SelectPath(focused_path);
                }
                return(true);
            }

            if (selection_mode == SelectionMode.Multiple &&
                (ev.State & Gdk.ModifierType.ShiftMask) > 0)
            {
                selected_paths.Clear();
                SelectAllBetween(selection_anchor, focused_path);
                return(true);
            }

            if (selection_mode == SelectionMode.Browse)
            {
                SelectPath(focused_path);
            }
            else
            {
                // TODO: Constrain this to only the previous focus and
                QueueDraw();
            }

            return(true);
        }
            private MoveDetails GetMove(int row, int col)
            {
                // now check if this is present
                int idx =
                    col ==
                    WHITE_MOVE_COL ?
                    WHITE_MOVE_DETAILS_COL :
                    BLACK_MOVE_DETAILS_COL;
                TreePath path =
                    new TreePath (new int[]{ row });
                TreeIter iter;
                if (!store.GetIter (out iter, path))
                    return null;

                MoveDetails details = store.GetValue (iter,
                                      idx) as
                    MoveDetails;
                if (details == null)
                    return null;

                SetHighlighted (iter, row, col);
                autoAppend = IsLastMove (row, col);
                ScrollToCell (path,
                          GetColumn (col), false, 0, 0);
                return details;
            }
示例#48
0
        protected override bool OnMotionNotifyEvent(Gdk.EventMotion ev)
        {
            if (!have_rubberband_selection)
            {
                return(false);
            }

            int x, y;

            Gdk.ModifierType state;
            if (ev.IsHint)
            {
                GdkWindow.GetPointer(out x, out y, out state);
            }
            else
            {
                x     = (int)ev.X;
                y     = (int)ev.Y;
                state = ev.State;
            }

            if (hadj != null)
            {
                x += (int)hadj.Value;
            }

            if (vadj != null)
            {
                y += (int)vadj.Value;
            }

            sel_rect.X      = Math.Min(sel_start.X, x);
            sel_rect.Y      = Math.Min(sel_start.Y, y);
            sel_rect.Width  = Math.Abs(sel_start.X - x);
            sel_rect.Height = Math.Abs(sel_start.Y - y);

            ArrayList tmp;

            if ((ev.State & Gdk.ModifierType.ControlMask) > 0)
            {
                tmp = (ArrayList)pre_rubberbanded_selection.Clone();
            }
            else
            {
                tmp = new ArrayList();
            }

            for (int i = 0; i < n_cells; i++)
            {
                GetCellPosition(i, out x, out y);

                cell_size.X = x;
                cell_size.Y = y;

                if (!cell_size.IntersectsWith(sel_rect))
                {
                    continue;
                }

                TreePath new_path = new TreePath(new int[] { i });
                if ((ev.State & Gdk.ModifierType.ControlMask) > 0)
                {
                    // If control is down and we highlight
                    // something that was selected before we
                    // started rubberbanding, deselect it
                    int index = tmp.IndexOf(new_path);
                    if (index >= 0)
                    {
                        tmp.RemoveAt(index);
                        continue;
                    }
                }

                tmp.Add(new_path);
            }

            // find out if selection has changed since last time
            bool dirty = false;

            if (selected_paths.Count != tmp.Count)
            {
                dirty = true;
            }
            else
            {
                for (int i = 0; i < selected_paths.Count; i++)
                {
                    if (!((TreePath)selected_paths[i]).Equals((TreePath)tmp[i]))
                    {
                        dirty = true;
                        break;
                    }
                }
            }

            selected_paths = tmp;

            if (dirty && SelectionChanged != null)
            {
                SelectionChanged(this, new EventArgs());
            }

            QueueDraw();

            return(true);
        }
 static bool TreeViewSelection(TreeSelection selection, TreeModel model, TreePath path, bool path_currently_selected)
 {
     return(false);
 }
示例#50
0
        void CellRendererEdited(CellRendererTextAdv sender,
                                string pathStr, string newText, int colNum)
        {
            TreeModelSort model = (TreeModelSort)treeDebaters.Model;
            TreePath      path  = new TreePath(pathStr);
            TreeIter      iter  = TreeIter.Zero;

            model.GetIter(out iter, path);

            EditableDebater d = (EditableDebater)model.GetValue(iter, 0);


            try {
                ColumnInfo prop = columns[treeDebaters.Columns[colNum].Title];
                // This parses the given new string,
                // and updates the data in store
                prop.parseAndSet(d, newText);

                // existing Debater: Update Data in (possibly) existing Rounds
                // tries to keep data consisting, but there's no guarantee
                // BlackList/WhiteList and ExtraInfo are not
                // used in RoundDebater, so skip this by condition colNum<4
                if (newDebaterPath == null && colNum < 4)
                {
                    var rd = new EditableDebater(d);
                    var p  = prop.get(d);

                    // Only simple Renaming of Role is possible if Rounds exist
                    if (colNum == 3 &&
                        Tournament.I.Rounds.Count > 0 &&
                        ((d.Role.IsTeamMember != rd.Role.IsTeamMember) ||
                         (d.Role.IsJudge != rd.Role.IsJudge)))
                    {
                        MiscHelpers.ShowMessage(this, "Changing Role from Judge to TeamMember (or vice versa)" +
                                                " is not possible since Rounds are already set.", MessageType.Error);
                        // reset to old role...
                        d.Role = rd.Role;
                        return;
                    }

                    // check if new TeamName is already present
                    if (colNum == 3 && d.Role.IsTeamMember)
                    {
                        int n = 0;
                        foreach (object[] row in store)
                        {
                            EditableDebater d_ = (EditableDebater)row[0];
                            if (!d.Equals(d_) && d_.Role.TeamName == d.Role.TeamName)
                            {
                                n++;
                            }
                        }
                        if (n == 3)
                        {
                            MiscHelpers.ShowMessage(this, "New TeamName is already present in three other Debaters.",
                                                    MessageType.Error);
                            // reset to old role...
                            d.Role = rd.Role;
                            return;
                        }
                    }

                    // check for duplicate
                    if (colNum < 3)
                    {
                        // need a temporary flag, throwing exceptions in delegates doesnt work...
                        // the following flag stuff isn't elegant, but it should work
                        bool flag = false;
                        model.Foreach((model_, _, iter_) => {
                            if (!iter.Equals(iter_))
                            {
                                EditableDebater d_ = (EditableDebater)model_.GetValue(iter_, 0);
                                if (d_.Equals(d))
                                {
                                    // reset to old value...
                                    prop.get(rd).Set(d);
                                    flag = true;
                                    return(true);
                                }
                            }
                            return(false);
                        });
                        if (flag)
                        {
                            throw new TargetInvocationException(new Exception("Debater exists."));
                        }
                    }

                    // keep data consistent in existing rounds
                    foreach (RoundData round in Tournament.I.Rounds)
                    {
                        foreach (RoomData room in round.Rooms)
                        {
                            foreach (RoundDebater rd_ in room.GetRoomMembers())
                            {
                                if (rd_ == null)
                                {
                                    continue;
                                }
                                if (rd_.Equals(rd))
                                {
                                    p.UnsafeSetRoundDebater(rd_);
                                }
                                if (rd_.Role.TeamName == rd.Role.TeamName)
                                {
                                    rd_.Role.TeamName = d.Role.TeamName;
                                }
                            }
                        }
                        if (rd.Role.IsTeamMember)
                        {
                            foreach (TeamData team in round.AllTeams)
                            {
                                foreach (RoundDebater rd_ in team)
                                {
                                    if (rd_.Equals(rd))
                                    {
                                        p.UnsafeSetRoundDebater(rd_);
                                    }
                                    if (rd_.Role.TeamName == rd.Role.TeamName)
                                    {
                                        rd_.Role.TeamName = d.Role.TeamName;
                                    }
                                }
                            }
                        }
                        else if (rd.Role.IsJudge)
                        {
                            foreach (RoundDebater rd_ in round.AllJudges)
                            {
                                if (rd_.Equals(rd))
                                {
                                    p.UnsafeSetRoundDebater(rd_);
                                }
                            }
                        }
                    }

                    // Renaming TeamName needs extra Handling
                    if (colNum == 3 && rd.Role.IsTeamMember && d.Role.IsTeamMember)
                    {
                        foreach (object[] row in store)
                        {
                            EditableDebater d_ = (EditableDebater)row[0];
                            if (d_.Role.TeamName == rd.Role.TeamName)
                            {
                                d_.Role.TeamName = d.Role.TeamName;
                            }
                        }
                    }
                }
                // newDebater is entered...
                else if (newDebaterPath != null && colNum < 3)
                {
                    // continue with entering data (goto next column)
                    // as idle so that cells are resized
                    GLib.Idle.Add(delegate {
                        treeDebaters.SetCursor(ConvertStorePathToModelPath(newDebaterPath),
                                               treeDebaters.Columns[colNum + 1], true);
                        return(false);
                    });
                }
                else if (newDebaterPath != null)
                {
                    // new Debater entered completely (at least all necessary data)
                    iter = TreeIter.Zero;
                    if (store.GetIter(out iter, newDebaterPath))
                    {
                        // as idle to prevent gtk critical (no idea why this happens)
                        GLib.Idle.Add(delegate {
                            store.Remove(ref iter);
                            newDebaterPath = null;
                            if (IsNotInStore(d))
                            {
                                store.AppendValues(d);
                                SaveDebaters();
                            }
                            else
                            {
                                MiscHelpers.ShowMessage(this, "Debater exists.", MessageType.Error);
                            }
                            UpdateDebatersInfo();
                            btnDebaterAdd.GrabFocus();
                            return(false);
                        });
                    }
                }

                // Gui stuff
                treeDebaters.ColumnsAutosize();
                // ugly method of resorting the TreeSortModel...
                SortType st;
                int      sortColumn;
                model.GetSortColumnId(out sortColumn,
                                      out st);
                if (st == SortType.Descending)
                {
                    model.SetSortColumnId(sortColumn, SortType.Ascending);
                    model.SetSortColumnId(sortColumn, SortType.Descending);
                }
                else
                {
                    model.SetSortColumnId(sortColumn, SortType.Descending);
                    model.SetSortColumnId(sortColumn, SortType.Ascending);
                }

                // save data from store if not adding new debater
                if (newDebaterPath == null)
                {
                    SaveDebaters();
                }
            }
            catch (TargetInvocationException e) {
                MessageDialog md = new MessageDialog(this, DialogFlags.Modal,
                                                     MessageType.Error,
                                                     ButtonsType.OkCancel,
                                                     e.InnerException.Message + ". Try again?");
                md.DefaultResponse = ResponseType.Ok;
                ResponseType r = (ResponseType)md.Run();
                md.Destroy();
                if (r == ResponseType.Ok)
                {
                    // As Idle otherwise Editable isn't destroyed correctly
                    GLib.Idle.Add(delegate {
                        sender.TempEditString = newText;
                        treeDebaters.SetCursor(path, treeDebaters.Columns[colNum], true);
                        return(false);
                    });
                }
                else
                {
                    if (newDebaterPath == null)
                    {
                        return;
                    }
                    iter = TreeIter.Zero;
                    if (store.GetIter(out iter, newDebaterPath))
                    {
                        // remove not finished new debater,
                        // with idle call,
                        // prevents Gtk critical filter model assertion.
                        GLib.Idle.Add(delegate {
                            newDebaterPath = null;
                            store.Remove(ref iter);
                            return(false);
                        });
                    }
                }
            }
        }
		/// <summary>
		/// Returns node at specified path
		/// </summary>
		public override object GetNodeAtPath (TreePath aPath)
		{
			return (null);
		}
示例#52
0
 public bool IsLeaf(TreePath treePath)
 {
     return(((CrackNode)treePath.LastNode).Children.Count == 0);
 }
示例#53
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);
        }
示例#54
0
 public System.Collections.IEnumerable GetChildren(TreePath treePath)
 {
     return(Children);
 }
            private void OnCursorChanged(object o,
						      System.EventArgs args)
            {
                TreePath path;
                TreeViewColumn col;
                view.GetCursor (out path, out col);
                ArrayList moves = new ArrayList ();

                TreePath tmppath = new TreePath ();
                foreach (int i in path.Indices)
                {
                    tmppath.AppendIndex (i);
                    TreeIter iter;
                    store.GetIter (out iter, tmppath);
                    moves.Add (store.GetValue (iter, 0));
                }

                boardWidget.PlayMoves (moves);
            }
 //UPGRADE_NOTE: The equivalent of method 'javax.swing.tree.TreeModel.valueForPathChanged' is not an override method. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1143_3"'
 //UPGRADE_ISSUE: Class 'javax.swing.tree.TreePath' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaxswingtreeTreePath_3"'
 public virtual void valueForPathChanged(TreePath path, System.Object newValue)
 {
     System.Console.Out.WriteLine("heh, who is calling this mystery method?");
 }