Ejemplo n.º 1
0
        protected virtual void Compose()
        {
            var options = new AlignerOptions {
                Dimension       = Dimension.X,
                PointOrderDelta = 40,
                Collisions      = Collisions.NextFree //| Collisions.Toggle
            };

            Action action = () => Columns(options);

            LogicalLayoutLeafCommand = new CommandView {
                Action = (s) => {
                    action = () => LogicalLayoutLeaf(options);
                    action();
                },
                Image       = Iconery.LogicalLayoutLeaf,
                Size        = DefaultSize,
                ToolTipText = "arrange leaf of selected"
            };

            LogicalLayoutCommand = new CommandView {
                Action = (s) => {
                    action = () => LogicalLayout(options);
                    action();
                },
                Image       = Iconery.LogicalLayout,
                Size        = DefaultSize,
                ToolTipText = "arrange siblings of selected"
            };

            FullLayoutCommand = new CommandView {
                Action = (s) => {
                    action = () => FullLayout(options);
                    action();
                },
                Image       = Iconery.FullLayout,
                Size        = DefaultSize,
                ToolTipText = "arrange all"
            };

            ColumnsCommand = new CommandView {
                Action = (s) => {
                    action = () => Columns(options);
                    action();
                },
                Image       = Iconery.ArrageRows,
                Size        = DefaultSize,
                ToolTipText = "arrange in columns"
            };

            OneColumnCommand = new CommandView {
                Action = (s) => {
                    action = () => OneColumn(options);
                    action();
                },
                Image       = Iconery.ArrangeOneRow,
                Size        = DefaultSize,
                ToolTipText = "arrange in one column"
            };

            ArrangeLeftCommand = new CommandView {
                Action = (s) => {
                    options.AlignX = Alignment.Start;
                    action();
                },
                Image       = Iconery.ArrangeLeft,
                Size        = DefaultSize,
                ToolTipText = "align left"
            };

            ArrangeCenterCommand = new CommandView {
                Action = (s) => {
                    options.AlignX = Alignment.Center;
                    action();
                },
                Image       = Iconery.ArrangeCenter,
                Size        = DefaultSize,
                ToolTipText = "align center"
            };

            ArrangeRightCommand = new CommandView {
                Action = (s) => {
                    options.AlignX = Alignment.End;
                    action();
                },
                Image       = Iconery.ArrangeRight,
                Size        = DefaultSize,
                ToolTipText = "align rigth"
            };

            ArrangeTopCommand = new CommandView {
                Action = (s) => {
                    options.AlignY = Alignment.Start;
                    action();
                },
                Image       = Iconery.ArrangeTop,
                Size        = DefaultSize,
                ToolTipText = "align top"
            };

            ArrangeCenterVCommand = new CommandView {
                Action = (s) => {
                    options.AlignY = Alignment.Center;
                    action();
                },
                Image       = Iconery.ArrangeMiddle,
                Size        = DefaultSize,
                ToolTipText = "align middle"
            };

            ArrangeBottomCommand = new CommandView {
                Action = (s) => {
                    options.AlignY = Alignment.End;
                    action();
                },
                Image       = Iconery.ArrangeBottom,
                Size        = DefaultSize,
                ToolTipText = "align bottom"
            };

            DimensionXCommand = new CommandView {
                Action = (s) => {
                    options.Dimension = Dimension.X;
                    action();
                },
                Image       = Iconery.DimensionX,
                Size        = DefaultSize,
                ToolTipText = "arrange left to right"
            };

            DimensionYCommand = new CommandView {
                Action = (s) => {
                    options.Dimension = Dimension.Y;
                    action();
                },
                Image       = Iconery.DimensionY,
                Size        = DefaultSize,
                ToolTipText = "arrange top to bottom"
            };

            UndoCommand = new CommandView {
                Action      = (s) => Undo(),
                Size        = DefaultSize,
                Image       = Iconery.Undo,
                ToolTipText = "undo last arrange"
            };

            var horizontalButton = new ToolbarDropDownButton(ArrangeLeftCommand);

            horizontalButton.AddItems(
                new ToolbarButton(ArrangeCenterCommand)
            {
                ToggleOnClick = horizontalButton
            },
                new ToolbarButton(ArrangeRightCommand)
            {
                ToggleOnClick = horizontalButton
            }
                );

            var verticalButton = new ToolbarDropDownButton(ArrangeTopCommand);

            verticalButton.AddItems(
                new ToolbarButton(ArrangeCenterVCommand)
            {
                ToggleOnClick = verticalButton
            },
                new ToolbarButton(ArrangeBottomCommand)
            {
                ToggleOnClick = verticalButton
            }
                );

            var layoutButton = new ToolbarDropDownButton(LogicalLayoutLeafCommand);

            layoutButton.AddItems(
                new ToolbarButton(LogicalLayoutCommand)
            {
                ToggleOnClick = layoutButton
            },
                new ToolbarButton(ColumnsCommand)
            {
                ToggleOnClick = layoutButton
            },
                new ToolbarButton(OneColumnCommand)
            {
                ToggleOnClick = layoutButton
            },
                new ToolbarButton(FullLayoutCommand)
                );

            var dimensionButton = new ToolbarDropDownButton(DimensionXCommand);

            dimensionButton.AddItems(
                new ToolbarButton(DimensionYCommand)
            {
                ToggleOnClick = dimensionButton
            }
                );

            this.AddItems(
                layoutButton,
                horizontalButton,
                verticalButton,
                dimensionButton,
                new ToolbarButton(UndoCommand),
                new ToolbarSeparator()
                );
        }
Ejemplo n.º 2
0
        protected virtual void Compose()
        {
            Action <IDisplay, bool> selectAction  = (display, value) => display.SelectAction.Enabled = value;
            Action <IDisplay, bool> panningAction = (display, value) => display.MouseScrollAction.Enabled = value;

            var actionGroup = new List <Action <IDisplay, bool> > ();

            actionGroup.Add(selectAction);
            actionGroup.Add(panningAction);
            Action <Action <IDisplay, bool>, bool> toogleAction = (ga, value) => {
                foreach (var a in actionGroup)
                {
                    if (ga == a)
                    {
                        DisplayAction(d => a(d, value));
                    }
                    else
                    {
                        DisplayAction(d => a(d, !value));
                    }
                }
            };

            EditCommand = new CommandView {
                Action = s => {
                    if (SplitView != null && SplitView.ContentVidget != null)
                    {
                        SplitView.ContentVidget.SetFocus();
                    }
                    // dirty hack:
                    if (SplitView != null && SplitView.ContentVidget is IMarkdownEdit)
                    {
                        var md = (IMarkdownEdit)SplitView.ContentVidget;
                        if (md != null)
                        {
                            md.InEdit = !md.InEdit;
                        }
                        return;
                    }
                    // dirty hack end
                    toogleAction(selectAction, true);
                },
                Image       = Iconery.Select,
                Size        = DefaultSize,
                ToolTipText = "Edit"
            };

            PanningCommand = new CommandView {
                Action      = s => toogleAction(panningAction, true),
                Image       = Iconery.Panning,
                Size        = DefaultSize,
                ToolTipText = "Move"
            };

            ZoomInOutCommand = new CommandView {
                Image       = Iconery.Zoom,
                Size        = DefaultSize,
                ToolTipText = "Zoom"
            };

            FitToWidthCommand = new CommandView {
                Action = s => ZoomAction(d => d.ZoomState = ZoomState.FitToWidth),
                Image  = Iconery.FitToWidth,
                Size   = DefaultSize,
                Label  = "Fit to Width"
            };

            FitToHeigthCommand = new CommandView {
                Action = s => ZoomAction(d => d.ZoomState = ZoomState.FitToHeigth),
                Image  = Iconery.FitToHeigth,
                Size   = DefaultSize,
                Label  = "Fit to Heigth",
            };

            FitToScreenCommand = new CommandView {
                Action = s => ZoomAction(d => d.ZoomState = ZoomState.FitToScreen),
                Image  = Iconery.FitToScreen,
                Size   = DefaultSize,
                Label  = "Fit to Screen"
            };

            OriginalSizeCommand = new CommandView {
                Action = s => ZoomAction(d => d.ZoomState = ZoomState.Original),
                Image  = Iconery.OriginalSize,
                Size   = DefaultSize,
                Label  = "Original size"
            };


            var selectButton = new ToolbarDropDownButton(EditCommand);

            selectButton.AddItems(
                new ToolbarButton(PanningCommand)
            {
                ToggleOnClick = selectButton
            }
                );

            var zoomButton = new ToolbarDropDownButton(ZoomInOutCommand);

            zoomButton.AddItems(
                new ToolbarButton(FitToScreenCommand),
                new ToolbarButton(FitToWidthCommand),
                new ToolbarButton(FitToHeigthCommand),
                new ToolbarButton(OriginalSizeCommand)
                );

            this.AddItems(
                selectButton,
                zoomButton,
                new ToolbarSeparator()
                );
        }