private void RenderVisualizeData(ConcreteTemplateNodeDefinition definition, VisualizeData visualizeData, int selectTabIndex) { string additionalXml = string.Empty; int tabIndex = tcBrowse.TabCount - 1; TemplateNodeInfo nodeInfo = definition.TemplateNode; tcBrowse.ShowSingleTab = !nodeInfo.IsHideTabs; if (visualizeData.PreprocessorAreas != null) { List<PreprocessorDataDescriptor> dialogObjects = visualizeData.PreprocessorAreas.SelectMany( a => a.NoSplitter || a.Preprocessors.Count == 0 || (a.Columns.Length == 1 && a.Rows.Length == 1) ? a.Preprocessors.SelectMany( data => new[] { new PreprocessorDataDescriptor(a, data) } ) : new[] { new PreprocessorDataDescriptor(a) } ).ToList(); // create tab pages with empty content first // to avoid flickering and extra reports loading List<TabPage> newPages = new List<TabPage>(); int bufferIndex = 0; foreach (PreprocessorDataDescriptor dialogObj in dialogObjects) { TabPage page = this._pageBuffer.GetPage(bufferIndex++); PreprocessorAreaData dialogArea = dialogObj.AreaData; page.Text = dialogArea != null ? dialogArea.Name : string.Empty; page.DisposeChildControls(); newPages.Add(page); tcBrowse.TabPages.Add(page); tabIndex++; if (selectTabIndex == tabIndex) { tcBrowse.SelectedIndex = selectTabIndex; } } // release extra pages in buffer this._pageBuffer.Resize(bufferIndex); // fill tab pages with report controls IEnumerator<TabPage> pageEnum = newPages.GetEnumerator(); foreach (PreprocessorDataDescriptor dialogObj in dialogObjects) { pageEnum.MoveNext(); TabPage page = pageEnum.Current; PreprocessorAreaData dialogArea = dialogObj.AreaData; if (dialogArea != null) { ConnectionTabArea ctrl = new ConnectionTabArea { Dock = DockStyle.Fill }; ctrl.Init(this, dialogArea, definition, this._model); page.Controls.Add(ctrl); } else { PreprocessorData dialogPreproc = dialogObj.Data; if (dialogPreproc != null) { Control control = dialogPreproc.ContentFactory.CreateControl(); if (control is WebBrowser || control is ReportViewrControl) { control.PreviewKeyDown += (s, e) => { if (e.KeyCode == Keys.F5) { F5RefreshView(); } }; if (control is ReportViewrControl && tcBrowse.Visible) { if ((control as ReportViewrControl).ReportXML != string.Empty) { using (MemoryStream xmlWriterStream = new MemoryStream()) { XmlWriterSettings xmlWriterSettings = new XmlWriterSettings { CheckCharacters = false, ConformanceLevel = ConformanceLevel.Auto, Encoding = Encoding.UTF8, Indent = true, IndentChars = " ", NewLineChars = Environment.NewLine, NewLineHandling = NewLineHandling.Replace, NewLineOnAttributes = false, OmitXmlDeclaration = false }; using (var xmlWriter = XmlWriter.Create(xmlWriterStream, xmlWriterSettings)) { XmlDocument doc = new XmlDocument(); doc.LoadXml((control as ReportViewrControl).ReportXML); doc.Save(xmlWriter); xmlWriter.Flush(); } additionalXml = Encoding.UTF8.GetString(xmlWriterStream.ToArray()); } } } } if (dialogPreproc.VerticalTextAlign != null) { TitleFrame titleFrame = new TitleFrame( dialogPreproc.VerticalTextAlign, dialogPreproc.TextAlign, control ); titleFrame.Title = dialogPreproc.Name; control = titleFrame; } control.Dock = DockStyle.Fill; page.Controls.Add(control); } } } } txtXml.Text = visualizeData.SourceXml + Environment.NewLine + additionalXml; txtXml.SelectionStart = 0; txtXml.SelectionLength = 0; txtXml.ReadOnly = true; txtXml.BackColor = Color.White; lblLastRefreshDate.Text = !visualizeData.NodeLastUpdated.HasValue ? ComposeBlankDateTimeString() : visualizeData.NodeLastUpdated.Value.ToString(); lblSpendTime.Text = visualizeData.NodeLastUpdateDuration.HasValue ? String.Format( " {0:00}:{1:00}:{2:00}", visualizeData.NodeLastUpdateDuration.Value.Hour, visualizeData.NodeLastUpdateDuration.Value.Minute, visualizeData.NodeLastUpdateDuration.Value.Second ) : String.Format( " {0:00}:{1:00}:{2:00}", 0, 0, 0 ); UpdateScheduledDate(nodeInfo); }
internal void Init(ConnectionTabControl parent, PreprocessorAreaData area, ConcreteTemplateNodeDefinition definition, MsSqlAuditorModel model) { if (parent == null) { throw new ArgumentNullException("parent"); } if (area == null) { throw new ArgumentNullException("area"); } if (definition == null) { throw new ArgumentNullException("definition"); } if (model == null) { throw new ArgumentNullException("model"); } if (!area.IsConfigured) { throw new ArgumentOutOfRangeException("area"); } this._area = area; this._parent = parent; this._model = model; table.StartConfiguring(); var rows = this._area.Rows; var columns = this._area.Columns; // _templateId = !String.IsNullOrWhiteSpace(definition.Connection.TemplateId) ? definition.Connection.TemplateId : definition.Connection.TemplateFileName; if (!String.IsNullOrWhiteSpace(definition.Connection.TemplateId)) { this._templateId = definition.Connection.TemplateId; } else { this._templateId = string.IsNullOrEmpty(definition.Connection.TemplateDir) ? definition.Connection.TemplateFileName : Path.Combine(definition.Connection.TemplateDir, definition.Connection.TemplateFileName); } this._nodeId = !String.IsNullOrWhiteSpace(definition.TemplateNode.Id) ? definition.TemplateNode.Id : definition.TemplateNode.Name; this._areaId = !String.IsNullOrWhiteSpace(this._area.Id) ? this._area.Id : this._area.Name; this._reportLanguage = this._model.Settings.ReportLanguage; this._splitterSettings = this._model.LayoutSettings.GetExtendedSettings <SplitterSettings>(this._templateId, String.Empty, this._reportLanguage); if (this._splitterSettings == null) { this._splitterSettings = new SplitterSettings { SplitterNodeSettingList = new List <SplitterSetting>() }; } var splitterSetting = this._splitterSettings.SplitterNodeSettingList.FirstOrDefault( s => string.Equals(s.NodeId, this._nodeId, StringComparison.InvariantCultureIgnoreCase) && string.Equals(s.AreaId, this._areaId, StringComparison.InvariantCultureIgnoreCase) ); if (splitterSetting != null) { var newRows = PreprocessorAreaData.ParseGridDimension(splitterSetting.Rows, "splitterSetting.Rows"); var newColumns = PreprocessorAreaData.ParseGridDimension(splitterSetting.Columns, "splitterSetting.Columns"); if (rows.Length == newRows.Length && columns.Length == newColumns.Length) { rows = newRows; columns = newColumns; } } table.SetRows(rows); table.SetColumns(columns); List <PreprocessorData> preprocessors = _area.Preprocessors; for (int i = 0, iMax = preprocessors.Count; i < iMax; i++) { PreprocessorData preprocessor = preprocessors[i]; Control control = preprocessor.ContentFactory.CreateControl(); if (control != null) { if (control is WebBrowser) { // control.PreviewKeyDown += (s, e) => control.PreviewKeyDown += ConnectionTabArea_PreviewKeyDown; this.Disposed += (s, e) => { // // #248 - fix memory leaks during Web rendering // // if (e.KeyCode == Keys.F5) // { // _parent.F5RefreshView(); // } control.PreviewKeyDown -= ConnectionTabArea_PreviewKeyDown; IntPtr currentProcessHandle = (IntPtr)(-1); SafeNativeMethods.EmptyWorkingSet(currentProcessHandle); }; } #region Wrap control to frame with title if (preprocessor.VerticalTextAlign != null) { var titleFrame = new TitleFrame( preprocessor.VerticalTextAlign, preprocessor.TextAlign, control ); titleFrame.Title = preprocessor.Name; control = titleFrame; } #endregion table.AddControlToCell( preprocessor.Column - 1, preprocessor.Row - 1, preprocessor.ColSpan, preprocessor.RowSpan, control ); } } table.StopConfiguring(); this._splitterChanged = false; if (!this._handlingSplitterMoved) { this._handlingSplitterMoved = true; table.SplitterMoved += TableSplitterMoved; } }
internal void Init(ConnectionTabControl parent, PreprocessorAreaData area, ConcreteTemplateNodeDefinition definition, MsSqlAuditorModel model) { if (parent == null) { throw new ArgumentNullException("parent"); } if (area == null) { throw new ArgumentNullException("area"); } if (definition == null) { throw new ArgumentNullException("definition"); } if (model == null) { throw new ArgumentNullException("model"); } if (!area.IsConfigured) { throw new ArgumentOutOfRangeException("area"); } this._area = area; this._parent = parent; this._model = model; table.StartConfiguring(); var rows = this._area.Rows; var columns = this._area.Columns; // _templateId = !String.IsNullOrWhiteSpace(definition.Connection.TemplateId) ? definition.Connection.TemplateId : definition.Connection.TemplateFileName; if (!String.IsNullOrWhiteSpace(definition.Connection.TemplateId)) { this._templateId = definition.Connection.TemplateId; } else { this._templateId = string.IsNullOrEmpty(definition.Connection.TemplateDir) ? definition.Connection.TemplateFileName : Path.Combine(definition.Connection.TemplateDir, definition.Connection.TemplateFileName); } this._nodeId = !String.IsNullOrWhiteSpace(definition.TemplateNode.Id) ? definition.TemplateNode.Id : definition.TemplateNode.Name; this._areaId = !String.IsNullOrWhiteSpace(this._area.Id) ? this._area.Id : this._area.Name; this._reportLanguage = this._model.Settings.ReportLanguage; this._splitterSettings = this._model.LayoutSettings.GetExtendedSettings<SplitterSettings>(this._templateId, String.Empty, this._reportLanguage); if (this._splitterSettings == null) { this._splitterSettings = new SplitterSettings { SplitterNodeSettingList = new List<SplitterSetting>() }; } var splitterSetting = this._splitterSettings.SplitterNodeSettingList.FirstOrDefault( s => string.Equals(s.NodeId, this._nodeId, StringComparison.InvariantCultureIgnoreCase) && string.Equals(s.AreaId, this._areaId, StringComparison.InvariantCultureIgnoreCase) ); if (splitterSetting != null) { var newRows = PreprocessorAreaData.ParseGridDimension(splitterSetting.Rows, "splitterSetting.Rows"); var newColumns = PreprocessorAreaData.ParseGridDimension(splitterSetting.Columns, "splitterSetting.Columns"); if (rows.Length == newRows.Length && columns.Length == newColumns.Length) { rows = newRows; columns = newColumns; } } table.SetRows(rows); table.SetColumns(columns); List<PreprocessorData> preprocessors = _area.Preprocessors; for (int i = 0, iMax = preprocessors.Count; i < iMax; i++) { PreprocessorData preprocessor = preprocessors[i]; Control control = preprocessor.ContentFactory.CreateControl(); if (control != null) { if (control is WebBrowser) { // control.PreviewKeyDown += (s, e) => control.PreviewKeyDown += ConnectionTabArea_PreviewKeyDown; this.Disposed += (s, e) => { // // #248 - fix memory leaks during Web rendering // // if (e.KeyCode == Keys.F5) // { // _parent.F5RefreshView(); // } control.PreviewKeyDown -= ConnectionTabArea_PreviewKeyDown; IntPtr currentProcessHandle = (IntPtr)(-1); SafeNativeMethods.EmptyWorkingSet(currentProcessHandle); }; } #region Wrap control to frame with title if (preprocessor.VerticalTextAlign != null) { var titleFrame = new TitleFrame( preprocessor.VerticalTextAlign, preprocessor.TextAlign, control ); titleFrame.Title = preprocessor.Name; control = titleFrame; } #endregion table.AddControlToCell( preprocessor.Column - 1, preprocessor.Row - 1, preprocessor.ColSpan, preprocessor.RowSpan, control ); } } table.StopConfiguring(); this._splitterChanged = false; if (!this._handlingSplitterMoved) { this._handlingSplitterMoved = true; table.SplitterMoved += TableSplitterMoved; } }