예제 #1
0
        public DrawGrid()
        {
            var colinfo = new RowColumnInfo_Steady_BindableProp(this, NumberOfColumnsProperty, ColumnWidthProperty);
            var rowinfo = new RowColumnInfo_Steady_BindableProp(this, NumberOfRowsProperty, RowHeightProperty);

            var padding4   = new ValuePerCell_Steady <Padding?> (new Padding(4, 4, 4, 4));
            var fill_blue  = new ValuePerCell_Steady <CrossGraphics.Color> (CrossGraphics.Colors.Blue);
            var fill_white = new ValuePerCell_Steady <CrossGraphics.Color> (CrossGraphics.Colors.White);            // TODO used to have radius 8

            Func <IDrawCell <IGraphics>, IDrawCell <IGraphics> > f = (IDrawCell <IGraphics> inner) => new DrawCell_Fill(
                fill_blue,
                new DrawCell_Chain_Padding(
                    padding4,
                    new DrawCell_Fill(
                        fill_white,
                        new DrawCell_Chain_Padding(
                            padding4,
                            inner
                            )
                        )
                    )
                );

            var dec_oval        = f(new DrawCell_Oval(CrossGraphics.Colors.Red));
            var dec_arc         = f(new DrawCell_Oval(CrossGraphics.Colors.Green));       // TODO was pie wedge
            var dec_roundedrect = f(new DrawCell_RoundedRect(CrossGraphics.Colors.Yellow));

            var map = new DisplayTypeMap();

            map.Add(0, dec_oval);
            map.Add(1, dec_arc);
            map.Add(2, dec_roundedrect);

            IGetCellDisplayType getter = new myGetCellDisplayType();
            //getter = new OneDisplayTypeForEachColumn (getter);

            var dec_switch = new DrawCell_Chain_DisplayTypes(getter, map);

            var dec_cache = new DrawCell_Chain_Cache(dec_switch, 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_cache),
                new DrawVisible_Adapter_DrawCell <IGraphics>(dec_selection)
            });

            Main = new MainPanel(
                colinfo,
                rowinfo,
                dh_layers
                );
            Notify_DemoToggleSelections.Listen(Main, sel);
        }
예제 #2
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
        }