コード例 #1
0
        private void HidenShow(ArticleMaster_Class st)
        {
            var cfg = new ActionSheetConfig()
                      .SetTitle("Sub Category")
                      .SetMessage(null)
                      .SetUseBottomSheet(false);

            foreach (var item in st.FranchiseStokeMaster_Class_List)
            {
                cfg.Add(
                    "Item : " + item.SubCategoryMaster_Class_Data.SubCategory_Name + "     Qty : " + item.Quantity

                    );
            }
            //cfg.SetDestructive();
            //if (true)
            cfg.SetCancel();

            var disp = UserDialogs.Instance.ActionSheet(cfg);

            if (this.AutoCancel)
            {
                Task.Delay(TimeSpan.FromSeconds(3))
                .ContinueWith(x => disp.Dispose());
            }
        }
コード例 #2
0
        private void ActionSheet()
        {
            var asc = new ActionSheetConfig()
                      .SetTitle("ActionSheet")
                      .SetMessage("アクションシート")
                      .SetUseBottomSheet(false);

            asc.Add("001", () => ShowActionSheetResult("イワン・ウイスキー"));
            asc.Add("002", () => ShowActionSheetResult("ジェット・リンク"));
            asc.Add("003", () => ShowActionSheetResult("フランソワーズ・アルヌール"));
            asc.Add("004", () => ShowActionSheetResult("アルベルト・ハインリヒ"));
            asc.Add("005", () => ShowActionSheetResult("ジェロニモ・ジュニア"));
            asc.Add("006", () => ShowActionSheetResult("張々湖"));
            asc.Add("007", () => ShowActionSheetResult("グレート・ブリテン"));
            asc.Add("008", () => ShowActionSheetResult("ピュンマ"));
            asc.Add("009", () => ShowActionSheetResult("島村ジョー"));

            // removeボタン
            asc.SetDestructive("削除", () => ShowActionSheetResult("削除"));

            // cancelボタン
            asc.SetCancel("キャンセル", () => ShowActionSheetResult("キャンセル"));

            // PopoverPresentationControllerの指定はできないっぽい
            // 吹き出しは画面下部中央からでてる

            _dialogs.ActionSheet(asc);
        }
コード例 #3
0
        public VwCambiarPais()
        {
            InitializeComponent();

            cvm = new CatalogosViewModel();

            catPais paisdef = cvm.lsPais().Where(x => x.paisdefault).FirstOrDefault();

            if (paisdef != null)
            {
                btnPais.Text   = paisdef.pais;
                btnPais.Source = paisdef.img;
                idpais         = paisdef.idpais;
            }
            btnPais.Clicked += (sender, ea) =>
            {
                var cfg = new ActionSheetConfig().SetTitle("Seleccione pais");
                foreach (catPais p in cvm.lsPais())
                {
                    cfg.Add(p.pais, () => Cambia(p.idpais));
                }
                cfg.SetCancel();
                UserDialogs.Instance.ActionSheet(cfg);
            };
        }
コード例 #4
0
        protected void OnAddPublisherClicked(object sender)
        {
            Catalogue catalogue = Catalogue.GetCatalogue();
            var       config    = new ActionSheetConfig();

            config.SetTitle(Localization.AddPublisher);
            config.SetDestructive(Localization.NewPublisher, async() =>
            {
                OnRemovePublisherClicked(null);
                await Navigation.PushModalAsync(new AddPublisherPage(Book, true));
            });
            config.SetCancel(Localization.Cancel);
            foreach (var publisher in catalogue.PublishersList)
            {
                if (Book.Publisher != publisher)
                {
                    config.Add(publisher.Name, () =>
                    {
                        OnRemovePublisherClicked(null);
                        publisher.AddBook(Book);
                        Book.Publisher = publisher;
                    });
                }
            }
            UserDialogs.Instance.ActionSheet(config);
        }
コード例 #5
0
        ICommand CreateActionSheetCommand(bool useBottomSheet, bool cancel, int items, string message = null)
        {
            return(new Command(() =>
            {
                var cfg = new ActionSheetConfig()
                          .SetTitle("Test Title")
                          .SetMessage(message)
                          .SetUseBottomSheet(useBottomSheet);

                for (var i = 0; i < items; i++)
                {
                    var display = i + 1;
                    cfg.Add(
                        "Option " + display,
                        () => this.Result($"Option {display} Selected"),
                        "icon.png"
                        );
                }
                cfg.SetDestructive(null, () => this.Result("Destructive BOOM Selected"), "icon.png");
                if (cancel)
                {
                    cfg.SetCancel(null, () => this.Result("Cancel Selected"), "icon.png");
                }

                var disp = this.Dialogs.ActionSheet(cfg);
                if (this.AutoCancel)
                {
                    Task.Delay(TimeSpan.FromSeconds(3))
                    .ContinueWith(x => disp.Dispose());
                }
            }));
        }
コード例 #6
0
        private void ExecuteOptions()
        {
            var actionConfig = new ActionSheetConfig();

            actionConfig.Add("Contact Donor", ExecuteOpenDialer);
            actionConfig.Add("View in Maps", async() => await ExecuteOpenMaps());
            actionConfig.SetCancel();

            UserDialogs.Instance.ActionSheet(actionConfig);
        }
コード例 #7
0
        private void DisplayEmployeeSkillActionSheet(Skill skill)
        {
            var cfg = new ActionSheetConfig()
                      .SetTitle("Select Action");

            cfg.Add("Remove Skill", async() => await RemoveSkillFromEmployee(skill));

            cfg.SetCancel("Cancel");

            _userDialogs.ActionSheet(cfg);
        }
コード例 #8
0
        // for upload profile image in profile page

        public void SelectPhoto()
        {
            UserDialogs.Instance.ShowLoading();
            var config = new ActionSheetConfig();

            config.Add("Take Photo", async() => { await TakePhoto(); });
            config.Add("Choose from library", async() => { await galleryFunc(); });
            config.SetCancel("Cancel");
            Acr.UserDialogs.UserDialogs.Instance.ActionSheet(config);
            UserDialogs.Instance.HideLoading();
        }
コード例 #9
0
        /// <summary>
        /// Show alert sheet.
        /// </summary>
        /// <param name="title">Dialog title.</param>
        /// <param name="buttons">Dialog buttons (id and name).</param>
        /// <param name="command">Command to execute on button click.</param>
        /// <returns>Chosen button name.</returns>
        public void ShowSheet(string title, Dictionary <int, string> buttonList, ICommand command)
        {
            var config = new ActionSheetConfig().SetTitle(title);

            foreach (var button in buttonList)
            {
                config.Add(button.Value, () => command.Execute(button.Key));
            }

            config.SetCancel(_baseCancel, () => command.Execute(-1));
            UserDialogs.Instance.ActionSheet(config);
        }
コード例 #10
0
        private void DisplayEmployeeActionSheet(Employee employee)
        {
            var cfg = new ActionSheetConfig()
                      .SetTitle("Select Action");

            cfg.Add("Edit", async() => await NavigateToEditEmployeePage(employee));
            cfg.Add("Delete", async() => await DeleteEmployee(employee));
            cfg.Add("Manage Skills", async() => await NavigateToEmployeeSkillsPage(employee.ID));

            cfg.SetCancel("Cancel");

            _userDialogs.ActionSheet(cfg);
        }
コード例 #11
0
        public void btnImageCalled(object sender, EventArgs e)
        {
            ActionSheetConfig sa = new ActionSheetConfig();

            sa.Title = "Choose Image";

            sa.Add("Camera", delegate { ChooseImageCamera(); });

            sa.Add("Gallery", delegate { ChooseImageGallery(); });

            sa.SetCancel();
            UserDialogs.Instance.ActionSheet(sa);
        }
コード例 #12
0
        void ExecuteOptionsCommand()
        {
            var actionConfig = new ActionSheetConfig();

            actionConfig.Add("Contact Donor", ExecuteOpenDialer);
            actionConfig.Add("View in Maps", async() => await ExecuteOpenMaps());
            if (Item.Status != DonationStatus.Completed)
            {
                actionConfig.Add("Cancel Pickup", (async() => await ExecuteCancelCommand()));
            }
            actionConfig.SetCancel("Close");

            UserDialogs.Instance.ActionSheet(actionConfig);
        }
コード例 #13
0
        private async void  ImageTap(object obj)
        {
            ActionSheetConfig config = new ActionSheetConfig();

            config.SetUseBottomSheet(true);
            var galeryIcon = await BitmapLoader.Current.LoadFromResource("ic_collections.png", 500f, 500f);

            var photoIcon = await BitmapLoader.Current.LoadFromResource("ic_camera_alt.png", 500f, 500f);

            config.Add("Take Picture From Galery", SetPictureFromGalery, galeryIcon);
            config.Add("Take Picture From Camera", SetFromCamera, photoIcon);
            config.SetCancel(null, null, null);
            _userDialogs.ActionSheet(config);
        }
コード例 #14
0
        protected void OnRemoveBookClicked(object sender)
        {
            var config = new ActionSheetConfig();

            config.SetTitle(Localization.BookToRemove);
            config.SetCancel(Localization.Cancel);
            foreach (var book in Publisher)
            {
                config.Add(book.Title, () =>
                {
                    Catalogue.GetCatalogue().RemoveBook(book);
                });
            }
            UserDialogs.Instance.ActionSheet(config);
        }
コード例 #15
0
ファイル: MainActivity.cs プロジェクト: xylocane/userdialogs
        private void ActionSheet()
        {
            var cfg = new ActionSheetConfig()
                      .SetTitle("Test Title");

            for (var i = 0; i < 5; i++)
            {
                var display = (i + 1);
                cfg.Add(
                    "Option " + display,
                    () => this.lblResult.Text = String.Format("Option {0} Selected", display)
                    );
            }
            cfg.SetDestructive("BOOM", () => this.lblResult.Text = "Destructive BOOM Selected");
            cfg.SetCancel("Cancel", () => this.lblResult.Text    = "Cancel Selected");

            UserDialogs.Instance.ActionSheet(cfg);
        }
コード例 #16
0
ファイル: MainPage.cs プロジェクト: se7ensoft/userdialogs
        void ActionSheet()
        {
            var cfg = new ActionSheetConfig()
                      .SetTitle("Test Title");

            for (var i = 0; i < 5; i++)
            {
                var display = (i + 1);
                cfg.Add(
                    "Option " + display,
                    () => this.lblResult.Text = $"Option {display} Selected"
                    );
            }
            cfg.SetDestructive(action: () => this.lblResult.Text = "Destructive BOOM Selected");
            cfg.SetCancel(action: () => this.lblResult.Text      = "Cancel Selected");

            UserDialogs.Instance.ActionSheet(cfg);
        }
コード例 #17
0
        private void MenuOptionListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            IsPresented = false;//slide the menu away
            var selectedItem = e.SelectedItem as UserMenuItemModel;

            if (selectedItem != null)
            {
                if (selectedItem.PageType == typeof(LoginPage))
                {
                    ActionSheetConfig sa = new ActionSheetConfig();
                    sa.Title = "Are you sure uou want to logout?";

                    sa.Add("Yes", delegate {
                        App.setting_Model.userModel = null;
                        var sUser = JsonConvert.SerializeObject(App.setting_Model);
                        Settings.GeneralSettings = sUser;
                        App.Current.MainPage     = new NavigationPage(new LoginPage())
                        {
                            BarBackgroundColor = Color.FromHex("2DCA71"),
                            BarTextColor       = Color.White
                        };
                        //App.baseUser = null;
                    });

                    sa.Add("No", delegate { sa.SetCancel(); });

                    UserDialogs.Instance.ActionSheet(sa);


                    slideOutMenu.MenuOptionListView.SelectedItem = null;
                }
                else
                {
                    //find which item was selected
                    //Pagetype property of modal helps t o load the appropriate page
                    //Page activator creates an instance from the type at runtime
                    Detail = new NavigationPage((Page)Activator.CreateInstance(selectedItem.PageType))
                    {
                        BarBackgroundColor = Color.FromHex("2DCA71"), BarTextColor = Color.White
                    };
                    slideOutMenu.MenuOptionListView.SelectedItem = null;
                }
            }
        }
コード例 #18
0
        public IDisposable ShowActionSheet(
            string title,
            string cancel,
            string destructive,
            List <ActionSheetButtonModel> actionSheetButtons)
        {
            var config = new ActionSheetConfig();

            config.SetTitle(title);
            config.SetCancel(cancel);
            config.Destructive = string.IsNullOrEmpty(destructive) ? null : new ActionSheetOption(destructive);

            foreach (var button in actionSheetButtons)
            {
                config.Add(button.Text, button.Action, button.IconName);
            }

            return(_dialogs.ActionSheet(config));
        }
コード例 #19
0
        ICommand CreateActionSheetCommand(bool useBottomSheet, bool cancel, int items, string message = null)
        {
            return(new Command(() =>
            {
                var cfg = new ActionSheetConfig()
                          .SetTitle("Test Title")
                          .SetMessage(message)
                          .SetUseBottomSheet(useBottomSheet);

                IBitmap testImage = null;
                try
                {
                    testImage = BitmapLoader.Current.LoadFromResource("icon.png", null, null).Result;
                }
                catch
                {
                    Debug.WriteLine("Could not load image");
                }

                for (var i = 0; i < items; i++)
                {
                    var display = i + 1;
                    cfg.Add(
                        "Option " + display,
                        () => this.Result($"Option {display} Selected"),
                        testImage
                        );
                }
                cfg.SetDestructive(null, () => this.Result("Destructive BOOM Selected"), testImage);
                if (cancel)
                {
                    cfg.SetCancel(null, () => this.Result("Cancel Selected"), testImage);
                }

                var disp = this.Dialogs.ActionSheet(cfg);
                if (this.AutoCancel)
                {
                    Task.Delay(TimeSpan.FromSeconds(3))
                    .ContinueWith(x => disp.Dispose());
                }
            }));
        }
コード例 #20
0
        protected void OnRemoveAuthorClicked(object sender)
        {
            var config = new ActionSheetConfig();

            config.SetTitle(Localization.AuthorToRemove);
            config.SetCancel(Localization.Cancel);
            foreach (var author in Book)
            {
                config.Add(author.FullName, () =>
                {
                    Book.RemoveAuthor(author);
                    author.RemoveBook(Book);
                    if (author.IsEmpty())
                    {
                        Catalogue.GetCatalogue().RemoveAuthor(author);
                    }
                });
            }
            UserDialogs.Instance.ActionSheet(config);
        }
コード例 #21
0
        void ActionSheet()
        {
            var cfg = new ActionSheetConfig()
                      .SetTitle("Test Title");

            var testImage = BitmapLoader.Current.LoadFromResource("icon.png", null, null).Result;

            for (var i = 0; i < 5; i++)
            {
                var display = (i + 1);
                cfg.Add(
                    "Option " + display,
                    () => this.Result($"Option {display} Selected"),
                    testImage
                    );
            }
            cfg.SetDestructive(action: () => this.Result("Destructive BOOM Selected"));
            cfg.SetCancel(action: () => this.Result("Cancel Selected"));

            UserDialogs.Instance.ActionSheet(cfg);
        }
コード例 #22
0
        protected void OnAddAuthorClicked(object sender)
        {
            Catalogue catalogue = Catalogue.GetCatalogue();
            var       config    = new ActionSheetConfig();

            config.SetTitle(Localization.AddAuthor);
            config.SetDestructive(Localization.NewAuthor, async() => { await Navigation.PushModalAsync(new AddAuthorPage(Book, true)); });
            config.SetCancel(Localization.Cancel);
            foreach (var author in catalogue.AuthorsList)
            {
                if (!Book.ContainsAuthor(author))
                {
                    config.Add(author.FullName, () =>
                    {
                        author.AddBook(Book);
                        Book.AddAuthor(author);
                    });
                }
            }
            UserDialogs.Instance.ActionSheet(config);
        }
コード例 #23
0
ファイル: PopupPage.xaml.cs プロジェクト: jazminewrooman/MT
        void OpenButtonClicked(object sender, EventArgs e)
        {
            var cfg = new ActionSheetConfig().SetTitle("Test Title");

            var testImage = BitmapLoader.Current.LoadFromResource("icon.png", null, null).Result;

            for (var i = 0; i < 5; i++)
            {
                var display = (i + 1);
                cfg.Add("Option " + display, () => this.Result($"Option {display} Selected"), testImage);
            }
            cfg.SetDestructive(action: () => this.Result("Destructive BOOM Selected"));
            cfg.SetCancel(action: () => this.Result("Cancel Selected"));

            var disp = UserDialogs.Instance.ActionSheet(cfg);
            //if (this.AutoCancel)
            //{
            //    Task.Delay(TimeSpan.FromSeconds(3))
            //        .ContinueWith(x => disp.Dispose());
            //}
        }
コード例 #24
0
        protected void OnAddBookClicked(object sender)
        {
            Catalogue catalogue = Catalogue.GetCatalogue();
            var       config    = new ActionSheetConfig();

            config.SetTitle(Localization.AddBook);
            config.SetDestructive(Localization.NewBook, async() => { await App.Current.MainPage.Navigation.PushModalAsync(new AddBookPage(Publisher, true)); });
            config.SetCancel(Localization.Cancel);
            foreach (var book in catalogue.BooksList)
            {
                if (book.Publisher == null && !Publisher.ContainsBook(book))
                {
                    config.Add(book.Title, () =>
                    {
                        book.Publisher = Publisher;
                        Publisher.AddBook(book);
                    });
                }
            }
            UserDialogs.Instance.ActionSheet(config);
        }
コード例 #25
0
        async void ActionSheetAction()
        {
            var config = new ActionSheetConfig();

            config.SetCancel("Cancel");

            var searchIcon = await Splat.BitmapLoader.Current.LoadFromResource("ic_search_brown.png", null, null);

            var bookmarkIcon = await Splat.BitmapLoader.Current.LoadFromResource("ic_bookmark_brown.png", null, null);

            var biggerFontIcon = await Splat.BitmapLoader.Current.LoadFromResource("ic_font_bigger.png", null, null);

            var lowerFontIcon = await Splat.BitmapLoader.Current.LoadFromResource("ic_font_lower.png", null, null);

            config.Options.Add(new ActionSheetOption("Search in Text", () => { }, searchIcon));
            config.Options.Add(new ActionSheetOption("Add to Bookmarks", () => { }, bookmarkIcon));
            config.Options.Add(new ActionSheetOption("Make Font Bigger", () => { }, biggerFontIcon));
            config.Options.Add(new ActionSheetOption("Make Font Smaller", () => { }, lowerFontIcon));

            var dialog = DependencyService.Get <ICustomUserDialog>();

            dialog.ActionSheet(config);
        }
コード例 #26
0
        public void Select()
        {
            var cfg = new ActionSheetConfig()
                      .SetTitle($"{this.Description} - {this.Uuid}")
                      .SetCancel();

            if (this.Characteristic.CanWriteWithResponse())
            {
                cfg.Add("Write With Response", () => this.DoWrite(true));
            }

            if (this.Characteristic.CanWriteWithoutResponse())
            {
                cfg.Add("Write Without Response", () => this.DoWrite(false));
            }

            if (this.Characteristic.CanWrite())
            {
                cfg.Add("Send Test BLOB", this.SendBlob);
            }

            if (this.Characteristic.CanRead())
            {
                cfg.Add("Read", this.DoRead);
            }

            if (this.Characteristic.CanNotify())
            {
                var txt = this.Characteristic.IsNotifying ? "Stop Notifying" : "Notify";
                cfg.Add(txt, this.ToggleNotify);
            }
            if (cfg.Options.Any())
            {
                this.dialogs.ActionSheet(cfg.SetCancel());
            }
        }
コード例 #27
0
        private async void OpenAddSkillActionSheet()
        {
            var cfg = new ActionSheetConfig()
                      .SetTitle("Select Action");

            try
            {
                _skillCache = await _skillsService.GetAllSkillsAsync();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                await _userDialogs.AlertAsync(ex.Message, "Error");
            }

            foreach (var skill in _skillCache)
            {
                cfg.Add(skill.Name, async() => await AddSkillToEmployee(skill.ID));
            }

            cfg.SetCancel("Cancel");

            _userDialogs.ActionSheet(cfg);
        }
コード例 #28
0
        public ProducersPageViewModel()
        {
            ResourceManager manager = new ResourceManager("BetterThanIMDB.Resources.locale", typeof(FilmsPageViewModel).GetTypeInfo().Assembly);

            ExpandItemCommand = new Command(() =>
            {
                if (_prevSelectedProducer == SelectedProducer)
                {
                    SelectedProducer.IsVisible = !SelectedProducer.IsVisible;
                }
                else
                {
                    if (_prevSelectedProducer != null)
                    {
                        _prevSelectedProducer.IsVisible = false;
                    }
                    SelectedProducer.IsVisible = true;
                }

                _prevSelectedProducer = SelectedProducer;
            });
            DeleteItemCommand = new Command(() =>
            {
                UserDialogs.Instance.Confirm(new ConfirmConfig()
                {
                    Message  = manager.GetString("confirm", CustomSettings.Settings.Instance.Culture),
                    OnAction = (confirmed) =>
                    {
                        if (confirmed)
                        {
                            ProducerCollection.Instance.DeleteProducer(SelectedProducer);
                            SelectedProducer = null;
                        }
                    }
                });
            });
            ShowFilmsCommand = new Command(() =>
            {
                ActionSheetConfig config = new ActionSheetConfig();
                foreach (var film in SelectedProducer.Films)
                {
                    config.Add(film.Title, async() => await App.NavigationService.NavigateAsync("EditFilmPage", film));
                }
                config.SetCancel();
                config.Title = manager.GetString("filmsList", CustomSettings.Settings.Instance.Culture);
                UserDialogs.Instance.ActionSheet(config);
            });
            ShowInfoAboutProducerCommand = new Command(async() =>
                                                       await App.NavigationService.NavigateAsync("EditProducerPage", SelectedProducer));

            AddProducerCommand = new Command(() =>
            {
                ActionSheetConfig config = new ActionSheetConfig();
                config.Add(manager.GetString("createProducer", CustomSettings.Settings.Instance.Culture), () => CreateNewProducer());
                config.Add(manager.GetString("getProducer", CustomSettings.Settings.Instance.Culture), async() => await App.NavigationService.NavigateAsync("TMDBPersonPage", "Producer"));
                config.SetCancel();
                UserDialogs.Instance.ActionSheet(config);
            });
            SearchProducerCommand = new Command(async() => await App.NavigationService.NavigateAsync("SearchProducersPage", this));

            UnapplyCommand    = new Command(() => Producers = ProducerCollection.Instance.Producers);
            SortByNameCommand = new Command(() =>
            {
                if (_sortedByName)
                {
                    Producers = new CustomObservableCollection <Producer>(Producers.OrderByDescending(p => p.Name));
                }
                else
                {
                    Producers = new CustomObservableCollection <Producer>(Producers.OrderBy(p => p.Name));
                }
                _sortedByName = !_sortedByName;
            });
            SortByDateCommand = new Command(() =>
            {
                if (_sortedByDate)
                {
                    Producers = new CustomObservableCollection <Producer>(Producers.OrderByDescending(p => DateTime.Parse(p.DateOfBirth)));
                }
                else
                {
                    Producers = new CustomObservableCollection <Producer>(Producers.OrderBy(p => DateTime.Parse(p.DateOfBirth)));
                }
                _sortedByDate = !_sortedByDate;
            });
            SortByCountCommand = new Command(() =>
            {
                if (_sortedByCount)
                {
                    Producers = new CustomObservableCollection <Producer>(Producers.OrderByDescending(p => p.Films.Count));
                }
                else
                {
                    Producers = new CustomObservableCollection <Producer>(Producers.OrderBy(p => p.Films.Count));
                }
                _sortedByCount = !_sortedByCount;
            });
        }
コード例 #29
0
        public StandardViewModel(IUserDialogs dialogs) : base(dialogs)
        {
            this.Alert         = this.Create(async token => await this.Dialogs.AlertAsync("Test alert", "Alert Title", null, token));
            this.AlertLongText = this.Create(async token =>
                                             await this.Dialogs.AlertAsync(
                                                 "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc consequat diam nec eros ornare, vitae cursus nunc molestie. Praesent eget lacus non neque cursus posuere. Nunc venenatis quam sed justo bibendum, ut convallis arcu lobortis. Vestibulum in diam nisl. Nulla pulvinar lacus vel laoreet auctor. Morbi mi urna, viverra et accumsan in, pretium vel lorem. Proin elementum viverra commodo. Sed nunc justo, sollicitudin eu fermentum vitae, faucibus a est. Nulla ante turpis, iaculis et magna sed, facilisis blandit dolor. Morbi est felis, semper non turpis non, tincidunt consectetur enim.",
                                                 cancelToken: token
                                                 )
                                             );

            this.ActionSheet = new Command(() =>
            {
                var cfg = new ActionSheetConfig()
                          .SetTitle("Test Title");

                //var testImage = BitmapLoader.Current.LoadFromResource("icon.png", null, null).Result;

                for (var i = 0; i < 5; i++)
                {
                    var display = (i + 1);
                    cfg.Add(
                        "Option " + display,
                        () => this.Result($"Option {display} Selected")
                        //testImage
                        );
                }
                cfg.SetDestructive(action: () => this.Result("Destructive BOOM Selected"));
                cfg.SetCancel(action: () => this.Result("Cancel Selected"));

                var disp = this.Dialogs.ActionSheet(cfg);
                if (this.AutoCancel)
                {
                    Task.Delay(TimeSpan.FromSeconds(3))
                    .ContinueWith(x => disp.Dispose());
                }
            });

            this.ActionSheetAsync = this.Create(async token =>
            {
                var result = await this.Dialogs.ActionSheetAsync("Test Title", "Cancel", "Destroy", token, "Button1", "Button2", "Button3");
                this.Result(result);
            });

            this.Confirm = this.Create(async token =>
            {
                var r    = await this.Dialogs.ConfirmAsync("Pick a choice", "Pick Title", cancelToken: token);
                var text = r ? "Yes" : "No";
                this.Result($"Confirmation Choice: {text}");
            });

            this.Login = this.Create(async token =>
            {
                var r = await this.Dialogs.LoginAsync(new LoginConfig
                {
                    Message = "DANGER"
                }, token);
                var status = r.Ok ? "Success" : "Cancelled";
                this.Result($"Login {status} - User Name: {r.LoginText} - Password: {r.Password}");
            });

            this.Prompt = new Command(() => this.Dialogs.ActionSheet(new ActionSheetConfig()
                                                                     .SetTitle("Choose Type")
                                                                     .Add("Default", () => this.PromptCommand(InputType.Default))
                                                                     .Add("E-Mail", () => this.PromptCommand(InputType.Email))
                                                                     .Add("Name", () => this.PromptCommand(InputType.Name))
                                                                     .Add("Number", () => this.PromptCommand(InputType.Number))
                                                                     .Add("Number with Decimal", () => this.PromptCommand(InputType.DecimalNumber))
                                                                     .Add("Password", () => this.PromptCommand(InputType.Password))
                                                                     .Add("Numeric Password (PIN)", () => this.PromptCommand(InputType.NumericPassword))
                                                                     .Add("Phone", () => this.PromptCommand(InputType.Phone))
                                                                     .Add("Url", () => this.PromptCommand(InputType.Url))
                                                                     .SetCancel()
                                                                     ));
            this.PromptNoTextOrCancel = this.Create(async token =>
            {
                var result = await this.Dialogs.PromptAsync(new PromptConfig
                {
                    Title         = "PromptWithTextAndNoCancel",
                    Text          = "Existing Text",
                    IsCancellable = false
                }, token);
                this.Result($"Result - {result.Text}");
            });

            this.Date = this.Create(async token =>
            {
                var result = await this.Dialogs.DatePromptAsync(new DatePromptConfig
                {
                    IsCancellable = true,
                    MinimumDate   = DateTime.Now.AddDays(-3),
                    MaximumDate   = DateTime.Now.AddDays(1)
                }, token);
                this.Result($"Date Prompt: {result.Ok} - Value: {result.SelectedDate}");
            });
            this.Time = this.Create(async token =>
            {
                var result = await this.Dialogs.TimePromptAsync(new TimePromptConfig
                {
                    IsCancellable = true
                }, token);
                this.Result($"Time Prompt: {result.Ok} - Value: {result.SelectedTime}");
            });
        }
コード例 #30
0
        //todo implement showinfoaboutactor/producer

        public FilmsPageViewModel()
        {
            ResourceManager manager = new ResourceManager("BetterThanIMDB.Resources.locale", typeof(FilmsPageViewModel).GetTypeInfo().Assembly);

            ExpandItemCommand = new Command(() =>
            {
                if (_prevSelectedFilm == SelectedFilm)
                {
                    SelectedFilm.IsVisible = !SelectedFilm.IsVisible;
                }
                else
                {
                    if (_prevSelectedFilm != null)
                    {
                        _prevSelectedFilm.IsVisible = false;
                    }
                    SelectedFilm.IsVisible = true;
                }

                _prevSelectedFilm = SelectedFilm;
            });

            DeleteItemCommand = new Command(() =>
            {
                UserDialogs.Instance.Confirm(new ConfirmConfig()
                {
                    Message  = manager.GetString("confirm", CustomSettings.Settings.Instance.Culture),
                    OnAction = (confirmed) =>
                    {
                        if (confirmed)
                        {
                            FilmCollection.Instance.DeleteFilm(SelectedFilm);
                            SelectedFilm = null;
                        }
                    }
                });
            });

            ShowActorsCommand = new Command(() =>
            {
                ActionSheetConfig config = new ActionSheetConfig();
                foreach (var actor in SelectedFilm.Actors)
                {
                    config.Add(actor.Name, async() => await App.NavigationService.NavigateAsync("EditActorPage", actor));
                }
                config.SetCancel();
                config.Title = manager.GetString("actorsList", CustomSettings.Settings.Instance.Culture);
                UserDialogs.Instance.ActionSheet(config);
            });

            ShowProducersCommand = new Command(() =>
            {
                ActionSheetConfig config = new ActionSheetConfig();
                foreach (var producer in SelectedFilm.Producers)
                {
                    config.Add(producer.Name, async() => await App.NavigationService.NavigateAsync("EditProducerPage", producer));
                }
                config.SetCancel();
                config.Title = manager.GetString("producersList", CustomSettings.Settings.Instance.Culture);
                UserDialogs.Instance.ActionSheet(config);
            });

            ShowGenresCommand = new Command(() =>
            {
                ActionSheetConfig config = new ActionSheetConfig();
                foreach (var genre in SelectedFilm.GenresList)
                {
                    config.Add(genre.ToString());
                }
                config.SetCancel();
                config.Title = manager.GetString("genresList", CustomSettings.Settings.Instance.Culture);
                UserDialogs.Instance.ActionSheet(config);
            });

            ShowInfoAboutFilmCommand = new Command(async() =>
                                                   await App.NavigationService.NavigateAsync("EditFilmPage", SelectedFilm));

            AddFilmCommand = new Command(() =>
            {
                ActionSheetConfig config = new ActionSheetConfig();
                config.Add(manager.GetString("createFilm", CustomSettings.Settings.Instance.Culture), () => CreateNewMovie());
                config.Add(manager.GetString("getFilm", CustomSettings.Settings.Instance.Culture), async() => await App.NavigationService.NavigateAsync("TMDBFilmsPage"));
                config.SetCancel();
                UserDialogs.Instance.ActionSheet(config);
            });

            SearchFilmCommand = new Command(async() => await App.NavigationService.NavigateAsync("SearchFilmsPage", this));

            UnapplyCommand = new Command(() => Films = FilmCollection.Instance.Films);

            SortByTitleCommand = new Command(() =>
            {
                if (_sortedByTitle)
                {
                    Films = new CustomObservableCollection <Film>(Films.OrderByDescending(f => f.Title));
                }
                else
                {
                    Films = new CustomObservableCollection <Film>(Films.OrderBy(f => f.Title));
                }
                _sortedByTitle = !_sortedByTitle;
            });
            SortByDateCommand = new Command(() =>
            {
                if (_sortedByDate)
                {
                    Films = new CustomObservableCollection <Film>(Films.OrderByDescending(f => DateTime.Parse(f.ReleaseDate)));
                }
                else
                {
                    Films = new CustomObservableCollection <Film>(Films.OrderBy(f => DateTime.Parse(f.ReleaseDate)));
                }
                _sortedByDate = !_sortedByDate;
            });
            SortByRuntimeCommand = new Command(() =>
            {
                if (_sortedByRuntime)
                {
                    Films = new CustomObservableCollection <Film>(Films.OrderByDescending(f => f.Duration));
                }
                else
                {
                    Films = new CustomObservableCollection <Film>(Films.OrderBy(f => f.Duration));
                }
                _sortedByRuntime = !_sortedByRuntime;
            });
        }