Ejemplo n.º 1
0
        public TrivialGrid()
        {
            var colinfo = new Dimension_FromDelegate(
                () => Cells.GetLength(1),
                (int n) => ColumnWidth,
                false);

            PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => {
                if (e.PropertyName == TrivialGrid.ColumnWidthProperty.PropertyName)
                {
                    colinfo.notify_changed(-1);
                }
                // TODO listen for change number
            };
            var rowinfo = new Dimension_FromDelegate(
                () => Cells.GetLength(0),
                (int n) => RowHeight,
                false);

            PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => {
                if (e.PropertyName == TrivialGrid.RowHeightProperty.PropertyName)
                {
                    rowinfo.notify_changed(-1);
                }
                // TODO listen for change number
            };

            var text = new ValuePerCell_FromDelegates <string> (gv);

            var fmt = new ValuePerCell_Steady <MyTextFormat> (
                new MyTextFormat
            {
                TextFont  = this.Font.ToCrossFont(),
                TextColor = CrossGraphics.Colors.Black,
                HorizontalTextAlignment = CrossGraphics.TextAlignment.Center,
                VerticalTextAlignment   = CrossGraphics.TextAlignment.Center,
            });

            IDrawCell <IGraphics> dec = new DrawCell_Text(text, fmt);

            var padding1   = new ValuePerCell_Steady <Padding?> (new Padding(1, 1, 1, 1));
            var padding4   = new ValuePerCell_Steady <Padding?> (new Padding(4, 4, 4, 4));
            var fill_white = new ValuePerCell_Steady <CrossGraphics.Color> (CrossGraphics.Colors.White);

            dec = new DrawCell_Chain_Padding(padding4, dec);
            dec = new DrawCell_Fill(fill_white, dec);
            dec = new DrawCell_Chain_Padding(padding1, dec);
            dec = new DrawCell_Chain_Cache(dec, colinfo, rowinfo);

            Main = new MainPanel(
                colinfo,
                rowinfo,
                new DrawVisible_Adapter_DrawCell <IGraphics>(dec)
                );
            var fill_gray      = new ValuePerCell_Steady <CrossGraphics.Color> (CrossGraphics.Colors.Gray);
            var frozen_textfmt = new ValuePerCell_Steady <MyTextFormat> (
                new MyTextFormat {
                TextFont  = CrossGraphics.Font.BoldSystemFontOfSize(18),
                TextColor = CrossGraphics.Colors.Black,
                HorizontalTextAlignment = CrossGraphics.TextAlignment.Center,
                VerticalTextAlignment   = CrossGraphics.TextAlignment.Center,
            });
            var val_rownum = new ValuePerCell_RowNumber();
            var val_colnum = new ValuePerCell_ColumnLetters();

            Left = new FrozenColumnsPanel(
                new Dimension_Steady(1, 80, false),
                rowinfo,
                new DrawVisible_Adapter_DrawCell <IGraphics>(
                    new DrawCell_Chain_Padding(
                        padding1,
                        new DrawCell_Fill(
                            fill_gray,
                            new DrawCell_Text(
                                val_rownum,
                                frozen_textfmt
                                )
                            )
                        )
                    )
                );

            Top = new FrozenRowsPanel(
                colinfo,
                new Dimension_Steady(1, 40, false),
                new DrawVisible_Adapter_DrawCell <IGraphics>(
                    new DrawCell_Chain_Padding(
                        padding1,
                        new DrawCell_Fill(
                            fill_gray,
                            new DrawCell_Text(
                                val_colnum,
                                frozen_textfmt
                                )
                            )
                        )
                    )
                );
        }
Ejemplo n.º 2
0
        public ColumnishGrid()
        {
            var colinfo = new myColumnInfo(this);
            var rowinfo = new myRowInfo(this);

            var fmt = new OneValueForEachColumn <MyTextFormat> (new ValuePerCell_FromDelegates <MyTextFormat> (gv_fmt));

            IRowList <T> rowlist = new RowList_Bindable_IList <T>(this, RowsProperty);

            // TODO it would be better if these propnames were stored separately
            // from the formatting info.
            var propnames = new Dictionary <int, string>();

            this.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => {
                if (e.PropertyName == ColumnsProperty.PropertyName)
                {
                    propnames.Clear();
                    for (int i = 0; i < Columns.Count; i++)
                    {
                        propnames[i] = Columns[i].PropertyName;
                    }
                }
            };

            IValuePerCell <string> vals = new ValuePerCell_RowList_Properties <string, T>(rowlist, propnames);

            IDrawCell <IGraphics> dec = new DrawCell_Text(vals, fmt);

            var padding1 = new ValuePerCell_Steady <Padding?> (new Padding(1, 1, 1, 1));
            var padding8 = new ValuePerCell_Steady <Padding?> (new Padding(8, 8, 8, 8));
            IValuePerCell <CrossGraphics.Color> bginfo = new ValuePerCell_FromDelegates <CrossGraphics.Color> (gv_clr);

            bginfo = new OneValueForEachColumn <CrossGraphics.Color> (bginfo);

            dec = new DrawCell_Chain_Padding(padding8, dec);
            dec = new DrawCell_Fill(bginfo, dec);
            dec = new DrawCell_Chain_Padding(padding1, dec);
            dec = new DrawCell_Chain_Cache(dec, colinfo, rowinfo);

            var sel = new Selection();

            var dec_selection = new DrawCell_FillRectIfSelected(sel, new CrossGraphics.Color(0, 255, 0, 120));

            var dh_layers = new DrawVisible_Layers(new IDrawVisible <IGraphics>[] {
                new DrawVisible_Adapter_DrawCell <IGraphics>(dec),
                new DrawVisible_Adapter_DrawCell <IGraphics>(dec_selection)
            });

            Main = new MainPanel(
                colinfo,
                rowinfo,
                dh_layers
                );
            Notify_DemoToggleSelections.Listen(Main, sel);
                        #if not
            // TODO the mod happens, but the notification does not
            _main.SingleTap += (object sender, CellCoords e) => {
                T          r   = Rows [e.Row];
                ColumnInfo ci  = Columns[e.Column];
                var        typ = typeof(T);
                var        ti  = typ.GetTypeInfo();
                var        p   = ti.GetDeclaredProperty(ci.PropertyName);
                if (p != null)
                {
                    var val = p.GetValue(r);
                    p.SetValue(r, val.ToString() + "*");
                }
            };
                        #endif

            var bginfo_gray = new ValuePerCell_Steady <CrossGraphics.Color> (CrossGraphics.Colors.Gray);
            Top = new FrozenRowsPanel(
                colinfo,
                new Dimension_Steady(1, 40, false),
                new DrawVisible_Adapter_DrawCell <IGraphics>(
                    new DrawCell_Chain_Padding(
                        padding1,
                        new DrawCell_Fill(
                            bginfo_gray,
                            new DrawCell_Text(
                                new myFrozenGetCellTextValue(this),
                                new ValuePerCell_Steady <MyTextFormat>(
                                    new MyTextFormat {
                TextFont  = CrossGraphics.Font.BoldSystemFontOfSize(20),
                TextColor = CrossGraphics.Colors.Red,
                HorizontalTextAlignment = CrossGraphics.TextAlignment.Center,
                VerticalTextAlignment   = CrossGraphics.TextAlignment.Center
            }
                                    )
                                )
                            )
                        )
                    )
                );
        }
Ejemplo n.º 3
0
        public A1Wraparound(int cols, int rows, bool wrap_col, bool wrap_row)
        {
            var colinfo = new Dimension_Steady(cols, SIZE, wrap_col);
            var rowinfo = new Dimension_Steady(rows, SIZE, wrap_row);

            var padding1   = new ValuePerCell_Steady <Padding?> (new Padding(1, 1, 1, 1));
            var fill_white = new ValuePerCell_Steady <CrossGraphics.Color> (CrossGraphics.Colors.White);

            IDrawCell <IGraphics> dec_text = new DrawCell_Text(
                new ValuePerCell_FromDelegates <string>(myutil.get_delegate()),
                new ValuePerCell_Steady <MyTextFormat> (
                    new MyTextFormat {
                TextFont  = CrossGraphics.Font.SystemFontOfSize((int)(SIZE / 3)),
                TextColor = CrossGraphics.Colors.Black,
                HorizontalTextAlignment = CrossGraphics.TextAlignment.Center,
                VerticalTextAlignment   = CrossGraphics.TextAlignment.Center,
            })
                );

            IDrawVisible <IGraphics> dv;

                        #if false
            // this approach uses one layer containing a chain
            // that cache-pad-fill-text

            IDrawEachCell dec = new DrawEachCell_Chain_Padding(
                padding1,
                new DrawEachCell_Fill(
                    fill_white,
                    dec_text
                    )
                );

            dec = new DrawEachCell_Chain_Cache(dec, colinfo, rowinfo);

            dv = new DrawVisibleCells_DrawEachCellAdapter(dec);
                        #else
            // this approach uses two layers, one is pad-fill,
            // and the other is cache-text

            IDrawCell <IGraphics> dec_bg = new DrawCell_Chain_Padding(
                padding1,
                new DrawCell_Fill(
                    fill_white
                    )
                );

            //dec_bg = new DrawEachCell_Chain_Cache (dec_bg, colinfo, rowinfo);

            //dec_text = new DrawEachCell_Chain_Cache (dec_text, colinfo, rowinfo);

                        #if false
            dv = new DrawVisibleCells_Layers(new IDrawVisibleCells[] {
                new DrawVisibleCells_DrawEachCellAdapter(dec_bg),
                new DrawVisibleCells_DrawEachCellAdapter(dec_text),
            });
                        #else
            IDrawCell <IGraphics> dec_layers = new DrawCell_Chain_Layers(new IDrawCell <IGraphics>[] {
                dec_bg,
                dec_text,
            });

            dec_layers = new DrawCell_Chain_Cache(dec_layers, colinfo, rowinfo);

            dv = new DrawVisible_Adapter_DrawCell <IGraphics>(dec_layers);
                        #endif
                        #endif

            Main = new MainPanel(
                colinfo,
                rowinfo,
                dv
                );
            Main.SingleTap += (object sender, CellCoords e) => {
                // TODO trigger a redraw
            };

            var fill_gray = new ValuePerCell_Steady <CrossGraphics.Color> (CrossGraphics.Colors.Gray);

            var frozen_textfmt = new ValuePerCell_Steady <MyTextFormat> (
                new MyTextFormat {
                TextFont  = CrossGraphics.Font.BoldSystemFontOfSize((int)(SIZE / 3)),
                TextColor = CrossGraphics.Colors.Black,
                HorizontalTextAlignment = CrossGraphics.TextAlignment.Center,
                VerticalTextAlignment   = CrossGraphics.TextAlignment.Center,
            });

            Func <FrozenColumnsPanel> f_c = () =>
                                            new FrozenColumnsPanel(
                new Dimension_Steady(1, SIZE, false),
                rowinfo,
                new DrawVisible_Adapter_DrawCell <IGraphics>(
                    new DrawCell_Chain_Padding(
                        padding1,
                        new DrawCell_Fill(
                            fill_gray,
                            new DrawCell_Text(
                                new ValuePerCell_RowNumber(),
                                frozen_textfmt
                                )
                            )
                        )
                    )
                );
            Left  = f_c();
            Right = f_c();

            Func <FrozenRowsPanel> f_r = () =>
                                         new FrozenRowsPanel(
                colinfo,
                new Dimension_Steady(1, SIZE, false),
                new DrawVisible_Adapter_DrawCell <IGraphics>(
                    new DrawCell_Chain_Padding(
                        padding1,
                        new DrawCell_Fill(
                            fill_gray,
                            new DrawCell_Text(
                                new ValuePerCell_ColumnLetters(),
                                frozen_textfmt
                                )
                            )
                        )
                    )
                );
            Top    = f_r();
            Bottom = f_r();
        }
Ejemplo n.º 4
0
        public SQLiteGrid()
        {
            sqlite3 conn = ugly.open(":memory:");

            conn.exec("BEGIN TRANSACTION");
            conn.exec("CREATE TABLE foo (a int, b int, c int);");
            for (int i = 0; i < 100; i++)
            {
                conn.exec("INSERT INTO foo (a,b,c) VALUES (?,?,?)", i, i * 5 - 3, i * i / 10);
            }
            conn.exec("COMMIT TRANSACTION");

            var stmt = conn.prepare("SELECT * FROM foo");

            var colinfo = new Dimension_Columns_SQLite(stmt);
            var rowinfo = new Dimension_Rows_SQLite();

            var mytextfmt = new MyTextFormat {
                TextFont  = this.Font.ToCrossFont(),
                TextColor = CrossGraphics.Colors.Black,
                HorizontalTextAlignment = CrossGraphics.TextAlignment.Center,
                VerticalTextAlignment   = CrossGraphics.TextAlignment.Center,
            };

            var fmt = new ValuePerCell_Steady <MyTextFormat> (
                mytextfmt
                );

            PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => {
                if (e.PropertyName == A1Grid.FontProperty.PropertyName)
                {
                    mytextfmt.TextFont = Font.ToCrossFont();
                    fmt.notify_changed(-1, -1);
                }
            };
            var padding1   = new ValuePerCell_Steady <Padding?> (new Padding(1));
            var padding4   = new ValuePerCell_Steady <Padding?> (new Padding(4));
            var fill_white = new ValuePerCell_Steady <CrossGraphics.Color> (CrossGraphics.Colors.White);

            var rowlist               = new RowList_SQLite_StringArray(stmt);
            var rowlist_cached        = new RowList_Cache <string[]> (rowlist);
            var vpc                   = new ValuePerCell_RowList_Indexed <string, string[]> (rowlist_cached);
            IDrawCell <IGraphics> dec = new DrawCell_Text(vpc, fmt);

            dec = new DrawCell_Chain_Padding(padding4, dec);
            dec = new DrawCell_Fill(fill_white, dec);
            dec = new DrawCell_Chain_Padding(padding1, dec);
            dec = new DrawCell_Chain_Cache(dec, colinfo, rowinfo);

            var sel = new Selection();

            var dec_selection = new DrawCell_FillRectIfSelected(sel, new CrossGraphics.Color(0, 255, 0, 120));

            var dh_layers = new DrawVisible_Layers(new IDrawVisible <IGraphics>[] {
                new DrawVisible_Adapter_DrawCell <IGraphics>(dec),
                new DrawVisible_Adapter_DrawCell <IGraphics>(dec_selection)
            });

            Main = new MainPanel(
                colinfo,
                rowinfo,
                dh_layers
                );
        }
Ejemplo n.º 5
0
        public A1Grid()
        {
            var colinfo = new RowColumnInfo_Steady_BindableProp(this, ColumnsProperty, ColumnWidthProperty);
            var rowinfo = new RowColumnInfo_Steady_BindableProp(this, RowsProperty, RowHeightProperty);

            var mytextfmt = new MyTextFormat {
                TextFont  = this.Font.ToCrossFont(),
                TextColor = CrossGraphics.Colors.Black,
                HorizontalTextAlignment = CrossGraphics.TextAlignment.Center,
                VerticalTextAlignment   = CrossGraphics.TextAlignment.Center,
            };

            var fmt = new ValuePerCell_Steady <MyTextFormat> (
                mytextfmt
                );

            PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => {
                if (e.PropertyName == A1Grid.FontProperty.PropertyName)
                {
                    mytextfmt.TextFont = Font.ToCrossFont();
                    fmt.notify_changed(-1, -1);
                }
            };
            IDrawCell <IGraphics> dec = new DrawCell_Text(
                new ValuePerCell_FromDelegates <string>(myutil.get_delegate()),
                fmt
                );

            var padding1   = new ValuePerCell_Steady <Padding?> (new Padding(1));
            var padding4   = new ValuePerCell_Steady <Padding?> (new Padding(4));
            var fill_white = new ValuePerCell_Steady <CrossGraphics.Color> (CrossGraphics.Colors.White);

            dec = new DrawCell_Chain_Padding(padding4, dec);
            dec = new DrawCell_Fill(fill_white, dec);
            dec = new DrawCell_Chain_Padding(padding1, dec);              // TODO probably useless
            //dec = new DrawCell_Chain_Cache (dec, colinfo, rowinfo);

                        #if not
            var sel = new Selection();

            var dec_selection = new DrawCell_FillRectIfSelected(sel, Color.FromRgba(0, 255, 0, 120));

            var dh_layers = new DrawVisible_Layers(new IDrawVisible <IGraphics>[] {
                new DrawVisible_Cache(new DrawVisible_Adapter_DrawCell <IGraphics>(dec), colinfo, rowinfo),
                //new DrawVisible_Adapter_DrawCell<IGraphics>(dec_selection)
            });
                        #endif

            Main = new MainPanel(
                colinfo,
                rowinfo,
                new DrawVisible_Cache(
                    new DrawVisible_Adapter_DrawCell <IGraphics>(dec)
                    , colinfo, rowinfo)
                );
            //Notify_DemoToggleSelections.Listen (Main, sel);

                        #if not
            var fill_gray      = new ValuePerCell_Steady <Color?> (Color.Gray);
            var frozen_textfmt = new ValuePerCell_Steady <MyTextFormat> (
                new MyTextFormat {
                TextFont  = Font.SystemFontOfSize(18, FontAttributes.Bold),
                TextColor = Color.Black,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
            });

            Left = new FrozenColumnsPanel(
                new Dimension_Steady(1, 80, false),
                rowinfo,
                new DrawVisible_Adapter_DrawCell <IGraphics>(
                    new DrawCell_Chain_Padding(
                        padding1,
                        new DrawCell_Fill(
                            fill_gray,
                            new DrawCell_Text(
                                new ValuePerCell_RowNumber(),
                                frozen_textfmt
                                )
                            )
                        )
                    )
                );
            Left.SingleTap += (object sender, CellCoords e) => {
                // hack for testing purposes
                this.Font = Font.SystemFontOfSize(this.Font.FontSize + 1);
            };

            Top = new FrozenRowsPanel(
                colinfo,
                new Dimension_Steady(1, 40, false),
                new DrawVisible_Adapter_DrawCell <IGraphics>(
                    new DrawCell_Chain_Padding(
                        padding1,
                        new DrawCell_Fill(
                            fill_gray,
                            new DrawCell_Text(
                                new ValuePerCell_ColumnLetters(),
                                frozen_textfmt
                                )
                            )
                        )
                    )
                );
            Top.SingleTap += (object sender, CellCoords e) => {
                // hack for testing purposes
                this.RowHeight *= 1.1;
            };
                        #endif
        }
Ejemplo n.º 6
0
        public ColumnishGrid()
        {
            var colinfo = new myColumnInfo(this);
            var rowinfo = new myRowInfo(this);

            var fmt = new OneValueForEachColumn <MyTextFormat> (new ValuePerCell_FromDelegates <MyTextFormat> (gv_fmt));

            IRowList <T> rowlist = new RowList_Bindable_ReactiveList <T>(this, RowsProperty);

            // TODO it would be better if these propnames were stored separately
            // from the formatting info.
            var propnames = new Dictionary <int, string>();

            this.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) => {
                if (e.PropertyName == ColumnsProperty.PropertyName)
                {
                    propnames.Clear();
                    for (int i = 0; i < Columns.Count; i++)
                    {
                        propnames[i] = Columns[i].PropertyName;
                    }
                }
            };

            IValuePerCell <string> vals = new ValuePerCell_RowList_Properties <string, T>(rowlist, propnames);

            IDrawCell <IGraphics> dec = new DrawCell_Text(vals, fmt);

            var padding1 = new ValuePerCell_Steady <Padding?> (new Padding(1, 1, 1, 1));
            var padding8 = new ValuePerCell_Steady <Padding?> (new Padding(8, 8, 8, 8));
            IValuePerCell <Color?> bginfo = new ValuePerCell_FromDelegates <Color?> (gv_clr);

            bginfo = new OneValueForEachColumn <Color?> (bginfo);

            dec = new DrawCell_Chain_Padding(padding8, dec);
            dec = new DrawCell_Fill(bginfo, dec);
            dec = new DrawCell_Chain_Padding(padding1, dec);
            dec = new DrawCell_Chain_Cache(dec, colinfo, rowinfo);

            Main = new MainPanel(
                colinfo,
                rowinfo,
                new DrawVisible_Adapter_DrawCell <IGraphics>(dec)
                );
            Main.SingleTap += (object sender, CellCoords e) => {
                // when we get a tap on a cell, append an asterisk to its text.
                // this should automatically trigger a display update because the
                // object is a ReactiveObject which tells its ReactiveList which
                // tells its RowList and so on.
                T          r   = Rows [e.Row];
                ColumnInfo ci  = Columns[e.Column];
                var        typ = typeof(T);
                var        ti  = typ.GetTypeInfo();
                var        p   = ti.GetDeclaredProperty(ci.PropertyName);
                if (p != null)
                {
                    var val = p.GetValue(r);
                    p.SetValue(r, val.ToString() + "*");
                }
            };

            var bginfo_gray = new ValuePerCell_Steady <Color?> (Color.Gray);

            Top = new FrozenRowsPanel(
                colinfo,
                new Dimension_Steady(1, 40, false),
                new DrawVisible_Adapter_DrawCell <IGraphics>(
                    new DrawCell_Chain_Padding(
                        padding1,
                        new DrawCell_Fill(
                            bginfo_gray,
                            new DrawCell_Text(
                                new myFrozenGetCellTextValue(this),
                                new ValuePerCell_Steady <MyTextFormat>(
                                    new MyTextFormat {
                TextFont  = Font.SystemFontOfSize(20, Xamarin.Forms.FontAttributes.Bold),
                TextColor = Color.Red,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center
            }
                                    )
                                )
                            )
                        )
                    )
                );
        }