コード例 #1
0
        public static UIActionSheet GetActionSheet(PictureMomentViewController controller, UINavigationController nav, Boolean video)
        {
            controller.VideoMode = video;
            controller.NavigationBar.TintColor = nav.NavigationBar.TintColor;
            var sheet = new UIActionSheet("Choose Source");

            sheet.AddButton("Camera");
            sheet.AddButton("Library");
            sheet.AddButton("Cancel");
            sheet.DestructiveButtonIndex = 2;
            sheet.Clicked += (send, evt) => {
                if (evt.ButtonIndex == 0)
                {
                    controller.SourceType = UIImagePickerControllerSourceType.Camera;
                    controller.MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.Camera);
                    if (video)
                    {
                        controller.CameraCaptureMode = UIImagePickerControllerCameraCaptureMode.Video;
                    }
                    else
                    {
                        controller.CameraCaptureMode = UIImagePickerControllerCameraCaptureMode.Photo;
                    }
                    nav.PresentViewController(controller, true, null);
                }
                else if (evt.ButtonIndex == 1)
                {
                    controller.MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.SavedPhotosAlbum);
                    controller.SourceType = UIImagePickerControllerSourceType.SavedPhotosAlbum;
                    nav.PresentViewController(controller, true, null);
                }
            };
            return(sheet);
        }
コード例 #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();


            this.TakePictureButton.TouchDown += (sender, e) => {
                var sheet = PictureMomentViewController.GetActionSheet(pictureMomentController, this.NavigationController, false);
                sheet.ShowFromTabBar(this.TabBarController.TabBar);
            };

            this.TakeVideoButton.TouchDown += (sender, e) => {
                var sheet = PictureMomentViewController.GetActionSheet(pictureMomentController, this.NavigationController, true);
                sheet.ShowFromTabBar(this.TabBarController.TabBar);
            };

            this.pictureMomentController.Finished += (moment) => {
                AppDelegate.MomentsManager.PublishMoment(moment);
                UIAlertView alert = new UIAlertView("Add Content", "Do you want to edit your moment now?", null, "Yes", "No");
                alert.Clicked += (s, evt) => {
                    if (evt.ButtonIndex == 0)
                    {
                        var edit = new EditDialog();
                        edit.Config(moment);
                        this.NavigationController.PushViewController(edit, true);
                    }
                };
                alert.Show();
            };



            this.TakeEmojiButton.Layer.CornerRadius   = 3f;
            this.TakePictureButton.Layer.CornerRadius = 3f;
            this.TakeVideoButton.Layer.CornerRadius   = 3f;
            //this.TabBarItem = new UITabBarItem ("New Moment", UIImage.FromFile ("images/plus.png"), 0);


            this.CaptureButton.TouchDown += (sender, e) => {
                Moment moment = new Moment();
                moment.Title   = "New Moment";
                moment.Comment = "No Content";
                AppDelegate.MomentsManager.PublishMoment(moment);
                UIAlertView alert = new UIAlertView("Add Content", "Do you want to edit your moment now?", null, "Yes", "No");
                alert.Clicked += (s, evt) => {
                    if (evt.ButtonIndex == 0)
                    {
                        var edit = new EditDialog();
                        edit.Config(moment);
                        this.NavigationController.PushViewController(edit, true);
                    }
                };
                alert.Show();
            };
        }
コード例 #3
0
        public void Config(Moment moment)
        {
            if (this.moment != null)
            {
                this.moment.SyncedChanged -= syncedChanged;
            }
            this.moment = moment;
            this.moment.SyncedChanged += syncedChanged;

            BooleanElement boolElement = new BooleanElement("Mark as Finished", this.moment.State == MomentState.Finished);

            boolElement.ValueChanged += (sender, e) => {
                if (boolElement.Value)
                {
                    this.moment.State = MomentState.Finished;
                }
                else
                {
                    this.moment.State = MomentState.InProgress;
                }
            };

            this.titleElement.Value   = moment.Title;
            this.commentElement.Value = moment.Comment;
            Root = new RootElement("Edit")
            {
                new Section("")
                {
                    new BasicViewElement(this.mapView, 120),
                    this.titleElement,
                    this.commentElement,
                    new StringElement("Erstellt:", moment.Date.ToString("H:mm:ss dd.MM.yy"))
                },

                new Section("Images")
                {
                    new BasicViewElement(imagesCollectionView, 120),
                    new StringElement("New Image", delegate {
                        var imagePicker = new PictureMomentViewController();
                        imagePicker.Config(moment);
                        var sheet = PictureMomentViewController.GetActionSheet(imagePicker, this.NavigationController, false);
                        sheet.ShowInView(this.TableView);
                        imagePicker.Finished += async(Moment obj) => {
                            Reload();
                            await Task.Delay(3000);
                            AppDelegate.MomentsManager.SaveMoments();
                            await AppDelegate.MomentsManager.SyncMoment(this.moment);
                        };
                    })
                },
                new Section("Videos")
                {
                    new BasicViewElement(videosCollectionView, 120),
                    new StringElement("New Video", delegate {
                        var imagePicker = new PictureMomentViewController();
                        imagePicker.Config(moment);
                        var sheet = PictureMomentViewController.GetActionSheet(imagePicker, this.NavigationController, true);
                        sheet.ShowInView(this.TableView);
                        imagePicker.Finished += (Moment obj) => {
                            Reload();
                            AppDelegate.MomentsManager.SaveMoments();
                            AppDelegate.MomentsManager.SyncMoment(this.moment);
                        };
                    })
                },
                new Section("Emojis")
                {
                    new BasicViewElement(emojiCollectionView, 120)
                },
            };
            Reload();
        }
コード例 #4
0
 public NewMomentViewController(IntPtr handle) : base(handle)
 {
     this.Title = "New Moment";
     this.pictureMomentController = new PictureMomentViewController();
 }