Пример #1
0
        public void ShareFile(string forLocation)
        {
            DateTime selectedExpirationDate = DateTime.Now.AddDays(7);              //Selectie standaard op 7 dagen na vandaag

            ActionSheetDatePickerCustom actionSheetDatePicker;

            actionSheetDatePicker                    = new ActionSheetDatePickerCustom(HomeController.homeController.View);
            actionSheetDatePicker.Title              = "Kies een vervaldatum:";
            actionSheetDatePicker.Picker.Mode        = UIDatePickerMode.Date;
            actionSheetDatePicker.Picker.MinimumDate = NSDateHelper.DateTimeToNSDate(DateTime.Today.AddDays(1));

            //Zet selectie standaard op 7 dagen na vandaag
            actionSheetDatePicker.Picker.SetDate(NSDateHelper.DateTimeToNSDate(DateTime.Today.AddDays(7)), true);

            actionSheetDatePicker.Picker.ValueChanged += (sender, e) => {
                var nsDate = (sender as UIDatePicker).Date;

                DateTime selectedDate = NSDateHelper.NSDateToDateTime(nsDate);
                selectedExpirationDate = selectedDate.AddDays(1);

                Console.WriteLine(selectedExpirationDate.ToString());
            };

            actionSheetDatePicker.DoneButton.Clicked += (object sender, EventArgs e) => {
                //Dismiss actionsheet
                actionSheetDatePicker.Hide(true);

                //Show progress dialog
                DialogHelper.ShowProgressDialog("Delen", "Publieke url aan het ophalen", async() => {
                    try {
                        PublicUrl publicUrl = await DataLayer.Instance.CreatePublicFileShare(forLocation, selectedExpirationDate.Date);

                        MFMailComposeViewController mvc = new MFMailComposeViewController();
                        mvc.SetSubject("Publieke URL naar gedeeld Pleiobox bestand");

                        string bodyText = "Mijn gedeelde bestand: \n" +
                                          publicUrl.publicUri + "\n \n" +
                                          "Deze link is geldig tot: " + selectedExpirationDate.ToString("dd-MM-yyyy");

                        mvc.SetMessageBody(bodyText, false);
                        mvc.Finished += (object s, MFComposeResultEventArgs args) => {
                            args.Controller.DismissViewController(true, null);
                        };
                        _nodeViewController.PresentViewController(mvc, true, null);

                        DialogHelper.HideProgressDialog();
                    }  catch (Exception ex) {
                        Insights.Report(ex);
                        DialogHelper.HideProgressDialog();
                        DialogHelper.ShowErrorDialog("Fout", "Er is een fout opgetreden bij het delen van het bestand." +
                                                     "\nVervers a.u.b. de map en probeer het opnieuw.");
                    }
                });
            };

            actionSheetDatePicker.Show();
        }
Пример #2
0
		public void ShareFile (string forLocation)
		{
			DateTime selectedExpirationDate = DateTime.Now.AddDays (7); //Selectie standaard op 7 dagen na vandaag
		
			ActionSheetDatePickerCustom actionSheetDatePicker;
			actionSheetDatePicker = new ActionSheetDatePickerCustom (HomeController.homeController.View);
			actionSheetDatePicker.Title = "Kies een vervaldatum:";
			actionSheetDatePicker.Picker.Mode = UIDatePickerMode.Date;
			actionSheetDatePicker.Picker.MinimumDate = NSDateHelper.DateTimeToNSDate (DateTime.Today.AddDays (1));

			//Zet selectie standaard op 7 dagen na vandaag
			actionSheetDatePicker.Picker.SetDate (NSDateHelper.DateTimeToNSDate (DateTime.Today.AddDays (7)), true);

			actionSheetDatePicker.Picker.ValueChanged += (sender, e) => {

				var nsDate = (sender as UIDatePicker).Date;

				DateTime selectedDate = NSDateHelper.NSDateToDateTime (nsDate);
				selectedExpirationDate = selectedDate.AddDays (1);

				Console.WriteLine (selectedExpirationDate.ToString ());
			};

			actionSheetDatePicker.DoneButton.Clicked += (object sender, EventArgs e) => {

				//Dismiss actionsheet
				actionSheetDatePicker.Hide (true);

				//Show progress dialog
				DialogHelper.ShowProgressDialog ("Delen", "Publieke url aan het ophalen", async () => {
					try {
						PublicUrl publicUrl = await DataLayer.Instance.CreatePublicFileShare (forLocation, selectedExpirationDate.Date);

						MFMailComposeViewController mvc = new MFMailComposeViewController ();
						mvc.SetSubject ("Publieke URL naar gedeeld Pleiobox bestand");

						string bodyText = "Mijn gedeelde bestand: \n" +
						                   publicUrl.publicUri + "\n \n" +
						                   "Deze link is geldig tot: " + selectedExpirationDate.ToString ("dd-MM-yyyy");

						mvc.SetMessageBody (bodyText, false);
						mvc.Finished += (object s, MFComposeResultEventArgs args) => {
							args.Controller.DismissViewController (true, null);
						};
						_nodeViewController.PresentViewController (mvc, true, null);

						DialogHelper.HideProgressDialog ();

					}  catch (Exception ex){
						Insights.Report(ex);
						DialogHelper.HideProgressDialog ();
						DialogHelper.ShowErrorDialog ("Fout", "Er is een fout opgetreden bij het delen van het bestand." +
						"\nVervers a.u.b. de map en probeer het opnieuw.");
					}
				});
			};

			actionSheetDatePicker.Show ();
		}