Пример #1
0
        private PropertyGridExportState SavePropertyGridState()
        {
            PropertyGridExportState propertyGridExportState = new PropertyGridExportState()
            {
                SelectedItem = this.propertyGrid.SelectedGridItem, HorizontalScrollbarValue = this.propertyGrid.PropertyGridElement.PropertyTableElement.HScrollBar.Value, VerticalScrolbarValue = this.propertyGrid.PropertyGridElement.PropertyTableElement.VScrollBar.Value
            };

            this.propertyGrid.SelectedGridItem = (PropertyGridItemBase)null;
            int num = 0;
            Queue <PropertyGridItemBase> propertyGridItemBaseQueue = new Queue <PropertyGridItemBase>();

            foreach (PropertyGridItemBase propertyGridItemBase in (ReadOnlyCollection <PropertyGridItem>) this.propertyGrid.Items)
            {
                propertyGridItemBaseQueue.Enqueue(propertyGridItemBase);
            }
            while (propertyGridItemBaseQueue.Count > 0)
            {
                PropertyGridItemBase propertyGridItemBase = propertyGridItemBaseQueue.Dequeue();
                if (propertyGridItemBase.Level > num)
                {
                    num = propertyGridItemBase.Level;
                }
                foreach (PropertyGridItemBase gridItem in (ReadOnlyCollection <PropertyGridItem>)propertyGridItemBase.GridItems)
                {
                    propertyGridItemBaseQueue.Enqueue(gridItem);
                }
            }
            this.depthOfTree = num;
            return(propertyGridExportState);
        }
Пример #2
0
        private void RunExportCall(string fileName)
        {
            PropertyGridExportState state = this.SavePropertyGridState();

            this.columnWidths = new List <int>();
            if (this.ExportVisualSettings)
            {
                this.elementProvider = this.propertyGrid.PropertyGridElement.PropertyTableElement.ViewElement.ElementProvider as PropertyGridItemElementProvider;
            }
            try
            {
                this.spreadExportRenderer.GetFormatProvider(this.ExportFormat);
                fileName = Path.GetDirectoryName(fileName) + (object)Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(fileName) + this.spreadExportRenderer.GetFileExtension(this.ExportFormat);
                FileStream fileStream;
                if (this.FileExportMode == FileExportMode.NewSheetInExistingFile && File.Exists(fileName) && this.ExportFormat == SpreadExportFormat.Xlsx)
                {
                    fileStream = new FileStream(fileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite, 32768, false);
                    this.spreadExportRenderer.ImportWorkbook((Stream)fileStream);
                }
                else
                {
                    fileStream = new FileStream(fileName, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite, 32768, false);
                    this.spreadExportRenderer.CreateWorkbook();
                }
                using (fileStream)
                    this.ExportToStream((Stream)fileStream);
                this.OnExportCompleted(new EventArgs());
                ControlTraceMonitor.TrackAtomicFeature((RadControl)this.propertyGrid, "Export", (object)fileName);
            }
            finally
            {
                this.applicationDoEvents = false;
                this.RestorePropertyGridState(state);
            }
        }
Пример #3
0
        public void RunExportAsync(Stream exportStream, ISpreadExportRenderer exportRenderer)
        {
            this.spreadExportRenderer = exportRenderer;
            if (this.GetWorker().IsBusy)
            {
                throw new Exception("There is an export operation that has not yet finished.");
            }
            List <PropertyGridSpreadExportRow> exportRows = (List <PropertyGridSpreadExportRow>)null;

            if (this.propertyGrid.InvokeRequired)
            {
                this.propertyGrid.Invoke((Delegate)(() =>
                {
                    PropertyGridExportState state = this.SavePropertyGridState();
                    exportRows = this.GetPropertyGridDataSnapshot();
                    this.RestorePropertyGridState(state);
                }));
            }
            else
            {
                PropertyGridExportState state = this.SavePropertyGridState();
                exportRows = this.GetPropertyGridDataSnapshot();
                this.RestorePropertyGridState(state);
            }
            this.GetWorker().RunWorkerAsync((object)new List <object>(2)
            {
                (object)new PropertyGridSpreadExportDataSnapshot(string.Empty, exportRows),
                (object)exportStream
            });
        }
Пример #4
0
        private void RunExportCall(Stream exportStream)
        {
            PropertyGridExportState state = this.SavePropertyGridState();

            this.columnWidths = new List <int>();
            if (this.ExportVisualSettings)
            {
                this.elementProvider = this.propertyGrid.PropertyGridElement.PropertyTableElement.ViewElement.ElementProvider as PropertyGridItemElementProvider;
            }
            try
            {
                this.spreadExportRenderer.GetFormatProvider(this.ExportFormat);
                this.spreadExportRenderer.CreateWorkbook();
                this.ExportToStream(exportStream);
                this.OnExportCompleted(new EventArgs());
                ControlTraceMonitor.TrackAtomicFeature((RadControl)this.propertyGrid, "Export");
            }
            finally
            {
                this.applicationDoEvents = false;
                this.RestorePropertyGridState(state);
            }
        }
Пример #5
0
 private void RestorePropertyGridState(PropertyGridExportState state)
 {
     this.propertyGrid.SelectedGridItem = state.SelectedItem;
     this.propertyGrid.PropertyGridElement.PropertyTableElement.HScrollBar.Value = state.HorizontalScrollbarValue;
     this.propertyGrid.PropertyGridElement.PropertyTableElement.VScrollBar.Value = state.VerticalScrolbarValue;
 }