コード例 #1
0
        /// <summary>
        /// Saves the TreePaths (expanded rows) of the selected assemblies in a file.
        /// </summary>
        ///
        private void SaveSelectedAssembliesTreePaths()
        {
            // Get the state of all the rows
            store.Foreach(ForeachRow);
            Gtk.TreePath       p = null;
            Gtk.TreeViewColumn c = null;

            // Get the current activated row
            assemblyTree.GetCursor(out p, out c);

            FileStream file = new FileStream(Path.Combine(reflector.GetConfigurationDirectory(),
                                                          "SolidReflector.session"), FileMode.Create,
                                             FileAccess.ReadWrite);

            // Save the states of the rows in file
            using (StreamWriter writer = new StreamWriter(file)) {
                foreach (string path in treePaths)
                {
                    writer.WriteLine(path.ToString());
                }

                // Save the current activated row so it will be reactivated when the app is restarted
                // The entry is saved last in the file
                writer.WriteLine(p.ToString());
                writer.Flush();
            }
        }
コード例 #2
0
 private bool ForeachRow(Gtk.TreeModel model, Gtk.TreePath path, Gtk.TreeIter iter)
 {
     if (assemblyTree.GetRowExpanded(path))
     {
         treePaths.Add(path.ToString());
     }
     return(false);
 }
コード例 #3
0
        public void GetPath()
        {
            Gtk.TreePath path;
            path = new Gtk.TreePath(GetPathCallback(0));
            Assert.AreEqual("0", path.ToString());

            path = new Gtk.TreePath(GetPathCallback(this._PastTheEndIndex - 1));
            int i = this._PastTheEndIndex - 1;

            Assert.AreEqual(i.ToString(), path.ToString());
        }
コード例 #4
0
        public Rectangle GetRowBounds(int row, bool includeMargin)
        {
            Gtk.TreePath path = new Gtk.TreePath(new [] { row });
            Gtk.TreeIter iter;
            if (!Widget.Model.GetIterFromString(out iter, path.ToString()))
            {
                return(Rectangle.Zero);
            }

            if (includeMargin)
            {
                return(GetRowBackgroundBounds(iter));
            }
            else
            {
                return(GetRowBounds(iter));
            }
        }
コード例 #5
0
        public Rectangle GetCellBounds(int row, CellView cell, bool includeMargin)
        {
            var col = GetCellColumn(cell);
            var cr  = GetCellRenderer(cell);

            Gtk.TreePath path = new Gtk.TreePath(new [] { row });

            Gtk.TreeIter iter;
            if (!Widget.Model.GetIterFromString(out iter, path.ToString()))
            {
                return(Rectangle.Zero);
            }

            if (includeMargin)
            {
                return(((ICellRendererTarget)this).GetCellBackgroundBounds(col, cr, iter));
            }
            else
            {
                return(((ICellRendererTarget)this).GetCellBounds(col, cr, iter));
            }
        }
コード例 #6
0
ファイル: ListViewBackend.cs プロジェクト: b-theile/xwt
        public Rectangle GetCellBounds(int row, CellView cell, bool includeMargin)
        {
            var col = GetCellColumn(cell);
            var cr  = GetCellRenderer(cell);

            Gtk.TreePath path = new Gtk.TreePath(new [] { row });

            Gtk.TreeIter iter;
            if (!Widget.Model.GetIterFromString(out iter, path.ToString()))
            {
                return(Rectangle.Zero);
            }

            col.CellSetCellData(Widget.Model, iter, false, false);

            Gdk.Rectangle rect = includeMargin ? Widget.GetBackgroundArea(path, col) : Widget.GetCellArea(path, col);

            int x, y, w, h;

            col.CellGetPosition(cr, out x, out w);
            col.CellGetSize(rect, out x, out y, out w, out h);

            return(new Rectangle(x, y, w, h));
        }
コード例 #7
0
ファイル: TreeModelIListTests.cs プロジェクト: bbriggs/wesay
		public void GetPath()
		{
			Gtk.TreePath path;
			path = new Gtk.TreePath(GetPathCallback(0));
			Assert.AreEqual("0", path.ToString());

			path = new Gtk.TreePath(GetPathCallback(this._PastTheEndIndex-1));
			int i = this._PastTheEndIndex -1;
			Assert.AreEqual(i.ToString(), path.ToString());
		}
コード例 #8
0
ファイル: ListViewBackend.cs プロジェクト: antmicro/xwt
        public Rectangle GetRowBounds(int row, bool includeMargin)
        {
            Gtk.TreePath path = new Gtk.TreePath (new [] { row });
            Gtk.TreeIter iter;
            if (!Widget.Model.GetIterFromString (out iter, path.ToString ()))
                return Rectangle.Zero;

            if (includeMargin)
                return GetRowBackgroundBounds (iter);
            else
                return GetRowBounds (iter);
        }
コード例 #9
0
ファイル: ListViewBackend.cs プロジェクト: antmicro/xwt
        public Rectangle GetCellBounds(int row, CellView cell, bool includeMargin)
        {
            var col = GetCellColumn (cell);
            var cr = GetCellRenderer (cell);
            Gtk.TreePath path = new Gtk.TreePath (new [] { row });

            Gtk.TreeIter iter;
            if (!Widget.Model.GetIterFromString (out iter, path.ToString ()))
                return Rectangle.Zero;

            if (includeMargin)
                return ((ICellRendererTarget)this).GetCellBackgroundBounds (col, cr, iter);
            else
                return ((ICellRendererTarget)this).GetCellBounds (col, cr, iter);
        }
コード例 #10
0
        /// <summary>
        /// Handles the drag data received event.
        /// </summary>
        /// <param name="o">The menu layout Gtk.TreeView.</param>
        /// <param name="args">The event data.</param>
        protected void HandleDragDataReceived(object o, Gtk.DragDataReceivedArgs args)
        {
            DebugDragDrop("HandleDragDataReceived");
            var treeView = o as Gtk.TreeView;

            Gtk.TreePath             path;
            Gtk.TreeViewDropPosition pos;
            if (treeView.GetDestRowAtPos(args.X, args.Y, out path, out pos))
            {
                DebugDragDrop("HandleDragDataReceived: path: " + path + " pos: " + pos);
            }

            Folder dropTarget     = null;
            int    insertLocation = -1;

            Gtk.TreeIter droppedOnItemIter;
            if (treeView.Model.GetIter(out droppedOnItemIter, path))
            {
                var droppedOnItem = treeView.Model.GetValue(droppedOnItemIter, 0) as FileNodeViewModel;
                dropTarget = droppedOnItem.Model as Folder;
                if (dropTarget == null)
                {
                    // Dropped on an item.
                    dropTarget = droppedOnItem.Parent as Folder;
                    switch (pos)
                    {
                    case Gtk.TreeViewDropPosition.Before:
                    case Gtk.TreeViewDropPosition.IntoOrBefore:
                        insertLocation = path.Indices.Last();     // insert before
                        break;

                    case Gtk.TreeViewDropPosition.After:
                    case Gtk.TreeViewDropPosition.IntoOrAfter:
                        insertLocation = path.Indices.Last() + 1;     // insert after
                        if (insertLocation >= dropTarget.Items.Count())
                        {
                            insertLocation = -1;
                        }
                        break;
                    }
                }
                else
                {
                    // Dropped on a folder.
                    switch (pos)
                    {
                    case Gtk.TreeViewDropPosition.Before:
                        dropTarget     = dropTarget.Parent as Folder;
                        insertLocation = path.Indices.Last();     // insert before folder
                        break;

                    case Gtk.TreeViewDropPosition.After:
                        dropTarget     = dropTarget.Parent as Folder;
                        insertLocation = path.Indices.Last() + 1;     // insert after folder
                        if (insertLocation >= dropTarget.Items.Count())
                        {
                            insertLocation = -1;
                        }
                        break;

                    case Gtk.TreeViewDropPosition.IntoOrBefore:
                        insertLocation = 0;     // insert at beginning of folder
                        break;

                    case Gtk.TreeViewDropPosition.IntoOrAfter:
                        insertLocation = -1;     // append at end of folder
                        break;
                    }
                }
            }
            else
            {
                // Append to end of root.
                pos        = Gtk.TreeViewDropPosition.After;
                dropTarget = ViewModel.HostPCMenuLayout.Model as Folder;
            }
            if (dropTarget != null)
            {
                var menuLayout = ViewModel.HostPCMenuLayout;
                if (args.Info == RomListViewModel.DragDropSourceDataIdentifier)
                {
                    DebugDragDrop("HandleDragDataReceived: Data from ROM list");
                    var itemsToAdd    = new List <ProgramDescription>();
                    var stringIndices = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data).Split('\n');
                    foreach (var stringIndex in stringIndices)
                    {
                        int index;
                        if (int.TryParse(stringIndex, out index))
                        {
                            var program = INTV.Shared.Model.Program.ProgramCollection.Roms[index];
                            if (program != null)
                            {
                                itemsToAdd.Add(program);
                            }
                        }
                    }
                    MenuLayoutViewModel.AddItems(menuLayout, dropTarget, itemsToAdd, insertLocation);
                }
                else if (args.Info == MenuLayoutViewModel.DragDataFormatIdentifier)
                {
                    DebugDragDrop("HandleDragDataReceived: Rearrange drop");
                    var itemsToMove = new List <FileNodeViewModel>();
                    var stringPaths = System.Text.Encoding.UTF8.GetString(args.SelectionData.Data).Split('\n');
                    foreach (var stringPath in stringPaths)
                    {
                        var          itemToMovePath = new Gtk.TreePath(stringPath);
                        Gtk.TreeIter itemIter;
                        if (treeView.Model.GetIter(out itemIter, itemToMovePath))
                        {
                            var fileNode = treeView.Model.GetValue(itemIter, 0) as FileNodeViewModel;
                            itemsToMove.Add(fileNode);
                            DebugDragDrop("HandleDragDataReceived: Plan to move: " + fileNode.LongName + " : " + itemToMovePath.ToString());
                        }
                    }
                    var newParent = menuLayout.FindViewModelForModel(dropTarget);
                    newParent.MoveItems(menuLayout, newParent, insertLocation, itemsToMove);
                }
            }
        }
コード例 #11
0
        public Rectangle GetCellBounds(int row, CellView cell, bool includeMargin)
        {
            var col = GetCellColumn (cell);
            var cr = GetCellRenderer (cell);
            Gtk.TreePath path = new Gtk.TreePath (new [] { row });

            Gtk.TreeIter iter;
            if (!Widget.Model.GetIterFromString (out iter, path.ToString ()))
                return Rectangle.Zero;

            col.CellSetCellData (Widget.Model, iter, false, false);

            Gdk.Rectangle rect = includeMargin ? Widget.GetBackgroundArea (path, col) : Widget.GetCellArea (path, col);

            int x, y, w, h;
            col.CellGetPosition (cr, out x, out w);
            col.CellGetSize (rect, out x, out y, out w, out h);

            return new Rectangle (x, y, w, h);
        }