示例#1
0
        // ** handle styles page

        private void _lbStyles_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            ReportStyle style = _lbStyles.SelectedItem as ReportStyle;

            _picStyle.Image          = (style != null) ? style.GetPreview(false) : null;
            _owner._defaultStyleName = style.Name;
        }
示例#2
0
        // ** ICloneable
        public object Clone()
        {
            ReportStyle clone = (ReportStyle)this.MemberwiseClone();

            for (int i = 0; i < _sections.Length; i++)
            {
                clone._sections[i] = (SectionStyle)_sections[i].Clone();
            }
            clone._builtIn = false;
            return(clone);
        }
示例#3
0
        private void _btnAdd_Click(object sender, System.EventArgs e)
        {
            // clone current style
            ReportStyle style = _list.SelectedItem as ReportStyle;
            ReportStyle clone = style.Clone() as ReportStyle;

            // ensure that new name is unique
            clone.Name = CreateUniqueName(clone.Name);

            // add it to list control
            _list.Items.Add(clone);
            _list.SelectedItem = clone;

            // remember we're dirty
            _dirty = true;
        }
示例#4
0
        private void _btnApply_Click(object sender, System.EventArgs e)
        {
            // get selected style
            ReportStyle style = _list.SelectedItem as ReportStyle;

            if (style != null && _designer != null && _designer.Report != null)
            {
                // save state, apply to report, repaint
                _designer.UndoSaveState();
                style.Apply(_designer.Report);
                _designer.Invalidate();

                // this is the new 'current' style
                _owner._defaultStyleName = style.Name;
            }
        }
示例#5
0
        // update preview when properties change
        private void _propGrid_PropertyValueChanged(object s, System.Windows.Forms.PropertyValueChangedEventArgs e)
        {
            // update preview
            ReportStyle style = _list.SelectedItem as ReportStyle;

            _preview.Image = style.GetPreview(true);

            // update list
            if (e.ChangedItem.PropertyDescriptor.Name == "Name")
            {
                int index = _list.SelectedIndex;
                _list.Items[index] = style;
            }

            // remember we're dirty
            _dirty = true;
        }
示例#6
0
        private void _btnRemove_Click(object sender, System.EventArgs e)
        {
            // get current style, index
            ReportStyle style = _list.SelectedItem as ReportStyle;
            int         index = _list.SelectedIndex;

            // remove current style
            _list.Items.Remove(style);

            // restore index
            if (index >= _list.Items.Count)
            {
                index = _list.Items.Count - 1;
            }
            _list.SelectedIndex = index;

            // remember we're dirty
            _dirty = true;
        }
示例#7
0
        // update style preview
        private void _list_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            // get current style
            ReportStyle style = _list.SelectedItem as ReportStyle;

            if (style == null)
            {
                return;
            }

            // update preview
            _preview.Image = style.GetPreview(false);

            // we add a readonly attribute to predefined styles so that the grid can be used
            // to explore it but cannot change it:
            _propGrid.Enabled = true;
            if (!style.IsCustom)
            {
                var roAttribute = new ReadOnlyAttribute(true);
                if (!TypeDescriptor.GetAttributes(style).Matches(roAttribute))
                {
                    TypeDescriptor.AddAttributes(style, roAttribute);
                }
            }

            // update property grid
            _propGrid.SelectedObject = style;

            _propGrid.Refresh();

            // only custom styles can be edited:
            _lblPropGrid.Text = style.IsCustom ? Strings.ReportStyleForm.CustomStyleCaption : Strings.ReportStyleForm.BuiltInStyleCaption;

            // update buttons
            _btnRemove.Enabled = style.IsCustom;
        }
示例#8
0
        // create report based on current user selections
        // note: at this point _rpt.DataSource is already set
        private void CreateReport()
        {
            // set report name
            _rpt.ReportName = _txtReportName.Text.Trim();

            // set up data source
            DataSource ds = _rpt.DataSource;

            ds.ConnectionString = _dsPicker.ConnectionString;
            ds.RecordSource     = _dsPicker.RecordSource;

            // get schema and field template list
            _schema    = _rpt.DataSource.DataSourceInfo;
            _fieldList = BuildFieldTemplateList();

            // set up layout object
            Layout lo = _rpt.Layout;

            lo.Orientation = (_btnLandscape.Checked)
                ? OrientationEnum.Landscape
                : OrientationEnum.Portrait;

            lo.Width = lo.PageSize.Width - lo.MarginLeft - lo.MarginRight;
            double width = lo.Width;

            // create report groups
            foreach (string s in _lstGroups.Items)
            {
                SortEnum sort = (IsFieldNumber(s)) ? SortEnum.Descending : SortEnum.Ascending;
                Group    g    = _rpt.Groups.Add(s, s, sort);
                g.KeepTogether            = KeepTogetherEnum.KeepFirstDetail;
                g.OutlineLabel.Expression = s;
                // Make group header/footer visible (they are not by default, have no idea why):
                g.SectionFooter.Visible = true;
                g.SectionFooter.Visible = true;
            }

            // special handling for label reports
            if (_btnLabels.Checked)
            {
                ListViewItem lvi = (_lvLabels.SelectedItems.Count > 0)
                    ? _lvLabels.SelectedItems[0]
                    : _lvLabels.Items[0];
                ReportLabel lbl = (ReportLabel)lvi.Tag;
                BuildDetail(lbl);
                return;
            }

            // build report header (1 field)
            Section section = _rpt.Sections[SectionTypeEnum.Header];

            section.Visible = true;
            section.Height  = 800;

            section.Fields.Add(
                MakeTextField("titleLbl",
                              _txtReportName.Text,
                              FIELD_OFFSET, 200, width, 600, FieldAlignEnum.LeftMiddle));

            // build page footer (2 fields)
            section         = _rpt.Sections[SectionTypeEnum.PageFooter];
            section.Visible = true;
            section.Height  = 500;

            section.Fields.Add(
                MakeTextField("ftrLeft",
                              new ScriptObjectValue()
            {
                Expression = "Now()"
            },
                              FIELD_OFFSET, 30, width / 2, 300, FieldAlignEnum.LeftTop));

            section.Fields.Add(
                MakeTextField("ftrRight",
                              new ScriptObjectValue()
            {
                Expression = Strings.ReportWizard.PageOfPagesText
            },
                              width / 2, 30, width / 2, 300, FieldAlignEnum.RightTop));

            // build other sections (these vary with selected layout)
            BuildPageHeader();
            for (int i = 0; i < _rpt.Groups.Count; i++)
            {
                BuildGroupHeader(i);
            }
            BuildDetail();

            // all done, apply selected style
            ReportStyle style = _lbStyles.SelectedItem as ReportStyle;

            if (style != null)
            {
                style.Apply(_rpt);
            }
        }