Browse Source

SharpReport use UIEditors in PropertyGrid, small changes from FxCop

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1326 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Peter Forstmeier 20 years ago
parent
commit
c631ff4aa7
  1. 1
      src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/BaseDesignerControl.cs
  2. 32
      src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportSection.cs
  3. 28
      src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs
  4. 2
      src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/ItemContextCommands.cs
  5. 253
      src/AddIns/Misc/SharpReport/SharpReportAddin/FieldsExplorer/FieldsExplorer.cs
  6. 5
      src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportAddin.addin
  7. 3
      src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportDisplayBinding.cs
  8. 79
      src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs

1
src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/BaseDesignerControl.cs

@ -76,6 +76,7 @@ namespace SharpReport.Designer @@ -76,6 +76,7 @@ namespace SharpReport.Designer
con.Items.Remove (item);
}
}
this.NotifyPropertyChanged("RemoveSelectedItem");
}

32
src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/ReportSection.cs

@ -8,7 +8,6 @@ @@ -8,7 +8,6 @@
*/
using System;
using System.Drawing.Printing;
using System.Globalization;
using System.Text;
using System.Reflection;
@ -85,9 +84,10 @@ namespace SharpReport{ @@ -85,9 +84,10 @@ namespace SharpReport{
}
}
void SerializeItemProperties (XmlDocument doc,
XmlElement xmlControl,
void SerializeItemProperties (XmlElement xmlControl,
BaseReportItem item,PropertyInfo [] prop) {
XmlElement xmlProperty;
XmlAttribute attPropValue;
@ -102,7 +102,8 @@ namespace SharpReport{ @@ -102,7 +102,8 @@ namespace SharpReport{
}
else {
attPropValue = xmlControl.OwnerDocument.CreateAttribute ("value");
attPropValue.InnerText = Convert.ToString(p.GetValue(item,null));
attPropValue.InnerText = Convert.ToString(p.GetValue(item,null),
CultureInfo.InvariantCulture);
xmlProperty.Attributes.Append(attPropValue);
}
xmlControl.AppendChild(xmlProperty);
@ -123,7 +124,7 @@ namespace SharpReport{ @@ -123,7 +124,7 @@ namespace SharpReport{
XmlAttribute baseAttr = doc.CreateAttribute ("basetype");
baseAttr.InnerText = type.BaseType.ToString();
xmlControl.Attributes.Append(baseAttr);
SerializeItemProperties (doc,xmlControl,item,prop);
SerializeItemProperties (xmlControl,item,prop);
return xmlControl;
}
@ -160,7 +161,8 @@ namespace SharpReport{ @@ -160,7 +161,8 @@ namespace SharpReport{
if (p.CanWrite) {
xmlProperty = doc.CreateElement (p.Name);
attPropValue = doc.CreateAttribute ("value");
attPropValue.InnerText = Convert.ToString(p.GetValue(this,null));
attPropValue.InnerText = Convert.ToString(p.GetValue(this,null),
CultureInfo.InvariantCulture);
xmlProperty.Attributes.Append(attPropValue);
section.AppendChild(xmlProperty);
}
@ -211,24 +213,18 @@ namespace SharpReport{ @@ -211,24 +213,18 @@ namespace SharpReport{
public void OnItemSelect(object sender, EventArgs e){
// if (!base.Suspend) {
if (ItemSelected != null)
ItemSelected(sender, e);
// }
if (ItemSelected != null)
ItemSelected(sender, e);
}
public void VisualControlClick(object sender, EventArgs e){
// if (!base.Suspend) {
this.OnSelect();
// }
this.OnSelect();
}
public void ReportItemSelected(object sender, EventArgs e){
// if (!base.Suspend) {
this.OnSelect ();
this.OnItemSelect(sender, e);
// }
this.OnSelect ();
this.OnItemSelect(sender, e);
}

28
src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs

@ -97,8 +97,8 @@ namespace SharpReport{ @@ -97,8 +97,8 @@ namespace SharpReport{
columnCollecion = dataManager.AvailableFields;
}
} catch (Exception e) {
throw e;
} catch (Exception ) {
throw;
} finally {
System.Console.WriteLine("ReportManager:ReadColumnCollection in finally");
}
@ -125,6 +125,10 @@ namespace SharpReport{ @@ -125,6 +125,10 @@ namespace SharpReport{
/// </summary>
/// <param name="model">ReportModel</param>
public void CreatePageHeader (ReportModel model) {
if (model == null) {
throw new ArgumentNullException("model");
}
BaseSection section = model.PageHeader;
section.SuspendLayout();
SharpReport.Designer.IDesignableFactory gf = new SharpReport.Designer.IDesignableFactory();
@ -146,6 +150,10 @@ namespace SharpReport{ @@ -146,6 +150,10 @@ namespace SharpReport{
/// <param name="model">ReportModel</param>
public void CreatePageNumber (ReportModel model) {
if (model == null) {
throw new ArgumentNullException("model");
}
BaseSection section = model.PageFooter;
section.SuspendLayout();
FunctionFactory gf = new FunctionFactory();
@ -181,6 +189,10 @@ namespace SharpReport{ @@ -181,6 +189,10 @@ namespace SharpReport{
/// <param name="model"><see cref="">ReportModel</see></param>
/// <param name="showInUserControl"></param>
public void ReportPreview (ReportModel model,bool standAlone) {
if (model == null) {
throw new ArgumentNullException("model");
}
try {
AbstractRenderer abstr = this.BuildStandartRenderer (model);
if (abstr != null) {
@ -194,7 +206,7 @@ namespace SharpReport{ @@ -194,7 +206,7 @@ namespace SharpReport{
private AbstractRenderer BuildStandartRenderer (ReportModel model) {
if (model == null) {
throw new ArgumentException("SharpReportManager:BuildStandartRenderer 'ReportModel'");
throw new ArgumentNullException("model");
}
if (base.ConnectionObject == null) {
@ -207,10 +219,10 @@ namespace SharpReport{ @@ -207,10 +219,10 @@ namespace SharpReport{
public AbstractRenderer GetRendererForPushDataReports (ReportModel model,DataSet dataSet) {
if (model == null) {
throw new ArgumentException("SharpReportManager:GetRendererForPushDataReports 'ReportModel'");
throw new ArgumentNullException("model");
}
if (dataSet == null) {
throw new ArgumentException("SharpReportManager:GetRendererForPushDataReports 'DataSet'");
throw new ArgumentNullException("dataSet");
}
return base.SetupPushDataRenderer(model,dataSet.Tables[0]);
}
@ -220,9 +232,11 @@ namespace SharpReport{ @@ -220,9 +232,11 @@ namespace SharpReport{
DataSet dataSet,
bool standAlone) {
if (model == null) {
throw new ArgumentException("SharpReportManager:ReportPreviewPushData 'ReportModel'");
throw new ArgumentNullException("model");
}
if (dataSet == null) {
throw new ArgumentNullException("dataSet");
}
try {
AbstractRenderer abstr = GetRendererForPushDataReports (model,dataSet);
if (abstr != null) {

2
src/AddIns/Misc/SharpReport/SharpReportAddin/Commands/ItemContextCommands.cs

@ -44,7 +44,7 @@ namespace SharpReportAddin.Commands { @@ -44,7 +44,7 @@ namespace SharpReportAddin.Commands {
///
public override void Run(){
if (this.IsEnabled){
base.View.DesignerControl.RemoveSelectedItem ();
base.View.RemoveSelectedItem();
}
}
}

253
src/AddIns/Misc/SharpReport/SharpReportAddin/FieldsExplorer/FieldsExplorer.cs

@ -49,7 +49,6 @@ namespace SharpReportAddin { @@ -49,7 +49,6 @@ namespace SharpReportAddin {
/// Clear the selected Section
/// </summary>
public void ClearNodeSection () {
// System.Console.WriteLine("ClearNodeSection");
if (this.SelectedNode is SectionTreeNode) {
if (this.SelectedNode.Nodes.Count > 0) {
this.SelectedNode.Nodes.Clear();
@ -100,6 +99,14 @@ namespace SharpReportAddin { @@ -100,6 +99,14 @@ namespace SharpReportAddin {
this.SelectedNode = node;
CheckNode (node);
if (e.Button == MouseButtons.Right) {
AbstractFieldsNode abstrNode = node as AbstractFieldsNode;
if (abstrNode != null) {
if (abstrNode.ContextmenuAddinTreePath.Length > 0) {
ContextMenuStrip ctMen = MenuService.CreateContextMenu (this,abstrNode.ContextmenuAddinTreePath);
ctMen.Show (this,new Point (e.X,e.Y));
}
}
/*
if (node is AbstractFieldsNode) {
AbstractFieldsNode abstrNode = (AbstractFieldsNode)node;
if (abstrNode.ContextmenuAddinTreePath.Length > 0) {
@ -107,6 +114,7 @@ namespace SharpReportAddin { @@ -107,6 +114,7 @@ namespace SharpReportAddin {
ctMen.Show (this,new Point (e.X,e.Y));
}
}
*/
}
}
}
@ -149,17 +157,16 @@ namespace SharpReportAddin { @@ -149,17 +157,16 @@ namespace SharpReportAddin {
void TreeViewDragDrop (object sender,DragEventArgs e) {
if(e.Data.GetDataPresent("SharpReportAddin.ColumnsTreeNode", false)){
Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y));
SectionTreeNode node = (SectionTreeNode)((TreeView)sender).GetNodeAt(pt);
Point pt = this.PointToClient (new Point( e.X,e.Y));
SectionTreeNode node = this.GetNodeAt (pt) as SectionTreeNode;
if (node != null) {
ColumnsTreeNode t = (ColumnsTreeNode)e.Data.GetData("SharpReportAddin.ColumnsTreeNode", true);
ColumnsTreeNode dest = new ColumnsTreeNode (t.Text);
// Useless to add a node twice
if (!CheckForExist (node,dest)) {
if (!FieldsExplorer.CheckForExist (node,dest)) {
dest.SortDirection = ListSortDirection.Ascending;
dest.ImageIndex = ascendingIcon;
dest.SelectedImageIndex = ascendingIcon;
@ -174,13 +181,13 @@ namespace SharpReportAddin { @@ -174,13 +181,13 @@ namespace SharpReportAddin {
}
private void Fill () {
private void FillExplorer () {
this.FillTree();
this.ExpandAll();
isFilled = true;
}
private bool CheckForExist (SectionTreeNode sec,ColumnsTreeNode col) {
private static bool CheckForExist (SectionTreeNode sec,ColumnsTreeNode col) {
if (sec.Nodes.Count > 0) {
for (int i = 0;i < sec.Nodes.Count ;i++ ) {
if (sec.Nodes[i].Text == col.Text) {
@ -193,21 +200,22 @@ namespace SharpReportAddin { @@ -193,21 +200,22 @@ namespace SharpReportAddin {
return false;
}
private void CheckNode (TreeNode node) {
if (node.Parent == nodeSorting) {
ColumnsTreeNode cn = (ColumnsTreeNode)node;
if (cn.SortDirection == ListSortDirection.Ascending) {
cn.ImageIndex = ascendingIcon;
} else {
cn.ImageIndex = descendingIcon;
ColumnsTreeNode cn = node as ColumnsTreeNode;
if (cn != null) {
if (node.Parent == nodeSorting) {
if (cn.SortDirection == ListSortDirection.Ascending) {
cn.ImageIndex = ascendingIcon;
} else {
cn.ImageIndex = descendingIcon;
}
} else if (node.Parent == this.nodeGrouping) {
cn.ImageIndex = clearIcon;
cn.SelectedImageIndex = clearIcon;
}
} else if (node.Parent == this.nodeGrouping) {
ColumnsTreeNode cn = (ColumnsTreeNode)node;
cn.ImageIndex = clearIcon;
cn.SelectedImageIndex = clearIcon;
}
}
#endregion
@ -221,75 +229,48 @@ namespace SharpReportAddin { @@ -221,75 +229,48 @@ namespace SharpReportAddin {
}
#region PadEvents
private void old_OnWindowChange (object sender,EventArgs e) {
try {
if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent is SharpReportView) {
if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow == null || WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent == null) {
return;
}
WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.Saving -= OnViewSaving;
WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.Saving += OnViewSaving;
PadDescriptor pad = WorkbenchSingleton.Workbench.GetPad(typeof(FieldsExplorer));
SharpReportView v =
WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent
as SharpReportView;
private void OnUpdateExplorerWindow (object sender,EventArgs e) {
if (WorkbenchSingleton.Workbench.ActiveContent != null) {
Type type = WorkbenchSingleton.Workbench.ActiveContent.GetType();
if (type != typeof(PropertyPad)) {
if (v != null) {
this.reportModel = v.ReportManager.BaseDesignControl.ReportModel;
if (this.reportModel != null) {
this.Fill();
WorkbenchSingleton.Workbench.ShowPad(pad);
try {
if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow == null || WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent == null) {
return;
}
WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.Saving -= OnViewSaving;
WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.Saving += OnViewSaving;
} else {
WorkbenchSingleton.Workbench.WorkbenchLayout.HidePad(pad);
}
} else {
System.Console.WriteLine("FieldsExplorer: NO view"); }
} catch (Exception) {
}
}
private void OnWindowChange (object sender,EventArgs e) {
// System.Console.WriteLine("FieldsExplorer:OnWindowChange");
// System.Console.WriteLine("active control {0}",WorkbenchSingleton.ActiveControl.ToString());
// ICSharpCode.SharpDevelop.Gui.DefaultWorkbench dw = (ICSharpCode.SharpDevelop.Gui.DefaultWorkbench)sender;
try {
if (WorkbenchSingleton.Workbench.ActiveWorkbenchWindow == null || WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent == null) {
return;
}
WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.Saving -= OnViewSaving;
WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ViewContent.Saving += OnViewSaving;
PadDescriptor pad = WorkbenchSingleton.Workbench.GetPad(typeof(FieldsExplorer));
SharpReportView v =
WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent
as SharpReportView;
if (v != null) {
this.reportModel = v.ReportManager.BaseDesignControl.ReportModel;
if (this.reportModel != null) {
PadDescriptor pad =
WorkbenchSingleton.Workbench.GetPad(typeof(FieldsExplorer));
if (pad != null) {
SharpReportView view =
WorkbenchSingleton.Workbench.ActiveWorkbenchWindow.ActiveViewContent
as SharpReportView;
if ((view != null) && (!view.Disposed)) {
this.reportModel = view.ReportManager.BaseDesignControl.ReportModel;
if (this.reportModel != null) {
this.FillExplorer();
WorkbenchSingleton.Workbench.ShowPad(pad);
pad.BringPadToFront();
}
}
}
this.Fill();
WorkbenchSingleton.Workbench.ShowPad(pad);
pad.BringPadToFront();
else {
WorkbenchSingleton.Workbench.WorkbenchLayout.HidePad(pad);
}
} catch (Exception) {
// throw;
}
} else {
WorkbenchSingleton.Workbench.WorkbenchLayout.HidePad(pad);
}
} catch (Exception) {
}
}
private void OnViewSaving (object sender, EventArgs e) {
if (this.isFilled) {
UpdateSorting();
@ -375,62 +356,50 @@ namespace SharpReportAddin { @@ -375,62 +356,50 @@ namespace SharpReportAddin {
void SetSortFields(){
try {
ColumnsTreeNode node;
this.nodeSorting.Nodes.Clear();
int scCount = this.reportModel.ReportSettings.SortColumnCollection.Count;
foreach (SortColumn sc in this.reportModel.ReportSettings.SortColumnCollection) {
node = new ColumnsTreeNode(sc.ColumnName,sc.SortDirection);
if (node.SortDirection == ListSortDirection.Ascending) {
node.ImageIndex = 4;
node.SelectedImageIndex = 4;
} else {
node.ImageIndex = descendingIcon;
node.SelectedImageIndex = descendingIcon;
}
this.nodeSorting.Nodes.Add(node);
ColumnsTreeNode node;
this.nodeSorting.Nodes.Clear();
foreach (SortColumn sc in this.reportModel.ReportSettings.SortColumnCollection) {
node = new ColumnsTreeNode(sc.ColumnName,sc.SortDirection);
if (node.SortDirection == ListSortDirection.Ascending) {
node.ImageIndex = 4;
node.SelectedImageIndex = 4;
} else {
node.ImageIndex = descendingIcon;
node.SelectedImageIndex = descendingIcon;
}
} catch (Exception) {
this.nodeSorting.Nodes.Add(node);
}
}
void SetGroupFields(){
try {
ColumnsTreeNode node;
this.nodeGrouping.Nodes.Clear();
int gcCount = this.reportModel.ReportSettings.GroupColumnsCollection.Count;
for (int i = 0;i < gcCount ;i++ ) {
GroupColumn gc = (GroupColumn)this.reportModel.ReportSettings.GroupColumnsCollection[i];
node = new ColumnsTreeNode(gc.ColumnName);
if (node.SortDirection == ListSortDirection.Ascending) {
node.ImageIndex = ascendingIcon;
node.SelectedImageIndex = ascendingIcon;
} else {
node.ImageIndex = descendingIcon;
node.SelectedImageIndex = descendingIcon;
}
this.nodeGrouping.Nodes.Add(node);
private void SetGroupFields(){
ColumnsTreeNode node;
this.nodeGrouping.Nodes.Clear();
foreach (GroupColumn gc in this.reportModel.ReportSettings.GroupColumnsCollection) {
node = new ColumnsTreeNode(gc.ColumnName);
if (node.SortDirection == ListSortDirection.Ascending) {
node.ImageIndex = ascendingIcon;
node.SelectedImageIndex = ascendingIcon;
} else {
node.ImageIndex = descendingIcon;
node.SelectedImageIndex = descendingIcon;
}
} catch (Exception) {
this.nodeGrouping.Nodes.Add(node);
}
}
void SetParamFields (){
ColumnsTreeNode node;
this.nodeParams.Nodes.Clear();
int parCount = this.reportModel.ReportSettings.SqlParametersCollection.Count;
if (parCount > 0) {
for (int i = 0;i < parCount ;i++ ) {
SqlParameter par = (SqlParameter)this.reportModel.ReportSettings.SqlParametersCollection[i];
node = new ColumnsTreeNode(par.ParameterName);
foreach (SqlParameter par in this.reportModel.ReportSettings.SqlParametersCollection) {
node = new ColumnsTreeNode(par.ParameterName);
node.Tag = par;
node.SelectedImageIndex = columnIcon;
node.ImageIndex = columnIcon;
this.nodeParams.Nodes.Add (node);
}
}
}
}
void SetFunctions(){
@ -513,29 +482,26 @@ namespace SharpReportAddin { @@ -513,29 +482,26 @@ namespace SharpReportAddin {
ImageList imageList = new ImageList();
imageList.ColorDepth = ColorDepth.Depth32Bit;
imageList.ImageSize = new System.Drawing.Size(16, 16);
try {
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.ClosedFolderBitmap"));
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.OpenFolderBitmap"));
imageList.Images.Add(new Bitmap(1, 1));
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.ClosedFolderBitmap"));
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.OpenFolderBitmap"));
imageList.Images.Add(new Bitmap(1, 1));
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.SelectionArrow"));
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.SharpReport.Ascending"));
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.SelectionArrow"));
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.SharpReport.Ascending"));
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.SharpReport.Descending"));
//Table's or procedure
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.SharpQuery.Table"));
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.SharpQuery.Procedure"));
//Parameters
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.SharpQuery.Column"));
//Function
imageList.Images.Add(ResourceService.GetIcon("Icons.16x16.SharpReport.Function"));
ImageList = imageList;
} catch (Exception e) {
MessageService.ShowError(e);
}
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.SharpReport.Descending"));
//Table's or procedure
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.SharpQuery.Table"));
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.SharpQuery.Procedure"));
//Parameters
imageList.Images.Add(IconService.GetBitmap("Icons.16x16.SharpQuery.Column"));
//Function
imageList.Images.Add(ResourceService.GetIcon("Icons.16x16.SharpReport.Function"));
ImageList = imageList;
}
#endregion
@ -601,8 +567,9 @@ namespace SharpReportAddin { @@ -601,8 +567,9 @@ namespace SharpReportAddin {
#endregion
public FieldsExplorer() {
WorkbenchSingleton.Workbench.ActiveWorkbenchWindowChanged += OnWindowChange;
WorkbenchSingleton.Workbench.ActiveWorkbenchWindowChanged += OnUpdateExplorerWindow;
LabelEdit = true;
AllowDrop = true;

5
src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportAddin.addin

@ -35,7 +35,6 @@ @@ -35,7 +35,6 @@
<!-- FieldsExplorer -->
<Path name ="/SharpDevelop/Workbench/Pads">
<Pad id="fieldsexplorer"
category = "Invisible"
icon="Icons.16x16.SharpQuery.Refresh"
title = "${res:SharpReport.FieldsExplorer.Title}"
shortcut = "Control|Alt|F"
@ -58,7 +57,9 @@ @@ -58,7 +57,9 @@
<!-- ContextMenu Items -->
<Path name ="/SharpReport/ContextMenu/Items">
<MenuItem id="cut" label="${res:SharpReport.ContextMenu.Cut}" class="SharpReportAddin.Commands.CutReportItem"/>
<MenuItem id="paste" label="${res:SharpReport.ContextMenu.Paste}" class="SharpReportAddin.Commands.PasteReportItem"/>
<!--
<MenuItem id="paste" label="${res:SharpReport.ContextMenu.Paste}" class="SharpReportAddin.Commands.PasteReportItem"/>
-->
</Path>
<!-- Fields Explorer ContextMenu's -->

3
src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportDisplayBinding.cs

@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
using System;
using System.Globalization;
using ICSharpCode.Core;
using SharpReportCore;
@ -76,6 +76,7 @@ namespace SharpReportAddin { @@ -76,6 +76,7 @@ namespace SharpReportAddin {
SharpReportView view = new SharpReportView();
try {
StatusBarService.SetMessage (String.Format("File : {0}",fileName));
view.Load (fileName);
view.UpdateView (false);
view.Selected();

79
src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs

@ -11,15 +11,13 @@ @@ -11,15 +11,13 @@
using System;
using System.IO;
using System.ComponentModel;
//using System.ComponentModel;
using System.Globalization;
using System.Drawing;
using System.Drawing.Printing;
using System.Windows.Forms;
using System.Data;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
@ -47,7 +45,8 @@ namespace SharpReportAddin{ @@ -47,7 +45,8 @@ namespace SharpReportAddin{
private AxSideTab sideTabFunctions = null;
private Panel panel;
private bool designerInitialised;
private bool disposed;
#region privates
void InitView() {
@ -56,7 +55,7 @@ namespace SharpReportAddin{ @@ -56,7 +55,7 @@ namespace SharpReportAddin{
panel = new Panel();
panel.AutoScroll = true;
CreateTabControl();
BuildToolBarItems();
SharpReportView.BuildToolBarItems();
if (PropertyPad.Grid != null) {
PropertyPad.Grid.SelectedObject = designerControl.ReportModel.ReportSettings;
PropertyPad.Grid.Refresh();
@ -99,7 +98,7 @@ namespace SharpReportAddin{ @@ -99,7 +98,7 @@ namespace SharpReportAddin{
#region SideBar Handling
private bool SharpReportIsRunning () {
private static bool SharpReportIsRunning () {
// Did we already exist
foreach (IViewContent content in WorkbenchSingleton.Workbench.ViewContentCollection) {
SharpReportView view = content as SharpReportView;
@ -110,17 +109,17 @@ namespace SharpReportAddin{ @@ -110,17 +109,17 @@ namespace SharpReportAddin{
return false;
}
private SharpDevelopSideBar GetSideBar () {
private static SharpDevelopSideBar GetSideBar () {
SideBarView v = (SideBarView)WorkbenchSingleton.Workbench.GetPad (typeof(SideBarView)).PadContent;
SharpDevelopSideBar sb =(SharpDevelopSideBar) v.Control;
return sb;
}
private void BuildToolBarItems() {
private static void BuildToolBarItems() {
SharpDevelopSideBar sideBar = GetSideBar();
SharpDevelopSideBar sideBar = SharpReportView.GetSideBar();
if (!this.SharpReportIsRunning()) {
if (!SharpReportView.SharpReportIsRunning()) {
SharpReport.BuildSideTab buildSideTab = new SharpReport.BuildSideTab (sideBar);
buildSideTab.CreateSidetabs();
sideBar.Refresh();
@ -132,9 +131,9 @@ namespace SharpReportAddin{ @@ -132,9 +131,9 @@ namespace SharpReportAddin{
void RemoveSideBarItem() {
if (!this.SharpReportIsRunning()) {
if (!SharpReportView.SharpReportIsRunning()) {
if (sideTabItem != null) {
SharpDevelopSideBar sideBar = GetSideBar();
SharpDevelopSideBar sideBar = SharpReportView.GetSideBar();
sideBar.Tabs.Remove (sideTabItem);
}
@ -214,8 +213,9 @@ namespace SharpReportAddin{ @@ -214,8 +213,9 @@ namespace SharpReportAddin{
#region Preview handling
private DataSet DataSetFromFile () {
private static DataSet DataSetFromFile () {
DataSet ds = new DataSet();
ds.Locale = CultureInfo.InvariantCulture;
using (OpenFileDialog openFileDialog = new OpenFileDialog()){
openFileDialog.Filter = GlobalValues.XsdFileFilter;
openFileDialog.DefaultExt = GlobalValues.XsdExtension;
@ -251,7 +251,7 @@ namespace SharpReportAddin{ @@ -251,7 +251,7 @@ namespace SharpReportAddin{
}
} catch (Exception e) {
MessageBox.Show("Error in RunPreview" + e.Message);
MessageService.ShowError(e);
}
}
@ -260,7 +260,7 @@ namespace SharpReportAddin{ @@ -260,7 +260,7 @@ namespace SharpReportAddin{
private void PreviewPushReport (bool standAlone){
try {
DataSet ds = DataSetFromFile ();
DataSet ds = SharpReportView.DataSetFromFile ();
reportManager.ReportPreviewPushData(designerControl.ReportModel,
ds,
standAlone);
@ -316,7 +316,8 @@ namespace SharpReportAddin{ @@ -316,7 +316,8 @@ namespace SharpReportAddin{
}
void SetTabTitel (string name) {
base.TitleName = String.Format("{0} [{1}]",name,this.tabControl.SelectedTab.Text);
base.TitleName = String.Format(CultureInfo.CurrentCulture,
"{0} [{1}]",name,this.tabControl.SelectedTab.Text);
}
private void OnTabPageChanged (object sender, EventArgs e) {
@ -355,11 +356,8 @@ namespace SharpReportAddin{ @@ -355,11 +356,8 @@ namespace SharpReportAddin{
private void OnPropertyChanged (object sender,
System.ComponentModel.PropertyChangedEventArgs e) {
if (this.designerInitialised) {
base.IsDirty = true;
OnObjectSelected (this,EventArgs.Empty);
}
this.designerInitialised = true;
base.IsDirty = true;
OnObjectSelected (this,EventArgs.Empty);
}
private void OnModelFileNameChanged (object sender,EventArgs e) {
@ -375,16 +373,8 @@ namespace SharpReportAddin{ @@ -375,16 +373,8 @@ namespace SharpReportAddin{
private void OnObjectSelected (object sender,EventArgs e) {
if (designerControl.ReportControl.SelectedObject != null) {
BaseReportObject oldobj = PropertyPad.Grid.SelectedObject as BaseReportObject;
// if (oldobj != null) {
// System.Console.WriteLine("");
// System.Console.WriteLine("leaving {0} <{1}> ",oldobj.Name,oldobj.Suspend);
// }
BaseReportObject newobj = designerControl.ReportControl.SelectedObject;
newobj.ResumeLayout();
// System.Console.WriteLine("View:OnObjectSelected {0} <{1}>",newobj.Name,newobj.Suspend);
if (PropertyPad.Grid != null) {
PropertyPad.Grid.SelectedObject = designerControl.ReportControl.SelectedObject;
@ -392,16 +382,7 @@ namespace SharpReportAddin{ @@ -392,16 +382,7 @@ namespace SharpReportAddin{
}
}
private void old_OnObjectSelected (object sender,EventArgs e) {
if (designerControl.ReportControl.SelectedObject != null) {
if (PropertyPad.Grid != null) {
PropertyPad.Grid.SelectedObject = designerControl.ReportControl.SelectedObject;
}
}
}
#endregion
@ -430,7 +411,10 @@ namespace SharpReportAddin{ @@ -430,7 +411,10 @@ namespace SharpReportAddin{
base.OnSaving(EventArgs.Empty);
this.RunPreview(false);
}
public void RemoveSelectedItem () {
this.designerControl.RemoveSelectedItem ();
}
/// <summary>
/// This Method is called after something has changed like Load a new report
@ -448,6 +432,7 @@ namespace SharpReportAddin{ @@ -448,6 +432,7 @@ namespace SharpReportAddin{
}
#endregion
#region Propertys
@ -471,6 +456,11 @@ namespace SharpReportAddin{ @@ -471,6 +456,11 @@ namespace SharpReportAddin{
}
}
public bool Disposed {
get {
return disposed;
}
}
#endregion
@ -563,7 +553,7 @@ namespace SharpReportAddin{ @@ -563,7 +553,7 @@ namespace SharpReportAddin{
AbstractRenderer renderer;
if (this.designerControl.ReportModel.DataModel == GlobalEnums.enmPushPullModel.PushData) {
renderer = reportManager.GetRendererForPushDataReports(this.designerControl.ReportModel,
this.DataSetFromFile());
SharpReportView.DataSetFromFile());
} else {
renderer = reportManager.GetRendererForStandartReports(this.designerControl.ReportModel);
@ -581,7 +571,7 @@ namespace SharpReportAddin{ @@ -581,7 +571,7 @@ namespace SharpReportAddin{
if (PropertyPad.Grid != null) {
PropertyPad.Grid.SelectedObject = null;
}
this.disposed = true;
RemoveSideBarItem();
this.Dispose(true);
GC.SuppressFinalize(this);
@ -600,7 +590,10 @@ namespace SharpReportAddin{ @@ -600,7 +590,10 @@ namespace SharpReportAddin{
if (this.designerControl != null) {
this.designerControl.Dispose();
}
this.tabControl.Dispose();
if (this.panel != null) {
this.panel.Dispose();
}
}
// Release unmanaged resources.

Loading…
Cancel
Save