コード例 #1
0
        public TabularDataViewer(IBioLinkReport report, DataMatrix data, IProgressObserver progress)
        {
            InitializeComponent();
            this.Data = data;
            _progress = progress;
            _report = report;
            var view = new GridView();

            var columns = report.DisplayColumns;
            if (columns == null || columns.Count == 0) {
                columns = GenerateDefaultColumns(data);
            }

            var hcs = viewerGrid.Resources["hcs"] as Style;

            foreach (DisplayColumnDefinition c in columns) {
                DisplayColumnDefinition coldef = c;
                var column = new GridViewColumn { Header = BuildColumnHeader(coldef), DisplayMemberBinding = new Binding(String.Format("[{0}]", data.IndexOf(coldef.ColumnName))), HeaderContainerStyle = hcs };
                view.Columns.Add(column);
            }

            lvw.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(GridViewColumnHeaderClickedHandler));

            lvw.MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(lvw_MouseRightButtonUp);

            lvw.ItemsSource = Data.Rows;
            this.lvw.View = view;
        }
コード例 #2
0
 public Object this [string columnName] {
     get {
         var index = _matrix.IndexOf(columnName);
         if (index >= 0)
         {
             return(this[index]);
         }
         return(null);
     }
     set {
         var index = _matrix.IndexOf(columnName);
         if (index >= 0)
         {
             this[index] = value;
         }
     }
 }
コード例 #3
0
        public FormattedLatLongVirtualColumn(DataMatrix matrix)
        {
            var areaTypeCol = matrix.IndexOf("AreaType");
            var latCol = matrix.IndexOf("Lat");
            var longCol = matrix.IndexOf("Long");
            var latCol2 = matrix.IndexOf("Lat2");
            var longCol2 = matrix.IndexOf("Long2");

            this.Name = "FormattedLatLong";

            this.ValueGenerator = (row) => {

                object objLat = row[latCol];
                object objlong = row[longCol];
                object objAreaType = row[areaTypeCol];

                AreaType areaType = AreaType.Point;
                if (objAreaType != null) {
                    areaType = (AreaType) int.Parse(objAreaType.ToString());
                }

                if (objLat != null && objlong != null) {
                    double lat = (double)objLat;
                    double @long = (double)objlong;
                    switch (areaType) {
                        case AreaType.Point:
                            return string.Format("{0}, {1}", GeoUtils.DecDegToDMS(lat, CoordinateType.Latitude), GeoUtils.DecDegToDMS(@long, CoordinateType.Longitude));
                        case AreaType.Line:
                            double lat2 = (double)row[latCol2];
                            double long2 = (double)row[longCol2];
                            return string.Format("Line: {0}, {1} - {2}, {3}",
                                GeoUtils.DecDegToDMS(lat, CoordinateType.Latitude), GeoUtils.DecDegToDMS(@long, CoordinateType.Longitude),
                                GeoUtils.DecDegToDMS(lat2, CoordinateType.Latitude), GeoUtils.DecDegToDMS(long2, CoordinateType.Longitude));
                        case AreaType.Box:
                            lat2 = (double)row[latCol2];
                            long2 = (double)row[longCol2];
                            return string.Format("Box: {0}, {1} - {2}, {3}",
                                GeoUtils.DecDegToDMS(lat, CoordinateType.Latitude), GeoUtils.DecDegToDMS(@long, CoordinateType.Longitude),
                                GeoUtils.DecDegToDMS(lat2, CoordinateType.Latitude), GeoUtils.DecDegToDMS(long2, CoordinateType.Longitude));
                    }
                }

                return "";
            };
        }
コード例 #4
0
        public FormattedDateVirtualColumn(DataMatrix matrix)
        {
            int dateTypeCol = matrix.IndexOf("DateType");
            int startDateCol = matrix.IndexOf("StartDate");
            int endDateCol = matrix.IndexOf("EndDate");
            int casualDateCol = matrix.IndexOf("CasualDate");

            Name = "Dates";
            ValueGenerator = (row) => {
                int dateType = 0;
                object objDateType = row[dateTypeCol];
                if (objDateType != null) {
                    int.TryParse(objDateType.ToString(), out dateType);
                    return DateUtils.FormatDates(dateType, row[startDateCol] as int?, row[endDateCol] as int?, row[casualDateCol] as string);

                }
                return "";
            };
        }
コード例 #5
0
ファイル: TaxonReferencesReport.cs プロジェクト: kehh/biolink
        public System.Windows.FrameworkElement ConstructView(IBioLinkReport report, DataMatrix reportData, IProgressObserver progress)
        {
            var options = (report as ReferenceLinksReport).Options;

            var viewer = new RTFReportViewer {ReportName = report.Name};
            var rtf = new RTFReportBuilder();
            rtf.AppendFullHeader();
            rtf.ReportHeading(options.BibliographyTitle);

            var idx = 1;
            var colIndex = reportData.IndexOf("RefID");

            var refIds = new List<Int32>();
            for (var i = 0; i < reportData.Rows.Count; ++i ) {
                refIds.Add(i);
            }

            int sortColumnIdx = reportData.IndexOf(options.SortColumn);
            int refTypeIndex = reportData.IndexOf("RefType");
            refIds.Sort((idx1, idx2) => {
                            // If grouping, first check the ref type
                            if (options.GroupByReferenceType) {
                                var refType1 = reportData.Rows[idx1][refTypeIndex] as String;
                                var refType2 = reportData.Rows[idx2][refTypeIndex] as String;
                                if (!refType1.Equals(refType2)) {
                                    return String.Compare(refType1, refType2, true);
                                }
                            }

                            // then by the nominated sort column
                            var objVal1 = reportData.Rows[idx1][sortColumnIdx];
                            var objVal2 = reportData.Rows[idx2][sortColumnIdx];
                            var val1 = RTFUtils.StripMarkup(objVal1 == null ? "" : objVal1.ToString());
                            var val2 = RTFUtils.StripMarkup(objVal2 == null ? "" : objVal2.ToString());

                            if (options.SortAscending) {
                                return String.Compare((String)val1, (String)val2, true);
                            } else {
                                return String.Compare((String)val2, (String)val1, true);
                            }
                        });

            var lastRefType = "";
            String[] allowedKeywords = { "b", "i", "sub", "super", "strike", "ul", "ulnone", "nosupersub" };
            foreach (var rowIdx in refIds) {
                var row = reportData.Rows[rowIdx];

                if (options.GroupByReferenceType) {
                    var refType = row["RefType"] as String;
                    if (!String.Equals(refType, lastRefType, StringComparison.CurrentCultureIgnoreCase)) {
                        rtf.Par();
                        rtf.Append(@" \pard\fs24\b\f1 ");
                        rtf.Append(refType);
                        rtf.Append(@" \b0");
                        rtf.Par();
                        lastRefType = refType;
                    }
                }

                rtf.Par();
                rtf.Append(@" \pard\fs20\f1 ");
                if (options.BibliographyIndexStyle != BibliographyIndexStyle.None) {
                    rtf.Append("[");
                    switch (options.BibliographyIndexStyle) {
                        case BibliographyIndexStyle.Number:
                            rtf.Append(idx);
                            break;
                        case BibliographyIndexStyle.RefCode:
                            rtf.Append(row["RefCode"]);
                            break;
                    }
                    rtf.Append("] ");
                }
                idx++;

                var fullRTF = RTFUtils.filter(row["FullRTF"] as string, true, false, allowedKeywords);
                rtf.Append(fullRTF);

                var bits = new List<String>();
                if (!String.IsNullOrWhiteSpace(row["LinkPage"] as String)) {
                    bits.Add(String.Format("page {0}", row["LinkPage"] as String));
                }

                if (options.IncludeQualification) {
                    var qual = row["LinkQualificationRTF"] as string;
                    if (!String.IsNullOrEmpty(qual)  ) {
                        bits.Add(RTFUtils.filter(qual, true, true, allowedKeywords).Trim());
                    }
                }

                if (bits.Count > 0) {
                    rtf.Append(" (").Append(bits.Join("; ").Trim()).Append(")");
                }

                rtf.Par();
            }

            Console.WriteLine(rtf.RTF);

            viewer.rtf.Rtf = rtf.RTF;

            return viewer;
        }
コード例 #6
0
ファイル: LabelSetReport.cs プロジェクト: kehh/biolink
        private DataMatrix MergeItemMatrices(DataMatrix siteData, DataMatrix siteVisitData, DataMatrix materialData)
        {
            var result = new DataMatrix();

            // Create the final column set (based on the specified criteria)
            foreach (QueryCriteria c in Criteria) {
                result.Columns.Add(new MatrixColumn { Name = c.Field.DisplayName });
            }

            // Now add the identity columns (as hidden columns, unless they already exist)
            string[] cols = { "Site Identifier", "Visit Identifier", "Material Identifier"};
            foreach (string col in cols) {
                if (result.IndexOf(col) < 0) {
                    result.Columns.Add(new MatrixColumn { Name = col, IsHidden = true });
                }
            }

            int currentOrderNum = 1;
            LabelSetItem item = null;
            while ((item = Items.FirstOrDefault((candidate) => { return candidate.PrintOrder == currentOrderNum; })) != null) {

                if (item.NumCopies > 0) {

                    var row = result.AddRow();

                    if (item.SiteID > 0) {
                        AddFieldData(row, item.SiteID, "Site Identifier", siteData);
                    }

                    if (item.VisitID > 0) {
                        AddFieldData(row, item.VisitID, "Visit Identifier", siteVisitData);
                    }

                    if (item.MaterialID > 0) {
                        AddFieldData(row, item.MaterialID, "Material Identifier", materialData);
                    }

                    if (item.NumCopies > 1) {
                        CopyRow(result, row, item.NumCopies - 1);
                    }
                }

                currentOrderNum++;
            }

            return result;
        }
コード例 #7
0
ファイル: LabelSetReport.cs プロジェクト: kehh/biolink
 private void CopyRow(DataMatrix dest, MatrixRow srcRow, int numCopies)
 {
     for (int i = 0; i < numCopies; ++i) {
         var newRow = dest.AddRow();
         foreach (MatrixColumn col in dest.Columns) {
             int index = dest.IndexOf(col.Name);
             newRow[index] = srcRow[index];
         }
     }
 }