Opening document depending on month of the year

BorisopritBorisoprit Member ✭✭✭

Hello,

I asked a question here over opening a document based on the month of the year.
https://www.c-sharpcorner.com/forums/show-document-depending-on-month-of-the-year

pritaeas gave me an option but there is a problem and he also dont know why it is not working

above the webview i have a label that is showing the month of the date on the phone.

That works also when i change the date.

changing the date to the 12 month it is working , and the 11 month also.

But month 1 till 10 not ??? the label is showing the month 1 till 10 but the document is not opening.

Changed the document but no problem there.

This is what pritaeas gave me to work with but i am stuck

`

    <Label x:Name="Maand"
           Text="{Binding Source={x:Static sys:DateTime.Now}, StringFormat='{0:MM}'}" />

    <!-- Place new controls here -->
    <ProgressBar Progress="0.2"  
             HorizontalOptions="FillAndExpand"  
             x:Name="progress"  
                     ProgressColor="Maroon"
             IsVisible="True"/>
    <WebView x:Name="Webview"  
         HeightRequest="1000"  
         WidthRequest="1000"  
         Navigating="OnNavigating"  
         Navigated="OnNavigated"  
         VerticalOptions="FillAndExpand"/>

</StackLayout>


`

And

` public MainPage()
{
InitializeComponent();

        Webview.Source= monthlySources[DateTime.Now.Month];

    }
    private readonly Dictionary<int, string> monthlySources = new Dictionary<int, string>()

{
{ 01, "https://docs.google.com/spreadsheets/d/1BEryoKhaTP6tx2VsYibYXE5kJoEBKqGFNrhov1W_b7s/edit?usp=sharing" },
{ 02, "https://docs.google.com/spreadsheets/d/1ldcZ6WXXMI73xXaGw1Nxa2LDTVydkRiYzMRs1nYzE84/edit?usp=sharing" },
{ 03, "https://docs.google.com/spreadsheets/d/1BEryoKhaTP6tx2VsYibYXE5kJoEBKqGFNrhov1W_b7s/edit?usp=sharing" },
{ 04, "https://docs.google.com/spreadsheets/d/1BEryoKhaTP6tx2VsYibYXE5kJoEBKqGFNrhov1W_b7s/edit?usp=sharing" },
{ 05, "https://docs.google.com/spreadsheets/d/1BEryoKhaTP6tx2VsYibYXE5kJoEBKqGFNrhov1W_b7s/edit?usp=sharing" },
{ 06, "https://docs.google.com/spreadsheets/d/1BEryoKhaTP6tx2VsYibYXE5kJoEBKqGFNrhov1W_b7s/edit?usp=sharing" },
{ 07, "https://docs.google.com/document/d/1cI2O4O4F6MOL8KIulzRDlO9xx2lhSJ0D4nZ8IONmyLY/edit?usp=sharing" },
{ 08, "https://docs.google.com/spreadsheets/d/1BEryoKhaTP6tx2VsYibYXE5kJoEBKqGFNrhov1W_b7s/edit?usp=sharing" },
{ 09, "https://docs.google.com/spreadsheets/d/1sHKgIxZ3ut0Dd-6fEt1Ynk84sOhyLC1Q1RX8SW3QtS4/edit?usp=sharing" },
{ 10, "https://docs.google.com/spreadsheets/d/1ldcZ6WXXMI73xXaGw1Nxa2LDTVydkRiYzMRs1nYzE84/edit?usp=sharing" },
{ 11, "https://docs.google.com/spreadsheets/d/1h2wQMlPpvnajq_Dg-Yx6Gwh4wzy7ZPd3Kp5gnDnEszY/edit?usp=sharing" },
{ 12, "https://docs.google.com/spreadsheets/d/1BEryoKhaTP6tx2VsYibYXE5kJoEBKqGFNrhov1W_b7s/edit?usp=sharing" },
};

    protected async override void OnAppearing()
    {
        base.OnAppearing();

        await progress.ProgressTo(0.9, 900, Easing.SpringIn);
    }

    protected void OnNavigating(object sender, WebNavigatingEventArgs e)
    {
        // SfBusyIndicator busyIndicator = new SfBusyIndicator();
        progress.IsVisible = true;
        // busyindicator.IsVisible = true;
    }

    protected void OnNavigated(object sender, WebNavigatedEventArgs e)
    {
        // SfBusyIndicator busyIndicator = new SfBusyIndicator();
        progress.IsVisible = false;
        //  busyindicator.IsVisible = false;
    }


}

}`

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai

    I've reproduced the code and it works fine on my side. All the documents corresponding with the months can be displayed as shown. What's the version of Xamarin.Forms?

    Here is the demo file you can refer to.

  • BorisopritBorisoprit Member ✭✭✭

    Hello Jarvan ,

    Thanks for the reply and sample.

    This is the version

    Now the strange part , the sample works but .

    Hope you like a challange , when i change the date on my android phone to let say september .

    It is not downloading anything anymore , not with mine or your example ?

    Am looking for something that looks wich month it is of the year and then download that document and show in webview.

    On the example on the other forum that pritaeas gave works with him but not on my phone.

    Yes works but when change the date to other month not any more ?????

    I cannot change the date on my computer because it is a company pc and the IT don't alllow that.

    So the simulator has no point thats why i put it on the android phone (

    Debug or Release makes no difference.

  • JarvanJarvan Member, Xamarin Team Xamurai

    I've tested on a physical device and changed the links because of the access reason. After changing the device month, the demo works fine.

    when i change the date on my android phone to let say september .

    Did this problem only occur with Septemeber?

Sign In or Register to comment.