コード例 #1
0
 // Open report file in flex viewer
 private void OpenFile(string rptFile, string rptName)
 {
     try
     {
         _flexReport = new C1FlexReport();
         string           filePath = rptFile.Substring(rptFile.IndexOf("Reports"));
         System.IO.Stream file     = null;
         if (File.Exists(rptFile))
         {
             file = new FileStream(rptFile, FileMode.Open, FileAccess.Read);
             ChangeConStrin(ref file);
             _flexReport.Load(file, rptName);
         }
         else if (File.Exists(filePath))
         {
             file = new FileStream(filePath, FileMode.Open, FileAccess.Read);
             ChangeConStrin(ref file);
             _flexReport.Load(file, rptName);
         }
         else
         {
             throw new FileNotFoundException(new FileNotFoundException() + " " + filePath);
         }
         flexViewer.DocumentSource = null;
         flexViewer.DocumentSource = _flexReport;
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }
コード例 #2
0
        public ExportPage()
        {
            this.InitializeComponent();

            _report = new C1FlexReport();

            //
            _previousItem = (ReportItem)tbReportFile.Items[0];
            tbReportFile.Items.Add(new ReportItem()
            {
                Caption = c_Builtin
            });
            tbReportFile.Items.Add(new ReportItem()
            {
                Caption = c_Browse
            });
            tbReportFile.SelectedIndex = 0;

            // build list of supported export filters
            foreach (var e in _report.SupportedExportProviders)
            {
                cbExportFilter.Items.Add(e.FormatName);
            }
            cbExportFilter.SelectedIndex = 0;
        }
コード例 #3
0
        private void LoadZip()
        {
            // locate zip file
            string strFile = Application.ExecutablePath;
            int    i       = strFile.IndexOf("\\bin");

            if (i > -1)
            {
                strFile = strFile.Substring(0, i);
            }
            strFile += "\\" + zipName;

            // open password-protected zip file
            C1ZipFile zip = new C1ZipFile();

            zip.Open(strFile);
            zip.Password = zipPwd;

            // load report definition XML document from compressed stream
            Stream stream = zip.Entries[0].OpenReader();

            _xmlDoc = new XmlDocument();
            _xmlDoc.PreserveWhitespace = true;
            _xmlDoc.Load(stream);
            stream.Close();
            //
            zip.Close();
            //
            _lbReports.Items.AddRange(C1FlexReport.GetReportList(_xmlDoc));
        }
コード例 #4
0
        public static void SetupField(C1FlexReport report, TextField f, string createInfo)
        {
            // get expression
            if (createInfo != null && _fieldList.Contains(createInfo))
            {
                string expression = _fieldList[createInfo] as string;
                // System.Diagnostics.Debug.Assert(expression != null);


                // if the field expression starts with an equals sign, evaluate
                // the expression at creation time and store the value
                if (expression.StartsWith("="))
                {
                    f.Text = report.Evaluate(expression.Substring(1)).ToString();
                }
                else // otherwise, evaluate at render time
                {
                    f.Text = "=" + expression;
                }
            }
            else
            {
                // arbitrary formula:
                f.Text = ("=" + createInfo) ?? "data";
            }
        }
コード例 #5
0
        async void ViewerPage_Loaded(object sender, RoutedEventArgs e)
        {
            _asm = typeof(ViewerPage).GetTypeInfo().Assembly;
            await ExportPage.CopyC1NWind();

            string[] reports = null;

            // get list of reports from resource using stream
            using (Stream stream = _asm.GetManifestResourceStream("FlexReportSamples.Resources.FlexCommonTasks_UWP.flxr"))
                reports = C1FlexReport.GetReportList(stream);

            cbReport.Items.Clear();
            cbReport.SelectionChanged += CbReport_SelectionChanged;

            if (reports != null && reports.Length > 0)
            {
                foreach (string s in reports)
                {
                    cbReport.Items.Add(s);
                }
            }

            foreach (string s in _pdfs)
            {
                cbReport.Items.Add(s);
            }

            cbReport.SelectedIndex = 0;
        }
コード例 #6
0
        public CurrentOpportunities()
        {
            this.InitializeComponent();

            _flexReport = new C1FlexReport();
            Loaded     += OnLoaded;
        }
コード例 #7
0
        public void Init(FlexDesignerHostServices services, object propOwner, string propName, object value, bool supportExpression)
        {
            _propOwner     = propOwner;
            _propName      = propName;
            _pictureHolder = value as PictureHolder ?? PictureHolder.FromObject(null, null);
            _services      = services;
            if (_services != null)
            {
                var grs = _services.GetService(typeof(IGetReportsService)) as IGetReportsService;
                if (grs != null)
                {
                    _report = grs.Report;
                }
            }

            _canExpression = supportExpression && _report != null;
            if (_services != null)
            {
                var scriptService = _services.GetScriptEditorService();
                _canEditScript = _canExpression && scriptService != null;
            }
            else
            {
                _canEditScript = false;
            }
            UpdateUI();
        }
コード例 #8
0
        public RegionWiseSales()
        {
            InitializeComponent();

            _flexReport = new C1FlexReport();
            Loaded     += ViewerPage_Loaded;
        }
コード例 #9
0
        /// <summary>
        /// Returns a collection of report names.
        /// </summary>
        /// <param name="ctx">An <see cref="ITypeDescriptorContext"/> that provides a format context that can be
        /// used to extract additional information about the environment from which this converter is invoked.
        /// This parameter or properties of this parameter can be a null reference (Nothing in Visual Basic).</param>
        /// <returns>A <see cref="TypeConverter.StandardValuesCollection"/> that holds a standard set of valid values.</returns>
        override public StandardValuesCollection GetStandardValues(ITypeDescriptorContext ctx)
        {
            object instance;
            FlexDesignerHostServices services;

            if (!Util.EditableModelHelper.GetInstanceAndServices(ctx, out instance, out services))
            {
                return(base.GetStandardValues(ctx));
            }

            var grs = services.GetGetReportService();

            if (grs == null)
            {
                return(base.GetStandardValues(ctx));
            }

            C1FlexReport report = grs.Report;

            if (report == null)
            {
                return(base.GetStandardValues(ctx));
            }

            // get report list from control
            List <string> reportNames = new List <string>();

            reportNames.Add(c_strNull);
            reportNames.AddRange(grs.GetReportList().Where((rep_) => !report.Equals(rep_)).Select((rep_) => rep_.ReportName));
            return(new StandardValuesCollection(reportNames));
        }
コード例 #10
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            //
            // create data table
            _dataTable = new DataTable();
            _dataTable.Columns.Add("ProductName", typeof(string));
            _dataTable.Columns.Add("UnitsInStock", typeof(int));
            _dataTable.Columns.Add("CategoryID", typeof(int));
            for (int i = 0; i < 100; i++)
            {
                string name  = "Product " + i;
                int    units = 5 * i;
                int    id    = i % 20 + 1;
                _dataTable.Rows.Add(new object[] { name, units, id });
            }

            // save original subreport filter expression
            SubreportField srField = (SubreportField)_c1flxr.Fields["SubreportField"];

            _strFilter = srField.SubreportFilter;

            // hook up startReport event to apply custom filter when needed
            C1FlexReport rptSubreport = srField.Subreport;

            rptSubreport.StartReport += new System.EventHandler(_StartReport);
        }
コード例 #11
0
        // apply custom filter if one wasn't provided
        private void _StartReport(object sender, System.EventArgs e)
        {
            // get subreport field
            SubreportField srField = (SubreportField)_c1flxr.Fields["SubreportField"];

            // if the filter is set, nothing to do
            if (!string.IsNullOrEmpty((string)srField.SubreportFilter))
            {
                return;
            }

            // build custom filter
            // (add 5 to current ID just to show that it works)
            int    currentID = (int)_c1flxr.Evaluate("CategoryID");
            string filter    = string.Format("CategoryID = '{0}'", currentID + 5);

            // apply custom filter
            DataView dv = _dataTable.DefaultView;

            dv.RowFilter = filter;

            // and apply data source to the report
            C1FlexReport rptSubreport = srField.Subreport;

            rptSubreport.DataSource.Recordset = dv.ToTable();
        }
コード例 #12
0
        public EditorScriptContextCollection(Forms.ScriptEditorFormEx owner, C1FlexReport report, C1FlexReportDesigner designer)
        {
            _owner  = owner;
            _report = report;
            string name;

            foreach (var ds in report.DataSources)
            {
                // For each data source, we add 3 contexts:
                // - data handler
                // - regular report
                // - data filter
                string dsName = ds.Name;
                name = EditorScriptContextBase.MakeContextName(ds.Name, ScriptEditorContextKind.DataHandler);
                _contexts.Add(name, new EditorScriptDataHandlerContext(name, _report, ds, designer));
                name = EditorScriptContextBase.MakeContextName(ds.Name, ScriptEditorContextKind.ReportScript);
                _contexts.Add(name, new EditorScriptReportScriptContext(name, _report, ds, designer));
                name = EditorScriptContextBase.MakeContextName(ds.Name, ScriptEditorContextKind.DataView);
                _contexts.Add(name, new EditorScriptDataFilterContext(name, _report, ds, designer));
            }
            // 'report-only' context (currently used for parameter's allowed values collection edits):
            name = EditorScriptContextBase.MakeContextName(string.Empty, ScriptEditorContextKind.ReportScript);
            _contexts.Add(name, new EditorScriptReportScriptContext(name, _report, null, designer));
            // meta context for expressions that can only access parameters (currently only data sort definition),
            // also is used for cases when corresponding context was not found (patchy but will do for now):
            name = EditorScriptContextBase.MakeContextName(null, ScriptEditorContextKind.MetaView);
            _contexts.Add(name, new EditorScriptMetaViewContext(name, _report, designer));
        }
コード例 #13
0
 private static string GetDataSourceName(FlexChartFieldBase field, C1FlexReport report)
 {
     if (field != null && !string.IsNullOrEmpty(field.DataSourceName))
     {
         return(field.DataSourceName);
     }
     return(report.DataSourceName);
 }
コード例 #14
0
        public ViewerPanePage()
        {
            this.InitializeComponent();
            this.Unloaded += ViewerPage_Unloaded;
            this.Loaded   += ViewerPage_Loaded;

            _report = new C1FlexReport();
        }
コード例 #15
0
        void ViewerPage_Unloaded(object sender, RoutedEventArgs e)
        {
            cbReport.SelectionChanged -= CbReport_SelectionChanged;

            flexViewerPane.DocumentSource = null;
            _report.Dispose();
            _report = null;
        }
コード例 #16
0
        public static string GuessContextName(C1FlexReport report, object @object, string propertyName)
        {
            string dsName;
            ScriptEditorContextKind kind;

            GuessContextName(report, @object, propertyName, out dsName, out kind);
            return(MakeContextName(dsName, kind));
        }
コード例 #17
0
 public void Discard()
 {
     if (Report != null)
     {
         Report.Dispose();
         Report = null;
     }
     Error = null;
 }
コード例 #18
0
        public MainPage()
        {
            this.InitializeComponent();

            _report = new C1FlexReport();
            flexViewer.PrepareToolMenu      += FlexViewer_PrepareToolMenu;
            flexViewer.NavigateToCustomTool += FlexViewer_NavigateToCustomTool;
            this.Loaded += MainPage_Loaded;
        }
コード例 #19
0
        // ** event handlers

        // initialize
        private void ReportWizard_Load(object sender, System.EventArgs e)
        {
            // hide tabs
            _tabPanel_SizeChanged(this, EventArgs.Empty);

            // create new report
            _rpt = new C1FlexReport();
            _rpt.DataSource.IsolationLevel = _owner._isolationLevel;
            _dsPicker.IsolationLevel       = _owner._isolationLevel;

            // Make sections visible:
            foreach (var s in C1FlexReportDesigner.GetSectionsInDesignerOrder(_rpt))
            {
                s.Visible = true;
            }

            // make wizard title bold, slightly bigger
            bool largeFonts = false;

            using (Graphics tg = Graphics.FromHwnd(IntPtr.Zero))
                largeFonts = tg.DpiX > 100;
            _lblTitle.Font = new Font(Font.Name, Font.SizeInPoints + (largeFonts ? 1 : 2), FontStyle.Bold, GraphicsUnit.Point);

            // select first page (step)
            _tab.SelectedIndex = 1;
            _tab.SelectedIndex = 0;

            // initialize layout page
            _btnTabular.Checked = false;
            _btnTabular.Checked = true;

            // initialize styles page
            foreach (ReportStyle style in ReportStyle.StyleList)
            {
                // add style to list
                _lbStyles.Items.Add(style);

                // select default style
                if (string.Compare(style.Name, _owner._defaultStyleName, true) == 0)
                {
                    _lbStyles.SelectedIndex = _lbStyles.Items.Count - 1;
                }
            }
            if (_lbStyles.SelectedIndex < 0)
            {
                _lbStyles.SelectedIndex = 0;
            }

            // initialize labels page
            _picLabels.Image      = BitmapFromStream("loLabels.bmp", Color.Red);
            _btnEnglish.Checked   = true;
            _btnSheetFeed.Checked = true;

            // initialize report title page
            _picFinish.Image    = BitmapFromStream("wizFinish.bmp", Color.Red);
            _txtReportName.Text = string.Empty;
        }
コード例 #20
0
        /// <summary>
        /// Gets the editor style used by the <see cref="EditValue"/> method.
        /// If there are available bindable fields, returns DropDown, otherwise Modal.
        /// </summary>
        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext ctx)
        {
            object instance;
            FlexDesignerHostServices services;

            if (!Util.EditableModelHelper.GetInstanceAndServices(ctx, out instance, out services))
            {
                return(UITypeEditorEditStyle.None);
            }

            if (ctx.PropertyDescriptor.PropertyType == typeof(ScriptEnumValue <SortDirection>))
            {
                _listBox.FillWithSortDirections();
            }
            else
            {
                var grs = services.GetGetReportService();
                if (grs == null)
                {
                    return(UITypeEditorEditStyle.None);
                }

                C1FlexReport report = grs.Report;
                if (report == null)
                {
                    return(UITypeEditorEditStyle.None);
                }

                string dataSourceName;
                ScriptEditorContextKind contextKind;
                EditorScriptContextBase.GuessContextName(report, instance, ctx.PropertyDescriptor.Name, out dataSourceName, out contextKind);

                if (contextKind == ScriptEditorContextKind.DataView)
                {
                    return(UITypeEditorEditStyle.Modal);
                }

                if (contextKind == ScriptEditorContextKind.MetaView)
                {
                    dataSourceName = report.DataSourceName;
                }

                var ds = report.DataSources.FindByName(dataSourceName);
                _listBox.FillWithFields(report, ds, contextKind);
            }

            if (_listBox.Items.Count == 1) // just the expression editor
            {
                return(UITypeEditorEditStyle.Modal);
            }

            // done
            return(UITypeEditorEditStyle.DropDown);
        }
コード例 #21
0
 public C1FlexReport GetReport(string reportName)
 {
     if (_stream != null)
     {
         _stream.Seek(0, SeekOrigin.Begin);
         var fr = new C1FlexReport();
         fr.Load(_stream, reportName);
         return(fr);
     }
     return(null);
 }
コード例 #22
0
 public ParametersState(C1FlexReport report)
 {
     _report     = report;
     _parameters = new List <ReportParameter>(_report.Parameters.Count);
     foreach (var p in report.Parameters)
     {
         var copy = new ReportParameter();
         copy.AssignFrom(p);
         _parameters.Add(copy);
     }
 }
コード例 #23
0
        public DialogResult ShowDialog(C1FlexReport rpt)
        {
            _reportInfo = rpt.ReportInfo.Clone();

            _txtTitle.DataBindings.Add(new Binding("Text", ReportInfo, "Title"));
            _txtAuthor.DataBindings.Add(new Binding("Text", ReportInfo, "Author"));
            _txtSubject.DataBindings.Add(new Binding("Text", ReportInfo, "Subject"));
            _txtCreator.DataBindings.Add(new Binding("Text", ReportInfo, "Creator"));
            _txtKeywords.DataBindings.Add(new Binding("Text", ReportInfo, "Keywords"));

            return(base.ShowDialog());
        }
コード例 #24
0
        private void DoDataTreeDelete()
        {
            if (!cDataTreeDelete.Enabled)
            {
                return;
            }

            C1FlexReport report = _flexDesigner.Report;

            if (report == null)
            {
                return;
            }

            var o = _dataTree.SelectedDataObject;

            _dataTree.EndInPlaceEdit();
            BeginUpdates();
            _flexDesigner.UndoSaveState();
            var nextBoss = _dataTree.GetNextBossKey();

            if (o is ReportParameter)
            {
                var rp = (ReportParameter)o;
                rp.Owner.Remove(rp);
                foreach (var ds in report.DataSources)
                {
                    ds.ResetDataSourceInfo();
                }
            }
            else if (o is DataSource)
            {
                var ds = (DataSource)o;
                report.DataSources.RemoveAt(report.DataSources.IndexOf(ds));
            }
            else if (o is CalculatedField)
            {
                var cf = (CalculatedField)o;
                cf.DataSource.CalculatedFields.Remove(cf);
            }
            else if (o is SortDefinition)
            {
                var se = (SortDefinition)o;
                se.Owner.Remove(se);
            }
            else
            {
                System.Diagnostics.Debug.Assert(false);
            }
            EndUpdates(true);
            UpdateUI(true, true);
            _dataTree.GoToNode(null, nextBoss, true);
        }
コード例 #25
0
 public DataSourcesState(C1FlexReport report)
 {
     _report             = report;
     _mainDataSourceName = report.DataSourceName;
     _dataSources        = new List <DataSource>(_report.DataSources.Count);
     foreach (var ds in report.DataSources)
     {
         var copy = new DataSource();
         copy.AssignFrom(ds, true);
         _dataSources.Add(copy);
     }
 }
コード例 #26
0
            public void Init(FlexDesignerHostServices services, C1FlexReport subreport)
            {
                _services   = services;
                _subreport  = subreport;
                _emptyNames = false;

                PopulateItems();
                if (Items.Count == 0)
                {
                    Items.Add("(no parameters in supreport)");
                    _emptyNames = true;
                }
            }
コード例 #27
0
        public void Init(IServiceProvider provider, string scriptSource, string scriptName)
        {
            _provider     = provider;
            _scriptSource = scriptSource;
            _scriptName   = scriptName;

            var grs = _provider.GetService(typeof(IGetReportsService)) as IGetReportsService;

            Debug.Assert(grs != null);
            _report = grs.Report;

            PopulateFields();
        }
コード例 #28
0
        void OnLoaded(object sender, RoutedEventArgs rea)
        {
            Loaded -= OnLoaded;

            using (_reportStream = File.OpenRead("Assets/Reports/RegionWiseSalesData.flxr"))
            {
                string[] reports = C1FlexReport.GetReportList(_reportStream);
                fv.DocumentSource = null;
                _reportStream.Seek(0, SeekOrigin.Begin);
                _flexReport.Load(_reportStream, reports[0]);
                fv.DocumentSource = _flexReport;
            }
        }
コード例 #29
0
 void CloseFile()
 {
     _doc = null;
     if (_report != null)
     {
         this.Text         = FormTitle;
         fv.DocumentSource = null;
         _report.Dispose();
         _report = null;
         _reportsCombo.Items.ClearAndDisposeItems();
         _reportsCombo.SelectedIndex = -1;
     }
     UpdateEnabled();
 }
コード例 #30
0
        private void DoAddSortDefinition()
        {
            if (!cAddSort.Enabled)
            {
                return;
            }

            C1FlexReport report = _flexDesigner.Report;

            if (report == null)
            {
                return;
            }

            var ds = _dataTree.GetCurrentDataSource();

            if (ds == null)
            {
                return;
            }

            var                     contextName = EditorScriptContextBase.MakeContextName(ds.Name, ScriptEditorContextKind.MetaView);
            SortDefinition          sd          = null;
            Func <DataSource, bool> addSort     = (ds_) =>
            {
                sd = new SortDefinition();
                ds_.SortDefinitions.Add(sd);
                using (Forms.AddSortDefForm addForm = new Forms.AddSortDefForm(ds))
                {
                    if (addForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        sd.Expression = addForm.SortExpression;
                        sd.Direction  = addForm.Ascending ? SortDirection.Ascending : SortDirection.Descending;
                        return(true);
                    }
                    else
                    {
                        sd = null;
                        return(false);
                    }
                }
            };

            DoDataSourcesAction(addSort, ds);

            if (sd != null)
            {
                _dataTree.GoToSortDefinition(ds, sd);
            }
        }