Ejemplo n.º 1
0
        private void DesignPanel_ComponentAdded(object sender, System.ComponentModel.Design.ComponentEventArgs e)
        {
            PageHeaderBand headerBand;

            host = (IDesignerHost)designer.DesignRibbonForm.DesignMdiController.ActiveDesignPanel.Report.Site.GetService(typeof(IDesignerHost));
            if (!(e.Component is XRLabel) && !(e.Component is XRTable))
            {
                return;
            }
            if (e.Component is XRLabel)
            {
                XRLabel label = e.Component as XRLabel;
                if (label.ExpressionBindings.Count == 0)
                {
                    return;
                }
                if (label.Parent is XRTableRow)
                {
                    return;
                }
                headerBand = CreatePageHeaderBand(designer.Report);
                XRLabel newLabel = CopyLabel(label, headerBand);
                headerBand.Controls.Add(newLabel);
                DesignToolHelper.AddToContainer(host, newLabel);
            }
            if (e.Component is XRTable)
            {
                headerBand = CreatePageHeaderBand(designer.Report);
                XRTableRow sourceRow   = (e.Component as XRTable).Rows[0];
                XRTable    headerTable = CreateTable(sourceRow, headerBand.HeightF);
                headerBand.Controls.Add(headerTable);
                DesignToolHelper.AddToContainer(host, headerTable);
            }
        }
Ejemplo n.º 2
0
            private void OnHandleAddSummaryField(object sender, CommandExecuteEventArgs e)
            {
                var designPanel = designMdiController.ActiveDesignPanel;
                var node        = (DataMemberListNodeBase)e.Args[0];

                var report        = designPanel.Report;
                var designerHost  = designPanel.GetService <IDesignerHost>();
                var changeServ    = designPanel.GetService <IComponentChangeService>();
                var selectionServ = designPanel.GetService <ISelectionService>();

                // Functionality patterned after AddCalculatedField() from DevExpress.XtraReports.Design.Commands.FieldListCommandExecutor, DevExpress.XtraReports.v16.1.Extensions.dll, Version=16.1.4.0
                var c = new SummaryField {
                    DataSource = node.DataSource != report.DataSource ? node.DataSource : null, DataMember = node.DataMember ?? string.Empty
                };
                var description = $"Add {nameof(SummaryField)} object";
                var transaction = designerHost.CreateTransaction(description);

                try
                {
                    var propertyDescriptor = XRAccessor.GetPropertyDescriptor(report, "CalculatedFields");
                    changeServ.OnComponentChanging(report, propertyDescriptor);
                    DesignToolHelper.AddToContainer(designerHost, c);
                    report.CalculatedFields.Add(c);
                    changeServ.OnComponentChanged(report, propertyDescriptor, null, null);
                }
                finally
                {
                    transaction.Commit();
                }
                selectionServ.SetSelectedComponents(new[] { c });
            }
        private void AddField(IComponent objeto, string desiredName)
        {
            IDesignerHost host = xrDesignPanel1.GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (host != null)
            {
#pragma warning disable CS0612 // Type or member is obsolete
                DesignToolHelper.AddToContainer(host, objeto, desiredName);
#pragma warning restore CS0612 // Type or member is obsolete
            }
        }
        public void AddChildControlsToContainer()
        {
            MyCompositeControl panel = this.XRControl as MyCompositeControl;

            foreach (XRControl childControl in panel.Controls)
            {
                System.Drawing.PointF loc          = childControl.LocationF;
                IDesignerHost         designerHost = (IDesignerHost)GetService(typeof(IDesignerHost));
                DesignToolHelper.AddToContainer(designerHost, childControl);
                childControl.LocationF = loc;
            }
        }
Ejemplo n.º 5
0
        PageHeaderBand CreatePageHeaderBand(XtraReport report)
        {
            PageHeaderBand headerBand = report.Bands[BandKind.PageHeader] as PageHeaderBand;

            // Remove the comments if you need to recreate the PageHeader band
            //if(headerBand != null) {
            //    for(int i = headerBand.Controls.Count - 1; i >= 0; i--)
            //        DesignToolHelper.RemoveFromContainer(host, headerBand.Controls[i]);
            //    headerBand.Controls.Clear();
            //    DesignToolHelper.RemoveFromContainer(host, headerBand);
            if (headerBand == null)
            {
                headerBand         = new PageHeaderBand();
                headerBand.HeightF = 0;
                headerBand.Visible = true;
                DesignToolHelper.AddToContainer(host, headerBand);
            }
            return(headerBand);
        }
        public override void HandleDragDrop(object sender, DragEventArgs e)
        {
            ResetUI(e);

            XRControl parent = BandViewSvc.GetControlByScreenPoint(new Point(e.X, e.Y));

            if (parent == null)
            {
                return;
            }

            XRRichText demoRichText = new XRRichText();
            PointF     location     = GetDragDropLocation(e, demoRichText, parent);

            DesignToolHelper.AddToContainer(Host, demoRichText);

            demoRichText.LocationF = location;
            demoRichText.Size      = new Size(100, 25);
            demoRichText.DataBindings.Add("Rtf", null, "test");
        }
Ejemplo n.º 7
0
            private void OnHandleAddSummaryField(object sender, CommandExecuteEventArgs e)
            {
                var designPanel      = designMdiController.ActiveDesignPanel;
                var fieldListControl = ((FieldListDockPanel)designDockManager[DesignDockPanelType.FieldList]).GetFieldList();
                var node             = fieldListControl.DataMemberNode;

                if (node == null)
                {
                    return;
                }
                if (!node.IsList)
                {
                    node = (DataMemberListNodeBase)node.ParentNode;
                }

                var report        = designPanel.Report;
                var designerHost  = designPanel.GetService <IDesignerHost>();
                var changeServ    = designPanel.GetService <IComponentChangeService>();
                var selectionServ = designPanel.GetService <ISelectionService>();

                // Functionality patterned after AddCalculatedField() from DevExpress.XtraReports.Design.Commands.FieldListCommandExecutor, DevExpress.XtraReports.v14.1.Extensions.dll, Version=14.1.5.0
                var c = new SummaryField {
                    DataSource = node.DataSource != report.DataSource ? node.DataSource : null, DataMember = node.DataMember ?? string.Empty
                };
                var description = string.Format("Add {0} object", typeof(SummaryField).Name);
                var transaction = designerHost.CreateTransaction(description);

                try
                {
                    var propertyDescriptor = XRAccessor.GetPropertyDescriptor(report, "CalculatedFields");
                    changeServ.OnComponentChanging(report, propertyDescriptor);
                    DesignToolHelper.AddToContainer(designerHost, c);
                    report.CalculatedFields.Add(c);
                    changeServ.OnComponentChanged(report, propertyDescriptor, null, null);
                }
                finally
                {
                    transaction.Commit();
                }
                selectionServ.SetSelectedComponents(new[] { c });
            }
Ejemplo n.º 8
0
        void CopyCell(XRTableCell source, XRTableRow row)
        {
            XRTableCell cell = new XRTableCell();

            cell.WidthF        = source.WidthF;
            cell.HeightF       = source.HeightF;
            cell.BackColor     = Color.Green;
            cell.ForeColor     = Color.Yellow;
            cell.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter;
            cell.Font          = new Font("Calibry", 11, FontStyle.Bold);
            string text  = source.ExpressionBindings[0].Expression;
            int    index = text.LastIndexOf(".");

            if (index > 0)
            {
                text = text.Substring(index + 1);
            }
            cell.Text = text;
            row.Cells.Add(cell);
            DesignToolHelper.AddToContainer(host, cell);
        }
 private void OnDesignerLoaded(object sender, DesignerLoadedEventArgs e)
 {
     DesignToolHelper.AddToContainer(e.DesignerHost, ds);
     DesignToolHelper.AddToContainer(e.DesignerHost, adapter);
 }