示例#1
0
        /// <summary>
        ///     Populates the page with content passed during navigation.  Any saved state is also
        ///     provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        ///     The source of the event; typically <see cref="NavigationHelper" />
        /// </param>
        /// <param name="e">
        ///     Event data that provides both the navigation parameter passed to
        ///     <see cref="Frame.Navigate(Type, Object)" /> when this page was initially requested and
        ///     a dictionary of state preserved by this page during an earlier
        ///     session.  The state will be null the first time a page is visited.
        /// </param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            //show loading indicator
            var progressbar = StatusBar.GetForCurrentView().ProgressIndicator;
            progressbar.Text = Localization.translate("please.wait");
            await progressbar.ShowAsync();

            var countryId = e.NavigationParameter as string;

            if (!string.IsNullOrWhiteSpace(countryId))
            {
                try
                {
                    selectedCountry = Convert.ToInt32(countryId);
                    var connectionParameters = ShowcaseUtils.getUserCredentials();
                    connectionParameters.Add(ShowcaseConstants.ID_KEY, selectedCountry.ToString());
                    try
                    {
                        AFList absenceTypesList = (AFList)AfWindowsPhone.getInstance()
                            .getListBuilder()
                            .initBuilder(ShowcaseConstants.ABSENCE_TYPE_LIST, "connection.xml",
                                ShowcaseConstants.ABSENCE_TYPE_LIST_CONNECTION_KEY, connectionParameters)
                            .setSkin(new MyAbsencesSkin())
                            .createComponent();
                        AbsenceTypesListPanel.Children.Add(absenceTypesList.getView());

                        AFForm absenceTypeForm = (AFForm)AfWindowsPhone.getInstance()
                            .getFormBuilder()
                            .initBuilder(ShowcaseConstants.ABSENCE_TYPE_FORM, "connection.xml",
                                ShowcaseConstants.ABSENCE_TYPE_FORM_CONNECTION_KEY, connectionParameters)
                            .createComponent();
                        AbsenceTypesFormPanel.Children.Add(absenceTypeForm.getView());

                        absenceTypesList.getListView().IsItemClickEnabled = true;
                        absenceTypesList.getListView().ItemClick += OnItemClick;
                    }
                    catch (Exception exception)
                    {
                        ShowcaseUtils.showComponentBuildFailedDialog();
                        Debug.WriteLine(exception.StackTrace);
                        progressbar.HideAsync();
                        return;
                    }
                    var perform = new Button();
                    perform.Content = Localization.translate("btn.perform");
                    perform.Click += Perform_Click;

                    var reset = new Button();
                    reset.Content = Localization.translate("btn.reset");
                    reset.Click += Reset_Click;

                    var clear = new Button();
                    clear.Content = Localization.translate("btn.clear");
                    clear.Click += Clear_Click;

                    var buttons = new StackPanel();
                    buttons.HorizontalAlignment = HorizontalAlignment.Center;
                    buttons.Orientation = Orientation.Horizontal;
                    buttons.Children.Add(perform);
                    buttons.Children.Add(reset);
                    buttons.Children.Add(clear);
                    AbsenceTypesFormPanel.Children.Add(buttons);


                    Debug.WriteLine(selectedCountry);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Cannot parse string to integer");
                    Debug.WriteLine(ex.StackTrace);
                }
            }
            else
            {
                Debug.WriteLine("Parameter was not passed succesfully (or is null or empty) ");
            }
            await progressbar.HideAsync();
        }
示例#2
0
 /// <summary>
 /// Populates the page with content passed during navigation.  Any saved state is also
 /// provided when recreating a page from a prior session.
 /// </summary>
 /// <param name="sender">
 /// The source of the event; typically <see cref="NavigationHelper"/>
 /// </param>
 /// <param name="e">Event data that provides both the navigation parameter passed to
 /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
 /// a dictionary of state preserved by this page during an earlier
 /// session.  The state will be null the first time a page is visited.</param>
 private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
 {
 }