Exemplo n.º 1
0
        private async Task <int> ExecuteInputPopup(string Title)
        {
            var inputView = new TextInputView(Title);
            var popup     = new InputAlertDialogBase <int>(inputView);

            inputView.CloseButtonEventHandler +=
                (sender, obj) =>
            {
                if (((TextInputView)sender).TextInputResult >= 0)
                {
                    ((TextInputView)sender).IsValidationLabelVisible = false;
                    popup.PageClosedTaskCompletionSource.SetResult(((TextInputView)sender).TextInputResult);
                }
                else
                {
                    ((TextInputView)sender).IsValidationLabelVisible = true;
                }
            };

            await PopupNavigation.PushAsync(popup);

            var result = await popup.PageClosedTask;
            await PopupNavigation.PopAsync();

            return(result);
        }
Exemplo n.º 2
0
        /// <inheritdoc/>
        public void AttachExtraPresenters(CLEMPresenter clemPresenter)
        {
            try
            {
                // Create the grid to display data in
                gridView = new GridView(clemPresenter.View as ViewBase);
                GridPresenter gridPresenter = new GridPresenter();

                // Create the SQL display
                sqlView = new TextInputView(clemPresenter.View as ViewBase);

                // Generate the table using the model
                pivot = clemPresenter.ClemModel as ReportPivot;
                gridPresenter.Attach(null, gridView, clemPresenter.ExplorerPresenter);

                // Attach the views to display data
                clem = clemPresenter.View as CLEMView;

                clem.AddTabView("Data", gridView);
                clemPresenter.PresenterList.Add("Data", this);

                clem.AddTabView("SQL", sqlView);
                clemPresenter.PresenterList.Add("SQL", this);
            }
            catch (Exception err)
            {
                clemPresenter.ExplorerPresenter.MainPresenter.ShowError(err);
            }
        }
Exemplo n.º 3
0
        public async Task <string> OpenTextInputAlertDialog(string titleText, string placeHolderText,
                                                            string closeButtonText, string validationLabelText)
        {
            // create the TextInputView
            var inputView = new TextInputView(titleText, placeHolderText,
                                              closeButtonText, validationLabelText);

            // create the Transparent Popup Page
            // of type string since we need a string return
            var popup = new InputAlertDialogBase <string>(inputView);

            // subscribe to the TextInputView's Button click event
            inputView.CloseButtonEventHandler +=
                (sender, obj) =>
            {
                if (!string.IsNullOrEmpty(((TextInputView)sender).TextInputResult))
                {
                    ((TextInputView)sender).IsValidationLabelVisible = false;
                    popup.PageClosedTaskCompletionSource.SetResult(((TextInputView)sender).TextInputResult);
                }
                else
                {
                    ((TextInputView)sender).IsValidationLabelVisible = true;
                }
            };

            // return user inserted text value
            return(await Navigate(popup));
        }
Exemplo n.º 4
0
            internal bool HideKeyboard()
            {
                if (TextInputView.IsFirstResponder)
                {
                    TextInputView.ResignFirstResponder();
                    return(true);
                }

                return(false);
            }
Exemplo n.º 5
0
        public MainPresenter CreateMainPresenter()
        {
            ToolbarView     toolbarView     = new ToolbarView();
            TextInputView   textInputView   = new TextInputView();
            WordCounterView wordCounterView = new WordCounterView();
            StatusBarView   statusBarView   = new StatusBarView();

            ToolbarModel toolbarModel = new ToolbarModel();
            //ToolbarPresenter toolbarPresenter = new ToolbarPresenter(toolbarView, toolbarModel);

            IModalDialogBuilder modalDialogBuilder = new ModalDialogBuilder();

            IFileSelectionView     fileSelectionView  = new FileSelectionView();
            FileSelectionModel     fileSelectionModel = new FileSelectionModel();
            FileSelectionPresenter openFilePresenter  = new FileSelectionPresenter(fileSelectionView, fileSelectionModel);

            TextInputModel     textInputModel     = new TextInputModel(fileSelectionModel);
            TextInputPresenter textInputPresenter = new TextInputPresenter(textInputView, textInputModel);

            WordFrequencyCounter wordFrequencyCounter = new WordFrequencyCounter();
            WordCounterModel     wordCounterModel     = new WordCounterModel(wordFrequencyCounter);
            WordCounterPresenter wordCounterPresenter = new WordCounterPresenter(wordCounterView, wordCounterModel);

            RunButtonNavigator runButtonNavigator = new RunButtonNavigator(toolbarView, wordCounterModel);

            MainView      mainView      = new MainView(toolbarView, textInputView, wordCounterView, statusBarView);
            MainModel     mainModel     = new MainModel();
            MainPresenter mainPresenter = new MainPresenter(mainView, mainModel);

            AboutView      aboutView      = new AboutView();
            AboutModel     aboutModel     = new AboutModel();
            AboutPresenter aboutPresenter = new AboutPresenter(aboutView, aboutModel);

            RunButtonNavigator   navigation           = new RunButtonNavigator(toolbarView, wordCounterModel);
            AboutButtonNavigator aboutButtonNavigator = new AboutButtonNavigator(toolbarView, aboutView);
            TextSynchronizer     modelConnector       = new TextSynchronizer(wordCounterModel, textInputModel);

            IFileSelectionDisplay fileSelectionDisplay = new FileSelectionDisplay(fileSelectionModel);

            ILoadTextFromFile           loadTextFromFile            = new LoadTextFromFile(fileSelectionDisplay);
            LoadTextFromFileToTextInput loadTextFromFileToTextInput = new LoadTextFromFileToTextInput(loadTextFromFile, textInputModel);
            FileSelectionNavigator      openFileButtonNavigator     = new FileSelectionNavigator(toolbarView, loadTextFromFileToTextInput);

            TextInputLoader textInputLoader = new TextInputLoader(textInputModel, fileSelectionModel);

            /*
             * Wyświetlanie MsgBox
             * Obsługa błędów otwarcia pliku
             */

            return(mainPresenter);
        }
Exemplo n.º 6
0
        private async Task <string> Aanpassen()
        {
            var result = string.Empty;
            // create the TextInputView
            var inputView = new TextInputView(
                "Geef je wachtwoord op", "wachtwoord...", "OK", "Annuleer", "Onjuist wachtwoord!");

            // create the Transparent Popup Page
            // of type string since we need a string return
            var popup = new InputAlertDialogBase <string>(inputView);

            // subscribe to the TextInputView's Button click event
            inputView.SaveButtonEventHandler +=
                (sender, obj) =>
            {
                if (bus.Vergelijken(inputView.TextInputResult) == true)
                {
                    ((TextInputView)sender).IsValidationLabelVisible = false;
                    popup.PageClosedTaskCompletionSource.SetResult(((TextInputView)sender).TextInputResult);
                    lstGebruiker.SelectedItem = (lstGebruiker.ItemsSource as List <Gebruiker>)[0];
                    Navigation.PushAsync(new GegevensAanpassen()
                    {
                        BindingContext = lstGebruiker.SelectedItem as Gebruiker
                    });
                }
                else
                {
                    ((TextInputView)sender).IsValidationLabelVisible = true;
                }
            };
            // subscribe to the TextInputView's Button click event
            inputView.CancelButtonEventHandler +=
                (sender, obj) =>
            {
                popup.PageClosedTaskCompletionSource.SetResult(null);
            };

            // Push the page to Navigation Stack
            await PopupNavigation.PushAsync(popup);

            // await for the user to enter the text input
            result = await popup.PageClosedTask;

            // Pop the page from Navigation Stack
            await PopupNavigation.PopAsync();

            // return user inserted text value
            return(result);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Attach the 'Model' and the 'View' to this presenter.
        /// </summary>
        /// <param name="model">The model to use</param>
        /// <param name="view">The view object</param>
        /// <param name="parentPresenter">The explorer presenter used</param>
        public void Attach(object model, object view, ExplorerPresenter parentPresenter)
        {
            memoModel         = model as Memo;
            explorerPresenter = parentPresenter;

            markdownView        = (view as ViewBase).GetControl <MarkdownView>("markdownView");
            textView            = (view as ViewBase).GetControl <TextInputView>("textEditor");
            editButton          = (view as ViewBase).GetControl <ButtonView>("editButton");
            helpButton          = (view as ViewBase).GetControl <ButtonView>("helpButton");
            helpButton.Clicked += HelpBtnClicked;
            textView.Visible    = false;
            textView.WrapText   = true;
            textView.ModifyFont(Utility.Configuration.Settings.EditorFontName);
            textView.Text          = memoModel.Text;
            textView.Changed      += OnTextHasChanged;
            markdownView.ImagePath = Path.GetDirectoryName(explorerPresenter.ApsimXFile.FileName);
            markdownView.Text      = memoModel.Text;
            editButton.Clicked    += OnEditButtonClick;
            helpButton.Visible     = false;
        }
Exemplo n.º 8
0
            internal void UpdateTextViewHeight()
            {
                if (TextInputView == null)
                {
                    return;
                }

                SendButton.Enabled = TextInputView.HasText;

                var oldTextMessageHeight = TextInputView.Frame.Height;
                var diffHeight           = HeightConstraint.Constant - oldTextMessageHeight;

                var newSize       = TextInputView.SizeThatFits(new CGSize(TextInputView.Bounds.Width, nfloat.MaxValue));
                var newSizeHeight = newSize.Height + diffHeight;

                var maxHeight = IsPortrait ? TextViewMaxHeightPortrait : TextViewMaxHeightLandscape;

                if (newSizeHeight > maxHeight)
                {
                    newSizeHeight = maxHeight;
                }

                if (HeightConstraint.Constant != newSizeHeight)
                {
                    HeightConstraint.Constant = newSizeHeight;

                    if (HeightChangeAction != null)
                    {
                        HeightChangeAction();
                    }

                    TextInputView.ReloadInputViews();

                    TextInputView.SetContentOffset(new CGPoint(0, 0), true);
                }

                if (SaveUnsentMessageAsync != null)
                {
                    SaveUnsentMessageAsync(TextInputView.Text, false);
                }
            }
Exemplo n.º 9
0
        private async Task <string> OpenTextInputAlertDialog()
        {
            // create the TextInputView
            var inputView = new TextInputView(
                "What's your name?", "enter here...", "Ok", "Ops! Can't leave this empty!");

            // create the Transparent Popup Page
            // of type string since we need a string return
            var popup = new InputAlertDialogBase <string>(inputView);

            // subscribe to the TextInputView's Button click event
            inputView.CloseButtonEventHandler +=
                (sender, obj) =>
            {
                if (!string.IsNullOrEmpty(((TextInputView)sender).TextInputResult))
                {
                    ((TextInputView)sender).IsValidationLabelVisible = false;
                    popup.PageClosedTaskCompletionSource.SetResult(((TextInputView)sender).TextInputResult);
                }
                else
                {
                    ((TextInputView)sender).IsValidationLabelVisible = true;
                }
            };

            // Push the page to Navigation Stack
            await PopupNavigation.PushAsync(popup);

            // await for the user to enter the text input
            var result = await popup.PageClosedTask;

            // Pop the page from Navigation Stack
            await PopupNavigation.PopAsync();

            // return user inserted text value
            return(result);
        }
Exemplo n.º 10
0
        public async Task NavigateForward(AbstractViewModel vm)
        {
            ContentPage cp      = null;
            bool        isPopup = vm is IPopupViewModel;

            if (vm is LoginViewModel)
            {
                cp = new LoginView();
            }
            else if (vm is AllSnippetsViewModel)
            {
                cp = new AllSnippetsView();
            }
            else if (vm is AllUsersViewModel)
            {
                cp = new AllUsersView();
            }
            else if (vm is YesNoPageViewModel)
            {
                cp = new YesNoPageView();
            }
            else if (vm is SnippetViewModel)
            {
                cp = new SnippetView();
            }
            else if (vm is UserViewModel)
            {
                cp = new UserView();
            }
            else if (vm is VariableViewModel)
            {
                cp = new VariableView();
            }
            else if (vm is MenuViewModel)
            {
                cp = new MenuView();
            }
            else if (vm is AlertViewModel)
            {
                cp = new AlertView();
            }
            else if (vm is ProfileViewModel)
            {
                cp = new ProfileView();
            }
            else if (vm is TextInputViewModel)
            {
                cp = new TextInputView();
            }

            cp.BindingContext = vm;

            await Task.Delay(100);

            if (isPopup)
            {
                SetHasBackButton(cp, false);
                await Navigation.PushModalAsync(cp);
            }
            else
            {
                await Navigation.PushAsync(cp);
            }
        }