Beispiel #1
0
        public override void SetContent()
        {
            base.SetContent();

            var gridRow = this.RowInfo as GridViewGroupRowInfo;

            if (gridRow == null)
            {
                return;
            }

            int  remainingFileCount = 0;
            long copiedBytes        = 0;
            long totalBytes         = 0;
            bool hasErrors          = false;

            foreach (var dataRow in RadGridViewHelper.GetChildDataRows(gridRow))
            {
                remainingFileCount = Math.Max(remainingFileCount, dataRow.Field <int>("remainingFileCount"));
                copiedBytes       += dataRow.Field <long>("copiedBytes");
                totalBytes        += dataRow.Field <long>("totalBytes");
                hasErrors         |= dataRow.Field <bool>("hasErrors");
            }

            _headerElement.Text     = gridRow.HeaderText;
            _hasErrorsElement.Image = hasErrors ? Resources.ExclamationRed : Resources.CheckedGreen;

            _progressElement.Value1 = totalBytes <= 0 ? 0 : Convert.ToInt32((double)copiedBytes / (double)totalBytes * 100);
            _progressElement.Text   = string.Format("{0} remaining ({1}/{2})", remainingFileCount, ByteSizeFriendlyName.Build(copiedBytes), ByteSizeFriendlyName.Build(totalBytes));
            _progressElement.IndicatorElement1.BackColor = (hasErrors || _progressElement.Value1 < 100) ? _defaultProgressBarColor : Color.LimeGreen;

            this.Text = string.Empty;
        }
Beispiel #2
0
        public override void Initialize(GridViewColumn column, GridRowElement row)
        {
            base.Initialize(column, row);

            var height = this.TableElement.GroupHeaderHeight + 8;

            _headerElement.Size    = new Size(this.ViewTemplate.Columns["destinationFolder"].Width, height);
            _progressElement.Size  = new Size(this.ViewTemplate.Columns["progressBar"].Width - 6, height - 6);
            _hasErrorsElement.Size = new Size(this.ViewTemplate.Columns["hasErrors"].Width, height);
            _stack.Size            = new Size(_headerElement.Size.Width + _progressElement.Size.Width + _hasErrorsElement.Size.Width, height);

            _stack.Margin = new Padding(Math.Max(0, 1 - row.RowInfo.HierarchyLevel) * this.TableElement.GroupIndent, 0, 0, 0);

            row.GridControl.Resize +=
                (s, e) =>
            {
                _headerElement.Size    = new Size(this.ViewTemplate.Columns["destinationFolder"].Width, height);
                _progressElement.Size  = new Size(this.ViewTemplate.Columns["progressBar"].Width - 6, height - 6);
                _hasErrorsElement.Size = new Size(this.ViewTemplate.Columns["hasErrors"].Width, height);
                _stack.Size            = new Size(_headerElement.Size.Width + _progressElement.Size.Width + _hasErrorsElement.Size.Width, height);
            };

            _progressElement.Visibility  = row.GridControl.AutoExpandGroups ? ElementVisibility.Hidden : ElementVisibility.Visible;
            _hasErrorsElement.Visibility = row.GridControl.AutoExpandGroups ? ElementVisibility.Hidden : ElementVisibility.Visible;

            row.GridControl.GroupExpanded +=
                (s, e) =>
            {
                var isExpanded = this.RowElement.GridControl != null && RadGridViewHelper.GetGroups(this.RowElement.GridControl.Groups).All(g => g.IsExpanded);

                _progressElement.Visibility  = isExpanded ? ElementVisibility.Hidden : ElementVisibility.Visible;
                _hasErrorsElement.Visibility = isExpanded ? ElementVisibility.Hidden : ElementVisibility.Visible;
            };


            // force grid to honor its AutoExpandGroups property when a group is initialized
            if (row.GridControl.AutoExpandGroups)
            {
                row.Data.Group.Expand();
            }
            else
            {
                row.Data.Group.Collapse();
            }
        }
Beispiel #3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            using (var theme = new VisualStudio2012DarkTheme())
                gridFiles.ThemeName = theme.ThemeName;

            gridFiles.DataSource = _fileInfos.DefaultView;
            gridFiles.Columns["remainingFileCount"].IsVisible = false;
            gridFiles.Columns["copiedBytes"].IsVisible        = false;
            gridFiles.Columns["totalBytes"].IsVisible         = false;

            gridFiles.ShowFilteringRow = false;
            gridFiles.ShowGroupPanel   = false;

            gridFiles.AutoExpandGroups = !this.ParentAgent.AutoCollapseGrid;
            gridFiles.GroupDescriptors.Add("machine", ListSortDirection.Ascending);
            gridFiles.GroupDescriptors.Add("sourceFolder", ListSortDirection.Ascending);

            var groupsExpanded = new Dictionary <DataGroup, bool>();

            this.RegisterObserver(
                AgentBroker.Instance.ObserveOne <bool>(this.ParentAgent.Id, "IsTransferringDataSource")
                .ObserveOn(WindowsFormsSynchronizationContext.Current)
                .Subscribe(
                    isTransferring =>
            {
                if (isTransferring)
                {
                    var subscription = _fileTransferSubscription;
                    if (subscription != null)
                    {
                        subscription.Dispose();
                    }

                    _fileTransferSubscription = SubscribeToFileTransferDataSource();
                }
                else
                {
                    _fileInfos.Rows.Clear();
                    groupsExpanded.Clear();
                }
            }));

            // fix a bug where the grid will expand all groups when a new row is added

            _fileInfos.RowChanging +=
                (ss, ee) =>
            {
                if (ee.Action == DataRowAction.Add)
                {
                    foreach (DataGroup group in RadGridViewHelper.GetGroups(gridFiles.Groups))
                    {
                        if (groupsExpanded.ContainsKey(group))
                        {
                            groupsExpanded[group] = group.IsExpanded;
                        }
                        else
                        {
                            groupsExpanded[group] = gridFiles.AutoExpandGroups;
                        }
                    }
                }
            };

            _fileInfos.RowChanged +=
                (ss, ee) =>
            {
                if (ee.Action == DataRowAction.Add)
                {
                    foreach (var ge in groupsExpanded)
                    {
                        if (ge.Value)
                        {
                            ge.Key.Expand();
                        }
                        else
                        {
                            ge.Key.Collapse();
                        }
                    }
                }
            };
        }