コード例 #1
0
        public RelationalDataIndex(IDataSheet <T> sourceSheet, Column indexColumn)
        {
            SourceSheet = sourceSheet;
            IndexColumn = indexColumn;

            BuildIndex();
        }
コード例 #2
0
 protected DataRowBase(IDataSheet sheet, int key, int offset)
 {
     Sheet            = sheet;
     Key              = key;
     Offset           = offset;
     _ValueReferences = new ConcurrentDictionary <int, WeakReference <object> >();
 }
コード例 #3
0
        public IDictionary <string, CellToPropertyMap> CreatePropertyMap <TModel>(IDataSheet worksheet,
                                                                                  Action <IMemberSpec <TModel> > mappingConfiguration) where TModel : class
        {
            var specs = GetSpecs(mappingConfiguration);

            return(InternalCreatePropertyMap(worksheet, specs));
        }
コード例 #4
0
        public PartialDataSheet(IDataSheet <T> sourceSheet, Range range, File file)
        {
            SourceSheet = sourceSheet;
            Range       = range;
            File        = file;

            Build();
        }
コード例 #5
0
ファイル: ExcelMapper.cs プロジェクト: icgam/Easify.Excel
        private IEnumerable <IDataSheetRow> GetRowsWithData(IDataSheet worksheet)
        {
            var firstRow = worksheet.FirstRowUsed().RowNumber + 1;
            var lastRow  = worksheet.LastRowUsed().RowNumber;
            var rows     = worksheet.Rows(firstRow, lastRow);

            return(rows);
        }
コード例 #6
0
        public DataRow(IDataSheet sheet, int key, int offset)
        {
            const int HeaderLength = 0x06;

            Sheet  = sheet;
            Key    = key;
            Offset = offset + HeaderLength;
        }
コード例 #7
0
ファイル: VectorField.cs プロジェクト: cohama/Conta
        /// <summary>
        /// ビットマップにベクトル図を描画します。
        /// </summary>
        /// <param name="bmp">描画先の System.Drawing.Bitmap</param>
        /// <param name="data">元となる 2 次元配列データ</param>
        /// <exception cref="Visualization.VectorDataNotFoundException">ベクトルデータがないときに投げられます。</exception>
        public override void DrawTo( Canvas canvas, IDataSheet data )
        {
            Bitmap bmp = canvas.Bitmap;
            if( !this.Setting.Show )
            {
                return;
            }
            if( !data.HasVectorData )
            {
                throw new VectorDataNotFoundException( "ベクトルデータがありません" );
            }
            if( !this.Setting.IsLengthFixed )
            {
                this.Setting.ReferredLength = data.MaxVector;
            }
            Graphics g = Graphics.FromImage( bmp );
            Pen p = new Pen( Setting.LineColor );
            Brush b = new SolidBrush( Setting.InnerColor );

            ArrowDrawer d = new ArrowDrawer( g, this.Setting, data.MaxVector, data.MinVector );

            int start = (this.Setting.Interval > 1) ? this.Setting.Offset : 0;
            int step = this.Setting.Interval;

            HashSet<int> iSet = new HashSet<int>();
            HashSet<int> jSet = new HashSet<int>();

            if( this.Setting.FixedBound )
            {
                iSet.Add( 0 );
                jSet.Add( 0 );
            }
            for( int i=start; i<data.Columns; i += step )
            {
                iSet.Add( i );
            }
            for( int j=start; j<data.Rows; j += step )
            {
                jSet.Add( j );
            }
            if( this.Setting.FixedBound )
            {
                iSet.Add( data.Columns-1 );
                jSet.Add( data.Rows-1 );
            }

            foreach( var i in iSet )
            {
                foreach( var j in jSet )
                {
                    Point pt = canvas.AsBitmapCoord( data.GetX( i ), data.GetY( j ) );
                    double u = data.GetU( i, j );
                    double v = data.GetV( i, j );
                    double len = Math.Sqrt( u*u + v*v );
                    d.DrawArrow( pt, u, v );
                }
            }
        }
コード例 #8
0
ファイル: DataRow.cs プロジェクト: viion/SaintCoinach
        public DataRow(IDataSheet sheet, int key, int offset)
            : base(sheet, key, offset + MetadataLength)
        {
            var b = sheet.GetBuffer();
            if (b.Length < offset + MetadataLength) throw new IndexOutOfRangeException();

            Length = OrderedBitConverter.ToInt32(b, offset, true);
            SubRowCount = OrderedBitConverter.ToInt16(b, offset + 4, true);
        }
コード例 #9
0
        public DataRow(IDataSheet sheet, int key, int offset) : base(sheet, key, offset + MetadataLength)
        {
            byte[] b = sheet.GetBuffer();
            if (b.Length < offset + MetadataLength)
            {
                throw new IndexOutOfRangeException();
            }

            Length      = OrderedBitConverter.ToInt32(b, offset, true);
            SubRowCount = OrderedBitConverter.ToInt16(b, offset + 4, true);
        }
コード例 #10
0
        public object Convert(IDataRow row, object rawValue)
        {
            int nr = System.Convert.ToInt32(rawValue);

            if (nr <= 0 || nr > 999999)
            {
                return(null);
            }

            IDataSheet sheet = row.Sheet;

            return(Imaging.IconHelper.GetIcon(sheet.Collection.PackCollection, sheet.Language, nr));
        }
コード例 #11
0
        public DataRow(IDataSheet sheet, int key, int offset) : base(sheet, key, offset + MetadataLength)
        {
            var b = sheet.GetBuffer();

            if (b.Length < offset + MetadataLength)
            {
                throw new IndexOutOfRangeException();
            }

            Length = OrderedBitConverter.ToInt32(b, offset, true);
            var c = OrderedBitConverter.ToInt16(b, offset + 4, true);

            if (c != 1)
            {
                throw new InvalidDataException();
            }
        }
コード例 #12
0
ファイル: GridPointField.cs プロジェクト: cohama/Conta
 public override void DrawTo( Canvas canvas, IDataSheet data )
 {
     if( !Setting.Show )
     {
         return;
     }
     Graphics g = Graphics.FromImage( canvas.Bitmap );
     Pen p = new Pen( Color.Black );
     for( int i=0; i<data.Columns; i++ )
     {
         for( int j=0; j<data.Rows; j++ )
         {
             Point pt = canvas.AsBitmapCoord( data.GetX( i ), data.GetY( j ) );
             g.DrawRectangle( p, pt.X - 1, pt.Y -1, 2, 2 );
         }
     }
 }
コード例 #13
0
 public IDictionary <string, CellToPropertyMap> CreatePropertyMap <TModel>(IDataSheet worksheet)
     where TModel : class
 {
     return(InternalCreatePropertyMap <TModel>(worksheet, null));
 }
コード例 #14
0
ファイル: CrossViewField.cs プロジェクト: cohama/Conta
        public override void DrawTo( Canvas canvas, IDataSheet data )
        {
            Bitmap bmp = canvas.Bitmap;
            if( !this.Setting.Show )
            {
                return;
            }
            if( !this.Setting.IsLengthFixed )
            {
                double absMax = (Math.Abs( data.MaxZ ) > Math.Abs( data.MinZ ))	? Math.Abs( data.MaxZ )
                                                                                : Math.Abs( data.MinZ );
                if( absMax == 0 ) absMax = 1;
                this.Setting.ReferredLength = absMax;
            }

            Graphics g = Graphics.FromImage( bmp );

            SolidBrush plotBlush = new SolidBrush( Setting.PlotColor );
            Pen plotPen = new Pen( Setting.PlotFrameColor );
            Pen linePen = new Pen( Setting.LineColor, Setting.LineWidth );
            Pen axisPen = new Pen( Setting.AxisColor, Setting.AxisWidth );

            Point lefttop = canvas.AsBitmapCoord( 0, 1 );
            Point rightbottom = canvas.AsBitmapCoord( 1, 0 );

            g.DrawRectangle( axisPen, lefttop.X, lefttop.Y, canvas.DrawingWidth, canvas.DrawingHeight );

            if( Setting.ReferenceI >= data.Columns ) Setting.ReferenceI = data.Columns - 1;
            if( Setting.ReferenceJ >= data.Rows ) Setting.ReferenceJ = data.Rows - 1;

            if( this.Setting.Horizontal )
            {
                double refY = data.GetY( this.Setting.ReferenceJ );
                g.DrawLine( axisPen, canvas.AsBitmapCoord( 0, refY ), canvas.AsBitmapCoord( 1, refY ) );
                List<Point> pt = new List<Point>();
                pt.Add( canvas.AsBitmapCoord( 0, refY ) );
                Func<int, int, double> value = (Setting.VectorMode)	? new Func<int, int, double>( data.GetV )
                                                                    : new Func<int, int, double>( data.GetZ );
                for( int i=0; i<data.Columns; i++ )
                {
                    int h = (int)(value( i, Setting.ReferenceJ )/this.Setting.ReferredLength*Setting.Scale + 0.5);
                    Point gridPt = canvas.AsBitmapCoord( data.GetX( i ), refY );
                    pt.Add( new Point( gridPt.X, gridPt.Y-h ) );
                }
                pt.Add( canvas.AsBitmapCoord( 1, refY ) );
                g.DrawLines( linePen, pt.ToArray() );
                int s = Setting.PlotSize;
                for( int i=1; i<pt.Count-1; i++ )
                {
                    g.FillEllipse( plotBlush, pt[i].X - s/2, pt[i].Y - s/2, s, s );
                    g.DrawEllipse( plotPen, pt[i].X - s/2, pt[i].Y - s/2, s, s );
                }

            }
            if( this.Setting.Vertical )
            {
                double refX = data.GetX( this.Setting.ReferenceI );
                g.DrawLine( axisPen, canvas.AsBitmapCoord( refX, 0 ), canvas.AsBitmapCoord( refX, 1 ) );
                List<Point> pt = new List<Point>();
                pt.Add( canvas.AsBitmapCoord( refX, 0 ) );
                Func<int, int, double> value = (Setting.VectorMode)	? new Func<int, int, double>( data.GetU )
                                                                    : new Func<int, int, double>( data.GetZ );
                for( int j=0; j<data.Rows; j++ )
                {
                    int h = (int)(value( Setting.ReferenceI, j )/this.Setting.ReferredLength*Setting.Scale + 0.5);
                    Point gridPt = canvas.AsBitmapCoord( refX, data.GetY( j ) );
                    pt.Add( new Point( gridPt.X+h, gridPt.Y ) );
                }
                pt.Add( canvas.AsBitmapCoord( refX, 1 ) );
                g.DrawLines( linePen, pt.ToArray() );
                int s = Setting.PlotSize;
                for( int i=1; i<pt.Count-1; i++ )
                {
                    g.FillEllipse( plotBlush, pt[i].X - s/2, pt[i].Y - s/2, s, s );
                    g.DrawEllipse( plotPen, pt[i].X - s/2, pt[i].Y - s/2, s, s );
                }
            }
        }
コード例 #15
0
ファイル: Field.cs プロジェクト: cohama/Conta
 public abstract void DrawTo( Canvas canvas, IDataSheet data );
コード例 #16
0
ファイル: ContourField.cs プロジェクト: cohama/Conta
        public override void DrawTo( Canvas canvas, IDataSheet data )
        {
            Bitmap bmp = canvas.Bitmap;
            if( !this.Setting.Show )
            {
                return;
            }
            if( this.Setting.AutoScaleColor )
            {
                this.Setting.MaxValue = data.MaxZ;
                this.Setting.MinValue = data.MinZ;
            }
            this.Setting.PropertyChanged = false;
            double max = this.Setting.MaxValue;
            double min = this.Setting.MinValue;
            BitmapData bd = canvas.Bitmap.LockBits( new Rectangle( 0, 0, canvas.Bitmap.Width, canvas.Bitmap.Height ), ImageLockMode.WriteOnly, canvas.Bitmap.PixelFormat );
            try
            {
                IntPtr scan0 = bd.Scan0;
                byte[] bytes = new byte[canvas.Bitmap.Width*canvas.Bitmap.Height*4];
                for( int i=0; i<bytes.Length; i+=4 )	// 白で初期化
                {
                    bytes[i+0] = 255; // as B
                    bytes[i+1] = 255; // as G
                    bytes[i+2] = 255; // as R
                    bytes[i+3] = 255; // as A
                }
                int width = canvas.DrawingWidth;	// コンターの幅
                int height = canvas.DrawingHeight;	// コンターの高さ

                double xBtoDRate = 1.0 / (width - 1);		// bmp 座標 → データ座標変換用
                double yBtoDRate = 1.0 / (height - 1);

                double newValue = 0;	// バイリニア補間されたデータ
                int index = 0;			// バイト配列アクセス用
                int hue = 0;			// 色相

                int dataYIndex = 0;

                for( int j=0; j<height; j++ )
                {
                    index = 4*(((height+canvas.Setting.Margin.Top)-1-j)*bmp.Width + canvas.Setting.Margin.Left);
                    double y = yBtoDRate*j;	// j のピクセル位置をデータ座標で表す
                    while( !(data.GetY( dataYIndex ) <= y && y <= data.GetY( dataYIndex+1 )) )
                    {
                        dataYIndex++;
                    }
                    double y0 = data.GetY( dataYIndex );
                    double y1 = data.GetY( dataYIndex+1 );

                    int dataXIndex = 0;

                    for( int i=0; i<width; i++ )
                    {
                        // bilinear interporation
                        double x = xBtoDRate*i;
                        while( !(data.GetX( dataXIndex ) <= x && x <= data.GetX( dataXIndex+1 )) )
                        {
                            dataXIndex++;
                        }
                        double x0 = data.GetX( dataXIndex );
                        double x1 = data.GetX( dataXIndex+1 );

                        double vx0y0 = data.GetZ( dataXIndex, dataYIndex );
                        double vx0y1 = data.GetZ( dataXIndex, dataYIndex+1 );
                        double vx1y0 = data.GetZ( dataXIndex+1, dataYIndex );
                        double vx1y1 = data.GetZ( dataXIndex+1, dataYIndex+1 );

                        newValue = bilinearInterpolation( x0, x, x1, y0, y, y1, vx0y0, vx0y1, vx1y0, vx1y1 );

                        hue = (int)((newValue - min) / (max - min) * 359.0);
                        if( hue >= 360 ) hue = 359;
                        if( hue < 0 ) hue = 0;
                        bytes[index+0] = ColorBar.FromHue( hue ).B;
                        bytes[index+1] = ColorBar.FromHue( hue ).G;
                        bytes[index+2] = ColorBar.FromHue( hue ).R;
                        bytes[index+3] = 255;		// as A
                        index += 4;
                    }
                }
                Marshal.Copy( bytes, 0, scan0, bytes.Length );
            }
            finally
            {
                bmp.UnlockBits( bd );
            }
        }
コード例 #17
0
 public RelationalDataRow(IDataSheet sheet, int key, int offset)
     : base(sheet, key, offset)
 {
 }
コード例 #18
0
 public IDictionary <string, CellToPropertyMap> CreatePropertyMap <TModel>(IDataSheet worksheet,
                                                                           MemberSpec <TModel> specs) where TModel : class
 {
     return(InternalCreatePropertyMap(worksheet, specs?.MemberSpecs));
 }
コード例 #19
0
 public RelationalDataRow(IDataSheet sheet, int key, int offset) : base(sheet, key, offset)
 {
 }
コード例 #20
0
ファイル: DataRowBase.cs プロジェクト: viion/SaintCoinach
 protected DataRowBase(IDataSheet sheet, int key, int offset)
 {
     Sheet = sheet;
     Key = key;
     Offset = offset;
 }
コード例 #21
0
        private IDictionary <string, CellToPropertyMap> InternalCreatePropertyMap <TModel>(IDataSheet worksheet,
                                                                                           IReadOnlyList <MemberSpec <TModel> > specs) where TModel : class
        {
            if (worksheet == null)
            {
                throw new ArgumentNullException(nameof(worksheet));
            }

            var ensuredSpecs      = EnsureSpecs(specs);
            var map               = new Dictionary <string, CellToPropertyMap>();
            var properties        = _propertiesExtractor.GetPublicProperties <TModel>();
            var headerRow         = worksheet.FirstRowUsed();
            var mappingExceptions = new List <MappingException>();

            foreach (var property in properties)
            {
                try
                {
                    var cell = FindMatchingCell(property, headerRow, ensuredSpecs);
                    if (cell.AnyValue())
                    {
                        var cellMap = new CellToPropertyMap(property, cell.ColumnLetter,
                                                            cell.RowNumber, cell.ToString());
                        map.Add(property.Name, cellMap);
                    }
                }
                catch (MappingException exception)
                {
                    LogFailedToMapProperty(property, exception);
                    mappingExceptions.Add(exception);
                }
            }

            if (mappingExceptions.Any())
            {
                throw new MappingException($"'{mappingExceptions.Count}' mapping issues found.", mappingExceptions);
            }

            return(map);
        }