Esempio n. 1
0
        private void ScrollToCell(Rect targetCell)
        {
            double deltaX = 0;
            double deltaY = 0;

            if (targetCell.Left < 0)
            {
                deltaX = targetCell.Left;
            }
            else if (this.ActualWidth < targetCell.Right)
            {
                deltaX = targetCell.Right - (this.ActualWidth);
            }

            if (targetCell.Top < 0)
            {
                deltaY = targetCell.Top;
            }
            else if (this.ActualHeight < targetCell.Bottom)
            {
                deltaY = targetCell.Bottom - (this.ActualHeight);
            }

            double resHorOffset  = Math.Max(0, MainScrollView.HorizontalOffset + deltaX);
            double resVertOffset = Math.Max(0, MainScrollView.VerticalOffset + deltaY);

            MainScrollView.ScrollToHorizontalOffset(resHorOffset);
            MainScrollView.ScrollToVerticalOffset(resVertOffset);
        }
Esempio n. 2
0
        /// <summary>
        /// Adds a FolderDisplay object to the UI's column view
        /// </summary>
        /// <param name="fd">FolderDisplay object to add</param>
        /// <param name="readd">Whether this FolderDisplay should be re-added to the displayList</param>
        private void addToTable(FolderDisplay fd, bool readd = true)
        {
            //create the grid separator

            /*ContentGrid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(5) });
             * GridSplitter gs = new GridSplitter() { Width = 5 };
             * ContentGrid.Children.Add(gs);
             * Grid.SetColumn(gs, ContentGrid.ColumnDefinitions.Count - 1);
             * Grid.SetRow(gs, 1);*/

            //add the datagrid
            ContentGrid.ColumnDefinitions.Add(new ColumnDefinition()
            {
                Width = new GridLength(1, GridUnitType.Star)
            });
            ContentGrid.Children.Add(fd.dg);
            Grid.SetRow(fd.dg, 1);
            Grid.SetColumn(fd.dg, ContentGrid.ColumnDefinitions.Count - 1);

            Label l = new Label()
            {
                Content = fd.folderData.path.Name + " - " + fd.totalSizeFormatted()
            };

            ContentGrid.Children.Add(l);
            Grid.SetRow(l, 0);
            Grid.SetColumn(l, ContentGrid.ColumnDefinitions.Count - 1);

            if (readd)
            {
                displayList.Add(fd);
            }

            //scroll to end
            MainScrollView.ScrollToHorizontalOffset(System.Int32.MaxValue);
            MainScrollView.UpdateLayout();
        }