Exemplo n.º 1
0
        public static void Gerar(XtraReport xtraReport, object data, bool edit, List <Parameter> parametros = null)
        {
            if (xtraReport != null || xtraReport != new XtraReport())
            {
                report = xtraReport;
            }

            dataSource               = data;
            report.DataSource        = dataSource;
            report.RequestParameters = false;

            if (parametros != null)
            {
                foreach (var parametro in parametros)
                {
                    if (report.Parameters != null)
                    {
                        var parametroAtual = report.Parameters[parametro.Name];

                        if (parametroAtual == null)
                        {
                            report.Parameters.Add(parametro);
                        }
                        else
                        {
                            parametroAtual.Value = parametro.Value;
                        }
                    }
                }
            }

            if (edit)
            {
                using (var xrDesignForm = new XRDesignForm())
                {
                    var mdiController = xrDesignForm.DesignMdiController;

                    mdiController.DesignPanelLoaded += (s, e) => mdiController.AddCommandHandler(new CommandHandler((XRDesignPanel)s));
                    mdiController.OpenReport(report);
                    xrDesignForm.ShowDialog();

                    if (mdiController.ActiveDesignPanel != null)
                    {
                        mdiController.ActiveDesignPanel.CloseReport();
                    }
                }
            }
            else
            {
                using (var reportPrintTool = new ReportPrintTool(report))
                {
                    reportPrintTool.AutoShowParametersPanel = false;
                    reportPrintTool.PreviewForm.WindowState = FormWindowState.Maximized;
                    reportPrintTool.ShowPreviewDialog();
                }
            }

            xtraReport = report;
        }
        private string CreateReport()
        {
            string       fileName = "temp.repx";
            XRDesignForm form     = new XRDesignForm();

            form.DesignMdiController.CreateNewReportWizard();
            form.ActiveDesignPanel.BeginInvoke(new MethodInvoker(() => { form.ActiveDesignPanel.Report.SaveLayout(fileName); }));
            return(fileName);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            XtraReport   report = new XtraReport();
            XRDesignForm form   = new XRDesignForm();

            form.DesignMdiController.AddService(typeof(IMenuCreationService),
                                                new CustomMenuCreationService(form.DesignMdiController));
            form.OpenReport(report);
            form.ShowDialog();
        }
        private void ShowReportDesigner()
        {
            XRDesignForm          form          = new XRDesignForm();
            XRDesignMdiController mdiController = form.DesignMdiController;

            mdiController.DesignPanelLoaded += new DesignerLoadedEventHandler(mdiController_DesignPanelLoaded);
            mdiController.OpenReport(new XtraReport1());
            form.ShowDialog();
            if (mdiController.ActiveDesignPanel != null)
            {
                mdiController.ActiveDesignPanel.CloseReport();
            }
        }
Exemplo n.º 5
0
        private void buttonReportDesignerRuntime_Click(object sender, EventArgs e)
        {
            var xr = new XRDesignForm();
            var b  = new XtraReportTabular();
            var v  = new ReportLayout("XtraReportTabular.repx");

            if (v.HasLayout)
            {
                b.LoadLayout(v.LayoutPath);
            }
            xr.OpenReport(b);
            xr.Show(this);
        }
Exemplo n.º 6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Create an End-User Designer form.
            XRDesignForm designForm = new XRDesignForm();

            // Handle the DesignPanelLoaded event.
            designForm.DesignMdiController.DesignPanelLoaded +=
                DesignMdiController_DesignPanelLoaded;
            // Load a report into the Designer.
            designForm.OpenReport(new XtraReport1());

            // Show the End-User Designer form, modally.
            designForm.ShowDialog();
        }
Exemplo n.º 7
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Create a new Design form.
            XRDesignForm designForm = new XRDesignForm();

            // Obtain the Field List and bring it to front.
            designForm.DesignDockManager[DesignDockPanelType.FieldList].Show();

            // Create a new blank report.
            designForm.OpenReport(new XtraReport1());

            // Show the Design form.
            designForm.ShowDialog();
        }
        private static XRDesignForm CreateDesignForm()
        {
            // Create Runtime Report Designer
            XRDesignForm form = new XRDesignForm();

            form.Text = "Ryan & Jer's Report Designer";

            // Report Factory Service (which uses custom MyReportBase class)
            var service = new ReportFactory();

            form.DesignMdiController.AddService(typeof(ReportTypeService), service);

            return(form);
        }
Exemplo n.º 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Create a new End-User Designer.
            XRDesignForm designForm = new XRDesignForm();

            // Handle the DesignPanelLoaded event.
            designForm.DesignMdiController.DesignPanelLoaded +=
                new DesignerLoadedEventHandler(DesignMdiController_DesignPanelLoaded);

            // Load the report into the designer.
            designForm.OpenReport(new XtraReport1());

            // Show the End-User Designer window.
            designForm.Show();
        }
        private void PromptSelectDatasource(XRDesignForm form, MyReportBase report)
        {
            Form dialog = null;

            // Datasource Selected Callback
            Action <DesignTimeDataSourceDefinition> callback = (definition) =>
            {
                dialog.Close();

                // Change Report Datasource
                report.ChangeDesignTimeDatasource(definition, this);
            };

            // Create Select Datasource Dialog
            dialog = new SelectDesignTimeDataSourceForm(this, report, callback);
            dialog.BringToFront();
            dialog.ShowDialog();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            // Create an End-User Designer form.
            XRDesignForm designForm = new XRDesignForm();

            // Open a new blank report in it.
            designForm.OpenReport(new XtraReport1());

            // Access the Group and Sort panel.
            GroupAndSortDockPanel groupSort =
                (GroupAndSortDockPanel)designForm.DesignDockManager[DesignDockPanelType.GroupAndSort];

            groupSort.Visibility = DockVisibility.AutoHide;

            // Access the Script Errors panel.
            ErrorListDockPanel errorList =
                (ErrorListDockPanel)designForm.DesignDockManager[DesignDockPanelType.ErrorList];

            errorList.Visibility = DockVisibility.AutoHide;

            // Access the Field List.
            FieldListDockPanel fieldList =
                (FieldListDockPanel)designForm.DesignDockManager[DesignDockPanelType.FieldList];

            fieldList.ShowNodeToolTips   = false;
            fieldList.ShowParametersNode = false;

            // Access the Report Explorer.
            ReportExplorerDockPanel reportExplorer =
                (ReportExplorerDockPanel)designForm.DesignDockManager[DesignDockPanelType.ReportExplorer];

            reportExplorer.CollapseAll();

            // Access the Property Grid.
            PropertyGridDockPanel propertyGrid =
                (PropertyGridDockPanel)designForm.DesignDockManager[DesignDockPanelType.PropertyGrid];

            propertyGrid.ShowCategories  = false;
            propertyGrid.ShowDescription = false;

            // Show the End-User Designer form.
            designForm.ShowDialog();
        }
        private void buttonDesign_Click(object sender, EventArgs e)
        {
            // Open a selected report in the report designer.
            XRDesignForm form = new XRDesignForm();
            string       url  = GetSelectedUrl();

            if (!string.IsNullOrEmpty(url))
            {
                form.OpenReport(url);
            }
            form.ShowDialog(this);

            object selectedItem = listBox1.SelectedItem;

            FillListBox();
            if (selectedItem != null && listBox1.Items.Contains(selectedItem))
            {
                listBox1.SelectedItem = selectedItem;
            }
        }
        private void AddToolbarButton_SelectDataSource(XRDesignForm form)
        {
            var item = new BarButtonItem(form.DesignBarManager, "Select Datasource...");

            // Click Handler
            item.ItemClick += (s, e) =>
            {
                if (form.DesignMdiController.ActiveDesignPanel == null)
                {
                    MessageBox.Show("Please create/open a report.");
                    return;
                }

                var report = form.DesignMdiController.ActiveDesignPanel.Report;
                report.TryAs <MyReportBase>(myReport => PromptSelectDatasource(form, myReport));
            };

            // Add Datasource Button
            form.DesignBarManager.Toolbar.AddItem(item);
        }
        private void LoadDesigner(ReportType type)
        {
            XRDesignForm form       = new XRDesignForm();
            var          controller = form.DesignMdiController;

            if (type == ReportType.Category)
            {
                controller.AddService(typeof(ReportTypeService),
                                      new CategoryReportService());
            }
            else
            {
                controller.AddService(typeof(ReportTypeService),
                                      new PersonReportService());
            }

            controller.CreateNewReport();
            form.DesignDockManager[DesignDockPanelType.FieldList].Show();
            form.ShowDialog();
            LoadReportMenu();
        }
Exemplo n.º 15
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Create a design form and get its MDI controller.
            XRDesignForm form = new XRDesignForm();

            mdiController = form.DesignMdiController;

            // Handle the DesignPanelLoaded event of the MDI controller,
            // to override the SaveCommandHandler for every loaded report.
            mdiController.DesignPanelLoaded +=
                new DesignerLoadedEventHandler(mdiController_DesignPanelLoaded);

            // Open an empty report in the form.
            mdiController.OpenReport(new XtraReport1());

            // Show the form.
            form.ShowDialog();
            if (mdiController.ActiveDesignPanel != null)
            {
                mdiController.ActiveDesignPanel.CloseReport();
            }
        }
        private void CreateDesigner(string relativeReportBasePath)
        {
            DesignForm = CreateDesignForm();
            var controller = DesignForm.DesignMdiController;

            // Hide Scripting & HTML Preview
            controller.SetCommandVisibility(ReportCommand.ShowScriptsTab, CommandVisibility.None);
            controller.SetCommandVisibility(ReportCommand.ShowHTMLViewTab, CommandVisibility.None);

            // Use ReportController during PrintPreview
            this.UseReportControllerDuringPrintPreview();

            // Pass Datasource to Subreports
            this.SetupDesignTimeSubreportDatasourcePassing();

            // Add toolbar button to select Datasource
            AddToolbarButton_SelectDataSource(DesignForm);

            // Relative Path ReportSourceURL (Sad this is static/global.  Bad Design, DevExpress.)
            var relativePathStorage = new RelativePathReportStorage(relativeReportBasePath);

            ReportStorageExtension.RegisterExtensionGlobal(relativePathStorage);
        }
Exemplo n.º 17
0
        public void DesignReport()
        {
            try
            {
                if (gridView1.FocusedRowHandle < 0)
                {
                    return;
                }
                this.Cursor = Cursors.WaitCursor;
                string rptName = gridView1.GetFocusedRowCellValue("Report_Name").ToStringEx();
                string rptId   = gridView1.GetFocusedRowCellValue("Report_Id").ToStringEx();
                var    list    = new List <MyParameter>();
                list.Add("cReport_Id", DbType.String, rptId, null);
                object obj = BaseService.Get("SystemReport_Data", list);

                string    wk = gridView1.GetFocusedRowCellValue("Report_WorkSet").ToStringEx();
                DataTable dt = new DataTable();

                if (!string.IsNullOrEmpty(wk))
                {
                    var mps = InitializeBind(wk);
                    dt = BaseService.Open(wk, mps);
                }
                dt.TableName = "DataSource";
                string       rptFile    = Guid.NewGuid().ToString();
                XRDesignForm designForm = new XRDesignForm();
                XtraReport   xtraReport = new XtraReport();
                xtraReport.Name = rptName;
                if (obj != DBNull.Value)
                {
                    byte[] bs = (byte[])obj;
                    File.WriteAllBytes(rptFile, bs);
                    xtraReport.LoadLayout(bs.ToStream());
                }
                //xtraReport.RequestParameters = false;
                xtraReport.DataSource = dt;
                //xtraReport.Parameters.Clear();
                //xtraReport.Parameters.AddRange(ps.ToArray());
                designForm.OpenReport(xtraReport);
                designForm.Shown += delegate
                {
                    if (designForm.ActiveDesignPanel != null)
                    {
                        designForm.ActiveDesignPanel.Text     = rptName;
                        designForm.ActiveDesignPanel.FileName = rptFile;
                    }
                };
                designForm.FormClosing += delegate
                {
                    MemoryStream ms = new MemoryStream();
                    designForm.ActiveDesignPanel.Report.SaveLayout(ms);
                    list.Add("Report_Bytes", DbType.Binary, ms.ToBytes(), null);
                    BaseService.Execute("SystemReport_Data", list, "U");
                    //gridView1.SetFocusedRowCellValue("Report_Bytes", ms.ToBytes());
                    File.Delete(rptFile);
                };
                designForm.Show();
            }
            catch (Exception ex)
            {
                SharedFunc.RaiseError(ex);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Exemplo n.º 18
0
 public DummyDesignerContext(IDataSourceLocator locator)
 {
     DataSourceLocator = locator;
     DesignForm        = new XRDesignForm();
 }
        private static void PromptSelectDatasource(XRDesignForm form, XtraReport report, IDesignDataContext dataContext)
        {
            Form dialog = null;


            // Create Select Datasource Dialog
            dialog = new SelectDesignTimeDataSourceForm(dataContext, report, DefaultEventAggregator, new ObjectGraphPathTraverser());
            dialog.BringToFront();
            dialog.ShowDialog();
        }
        private void AddToolbarButton_SelectDataSource(XRDesignForm form)
        {
            var item = new BarButtonItem(form.DesignBarManager, "Select Datasource...");

            // Click Handler
            item.ItemClick += (s, e) =>
            {
                if (form.DesignMdiController.ActiveDesignPanel == null)
                {
                    MessageBox.Show("Please create/open a report.");
                    return;
                }

                var report = form.DesignMdiController.ActiveDesignPanel.Report;
                report.TryAs<MyReportBase>(myReport => PromptSelectDatasource(form, myReport));
            };

            // Add Datasource Button
            form.DesignBarManager.Toolbar.AddItem(item);
        }
        private static XRDesignForm CreateDesignForm()
        {
            // Create Runtime Report Designer
            XRDesignForm form = new XRDesignForm();

            form.Text = "Ryan & Jer's Report Designer";

            // Report Factory Service (which uses custom MyReportBase class)
            var service = new ReportFactory();
            form.DesignMdiController.AddService(typeof(ReportTypeService), service);

            return form;
        }
        private void PromptSelectDatasource(XRDesignForm form, MyReportBase report)
        {
            Form dialog = null;

            // Datasource Selected Callback
            Action<DesignTimeDataSourceDefinition> callback = (definition) =>
            {
                dialog.Close();

                // Change Report Datasource
                report.ChangeDesignTimeDatasource(definition, this);
            };

            // Create Select Datasource Dialog
            dialog = new SelectDesignTimeDataSourceForm(this, report, callback);
            dialog.BringToFront();
            dialog.ShowDialog();
        }
        private void CreateDesigner(string relativeReportBasePath)
        {
            DesignForm = CreateDesignForm();
            var controller = DesignForm.DesignMdiController;

            // Hide Scripting & HTML Preview
            controller.SetCommandVisibility(ReportCommand.ShowScriptsTab, CommandVisibility.None);
            controller.SetCommandVisibility(ReportCommand.ShowHTMLViewTab, CommandVisibility.None);

            // Use ReportController during PrintPreview
            this.UseReportControllerDuringPrintPreview();

            // Pass Datasource to Subreports
            this.SetupDesignTimeSubreportDatasourcePassing();

            // Add toolbar button to select Datasource
            AddToolbarButton_SelectDataSource(DesignForm);

            // Relative Path ReportSourceURL (Sad this is static/global.  Bad Design, DevExpress.)
            var relativePathStorage = new RelativePathReportStorage(relativeReportBasePath);
            ReportStorageExtension.RegisterExtensionGlobal(relativePathStorage);
        }
 public DummyDesignerContext(IDataSourceLocator locator)
 {
     DataSourceLocator = locator;
     DesignForm = new XRDesignForm();
 }