public static void Initialize(PageService pageService, IFileRepository fileRepository, IExternalBrowserService externalBrowserService, ApplicationEvents applicationEvents)
 {
     Current = new PageFactory
     {
         _pageService = pageService,
         _fileRepository = fileRepository,
         _externalBrowserService = externalBrowserService,
         _applicationEvents = applicationEvents
     };
 }
        public EditFilePage(string pageName, PageService pageService)
        {
            _pageName = pageName;
            _pageService = pageService;
            _originalText = pageService.GetTextOfPage(pageName);
            PersistedState.PageInEditMode = pageName;

            _editBox = new Editor
            {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Text = _originalText,
            };
            _editBox.TextChanged += (sender, args) => PersistedState.AutoSaveEditText = args.NewTextValue;

            Content = new ScrollView
            {
                Content = new StackLayout
                {
                    Children = {_editBox}
                }
            };

            ToolbarItems.Add(new ToolbarItem
            {
                Text = "Save",
                Icon = "ic_menu_save.png",
                Command = new Command(Save),
                Order = ToolbarItemOrder.Primary
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text = "Clear",
                Icon = "ic_menu_clear_playlist.png",
                Command = new Command(Clear)
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text = "Delete",
                Icon = "ic_menu_delete.png",
                Command = new Command(Delete),
                Order = ToolbarItemOrder.Secondary
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text = "Cancel",
                Command = new Command(Cancel),
                Order = ToolbarItemOrder.Secondary
            });
        }
Beispiel #3
0
        public App(IFileRepository fileRepository, IExternalBrowserService externalBrowserService)
        {
            var service = new PageService(new WikiStorage(fileRepository), new HtmlWrapper(fileRepository), new MarkdownImpl());
            _applicationEvents = new ApplicationEvents();

            try
            {
                fileRepository.StorageDirectory = PersistedState.CustomStorageDirectory;
            }
            catch
            {
                //can't do much about it now.
            }

            PageFactory.Initialize(service, fileRepository, externalBrowserService, _applicationEvents);

            SyncBootstrapper.RefreshDropboxSync(fileRepository);
            SyncBootstrapper.RefreshFromSyncInterval();

            MainPage = new NavigationPage(PageFactory.Current.CreateEmaWikiPage());
        }
        /// <summary>
        /// constructor; builds the page and controls.
        /// </summary>
        public EmaWikiPage(PageService pageService, IExternalBrowserService externalBrowserService)
        {
            _pageService = pageService;

            _searchBar = new SearchBar
            {
                Placeholder = "Search in wiki",
                IsVisible = false
            };
            _searchBar.SearchButtonPressed += SearchBarOnSearchButtonPressed;

            var syncProgress = new SyncProgressContentView {IsVisible = false};
            SyncBootstrapper.ShowSyncProgressIn(syncProgress);

            //prominent: the webview.
            _webView = new EmaWebView(externalBrowserService);
            _webView.RequestPage += (sender, args) => GoTo(args.PageName);
            _webView.RequestEdit += (sender, args) => EditCurrentPage();

            Content = new StackLayout
            {
                Children =
                {
                    _searchBar,
                    syncProgress,
                    _webView
                }
            };

            ToolbarItems.Add(new ToolbarItem
            {
                Text = "Home",
                Icon = "ic_menu_home.png",
                Command = new Command(() => GoTo(PageService.DefaultPage)),
                Order = ToolbarItemOrder.Primary
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text = "Edit",
                Icon = "ic_menu_edit.png",
                Command = new Command(EditCurrentPage),
                Order = ToolbarItemOrder.Primary
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text = "Search",
                Icon = "ic_menu_search.png",
                Order = ToolbarItemOrder.Secondary,
                Command = new Command(() =>
                {
                    _searchBar.Text = "";
                    _searchBar.IsVisible = !_searchBar.IsVisible;

                    if (_searchBar.IsVisible)
                    {
                        _searchBar.Focus();
                    }
                })
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text = "Refresh",
                Command = new Command(Refresh),
                Order = ToolbarItemOrder.Secondary
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Icon = "ic_menu_upload.png",
                Text = "Synchronize",
                Command = new Command(async () => await Synchronize()),
                Order = ToolbarItemOrder.Secondary
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text = "Preferences",
                Icon = "ic_menu_preferences.png",
                Command = new Command(Settings),
                Order = ToolbarItemOrder.Secondary
            });
        }