Example #1
0
        public void update()
        {
            double ActualWidths  = ActualWidth - 60;
            double ActualHeights = ActualHeight - 60 - 60;

            VisiableGrid.Children.Clear();
            VisiableGrid.ColumnDefinitions.Clear();
            VisiableGrid.RowDefinitions.Clear();
            int    cnt             = (int)Math.Floor(ActualWidths / 266.25); // Visiable Area Length ( Widths )
            int    hcnt            = (int)Math.Floor(ActualHeights / 171);
            int    shouldShowDatas = TeamData.files == null ? 0 : TeamData.files.Length;
            int    count           = page == 0 ? 0 : page * cnt * hcnt;
            double another         = ActualWidths - cnt * 266.25; // Side Area check ( Cause we will make this to center )
            double tanother        = ActualHeights - (hcnt * 171);
            int    current         = -3;
            int    rcurrent        = -3;

            control.setMaxPage(shouldShowDatas > cnt * hcnt ? (int)Math.Ceiling(shouldShowDatas / (double)(cnt * hcnt)) : 1);
            RowDefinition row = new RowDefinition();

            if (another > 0)
            {
                ColumnDefinition col = new ColumnDefinition();
                col.Width = new GridLength(another / 2);
                VisiableGrid.ColumnDefinitions.Add(col);
                current++;
            }
            if (tanother > 0)
            {
                row        = new RowDefinition();
                row.Height = new GridLength(tanother / 2);
                VisiableGrid.RowDefinitions.Add(row);
                rcurrent++;
            }
            /*Adding Grid*/
            for (int j = 0; j < hcnt; j++)
            {
                row        = new RowDefinition();
                row.Height = new GridLength(10.5);
                VisiableGrid.RowDefinitions.Add(row);
                row        = new RowDefinition();
                row.Height = new GridLength(150);
                VisiableGrid.RowDefinitions.Add(row);
                row        = new RowDefinition();
                row.Height = new GridLength(10.5);
                VisiableGrid.RowDefinitions.Add(row);
            }
            for (int i = 0; i < cnt; i++)
            {
                ColumnDefinition col1 = new ColumnDefinition();
                col1.Width = new GridLength(30.25 / 2);
                ColumnDefinition col2 = new ColumnDefinition();
                col2.Width = new GridLength(236);
                ColumnDefinition col3 = new ColumnDefinition();
                col3.Width = new GridLength(30.25 / 2);
                VisiableGrid.ColumnDefinitions.Add(col1);
                VisiableGrid.ColumnDefinitions.Add(col2);
                VisiableGrid.ColumnDefinitions.Add(col3);
            }
            /* Setter */

            for (int i = 0; i < ((shouldShowDatas - (cnt * hcnt * page)) / cnt + 1 > hcnt ? hcnt : (shouldShowDatas - (cnt * hcnt * page)) / cnt + 1); i++)
            {
                rcurrent += 3;
                for (int j = 0; j < ((shouldShowDatas - (cnt * hcnt * page)) - (cnt * i) > cnt ? cnt : (shouldShowDatas - (cnt * hcnt * page)) - (cnt * i)); j++)
                {
                    current += 3;
                    ShareUI ui = new ShareUI();
                    ui.Width  = 236;
                    ui.Height = 150;
                    ui.setName(TeamData.files[count++]);
                    ui.setIndex(count - 1);
                    Grid.SetColumn(ui, current + 1);
                    Grid.SetRow(ui, rcurrent + 1);
                    VisiableGrid.Children.Add(ui);
                }
                current = another > 0 ? -2 : -3;
            }
            row        = new RowDefinition();
            row.Height = new GridLength(100);
            VisiableGrid.RowDefinitions.Add(row);

            control.Height = 60;
            Grid.SetRow(control, 3 * hcnt + 3);
            Grid.SetColumnSpan(control, 3 * cnt + (another > 0 ? 1 : 0) + 1);
            control.HorizontalAlignment = HorizontalAlignment.Center;
            control.VerticalAlignment   = VerticalAlignment.Top;
            VisiableGrid.Children.Add(control);
        }