示例#1
0
        internal static void SaveBrowserHistory(NavigationToolbar historyToolbar, ITabState state)
        {
            if (state == null)
            {
                return;
            }

            state.CurrentHistoryItem    = null;
            state.GoBackHistoryItems    = null;
            state.GoForwardHistoryItems = null;

            if (historyToolbar.CurrentItem != null)
            {
                state.CurrentHistoryItem = (ITextImageItem)historyToolbar.CurrentItem.Tag;

                List <ITextImageItem> items = new List <ITextImageItem>(historyToolbar.BackHistoryCount);
                foreach (var hitem in historyToolbar.BackHistory)
                {
                    items.Add((ITextImageItem)hitem.Tag);
                }
                state.GoBackHistoryItems = items.ToArray();

                items = new List <ITextImageItem>(historyToolbar.ForwardHistoryCount);
                foreach (var hitem in historyToolbar.ForwardHistory)
                {
                    items.Add((ITextImageItem)hitem.Tag);
                }
                state.GoForwardHistoryItems = items.ToArray();
            }
        }
        public MainWindow()
        {
            InitializeComponent();
            SetExceptionHandler();
            IApplication app = new XMLApplication();

            XmlDocLoader.LoadXmlDocuments(app);
            NavModel = new NavigationModel(this);
            NavigationToolbar.Set_NavModel(NavModel);
            App = app;
            NavModel.GoTo_Documents();
        }
示例#3
0
        internal static void ResetBrowserHistory(NavigationToolbar historyToolbar, ITabState state)
        {
            historyToolbar.ResetNavigationHistory();

            if (state == null || state.CurrentHistoryItem == null)
            {
                return;
            }

            List <NavigationHistoryItem> back    = null;
            List <NavigationHistoryItem> forward = null;

            if (state.GoBackHistoryItems != null && state.GoBackHistoryItems.Length > 0)
            {
                back = new List <NavigationHistoryItem>(state.GoBackHistoryItems.Length);
                for (int i = 0; i < state.GoBackHistoryItems.Length; i++)
                {
                    ITextImageItem item = state.GoBackHistoryItems[i];
                    back.Add(new NavigationHistoryItem(item.Text, item));
                }
            }

            if (state.GoForwardHistoryItems != null && state.GoForwardHistoryItems.Length > 0)
            {
                forward = new List <NavigationHistoryItem>(state.GoForwardHistoryItems.Length);
                for (int i = 0; i < state.GoForwardHistoryItems.Length; i++)
                {
                    ITextImageItem item = state.GoForwardHistoryItems[i];
                    forward.Add(new NavigationHistoryItem(item.Text, item));
                }
            }

            historyToolbar.InitializeHistory(
                back == null ? null : back.ToArray(),
                forward == null ? null : forward.ToArray(),
                new NavigationHistoryItem(state.CurrentHistoryItem.Text, state.CurrentHistoryItem));
        }
示例#4
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
            ThemeData     themeData   = Theme.of(context);
            ScaffoldState scaffold    = Scaffold.of(context, nullOk: true);
            ModalRoute    parentRoute = ModalRoute.of(context);

            bool hasDrawer      = scaffold?.hasDrawer ?? false;
            bool hasEndDrawer   = scaffold?.hasEndDrawer ?? false;
            bool canPop         = parentRoute?.canPop ?? false;
            bool useCloseButton = parentRoute is PageRoute && ((PageRoute)parentRoute).fullscreenDialog;

            IconThemeData appBarIconTheme = this.widget.iconTheme ?? themeData.primaryIconTheme;
            TextStyle     centerStyle     = this.widget.textTheme?.title ?? themeData.primaryTextTheme.title;
            TextStyle     sideStyle       = this.widget.textTheme?.body1 ?? themeData.primaryTextTheme.body1;

            if (this.widget.toolbarOpacity != 1.0f)
            {
                float opacity =
                    new Interval(0.25f, 1.0f, curve: Curves.fastOutSlowIn).transform(this.widget.toolbarOpacity);
                if (centerStyle?.color != null)
                {
                    centerStyle = centerStyle.copyWith(color: centerStyle.color.withOpacity(opacity));
                }

                if (sideStyle?.color != null)
                {
                    sideStyle = sideStyle.copyWith(color: sideStyle.color.withOpacity(opacity));
                }

                appBarIconTheme = appBarIconTheme.copyWith(
                    opacity: opacity * (appBarIconTheme.opacity ?? 1.0f)
                    );
            }

            Widget leading = this.widget.leading;

            if (leading == null && this.widget.automaticallyImplyLeading)
            {
                if (hasDrawer)
                {
                    leading = new IconButton(
                        icon: new Icon(Icons.menu),
                        onPressed: this._handleDrawerButton,
                        tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip);
                }
                else
                {
                    if (canPop)
                    {
                        leading = useCloseButton ? (Widget) new CloseButton() : new BackButton();
                    }
                }
            }

            if (leading != null)
            {
                leading = new ConstrainedBox(
                    constraints: BoxConstraints.tightFor(width: AppBarUtils._kLeadingWidth),
                    child: leading);
            }

            Widget title = this.widget.title;

            if (title != null)
            {
                title = new DefaultTextStyle(
                    style: centerStyle,
                    softWrap: false,
                    overflow: TextOverflow.ellipsis,
                    child: title);
            }

            Widget actions = null;

            if (this.widget.actions != null && this.widget.actions.isNotEmpty())
            {
                actions = new Row(
                    mainAxisSize: MainAxisSize.min,
                    crossAxisAlignment: CrossAxisAlignment.stretch,
                    children: this.widget.actions);
            }
            else if (hasEndDrawer)
            {
                actions = new IconButton(
                    icon: new Icon(Icons.menu),
                    onPressed: this._handleDrawerButtonEnd,
                    tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip);
            }

            Widget toolbar = new NavigationToolbar(
                leading: leading,
                middle: title,
                trailing: actions,
                centerMiddle: this.widget._getEffectiveCenterTitle(themeData).Value,
                middleSpacing: this.widget.titleSpacing);

            Widget appBar = new ClipRect(
                child: new CustomSingleChildLayout(
                    layoutDelegate: new _ToolbarContainerLayout(),
                    child: IconTheme.merge(
                        data: appBarIconTheme,
                        child: new DefaultTextStyle(
                            style: sideStyle,
                            child: toolbar)
                        )
                    )
                );

            if (this.widget.bottom != null)
            {
                appBar = new Column(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: new List <Widget> {
                    new Flexible(
                        child: new ConstrainedBox(
                            constraints: new BoxConstraints(maxHeight: Constants.kToolbarHeight),
                            child: appBar
                            )
                        ),
                    this.widget.bottomOpacity == 1.0f
                            ? (Widget)this.widget.bottom
                            : new Opacity(
                        opacity: new Interval(0.25f, 1.0f, curve: Curves.fastOutSlowIn).transform(this.widget
                                                                                                  .bottomOpacity),
                        child: this.widget.bottom
                        )
                }
                    );
            }

            if (this.widget.primary)
            {
                appBar = new SafeArea(
                    top: true,
                    child: appBar);
            }

            appBar = new Align(
                alignment: Alignment.topCenter,
                child: appBar);

            if (this.widget.flexibleSpace != null)
            {
                appBar = new Stack(
                    fit: StackFit.passthrough,
                    children: new List <Widget> {
                    this.widget.flexibleSpace,
                    appBar
                }
                    );
            }

            Brightness           brightness   = this.widget.brightness ?? themeData.primaryColorBrightness;
            SystemUiOverlayStyle overlayStyle = brightness == Brightness.dark
                ? SystemUiOverlayStyle.light
                : SystemUiOverlayStyle.dark;

            return(new AnnotatedRegion <SystemUiOverlayStyle>(
                       value: overlayStyle,
                       child: new Material(
                           color: this.widget.backgroundColor ?? themeData.primaryColor,
                           elevation: this.widget.elevation,
                           child: appBar
                           )));
        }