コード例 #1
0
        private void Init()
        {
            SubscribeYubiKey(true);
            if (_providers.Count > 1)
            {
                var sendEmailTask = SendEmailAsync(false);
            }

            ToolbarItems.Clear();
            var scrollView = new ScrollView();

            var anotherMethodButton = new ExtendedButton
            {
                Text            = AppResources.UseAnotherTwoStepMethod,
                Style           = (Style)Application.Current.Resources["btn-primaryAccent"],
                Margin          = new Thickness(15, 0, 15, 25),
                Command         = new Command(() => AnotherMethodAsync()),
                Uppercase       = false,
                BackgroundColor = Color.Transparent,
                VerticalOptions = LayoutOptions.Start
            };

            var instruction = new Label
            {
                LineBreakMode           = LineBreakMode.WordWrap,
                Margin                  = new Thickness(15),
                HorizontalTextAlignment = TextAlignment.Center
            };

            RememberCell = new ExtendedSwitchCell
            {
                Text = AppResources.RememberMe,
                On   = false
            };

            var continueToolbarItem = new ToolbarItem(AppResources.Continue,
                                                      Helpers.ToolbarImage("ion_chevron_right.png"), async() =>
            {
                var token = TokenCell?.Entry.Text.Trim().Replace(" ", "");
                await LogInAsync(token);
            }, ToolbarItemOrder.Default, 0);

            if (!_providerType.HasValue)
            {
                instruction.Text = AppResources.NoTwoStepAvailable;

                var layout = new StackLayout
                {
                    Children = { instruction, anotherMethodButton },
                    Spacing  = 0
                };

                scrollView.Content = layout;

                Title   = AppResources.LoginUnavailable;
                Content = scrollView;
            }
            else if (_providerType.Value == TwoFactorProviderType.Authenticator ||
                     _providerType.Value == TwoFactorProviderType.Email)
            {
                var padding = Helpers.OnPlatform(
                    iOS: new Thickness(15, 20),
                    Android: new Thickness(15, 8),
                    Windows: new Thickness(10, 8));

                TokenCell = new FormEntryCell(AppResources.VerificationCode, useLabelAsPlaceholder: true,
                                              imageSource: "lock", containerPadding: padding);

                TokenCell.Entry.Keyboard   = Keyboard.Numeric;
                TokenCell.Entry.ReturnType = ReturnType.Go;

                var table = new TwoFactorTable(
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                {
                    TokenCell,
                    RememberCell
                });

                var layout = new RedrawableStackLayout
                {
                    Children = { instruction, table },
                    Spacing  = 0
                };

                table.WrappingStackLayout = () => layout;
                scrollView.Content        = layout;

                switch (_providerType.Value)
                {
                case TwoFactorProviderType.Authenticator:
                    instruction.Text = AppResources.EnterVerificationCodeApp;
                    layout.Children.Add(anotherMethodButton);
                    break;

                case TwoFactorProviderType.Email:
                    var emailParams   = _providers[TwoFactorProviderType.Email];
                    var redactedEmail = emailParams["Email"].ToString();

                    instruction.Text = string.Format(AppResources.EnterVerificationCodeEmail, redactedEmail);
                    var resendEmailButton = new ExtendedButton
                    {
                        Text            = AppResources.SendVerificationCodeAgain,
                        Style           = (Style)Application.Current.Resources["btn-primaryAccent"],
                        Margin          = new Thickness(15, 0, 15, 0),
                        Command         = new Command(async() => await SendEmailAsync(true)),
                        Uppercase       = false,
                        BackgroundColor = Color.Transparent,
                        VerticalOptions = LayoutOptions.Start
                    };

                    layout.Children.Add(resendEmailButton);
                    layout.Children.Add(anotherMethodButton);
                    break;

                default:
                    break;
                }

                ToolbarItems.Add(continueToolbarItem);
                Title = AppResources.VerificationCode;

                Content = scrollView;
                TokenCell.Entry.FocusWithDelay();
            }
            else if (_providerType == TwoFactorProviderType.Duo ||
                     _providerType == TwoFactorProviderType.OrganizationDuo)
            {
                var duoParams = _providers[_providerType.Value];

                var host = WebUtility.UrlEncode(duoParams["Host"].ToString());
                var req  = WebUtility.UrlEncode(duoParams["Signature"].ToString());

                var webVaultUrl = "https://vault.bitwarden.com";
                if (!string.IsNullOrWhiteSpace(_appSettingsService.BaseUrl))
                {
                    webVaultUrl = _appSettingsService.BaseUrl;
                }
                else if (!string.IsNullOrWhiteSpace(_appSettingsService.WebVaultUrl))
                {
                    webVaultUrl = _appSettingsService.WebVaultUrl;
                }

                var webView = new HybridWebView
                {
                    Uri = $"{webVaultUrl}/duo-connector.html?host={host}&request={req}",
                    HorizontalOptions    = LayoutOptions.FillAndExpand,
                    VerticalOptions      = LayoutOptions.FillAndExpand,
                    MinimumHeightRequest = 400
                };
                webView.RegisterAction(async(sig) =>
                {
                    await LogInAsync(sig);
                });

                var table = new TwoFactorTable(
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                {
                    RememberCell
                });

                var layout = new RedrawableStackLayout
                {
                    Children = { webView, table, anotherMethodButton },
                    Spacing  = 0
                };

                table.WrappingStackLayout = () => layout;
                scrollView.Content        = layout;

                Title   = _providerType == TwoFactorProviderType.Duo ? "Duo" : _duoOrgTitle;
                Content = scrollView;
            }
            else if (_providerType == TwoFactorProviderType.YubiKey)
            {
                instruction.Text = Device.RuntimePlatform == Device.iOS ? AppResources.YubiKeyInstructionIos :
                                   AppResources.YubiKeyInstruction;

                var image = new CachedImage
                {
                    Source            = "yubikey.png",
                    VerticalOptions   = LayoutOptions.Start,
                    HorizontalOptions = LayoutOptions.Center,
                    WidthRequest      = 266,
                    HeightRequest     = 160,
                    Margin            = new Thickness(0, 0, 0, 25)
                };

                var section = new TableSection(Helpers.GetEmptyTableSectionTitle())
                {
                    RememberCell
                };

                if (Device.RuntimePlatform != Device.iOS)
                {
                    TokenCell = new FormEntryCell("", isPassword: true, imageSource: "lock",
                                                  useLabelAsPlaceholder: true);
                    TokenCell.Entry.ReturnType = ReturnType.Go;
                    section.Insert(0, TokenCell);
                }

                var table  = new TwoFactorTable(section);
                var layout = new RedrawableStackLayout
                {
                    Children = { instruction, image, table },
                    Spacing  = 0
                };

                if (Device.RuntimePlatform == Device.iOS)
                {
                    var tryAgainButton = new ExtendedButton
                    {
                        Text            = AppResources.TryAgain,
                        Style           = (Style)Application.Current.Resources["btn-primaryAccent"],
                        Margin          = new Thickness(15, 0, 15, 0),
                        Command         = new Command(() => ListenYubiKey(true, true)),
                        Uppercase       = false,
                        BackgroundColor = Color.Transparent,
                        VerticalOptions = LayoutOptions.Start
                    };
                    layout.Children.Add(tryAgainButton);
                }
                else
                {
                    ToolbarItems.Add(continueToolbarItem);
                }

                layout.Children.Add(anotherMethodButton);

                table.WrappingStackLayout = () => layout;
                scrollView.Content        = layout;

                Title   = AppResources.YubiKeyTitle;
                Content = scrollView;
            }
        }
コード例 #2
0
        public UploadImgPage()
        {
            BackgroundColor = ColorConstants.NewTripBackground;

            _stack = new StackLayout {
                Orientation = StackOrientation.Horizontal
            };
            _scrool = new ScrollView {
                Orientation = ScrollOrientation.Horizontal, Content = _stack
            };

            var instruction = new UploadImgLabelInstruction();

            var newPhotoBtn = new ToolbarItem {
                Icon = ImgConstants.Camera
            };
            var newImgBtn = new ToolbarItem {
                Icon = ImgConstants.Album
            };
            var nextBtn = new ToolbarItem {
                Icon = ImgConstants.Next
            };

            nextBtn.Clicked += (sender, e) => Navigation.PushAsync(new AddPlacePage());

            ToolbarItems.Add(newPhotoBtn);
            ToolbarItems.Add(newImgBtn);
            ToolbarItems.Add(nextBtn);

            newImgBtn.Clicked += async(sender, e) =>
            {
                if (!CrossMedia.Current.IsPickPhotoSupported)
                {
                    return;
                }

                var photo = await CrossMedia.Current.PickPhotoAsync();

                if (photo == null)
                {
                    return;
                }
                if (Content == instruction)
                {
                    Content = _scrool;
                }

                var image = new Image
                {
                    Margin       = 10,
                    Aspect       = Aspect.AspectFit,
                    WidthRequest = App.ScreenWidth - 20,
                    Source       = ImageSource.FromStream(() =>
                    {
                        var stream = photo.GetStream();
                        photo.Dispose();
                        return(stream);
                    })
                };

                var tgr = new TapGestureRecognizer {
                    NumberOfTapsRequired = 2
                };

                tgr.Tapped += async(iSender, iE) =>
                {
                    if (await DisplayAlert("Delete", "Would you like to delete this photo?", "Yes", "No"))
                    {
                        _stack.Children.Remove(image);
                    }
                };

                image.GestureRecognizers.Add(tgr);
                _stack.Children.Add(image);
            };

            Content = instruction;
        }
コード例 #3
0
        public TaskDetailsPageView(TasksViewModel tasksViewModel)
        {
            MessagingCenter.Subscribe <TasksViewModel, string>(this, "message", OnMessageReceived);

            BindingContext = tasksViewModel;

            Title = "Details";

            var postToolbarItem = new ToolbarItem
            {
                Text    = "POST",
                Icon    = "add.png",
                Order   = ToolbarItemOrder.Primary,
                Command = tasksViewModel.PostCommand,
            };
            var deleteToolbarItem = new ToolbarItem
            {
                Text    = "DELETE",
                Icon    = "delete.png",
                Order   = ToolbarItemOrder.Primary,
                Command = tasksViewModel.DeleteCommand,
            };
            var putToolbarItem = new ToolbarItem
            {
                Text    = "PUT",
                Icon    = "edit.png",
                Order   = ToolbarItemOrder.Primary,
                Command = tasksViewModel.PutCommand,
            };

            ToolbarItems.Add(deleteToolbarItem);
            ToolbarItems.Add(putToolbarItem);
            ToolbarItems.Add(postToolbarItem);

            var titleLabel = new Label
            {
                Text     = "Title",
                FontSize = 16
            };
            var titleEntry = new Entry();

            titleEntry.SetBinding(Entry.TextProperty, "SelectedTask.Title");

            var contentLabel = new Label
            {
                Text     = "Content",
                FontSize = 16
            };
            var contentEntry = new Entry();

            contentEntry.SetBinding(Entry.TextProperty, "SelectedTask.Content");

            var createdAtLabel = new Label
            {
                Text     = "Created At",
                FontSize = 16
            };
            var createdAtDatePicker = new DatePicker();

            createdAtDatePicker.SetBinding(
                DatePicker.DateProperty,
                "SelectedTask.CreatedAt",
                BindingMode.TwoWay);

            var activityIndicator = new ActivityIndicator
            {
                Color         = Color.Navy,
                HeightRequest = 50,
            };

            activityIndicator.SetBinding(IsVisibleProperty, "IsBusy");
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");

            var stackLayout = new StackLayout
            {
                Children =
                {
                    titleLabel,
                    titleEntry,
                    contentLabel,
                    contentEntry,
                    createdAtLabel,
                    createdAtDatePicker,
                    activityIndicator
                }
            };

            Content = stackLayout;
        }
コード例 #4
0
        public DevicesPage()
        {
            InitializeComponent();

            ToolbarItem menu = new ToolbarItem
            {
                Text     = "Menu",
                Order    = ToolbarItemOrder.Primary,
                Priority = 1
            };

            ToolbarItem babies = new ToolbarItem
            {
                Text     = "Babies",
                Order    = ToolbarItemOrder.Secondary,
                Priority = 2
            };

            ToolbarItem reminders = new ToolbarItem
            {
                Text     = "Reminders",
                Order    = ToolbarItemOrder.Secondary,
                Priority = 3
            };

            ToolbarItem devices = new ToolbarItem
            {
                Text     = "Devices",
                Order    = ToolbarItemOrder.Secondary,
                Priority = 4
            };

            ToolbarItem logout = new ToolbarItem
            {
                Text     = "Logout",
                Order    = ToolbarItemOrder.Secondary,
                Priority = 6
            };

            ToolbarItem profile = new ToolbarItem
            {
                Text     = "Profile",
                Order    = ToolbarItemOrder.Secondary,
                Priority = 7
            };

            babies.Clicked += async(s, e) =>
            {
                await Navigation.PushModalAsync(new NavigationPage(new BabiesPage()));
            };

            reminders.Clicked += async(s, e) =>
            {
                await Navigation.PushModalAsync(new NavigationPage(new RemindersPage()));
            };

            devices.Clicked += async(s, e) =>
            {
                await Navigation.PushModalAsync(new NavigationPage(new DevicesPage()));
            };

            logout.Clicked += async(s, e) =>
            {
                await Navigation.PushModalAsync(new NavigationPage(new LoginPage()));
            };

            profile.Clicked += async(s, e) =>
            {
                await Navigation.PushModalAsync(new NavigationPage(new ProfilePage()));
            };

            ToolbarItems.Add(menu);
            ToolbarItems.Add(babies);
            ToolbarItems.Add(reminders);
            ToolbarItems.Add(devices);
            ToolbarItems.Add(logout);
            ToolbarItems.Add(profile);
        }
コード例 #5
0
        public TodoListPage()
        {
            Title = AppResources.ApplicationTitle;             // "Todo";

            listView = new ListView {
                RowHeight = 40
            };
            listView.ItemTemplate = new DataTemplate(typeof(TodoItemCell));

            listView.ItemSelected += (sender, e) => {
                var todoItem = (TodoItem)e.SelectedItem;

                // use C# localization
                var todoPage = new TodoItemPage();

                // use XAML localization
//				var todoPage = new TodoItemXaml();


                todoPage.BindingContext = todoItem;
                Navigation.PushAsync(todoPage);
            };

            var layout = new StackLayout();

            if (Device.OS == TargetPlatform.WinPhone)               // WinPhone doesn't have the title showing
            {
                layout.Children.Add(new Label {
                    Text = "Todo", Font = Font.SystemFontOfSize(NamedSize.Large, FontAttributes.Bold)
                });
            }
            layout.Children.Add(listView);
            layout.VerticalOptions = LayoutOptions.FillAndExpand;
            Content = layout;


            var tbiAdd = new ToolbarItem("Add", "plus.png", () =>
            {
                var todoItem            = new TodoItem();
                var todoPage            = new TodoItemPage();
                todoPage.BindingContext = todoItem;
                Navigation.PushAsync(todoPage);
            }, 0, 0);


            ToolbarItems.Add(tbiAdd);


            var tbiSpeak = new ToolbarItem("Speak", "chat.png", () => {
                var todos   = App.Database.GetItemsNotDone();
                var tospeak = "";
                foreach (var t in todos)
                {
                    tospeak += t.Name + " ";
                }
                if (tospeak == "")
                {
                    tospeak = "there are no tasks to do";
                }

                if (todos.Any())
                {
                    var s   = L10n.Localize("SpeakTaskCount", "Number of tasks to do");
                    tospeak = String.Format(s, todos.Count()) + tospeak;
                }

                DependencyService.Get <ITextToSpeech>().Speak(tospeak);
            }, 0, 0);

            ToolbarItems.Add(tbiSpeak);
        }
コード例 #6
0
        public HomeView()
        {
            Title          = "Skills";
            BindingContext = new SkillsListViewModel();

            var refresh = new ToolbarItem {
                Command  = ViewModel.LoadAllItemsCommand,
                Icon     = "refresh.png",
                Name     = "refresh",
                Priority = 0
            };

            ToolbarItems.Add(refresh);

            Label header = new Label
            {
                Text              = "Skills View",
                BackgroundColor   = Color.Blue,
                Font              = Font.BoldSystemFontOfSize(30),
                HorizontalOptions = LayoutOptions.Center
            };

            var listView = new ListView();

            listView.ItemsSource = ViewModel.SkillItems;

            var cell = new DataTemplate(typeof(TextCell));

            cell.SetBinding(TextCell.TextProperty, "title");

            listView.ItemTemplate = cell;

            listView.ItemTapped += (sender, args) =>
            {
                var skill = args.Item as Skill;

                if (skill == null)
                {
                    return;
                }

                Navigation.PushAsync(new SkillView(skill));

                // Reset the selected item
                listView.SelectedItem = null;
            };

            var stackPanel = new StackLayout();

            stackPanel.Padding = new Thickness(0, 0, 0, 0);
            stackPanel.Children.Insert(1, listView);

            var activity = new ActivityIndicator {
                Color     = Util.Color.DarkBlue.ToFormsColor(),
                IsEnabled = true
            };

            activity.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy");
            activity.SetBinding(ActivityIndicator.IsRunningProperty, "IsBusy");

            stackPanel.Children.Add(activity);

            if (Device.OS == TargetPlatform.WinPhone)
            {
                stackPanel.Children.Insert(0, header);
            }

            Content = stackPanel;
        }
コード例 #7
0
ファイル: ListingListas.cs プロジェクト: jorgeafs/HAVO
        public ListingListas()
        {
            Title = "Showing List";

            NavigationPage.SetHasNavigationBar(this, true);

            listView = new ListView
            {
                RowHeight    = 40,
                ItemTemplate = new DataTemplate(typeof(ItemCell))
            };

            listView.SeparatorVisibility = SeparatorVisibility.Default;
            listView.SeparatorColor      = Color.White;
            listView.ItemSelected       += (sender, e) =>
            {
                var lista       = (Lista)e.SelectedItem;
                var taskListing = new ListingTasks(lista.ID, true);
                Navigation.PushAsync(taskListing);
            };

            var layout = new StackLayout();

            if (Device.OS == TargetPlatform.WinPhone)
            { // WinPhone doesn't have the title showing
                layout.Children.Add(new Label
                {
                    FontSize       = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                    FontAttributes = FontAttributes.Bold
                });
            }
            layout.Children.Add(listView);
            layout.VerticalOptions = LayoutOptions.FillAndExpand;
            Content = layout;


            ToolbarItem tbi = null;

            if (Device.OS == TargetPlatform.iOS)
            {
                tbi = new ToolbarItem("+", null, () =>
                {
                    var lista                      = new Lista();
                    var listaCreatePage            = new ListaCreatePage();
                    listaCreatePage.BindingContext = lista;
                    Navigation.PushAsync(listaCreatePage);
                }, 0, 0);
            }
            if (Device.OS == TargetPlatform.Android)
            { // BUG: Android doesn't support the icon being null
                tbi = new ToolbarItem("+", "plus", () =>
                {
                    var lista                      = new Lista();
                    var listaCreatePage            = new ListaCreatePage();
                    listaCreatePage.BindingContext = lista;
                    Navigation.PushAsync(listaCreatePage);
                }, 0, 0);
            }

            if (Device.OS == TargetPlatform.WinPhone)
            {
                tbi = new ToolbarItem("Add", "add.png", () =>
                {
                    var lista                      = new Lista();
                    var listaCreatePage            = new ListaCreatePage();
                    listaCreatePage.BindingContext = lista;
                    Navigation.PushAsync(listaCreatePage);
                }, 0, 0);
            }

            ToolbarItems.Add(tbi);
        }
コード例 #8
0
ファイル: EventView.xaml.cs プロジェクト: sk8tz/MeetupManager
        public EventView(Event e, string gId, string gName)
        {
            InitializeComponent();

            BindingContext = viewModel = new EventViewModel(this, e, gId, gName);

            ToolbarItems.Add(new ToolbarItem
            {
                StyleId = "AddNewMember",
                Text    = "Add New Member",
                Order   = ToolbarItemOrder.Primary,
                Icon    = "ic_action_social_person_add.png",
                Command = viewModel.AddNewUserCommand
            });
            ToolbarItems.Add(new ToolbarItem
            {
                StyleId = "PickWinner",
                Text    = "Pick Winner",
                Icon    = "ic_action_winner.png",
                Order   = ToolbarItemOrder.Primary,
                Command = viewModel.SelectWinnerCommand
            });

            MembersList.ItemSelected += (sender, ee) =>
            {
                if (MembersList.SelectedItem == null)
                {
                    return;
                }

                viewModel.CheckInCommand.Execute(ee.SelectedItem);
                MembersList.SelectedItem = null;
            };

            MembersList.ItemAppearing += (sender, ee) =>
            {
                if (viewModel.IsBusy || viewModel.Members.Count == 0)
                {
                    return;
                }
                //hit bottom!
                if (((MemberViewModel)ee.Item).Name == viewModel.Members[viewModel.Members.Count - 1].Member.Name)
                {
                    viewModel.LoadMoreCommand.Execute(null);
                }
            };

            //ensure after first load that we scroll to the top.

            /*viewModel.FinishedFirstLoad = (index) =>
             *  {
             *      if(viewModel.Members.Count == 0)
             *          return;
             *      Device.StartTimer(TimeSpan.FromMilliseconds(100), ()=>
             *          {
             *              Device.BeginInvokeOnMainThread(() =>
             *                  MembersList.ScrollTo(viewModel.Members[index], ScrollToPosition.MakeVisible, false));
             *
             *              return false;
             *          });
             *  };*/
        }
コード例 #9
0
        public LibInfoPage_d(LibInfo.RootObject lib)
        {
            libInfo = lib;

            #region Grid Interface
            for (int i = 0; i < libInfo.Items.Count; i++)
            {
                var controlgrid = new Grid
                {
                    VerticalOptions = LayoutOptions.FillAndExpand,
                    RowSpacing      = 10,
                    ColumnSpacing   = 5,
                    Padding         = new Thickness(5, 0, 5, 0),
                    BackgroundColor = Color.White,
                    RowDefinitions  =
                    {
                        new RowDefinition {
                            Height = GridLength.Auto
                        },
                        new RowDefinition {
                            Height = GridLength.Auto
                        },
                        new RowDefinition {
                            Height = GridLength.Auto
                        },
                        new RowDefinition {
                            Height = GridLength.Auto
                        },
                        new RowDefinition {
                            Height = GridLength.Auto
                        },
                        new RowDefinition {
                            Height = GridLength.Auto
                        },
                        new RowDefinition {
                            Height = GridLength.Auto
                        },
                        new RowDefinition {
                            Height = GridLength.Auto
                        },
                        new RowDefinition {
                            Height = GridLength.Auto
                        },
                        new RowDefinition {
                            Height = GridLength.Auto
                        },
                        new RowDefinition {
                            Height = GridLength.Auto
                        },
                        new RowDefinition {
                            Height = GridLength.Auto
                        },
                        new RowDefinition {
                            Height = GridLength.Auto
                        },
                        new RowDefinition {
                            Height = GridLength.Auto
                        },
                        new RowDefinition {
                            Height = new GridLength(300, GridUnitType.Absolute)
                        }
                    },
                    ColumnDefinitions =
                    {
                        new ColumnDefinition {
                            Width = new GridLength(.475, GridUnitType.Star)
                        },
                        new ColumnDefinition {
                            Width = new GridLength(.05, GridUnitType.Star)
                        },
                        new ColumnDefinition {
                            Width = new GridLength(.475, GridUnitType.Star)
                        }
                    }
                };
                controlgrid.Children.Add(new Image
                {
                    VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.CenterAndExpand,
                    WidthRequest    = 320,
                    HeightRequest   = 130,
                    IsVisible       = string.IsNullOrEmpty(libInfo.Items[i].image) ? false : true,
                    Source          = ImageSource.FromResource(LibInfo.Imagefolderclinetlogos + lib.Items[i].image, typeof(LibInfoPage_d)),
                }, 0, 3, 0, 1);
                controlgrid.Children.Add(new Label
                {
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    Text     = libInfo.Items[i].branchName,
                    FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                }, 0, 3, 1, 2);



                controlgrid.Children.Add(new Button
                {
                    CommandParameter = i,
                    Command          = new Command(o =>
                    {
                        var phoneCallTask = CrossMessaging.Current.PhoneDialer;
                        if (phoneCallTask.CanMakePhoneCall)
                        {
                            phoneCallTask.MakePhoneCall(libInfo.Items[int.Parse(o.ToString())].phoneNumber.CleanPhone());
                        }
                    }),
                    Text = string.Format("Call:{0}",
                                         libInfo.Items[i].phoneNumber),
                    Image           = "phone.png",
                    TextColor       = Color.FromHex(libInfo.TextColor),
                    CornerRadius    = 1,
                    BackgroundColor = Color.FromHex(libInfo.backGroundColor),
                    BorderColor     = Color.FromHex(libInfo.borderColor),
                }, 0, 1, 2, 3);
                controlgrid.Children.Add(new Label
                {
                    Text = string.Format("Fax:{0}", libInfo.Items[i].Fax),

                    TextColor = Color.FromHex(libInfo.TextColor),

                    BackgroundColor   = Color.FromHex(libInfo.backGroundColor),
                    VerticalOptions   = LayoutOptions.Center,
                    HorizontalOptions = LayoutOptions.End
                }, 2, 3, 2, 3);
                controlgrid.Children.Add(new Button
                {
                    CommandParameter = i,

                    Command = new Command(o =>
                    {
                        Device.OpenUri(new Uri("mailto:" + libInfo.Items[int.Parse(o.ToString())].email));
                    }),


                    IsVisible = string.IsNullOrEmpty(libInfo.Items[i].email) ? false : true,

                    Text = libInfo.Items[i].email,

                    TextColor       = Color.FromHex(libInfo.TextColor),
                    CornerRadius    = 1,
                    BackgroundColor = Color.FromHex(libInfo.backGroundColor),
                    BorderColor     = Color.FromHex(libInfo.borderColor),
                }, 0, 3, 3, 4);

                controlgrid.Children.Add(new Label
                {
                    Text = "Library Hours",

                    TextColor      = Color.FromHex(libInfo.backGroundColor),
                    FontSize       = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                    FontAttributes = FontAttributes.Bold,
                }, 0, 3, 4, 5);

                controlgrid.Children.Add(new Label
                {
                    Text = "Monday",

                    VerticalOptions = LayoutOptions.Center,
                    FontSize        = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                    FontAttributes  = FontAttributes.Bold,
                }, 0, 2, 5, 6);
                controlgrid.Children.Add(new Label
                {
                    Text = string.Format("{0} - {1}",
                                         libInfo.Items[i].Time.MondayOpen,
                                         libInfo.Items[i].Time.MondayClose),

                    FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),

                    HorizontalOptions = LayoutOptions.End,
                }, 2, 3, 5, 6);
                controlgrid.Children.Add(new Label
                {
                    Text = "Tuesday",

                    VerticalOptions = LayoutOptions.Center,
                    FontSize        = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                    FontAttributes  = FontAttributes.Bold,
                }, 0, 2, 6, 7);
                controlgrid.Children.Add(new Label
                {
                    Text = string.Format("{0} - {1}",
                                         libInfo.Items[i].Time.TuesdayOpen,
                                         libInfo.Items[i].Time.TuesdayClose),

                    FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),

                    HorizontalOptions = LayoutOptions.End,
                }, 2, 3, 6, 7);
                controlgrid.Children.Add(new Label
                {
                    Text = "Wednesday",

                    VerticalOptions = LayoutOptions.Center,
                    FontSize        = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                    FontAttributes  = FontAttributes.Bold,
                }, 0, 2, 7, 8);
                controlgrid.Children.Add(new Label
                {
                    Text = string.Format("{0} - {1}",
                                         libInfo.Items[i].Time.WednesdayOpen,
                                         libInfo.Items[i].Time.WednesdayClose),

                    FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),

                    HorizontalOptions = LayoutOptions.End,
                }, 2, 3, 7, 8);

                controlgrid.Children.Add(new Label
                {
                    Text = "Thursday",

                    VerticalOptions = LayoutOptions.Center,
                    FontSize        = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                    FontAttributes  = FontAttributes.Bold,
                }, 0, 2, 8, 9);
                controlgrid.Children.Add(new Label
                {
                    Text = string.Format("{0} - {1}",
                                         libInfo.Items[i].Time.ThursdayOpen,
                                         libInfo.Items[i].Time.ThursdayClose),

                    FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),

                    HorizontalOptions = LayoutOptions.End,
                }, 2, 3, 8, 9);
                controlgrid.Children.Add(new Label
                {
                    Text            = "Friday",
                    VerticalOptions = LayoutOptions.Center,
                    FontSize        = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                    FontAttributes  = FontAttributes.Bold,
                }, 0, 2, 9, 10);
                controlgrid.Children.Add(new Label
                {
                    Text = string.Format("{0} - {1}",
                                         libInfo.Items[i].Time.FridayOpen,
                                         libInfo.Items[i].Time.FridayClose),

                    FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),

                    HorizontalOptions = LayoutOptions.End,
                }, 2, 3, 9, 10);

                controlgrid.Children.Add(new Label
                {
                    Text            = "Saturday",
                    VerticalOptions = LayoutOptions.Center,
                    FontSize        = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                    FontAttributes  = FontAttributes.Bold,
                }, 0, 2, 10, 11);
                controlgrid.Children.Add(new Label
                {
                    Text = string.Format("{0} - {1}",
                                         libInfo.Items[i].Time.SaturdayOpen,
                                         libInfo.Items[i].Time.SaturdayClose),

                    FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),

                    HorizontalOptions = LayoutOptions.End,
                }, 2, 3, 10, 11);

                controlgrid.Children.Add(new Label
                {
                    Text            = "Sunday",
                    VerticalOptions = LayoutOptions.Center,
                    FontSize        = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                    FontAttributes  = FontAttributes.Bold,
                }, 0, 2, 11, 12);
                controlgrid.Children.Add(new Label
                {
                    Text = string.Format("{0} - {1}",
                                         libInfo.Items[i].Time.SundayOpen,
                                         libInfo.Items[i].Time.SundayClose),

                    FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),

                    HorizontalOptions = LayoutOptions.End,
                }, 2, 3, 11, 12);

                controlgrid.Children.Add(new Label
                {
                    Text            = "Location",
                    VerticalOptions = LayoutOptions.Center,
                    FontSize        = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                    FontAttributes  = FontAttributes.Bold,
                    TextColor       = Color.FromHex(libInfo.backGroundColor)
                }, 0, 3, 12, 13);

                controlgrid.Children.Add(new Button
                {
                    CommandParameter = libInfo.Items[i],
                    Command          = new Command <LibInfo.Item>(obj =>
                                                                  CrossExternalMaps.Current.NavigateTo(
                                                                      obj.branchName,
                                                                      obj.Latitude,
                                                                      obj.Longitude)),
                    Text            = "Navigate",
                    Image           = "navigation.png",
                    VerticalOptions = LayoutOptions.FillAndExpand,
                    TextColor       = Color.FromHex(libInfo.TextColor),
                    CornerRadius    = 1,
                    BackgroundColor = Color.FromHex(libInfo.backGroundColor),
                    BorderColor     = Color.FromHex(libInfo.borderColor)
                }, 0, 1, 13, 14);


                controlgrid.Children.Add(new Label
                {
                    Text = string.Format(" {0} {4} {1}, {2} {3}",
                                         libInfo.Items[i].Address.Street,
                                         libInfo.Items[i].Address.City,
                                         libInfo.Items[i].Address.State,
                                         libInfo.Items[i].Address.zipCode,
                                         Environment.NewLine),
                    VerticalOptions   = LayoutOptions.CenterAndExpand,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    FontSize          = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                }, 1, 3, 13, 14);
                var map = new Map()
                {
                    IsShowingUser = true,
                    MapType       = MapType.Hybrid,
                };
                controlgrid.Children.Add(map, 0, 3, 14, 15);
                gridlist.Add(controlgrid);
                Maplist.Add(map);
            }
            #endregion


            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "Setting",
                Command = new Command(async(obj) =>
                {
                    await Navigation.PushAsync(new PickerPage());
                })
            });
            var stack = new StackLayout();
            for (int i = 0; i < libInfo.Items.Count; i++)
            {
                stack.Children.Add(gridlist[i]);
            }
            Content = new ScrollView
            {
                Padding         = new Thickness(5, 10, 5, 5),
                BackgroundColor = Color.FromHex(libInfo.backGroundColor),
                Content         = stack
            };
        }
コード例 #10
0
        public PlusPage() : base(0, 0)
        {
            InitializeComponent();

            ToolbarItems.Add(new ToolbarItem("Déconnexion", "", HandleAction));
        }
コード例 #11
0
ファイル: ReadPageCS.cs プロジェクト: iremcaliskan/LOT
        public ReadPageCS()
        {
            Title = "ReadList";

            var toolbarItem = new ToolbarItem
            {
                Text            = "+",
                IconImageSource = Device.RuntimePlatform == Device.iOS ? null : "plus.png"
            };

            toolbarItem.Clicked += async(sender, e) =>
            {
                await Navigation.PushAsync(new ReadItemPageCS
                {
                    BindingContext = new ReadItem()
                });
            };
            ToolbarItems.Add(toolbarItem);

            listView = new ListView
            {
                Margin       = new Thickness(20),
                ItemTemplate = new DataTemplate(() =>
                {
                    var label = new Label
                    {
                        VerticalTextAlignment = TextAlignment.Center,
                        HorizontalOptions     = LayoutOptions.StartAndExpand
                    };
                    label.SetBinding(Label.TextProperty, "Name");

                    var tick = new Image
                    {
                        Source            = ImageSource.FromFile("check.png"),
                        HorizontalOptions = LayoutOptions.End
                    };
                    tick.SetBinding(VisualElement.IsVisibleProperty, "Done");

                    var stackLayout = new StackLayout
                    {
                        Margin            = new Thickness(20, 0, 0, 0),
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Children          = { label, tick }
                    };

                    return(new ViewCell {
                        View = stackLayout
                    });
                })
            };
            listView.ItemSelected += async(sender, e) =>
            {
                if (e.SelectedItem != null)
                {
                    await Navigation.PushAsync(new ReadItemPageCS
                    {
                        BindingContext = e.SelectedItem as ReadItem
                    });
                }
            };

            Content = listView;
        }
コード例 #12
0
        protected override void Initialize()
        {
            Title = "Match Score";

            var scrollView = new ScrollView {
                BackgroundColor = Color.White,
            };

            var stackLayout = new StackLayout {
                Spacing = 10,
                Padding = 0,
            };

            var btnSubmit = new Button {
                Text = "Post Match Score",
                BackgroundColor = ViewModel.Challenge.League.Theme.Dark,
            };

            var btnCancel = new ToolbarItem {
                Text = "Cancel"
            };
            ToolbarItems.Add(btnCancel);

            btnCancel.Clicked += async(sender, e) =>
            {
                await Navigation.PopModalAsync();
            };

            ViewModel.Challenge.MatchResult.Clear();
            for(int i = 0; i < ViewModel.Challenge.League.MatchGameCount; i++)
            {
                var gameResult = new GameResult {
                    Index = i,
                    ChallengeId = ViewModel.Challenge.Id,
                };

                ViewModel.Challenge.MatchResult.Add(gameResult);

                var form = new GameResultFormView(ViewModel.Challenge, gameResult, i);
                stackLayout.Children.Add(form);
            }

            scrollView.Content = stackLayout;
            stackLayout.Children.Add(new StackLayout {
                Padding = 24,
                Children = {
                    btnSubmit
                },
            });
            Content = scrollView;

            btnSubmit.Clicked += async(sender, e) =>
            {
                var errorMsg = ViewModel.ValidateMatchResults();

                if(errorMsg != null)
                {
                    errorMsg?.ToToast(ToastNotificationType.Error, "No can do");
                    return;
                }

                bool submit = await DisplayAlert("This will end the match", "Are you sure you want to submit these scores?", "Yes", "No");

                if(submit)
                {
                    using(new HUD("Posting results..."))
                    {
                        await ViewModel.PostMatchResults();
                    }

                    await Navigation.PopModalAsync();

                    if(OnMatchResultsPosted != null)
                        OnMatchResultsPosted();

                    var title = App.CurrentAthlete.Id == ViewModel.Challenge.WinningAthlete.Id ? "Victory!" : "Bummer";
                    "Results submitted - congrats to {0}!".Fmt(ViewModel.Challenge.WinningAthlete.Name).ToToast(ToastNotificationType.Success, title);
                }
            };
        }
コード例 #13
0
ファイル: Profile.xaml.cs プロジェクト: bassim69/Test1
        public Profile()
        {
            InitializeComponent();

            ToolbarItems.Add(new ToolbarItem("Edit", null, Make_User_Editable));
        }
コード例 #14
0
        public AutomationPropertiesGallery()
        {
            // https://developer.xamarin.com/guides/android/advanced_topics/accessibility/
            // https://developer.xamarin.com/guides/ios/advanced_topics/accessibility/
            // https://msdn.microsoft.com/en-us/windows/uwp/accessibility/basic-accessibility-information

            const string EntryPlaceholder = "Your name.";
            const string EntryHelpText    = "Type your name.";
            const string ImageName        = "Roof";
            const string ImageHelpText    = "Tap to show an alert.";
            const string BoxHelpText      = "Shows a purple box.";
            const string BoxName          = "Box";

            string screenReader          = "";
            string scrollFingers         = "";
            string explore               = "";
            string labeledByInstructions = "";
            string imageInstructions     = "";
            string boxInstructions       = "";
            string toolbarInstructions   = "";
            string toolbarItemName       = "Get some coffee";
            string toolbarItem2Text      = "Go";
            string toolbarItemHint2      = "Somewhere else";

            switch (Device.RuntimePlatform)
            {
            case Device.iOS:
                screenReader          = "VoiceOver";
                scrollFingers         = "three fingers";
                explore               = "Use two fingers to swipe up or down the screen to read all of the elements on this page.";
                labeledByInstructions = $"The following Entry should read aloud \"{EntryPlaceholder}.\", plus native instructions on how to use an Entry element. This text comes from the placeholder.";
                imageInstructions     = $"The following Image should read aloud \"{ImageName}. {ImageHelpText}\". You should be able to tap the image and hear an alert box.";
                boxInstructions       = $"The following Box should read aloud \"{BoxName}. {BoxHelpText}\". You should be able to tap the box and hear an alert box.";
                toolbarInstructions   = $"The Toolbar should have a coffee cup icon. Activating the coffee cup should read aloud \"{toolbarItemName}\". The Toolbar should also show the text \"{toolbarItem2Text}\". Activating this item should read aloud \"{toolbarItem2Text}. {toolbarItemHint2}\".";
                break;

            case Device.Android:
                screenReader          = "TalkBack";
                scrollFingers         = "two fingers";
                explore               = "Drag one finger across the screen to read each element on the page.";
                labeledByInstructions = $"The following Entry should read aloud \"EditBox {EntryPlaceholder} for {EntryHelpText}.\", plus native instructions on how to use an Entry element. This text comes from the Entry placeholder and text of the Label.";
                imageInstructions     = $"The following Image should read aloud \"{ImageName}. {ImageHelpText}\". You should be able to tap the image and hear an alert box.";
                boxInstructions       = $"The following Box should read aloud \"{BoxName}. {BoxHelpText}\". You should be able to tap the box and hear an alert box.";
                toolbarInstructions   = $"The Toolbar should have a coffee cup icon. Activating the coffee cup should read aloud \"{toolbarItemName}\". The Toolbar should also show the text \"{toolbarItem2Text}\". Activating this item should read aloud \"{toolbarItem2Text}. {toolbarItemHint2}\".";
                break;

            case Device.UWP:
            case Device.WPF:
                screenReader          = "Narrator";
                scrollFingers         = "two fingers";
                explore               = "Use three fingers to swipe up the screen to read all of the elements on this page.";
                labeledByInstructions = $"The following Entry should read aloud \"{EntryHelpText}\", plus native instructions on how to use an Entry element. This text comes from the text of the label.";
                imageInstructions     = $"The following Image should read aloud \"{ImageName}. {ImageHelpText}\". Windows does not currently support TapGestures while the Narrator is active.";
                boxInstructions       = $"The following Box should read aloud \"{BoxName}. {BoxHelpText}\". Windows does not currently support TapGestures while the Narrator is active.";
                toolbarInstructions   = $"The Toolbar should have a coffee cup icon. Activating the coffee cup should read aloud \"{toolbarItemName}\". The Toolbar should also show the text \"{toolbarItem2Text}\". Activating this item should read aloud \"{toolbarItem2Text}. {toolbarItemHint2}\".";
                break;

            case Device.macOS:
                screenReader          = "VoiceOver (CMD + F5) or Accesibility Inspector";
                labeledByInstructions = $"The following Entry should read aloud \"{EntryPlaceholder}.\", plus native instructions on how to use an Entry element. This text comes from the placeholder.";
                imageInstructions     = $"The following Image should read aloud \"{ImageName}. {ImageHelpText}\". You should be able to tap the image and hear an alert box.";
                boxInstructions       = $"The following Box should read aloud \"{BoxName}. {BoxHelpText}\". You should be able to tap the box and hear an alert box.";
                toolbarInstructions   = $"The Toolbar should have a coffee cup icon. Activating the coffee cup should read aloud \"{toolbarItemName}\". The Toolbar should also show the text \"{toolbarItem2Text}\". Activating this item should read aloud \"{toolbarItem2Text}. {toolbarItemHint2}\".";
                break;

            case Device.Tizen:
                screenReader          = "Screen reader(TTS)";
                scrollFingers         = "two fingers";
                explore               = "Use two fingers to swipe up the screen to read all of the elements on this page.";
                labeledByInstructions = $"The following Entry should read aloud \"{EntryHelpText}\", plus native instructions on how to use an Entry element. This text comes from the text of the label.";
                imageInstructions     = $"The following Image should read aloud \"{ImageName}. {ImageHelpText}\". Tizen does not currently support TapGestures while the\"{screenReader}\" is active.";
                boxInstructions       = $"Tizen does not currently support accessibility for the BoxView due to platform limitation.";
                toolbarInstructions   = $"The Toolbar should have a coffee cup icon. Activating the coffee cup should read aloud \"{toolbarItemName}\".";
                break;

            default:
                screenReader = "the native screen reader";
                break;
            }

            var instructions = new Label {
                Text = $"Please enable {screenReader}. {explore} Use {scrollFingers} to scroll the view. Tap an element once to hear the name and HelpText and native instructions. Double tap anywhere on the screen to activate the selected element. Swipe left or right with one finger to switch to the previous or next element."
            };

            Title = "Accessibility";
            NavigationPage.SetBackButtonTitle(this, Title);

            NavigationPage.SetHasBackButton(this, true);
            this.SetAutomationPropertiesName("Accessibility Gallery Page");
            this.SetAutomationPropertiesHelpText("Demonstrates accessibility settings");

            var toolbarItem = new ToolbarItem {
                IconImageSource = "coffee.png"
            };

            toolbarItem.SetAutomationPropertiesName(toolbarItemName);
            ToolbarItems.Add(toolbarItem);
            toolbarItem.Command = new Command(() => { Navigation.PushAsync(new ContentPage()); });
            var toolbarItem2 = new ToolbarItem {
                Text = toolbarItem2Text
            };

            toolbarItem2.SetAutomationPropertiesHelpText(toolbarItemHint2);
            ToolbarItems.Add(toolbarItem2);

            var toolbarInstructionsLbl = new Label {
                Text = toolbarInstructions
            };
            var instructions2 = new Label {
                Text = labeledByInstructions
            };
            var entryLabel = new Label {
                Text = EntryHelpText, VerticalOptions = LayoutOptions.Center
            };
            var entry = new Entry {
                Placeholder = EntryPlaceholder
            };

            entry.SetAutomationPropertiesLabeledBy(entryLabel);

            var entryGroup = new Grid();

            entryGroup.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Auto)
            });
            entryGroup.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            entryGroup.AddChild(entryLabel, 0, 0);
            entryGroup.AddChild(entry, 1, 0);


            var textCellA = new TextCell
            {
                Text = "A"
            };

            textCellA.SetAutomationPropertiesName("Option A");

            var textCellB = new TextCell
            {
                Text = "B"
            };

            textCellB.SetAutomationPropertiesName("Option B");

            var textCellC = new TextCell
            {
                Text = "C"
            };

            textCellC.SetAutomationPropertiesName("Option C");

            var textCellD = new TextCell
            {
                Text = "D"
            };

            textCellD.SetAutomationPropertiesName("Option D");

            TableView tbl = new TableView
            {
                Intent = TableIntent.Menu,
                Root   = new TableRoot
                {
                    new TableSection("TableView")
                    {
                        textCellA,
                        textCellB,
                        textCellC,
                        textCellD,
                    }
                }
            };


            var activityIndicator = new ActivityIndicator();

            activityIndicator.SetAutomationPropertiesName("Progress indicator");


            const string ButtonText     = "Update progress";
            const string ButtonHelpText = "Tap to start/stop the activity indicator.";
            var          instructions3  = new Label {
                Text = $"The following Button should read aloud \"{ButtonText}.\", plus native instructions on how to use a button."
            };
            var button = new Button {
                Text = ButtonText
            };

            button.SetAutomationPropertiesHelpText(ButtonHelpText);
            button.Clicked += (sender, e) =>
            {
                activityIndicator.IsRunning = !activityIndicator.IsRunning;
                activityIndicator.SetAutomationPropertiesHelpText(activityIndicator.IsRunning ? "Running." : "Not running");
            };


            var instructions4 = new Label {
                Text = imageInstructions
            };
            var image = new Image {
                Source = "photo.jpg"
            };

            // The tap gesture will NOT work on Win and Tizen
            image.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => DisplayAlert("Success", "You tapped the image", "OK"))
            });
            image.SetAutomationPropertiesName(ImageName);
            image.SetAutomationPropertiesHelpText(ImageHelpText);
            // Images are ignored by default on Tizen;
            // make accessible in order to enable the gesture and narration
            image.SetAutomationPropertiesIsInAccessibleTree(true);

            var instructions5 = new Label {
                Text = boxInstructions
            };
            var boxView = new BoxView {
                Color = Color.Purple
            };

            // The tap gesture will NOT work on Win and Tizen
            boxView.GestureRecognizers.Add(new TapGestureRecognizer {
                Command = new Command(() => DisplayAlert("Success", "You tapped the box", "OK"))
            });
            boxView.SetAutomationPropertiesName(BoxName);
            boxView.SetAutomationPropertiesHelpText(BoxHelpText);
            // BoxViews are ignored by default on Win;
            // make accessible in order to enable the gesture and narration
            boxView.SetAutomationPropertiesIsInAccessibleTree(true);


            var stack = new StackLayout
            {
                Children =
                {
                    instructions,
                    toolbarInstructionsLbl,
                    instructions2,
                    entryGroup,
                    tbl,
                    instructions3,
                    button,
                    activityIndicator,
                    instructions4,
                    image,
                    instructions5,
                    boxView,
                }
            };

            var scrollView = new ScrollView {
                Content = stack
            };

            Content = scrollView;
        }
コード例 #15
0
        public SettingsForm_Printers(SettingsForm SettingsForm, List <PrinterModel> Printers)
        {
            InitializeComponent();

            this.SettingsForm = SettingsForm;

            ToolbarItem_Add            = new ToolbarItem();
            ToolbarItem_Add.Text       = "چاپگر جدید";
            ToolbarItem_Add.Icon       = "Add.png";
            ToolbarItem_Add.Order      = ToolbarItemOrder.Primary;
            ToolbarItem_Add.Priority   = 4;
            ToolbarItem_Add.Activated += ToolbarItem_Add_Activated;

            ToolbarItem_Edit            = new ToolbarItem();
            ToolbarItem_Edit.Text       = "ویرایش";
            ToolbarItem_Edit.Icon       = "Edit.png";
            ToolbarItem_Edit.Order      = ToolbarItemOrder.Primary;
            ToolbarItem_Edit.Priority   = 3;
            ToolbarItem_Edit.Activated += ToolbarItem_Edit_Activated;

            ToolbarItem_Remove            = new ToolbarItem();
            ToolbarItem_Remove.Text       = "حذف";
            ToolbarItem_Remove.Icon       = "Delete.png";
            ToolbarItem_Remove.Order      = ToolbarItemOrder.Primary;
            ToolbarItem_Remove.Priority   = 2;
            ToolbarItem_Remove.Activated += ToolbarItem_Remove_Activated;

            ToolbarItem_Activate            = new ToolbarItem();
            ToolbarItem_Activate.Text       = "فعال";
            ToolbarItem_Activate.Icon       = "OK_W.png";
            ToolbarItem_Activate.Order      = ToolbarItemOrder.Primary;
            ToolbarItem_Activate.Priority   = 1;
            ToolbarItem_Activate.Activated += ToolbarItem_Activate_Activated;

            PrintersList.ItemTemplate  = new DataTemplate(typeof(PrinterListCell));
            PrintersList.ItemSelected += (sender, e) => {
                ((ListView)sender).SelectedItem = null;
            };
            PrintersList.ItemTapped += (sender, e) => {
                var TappedItem = (PrinterModel)e.Item;
                if (TappedItem == LastSelectedPrinter)
                {
                    LastSelectedPrinter = null;
                    TappedItem.Selected = false;

                    if (!ToolbarItems.Contains(ToolbarItem_Add))
                    {
                        ToolbarItems.Add(ToolbarItem_Add);
                    }

                    if (ToolbarItems.Contains(ToolbarItem_Edit))
                    {
                        ToolbarItems.Remove(ToolbarItem_Edit);
                    }
                    if (ToolbarItems.Contains(ToolbarItem_Remove))
                    {
                        ToolbarItems.Remove(ToolbarItem_Remove);
                    }
                    if (ToolbarItems.Contains(ToolbarItem_Activate))
                    {
                        ToolbarItems.Remove(ToolbarItem_Activate);
                    }
                }
                else
                {
                    if (LastSelectedPrinter != null)
                    {
                        LastSelectedPrinter.Selected = false;
                    }
                    LastSelectedPrinter          = TappedItem;
                    LastSelectedPrinter.Selected = true;

                    if (ToolbarItems.Contains(ToolbarItem_Add))
                    {
                        ToolbarItems.Remove(ToolbarItem_Add);
                    }

                    if (!ToolbarItems.Contains(ToolbarItem_Edit))
                    {
                        ToolbarItems.Add(ToolbarItem_Edit);
                    }
                    if (!ToolbarItems.Contains(ToolbarItem_Remove))
                    {
                        ToolbarItems.Add(ToolbarItem_Remove);
                    }
                    if (!ToolbarItems.Contains(ToolbarItem_Activate))
                    {
                        ToolbarItems.Add(ToolbarItem_Activate);
                    }
                }
            };
            PrintersList.SeparatorColor = Color.FromHex("A5ABB7");
            PrintersList.HasUnevenRows  = true;

            RefreshPrintersList();
        }
コード例 #16
0
        public AddFoodPage() : base(PageTitleConstants.AddFoodPage)
        {
            MediaService.NoCameraFound     += HandleNoCameraFound;
            ViewModel.UploadPhotoCompleted += HandleUploadPhotoCompleted;
            ViewModel.UploadPhotoFailed    += HandleUploadPhotoFailed;

            _takePhotoButton = new HealthClinicButton
            {
                Text = "Take Photo",
            };
            _takePhotoButton.SetBinding(Button.CommandProperty, nameof(ViewModel.TakePhotoCommand));
            _takePhotoButton.SetBinding(IsEnabledProperty, new Binding(nameof(ViewModel.IsPhotoUploading), BindingMode.Default, new InverseBooleanConverter(), ViewModel.IsPhotoUploading));

            _photoImage = new Image();
            _photoImage.SetBinding(Image.SourceProperty, nameof(ViewModel.PhotoImageSource));

            _uploadToolbarItem = new ToolbarItem
            {
                Text         = "Upload",
                Priority     = 0,
                AutomationId = AutomationIdConstants.AddFoodPage_UploadButton,
            };
            _uploadToolbarItem.SetBinding(MenuItem.CommandProperty, nameof(ViewModel.UploadButtonCommand));
            ToolbarItems.Add(_uploadToolbarItem);

            _cancelToolbarItem = new ToolbarItem
            {
                Text         = "Cancel",
                Priority     = 1,
                AutomationId = AutomationIdConstants.AddFoodPage_CancelButton
            };
            _cancelToolbarItem.Clicked += HandleCancelToolbarItemClicked;

            ToolbarItems.Add(_cancelToolbarItem);

            var activityIndicator = new ActivityIndicator
            {
                Color        = ColorConstants.Maroon,
                AutomationId = AutomationIdConstants.AddFoodPage_ActivityIndicator
            };

            activityIndicator.SetBinding(IsVisibleProperty, nameof(ViewModel.IsPhotoUploading));
            activityIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(ViewModel.IsPhotoUploading));

            Padding = new Thickness(20);

            var stackLayout = new StackLayout
            {
                Spacing = 20,

                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.FillAndExpand,

                Children =
                {
                    _photoImage,
                    _takePhotoButton,
                    activityIndicator
                }
            };

            Content = new ScrollView {
                Content = stackLayout
            };
        }
コード例 #17
0
ファイル: PendingScriptsPage.cs プロジェクト: jirlong/sensus
        public PendingScriptsPage()
        {
            Title = "Pending Surveys";

            ListView scriptList = new ListView(ListViewCachingStrategy.RecycleElement)
            {
                BindingContext = SensusServiceHelper.Get().ScriptsToRun  // used to show/hid when there are no surveys
            };

            scriptList.SetBinding(IsVisibleProperty, new Binding("Count", converter: new ViewVisibleValueConverter(), converterParameter: false));  // don't show list when there are no surveys
            scriptList.ItemTemplate = new DataTemplate(typeof(PendingScriptTextCell));
            scriptList.ItemTemplate.SetBinding(TextCell.TextProperty, nameof(Script.Caption));
            scriptList.ItemTemplate.SetBinding(TextCell.DetailProperty, nameof(Script.SubCaption));
            scriptList.ItemsSource = SensusServiceHelper.Get().ScriptsToRun;
            scriptList.ItemTapped += (o, e) =>
            {
                if (scriptList.SelectedItem == null)
                {
                    return;
                }

                Script selectedScript = scriptList.SelectedItem as Script;

                selectedScript.Submitting = true;

                SensusServiceHelper.Get().PromptForInputsAsync(selectedScript.RunTime,
                                                               selectedScript.InputGroups,
                                                               null,
                                                               selectedScript.Runner.AllowCancel,
                                                               null,
                                                               null,
                                                               selectedScript.Runner.IncompleteSubmissionConfirmation,
                                                               "Are you ready to submit your responses?",
                                                               selectedScript.Runner.DisplayProgress,
                                                               null,
                                                               inputGroups =>
                {
                    bool canceled = inputGroups == null;

                    // process all inputs in the script
                    foreach (InputGroup inputGroup in selectedScript.InputGroups)
                    {
                        foreach (Input input in inputGroup.Inputs)
                        {
                            // only consider inputs that still need to be stored. if an input has already been stored, it should be ignored.
                            if (input.NeedsToBeStored)
                            {
                                // if the user canceled the prompts, reset the input. we reset here within the above if-check because if an
                                // input has already been stored we should not reset it. its value and read-only status are fixed for all
                                // time, even if the prompts are later redisplayed by the invalid script handler.
                                if (canceled)
                                {
                                    input.Reset();
                                }
                                else if (input.Valid && input.Display)  // store all inputs that are valid and displayed. some might be valid from previous responses but not displayed because the user navigated back through the survey and changed a previous response that caused a subsesequently displayed input to be hidden via display contingencies.
                                {
                                    // the _script.Id allows us to link the data to the script that the user created. it never changes. on the other hand, the script
                                    // that is passed into this method is always a copy of the user-created script. the script.Id allows us to link the various data
                                    // collected from the user into a single logical response. each run of the script has its own script.Id so that responses can be
                                    // grouped across runs. this is the difference between scriptId and runId in the following line.
                                    selectedScript.Runner.Probe.StoreDatum(new ScriptDatum(input.CompletionTimestamp.GetValueOrDefault(DateTimeOffset.UtcNow), selectedScript.Runner.Script.Id, selectedScript.Runner.Name, input.GroupId, input.Id, selectedScript.Id, input.Value, selectedScript.CurrentDatum?.Id, input.Latitude, input.Longitude, input.LocationUpdateTimestamp, selectedScript.RunTime.Value, input.CompletionRecords, input.SubmissionTimestamp.Value), default(CancellationToken));

                                    // once inputs are stored, they should not be stored again, nor should the user be able to modify them if the script is viewed again.
                                    input.NeedsToBeStored = false;
                                    SensusContext.Current.MainThreadSynchronizer.ExecuteThreadSafe(() => input.Enabled = false);
                                }
                            }
                        }
                    }

                    if (selectedScript.Valid)
                    {
                        // add completion time and remove all completion times before the participation horizon
                        lock (selectedScript.Runner.CompletionTimes)
                        {
                            selectedScript.Runner.CompletionTimes.Add(DateTime.Now);
                            selectedScript.Runner.CompletionTimes.RemoveAll(completionTime => completionTime < selectedScript.Runner.Probe.Protocol.ParticipationHorizon);
                        }
                    }

                    selectedScript.Submitting = false;

                    if (!canceled)
                    {
                        SensusServiceHelper.Get().RemoveScript(selectedScript);
                    }

                    SensusServiceHelper.Get().Logger.Log("\"" + selectedScript.Runner.Name + "\" has finished running.", LoggingLevel.Normal, typeof(Script));
                });
            };

            // display an informative message when there are no surveys
            Label noSurveysLabel = new Label
            {
                Text              = "You have no pending surveys.",
                TextColor         = Color.Accent,
                FontSize          = 20,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center,
                BindingContext    = SensusServiceHelper.Get().ScriptsToRun
            };

            noSurveysLabel.SetBinding(IsVisibleProperty, new Binding("Count", converter: new ViewVisibleValueConverter(), converterParameter: true));

            // create grid showing surveys
            Grid contentGrid = new Grid
            {
                RowDefinitions = { new RowDefinition {
                                       Height = new GridLength(1, GridUnitType.Star)
                                   } },
                ColumnDefinitions = { new ColumnDefinition {
                                          Width = new GridLength(1, GridUnitType.Star)
                                      } },
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            contentGrid.Children.Add(noSurveysLabel, 0, 0);
            contentGrid.Children.Add(scriptList, 0, 0);

            Content = contentGrid;

            ToolbarItems.Add(new ToolbarItem("Clear", null, async() =>
            {
                if (await DisplayAlert("Clear all surveys?", "This action cannot be undone.", "Clear", "Cancel"))
                {
                    SensusServiceHelper.Get().ClearScripts();
                }
            }));

            // use timer to update available surveys
            System.Timers.Timer filterTimer = new System.Timers.Timer(1000);

            filterTimer.Elapsed += (sender, e) =>
            {
                SensusServiceHelper.Get().RemoveExpiredScripts(true);
            };

            Appearing += (sender, e) =>
            {
                filterTimer.Start();
            };

            Disappearing += (sender, e) =>
            {
                filterTimer.Stop();
            };
        }
コード例 #18
0
        private void Init()
        {
            var padding = Device.OnPlatform(
                iOS: new Thickness(15, 20),
                Android: new Thickness(15, 8),
                WinPhone: new Thickness(15, 20));

            EmailCell = new FormEntryCell(AppResources.EmailAddress, entryKeyboard: Keyboard.Email,
                                          useLabelAsPlaceholder: true, imageSource: "envelope", containerPadding: padding);

            EmailCell.Entry.ReturnType = Enums.ReturnType.Go;
            EmailCell.Entry.Completed += Entry_Completed;

            var table = new ExtendedTableView
            {
                Intent          = TableIntent.Settings,
                EnableScrolling = false,
                HasUnevenRows   = true,
                EnableSelection = true,
                NoFooter        = true,
                VerticalOptions = LayoutOptions.Start,
                Root            = new TableRoot
                {
                    new TableSection()
                    {
                        EmailCell
                    }
                }
            };

            var hintLabel = new Label
            {
                Text          = AppResources.EnterEmailForHint,
                LineBreakMode = LineBreakMode.WordWrap,
                FontSize      = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                Style         = (Style)Application.Current.Resources["text-muted"],
                Margin        = new Thickness(15, (this.IsLandscape() ? 5 : 0), 15, 25)
            };

            var layout = new StackLayout
            {
                Children = { table, hintLabel },
                Spacing  = 0
            };

            var scrollView = new ScrollView {
                Content = layout
            };

            if (Device.OS == TargetPlatform.iOS)
            {
                table.RowHeight          = -1;
                table.EstimatedRowHeight = 70;
            }

            var submitToolbarItem = new ToolbarItem(AppResources.Submit, null, async() =>
            {
                await SubmitAsync();
            }, ToolbarItemOrder.Default, 0);

            ToolbarItems.Add(submitToolbarItem);
            Title   = AppResources.PasswordHint;
            Content = scrollView;
        }
コード例 #19
0
        /// <summary>
        /// Record Answer screen constructor
        /// </summary>
        /// <param name="selectedQuestion"></param>
        public RecordAnswer(object selectedQuestion)
        {
            InitializeComponent();

            var question = (Question)selectedQuestion;

            NavigationPage.SetBackButtonTitle(this, string.Empty);

            BindingContext            = _viewModel = new RecordAnswerViewModel(this);
            _viewModel.Subtitle       = question.QuestionName;
            _viewModel.RecordResponse = question;

            switch (question.QuestionType)
            {
            case (short)QuestionType.NumericAnswer:
                _viewModel.IsNumeric = true;
                _viewModel.IsYesNo   = false;
                break;

            case (short)QuestionType.YesOrNo:
                _viewModel.IsYesNo   = true;
                _viewModel.IsNumeric = false;
                _viewModel.Answer    = HACCPUtil.GetResourceString("Yes");
                break;
            }
            correctiveActionList.ItemSelected += (sender, e) =>
            {
                if (correctiveActionList.SelectedItem == null)
                {
                    return;
                }
                var correctiveAction = ((CorrectiveAction)e.SelectedItem).CorrActionName;

                if (!string.IsNullOrEmpty(_viewModel.Answer))
                {
                    if ((_viewModel.IsYesNo && _viewModel.Answer == HACCPUtil.GetResourceString("No")) ||
                        (!_viewModel.IsYesNo &&
                         (HACCPUtil.ConvertToDouble(_viewModel.Answer) <
                          HACCPUtil.ConvertToDouble(_viewModel.RecordResponse.Min) ||
                          HACCPUtil.ConvertToDouble(_viewModel.Answer) >
                          HACCPUtil.ConvertToDouble(_viewModel.RecordResponse.Max))))
                    {
                        if (correctiveAction != HACCPUtil.GetResourceString("None"))
                        {
                            _viewModel.SelectedCorrectiveAction  = correctiveAction;
                            _viewModel.IsCorrctiveOptionsVisible = false;
                        }
                    }
                    else
                    {
                        _viewModel.SelectedCorrectiveAction  = correctiveAction;
                        _viewModel.IsCorrctiveOptionsVisible = false;
                    }
                }
                else
                {
                    _viewModel.SelectedCorrectiveAction  = correctiveAction;
                    _viewModel.IsCorrctiveOptionsVisible = false;
                }
                correctiveActionList.SelectedItem = null;
            };

            actionBtn.Clicked += (sender, e) => { numericValueEntry.Unfocus(); };

            toggleBtn.Clicked += (sender, e) =>
            {
                if (_viewModel.IsNumeric)
                {
                    if (numericValueEntry.IsFocused)
                    {
                        numericValueEntry.Unfocus();
                    }
                    else
                    {
                        numericValueEntry.Focus();
                    }
                }
            };
            if (HaccpAppSettings.SharedInstance.IsWindows)
            {
                ToolbarItems.Add(new ToolbarItem
                {
                    Icon    = "logout.png",
                    Order   = ToolbarItemOrder.Primary,
                    Command = _viewModel.LogInCommand
                });
            }
        }
コード例 #20
0
        public MapPage(MapViewModel <T> viewModel)
        {
            BindingContext = viewModel;

            this.SetBinding(Page.TitleProperty, "Title");
            this.SetBinding(Page.IconProperty, "Icon");

            var map   = MakeMap();
            var stack = new StackLayout {
                Spacing = 0
            };

#if __ANDROID__ || __IOS__
            var searchAddress = new SearchBar {
                Placeholder = "Search Address", BackgroundColor = Xamarin.Forms.Color.White
            };

            searchAddress.SearchButtonPressed += async(e, a) =>
            {
                var addressQuery = searchAddress.Text;
                searchAddress.Text = "";
                searchAddress.Unfocus();

                var positions = (await(new Geocoder()).GetPositionsForAddressAsync(addressQuery)).ToList();
                if (!positions.Any())
                {
                    return;
                }

                var position = positions.First();
                map.MoveToRegion(MapSpan.FromCenterAndRadius(position,
                                                             Distance.FromMiles(0.1)));
                map.Pins.Add(new Pin
                {
                    Label    = addressQuery,
                    Position = position,
                    Address  = addressQuery
                });
            };

            stack.Children.Add(searchAddress);
#elif WINDOWS_PHONE
            ToolbarItems.Add(new ToolbarItem("filter", "filter.png", async() =>
            {
                var page   = new ContentPage();
                var result = await page.DisplayAlert("Title", "Message", "Accept", "Cancel");
                Debug.WriteLine("success: {0}", result);
            }));

            ToolbarItems.Add(new ToolbarItem("search", "search.png", () =>
            {
            }));
#endif

            map.VerticalOptions = LayoutOptions.FillAndExpand;
            map.HeightRequest   = 100;
            map.WidthRequest    = 960;

            stack.Children.Add(map);
            Content = stack;
        }
コード例 #21
0
        public void Init()
        {
            // Not Started

            var notStartedLabel = new Label
            {
                Text                    = "Get instant access to your passwords!",
                VerticalOptions         = LayoutOptions.Start,
                HorizontalOptions       = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                LineBreakMode           = LineBreakMode.WordWrap,
                FontSize                = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };

            var notStartedSublabel = new Label
            {
                Text                    = "To turn on bitwarden in Safari and other apps, tap the \"more\" icon on the bottom row of the menu.",
                VerticalOptions         = LayoutOptions.Start,
                HorizontalOptions       = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                LineBreakMode           = LineBreakMode.WordWrap
            };

            var notStartedImage = new Image
            {
                Source            = "ext-more",
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.Center,
                Margin            = new Thickness(0, -10, 0, 0)
            };

            var notStartedButton = new ExtendedButton
            {
                Text              = "Enable App Extension",
                Command           = new Command(() => ShowExtension("NotStartedEnable")),
                VerticalOptions   = LayoutOptions.End,
                HorizontalOptions = LayoutOptions.Fill,
                Style             = (Style)Application.Current.Resources["btn-primary"]
            };

            var notStartedStackLayout = new StackLayout
            {
                Orientation     = StackOrientation.Vertical,
                Spacing         = 20,
                Padding         = new Thickness(20, 20, 20, 30),
                Children        = { notStartedLabel, notStartedSublabel, notStartedImage, notStartedButton },
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            notStartedStackLayout.SetBinding <AppExtensionPageModel>(IsVisibleProperty, m => m.NotStarted);

            // Not Activated

            var notActivatedLabel = new Label
            {
                Text                    = "Almost done!",
                VerticalOptions         = LayoutOptions.Start,
                HorizontalOptions       = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                LineBreakMode           = LineBreakMode.WordWrap,
                FontSize                = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };

            var notActivatedSublabel = new Label
            {
                Text                    = "Tap the bitwarden icon in the menu to launch the extension.",
                VerticalOptions         = LayoutOptions.Start,
                HorizontalOptions       = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                LineBreakMode           = LineBreakMode.WordWrap
            };

            var notActivatedImage = new Image
            {
                Source            = "ext-act",
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.Center,
                Margin            = new Thickness(0, -10, 0, 0)
            };

            var notActivatedButton = new ExtendedButton
            {
                Text              = "Enable App Extension",
                Command           = new Command(() => ShowExtension("NotActivatedEnable")),
                VerticalOptions   = LayoutOptions.End,
                HorizontalOptions = LayoutOptions.Fill,
                Style             = (Style)Application.Current.Resources["btn-primary"]
            };

            var notActivatedStackLayout = new StackLayout
            {
                Orientation     = StackOrientation.Vertical,
                Spacing         = 20,
                Padding         = new Thickness(20, 20, 20, 30),
                Children        = { notActivatedLabel, notActivatedSublabel, notActivatedImage, notActivatedButton },
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            notActivatedStackLayout.SetBinding <AppExtensionPageModel>(IsVisibleProperty, m => m.StartedAndNotActivated);

            // Activated

            var activatedLabel = new Label
            {
                Text                    = "You're ready to log in!",
                VerticalOptions         = LayoutOptions.Start,
                HorizontalOptions       = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                LineBreakMode           = LineBreakMode.WordWrap,
                FontSize                = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };

            var activatedSublabel = new Label
            {
                Text                    = "In Safari, find bitwarden using the share icon (hint: scroll to the right on the bottom row of the menu).",
                VerticalOptions         = LayoutOptions.Start,
                HorizontalOptions       = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                LineBreakMode           = LineBreakMode.WordWrap,
                Margin                  = new Thickness(0, 10, 0, 0)
            };

            var activatedImage = new Image
            {
                Source            = "ext-use",
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.Center,
                Margin            = new Thickness(0, -10, 0, 0)
            };

            var activatedButton = new ExtendedButton
            {
                Text    = "See Supported Apps",
                Command = new Command(() =>
                {
                    _googleAnalyticsService.TrackAppEvent("SeeSupportedApps");
                    Device.OpenUri(new Uri("https://bitwarden.com/ios/"));
                }),
                VerticalOptions   = LayoutOptions.End,
                HorizontalOptions = LayoutOptions.Fill,
                Style             = (Style)Application.Current.Resources["btn-primary"]
            };

            var activatedButtonReenable = new ExtendedButton
            {
                Text              = "Re-enable App Extension",
                Command           = new Command(() => ShowExtension("Re-enable")),
                VerticalOptions   = LayoutOptions.End,
                HorizontalOptions = LayoutOptions.Fill,
                Style             = (Style)Application.Current.Resources["btn-primaryAccent"]
            };

            var activatedStackLayout = new StackLayout
            {
                Orientation     = StackOrientation.Vertical,
                Spacing         = 10,
                Padding         = new Thickness(20, 20, 20, 30),
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children        = { activatedLabel, activatedSublabel, activatedImage, activatedButton, activatedButtonReenable }
            };

            activatedStackLayout.SetBinding <AppExtensionPageModel>(IsVisibleProperty, m => m.StartedAndActivated);

            var stackLayout = new StackLayout
            {
                Children        = { notStartedStackLayout, notActivatedStackLayout, activatedStackLayout },
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            if (Device.OS == TargetPlatform.iOS)
            {
                ToolbarItems.Add(new DismissModalToolBarItem(this, "Close"));
            }

            Title   = "App Extension";
            Content = new ScrollView {
                Content = stackLayout
            };
            BindingContext = Model;
        }
コード例 #22
0
        private void Init()
        {
            SearchItem = new SearchToolBarItem(this);
            ToolbarItems.Add(SearchItem);

            ListView = new ExtendedListView(ListViewCachingStrategy.RecycleElement)
            {
                IsGroupingEnabled   = true,
                ItemsSource         = PresentationSections,
                HasUnevenRows       = true,
                GroupHeaderTemplate = new DataTemplate(() => new SectionHeaderViewCell(
                                                           nameof(Section <Grouping> .Name), nameof(Section <Grouping> .Count), new Thickness(16, 12))),
                ItemTemplate = new GroupingOrCipherDataTemplateSelector(this)
            };

            if (Device.RuntimePlatform == Device.iOS)
            {
                ListView.RowHeight = -1;
            }

            var noDataLabel = new Label
            {
                Text = AppResources.NoItems,
                HorizontalTextAlignment = TextAlignment.Center,
                FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                Style    = (Style)Application.Current.Resources["text-muted"]
            };

            var addCipherButton = new ExtendedButton
            {
                Text    = AppResources.AddAnItem,
                Command = new Command(() => Helpers.AddCipher(this, null)),
                Style   = (Style)Application.Current.Resources["btn-primaryAccent"]
            };

            NoDataStackLayout = new StackLayout
            {
                Children        = { noDataLabel, addCipherButton },
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Padding         = new Thickness(20, 0),
                Spacing         = 20
            };

            LoadingIndicator = new ActivityIndicator
            {
                IsRunning = true
            };

            if (Device.RuntimePlatform != Device.UWP)
            {
                LoadingIndicator.VerticalOptions   = LayoutOptions.CenterAndExpand;
                LoadingIndicator.HorizontalOptions = LayoutOptions.Center;
            }

            ContentView = new ContentView
            {
                Content = LoadingIndicator
            };

            var fabLayout = new FabLayout(ContentView);

            if (Device.RuntimePlatform == Device.Android)
            {
                Fab = new Fab(fabLayout, "plus.png", (sender, args) => Helpers.AddCipher(this, null));
                ListView.BottomPadding = 170;
            }
            else
            {
                AddCipherItem = new AddCipherToolBarItem(this, null);
                ToolbarItems.Add(AddCipherItem);
            }

            Content = fabLayout;
            Title   = AppResources.MyVault;
        }
コード例 #23
0
        void _Update()
        {
            if (MainThread.IsMainThread == false)
            {
                MainThread.BeginInvokeOnMainThread(() =>
                {
                    _Update();
                });
                return;
            }

            if (App.Instance.Player.SupportsSnapclient() == false)
            {
                if (ToolbarItems.Contains(tbPlay))
                {
                    ToolbarItems.Remove(tbPlay); // remove "Play" button for platforms that don't support it
                }
            }

            tbPlay.IsEnabled = m_Client != null && m_Client.IsConnected() && m_Client.ServerData != null;
            tbPlay.Text      = App.Instance.Player.IsPlaying() == false ? "Play" : "Stop";

            _ClearConnectionFailureLabel();

            Groups.Children.Clear();

            if (m_Client != null && m_Client.IsConnected() && m_Client.ServerData != null)
            {
                foreach (Group g in m_Client.ServerData.groups)
                {
                    Controls.Group cGroup = new Controls.Group(m_Client, g);
                    Groups.Children.Add(cGroup);
                }
            }

            try
            {
                GroupsRefreshView.IsRefreshing = m_Client.IsConnected() == false &&
                                                 m_Client?.ConnectionFailed == false;
            }
            catch (Exception e)
            {
                Debug.WriteLine("Exc: " + e.Message);
            }

            if (m_Client?.ConnectionFailed == true)
            {
                if (m_ConnectionFailedLabel == null)
                {
                    m_ConnectionFailedLabel = new Label();
                }

                m_ConnectionFailedLabel.HorizontalTextAlignment = TextAlignment.Center;
                m_ConnectionFailedLabel.Margin = new Thickness(40);
                if (string.IsNullOrWhiteSpace(SnapSettings.Server))
                {
                    m_ConnectionFailedLabel.Text = "This app requires Snapserver to be installed and running on your local network.\n" +
                                                   "Fill in the address to your server via\nMenu -> Settings.\n\n" +
                                                   "For more information, visit:\n\nhttps://github.com/badaix/snapcast\nand\nhttps://github.com/stijnvdb88/snap.net";
                }
                else
                {
                    m_ConnectionFailedLabel.Text = $"Couldn't connect to snapserver at {SnapSettings.Server}:{SnapSettings.ControlPort}";
                }
                m_ConnectionFailedLabel.HorizontalOptions = LayoutOptions.CenterAndExpand;
                m_ConnectionFailedLabel.VerticalOptions   = LayoutOptions.CenterAndExpand;
                Groups.Children.Add(m_ConnectionFailedLabel);
            }
            else
            {
                _ClearConnectionFailureLabel();
            }
        }
コード例 #24
0
        public WalletPage()
        {
            var newToken = new ToolbarItem
            {
                Text = "Add	Token"
            };

            newToken.SetBinding(ToolbarItem.CommandProperty, "CreateNewToken");

            ToolbarItems.Add(newToken);
            //	Declare	and	initialize	our	Model	Binding	Context
            BindingContext = new WalletViewModel(DependencyService.Get <IChikwamaNavService>());


            var tokensList = new ListView

            {
                HasUnevenRows  = true,
                ItemTemplate   = new DataTemplate(typeof(ChikwamaCellDataTemplate)),
                SeparatorColor = Color.FromHex("#ddd"),
            };

            //	Set	the	Binding	property for	our tokens
            tokensList.SetBinding(ItemsView <Cell> .ItemsSourceProperty, "tokens");
            tokensList.SetBinding(ItemsView <Cell> .IsVisibleProperty, "IsProcessBusy", converter: new BooleanConverter());

            //	Set	up	our	event	handler
            tokensList.ItemTapped += (object sender, ItemTappedEventArgs e) =>
            {
                var item = (WalletModel)e.Item;
                if (item == null)
                {
                    return;
                }
                _viewModel.ChikwamaTokenDetails.Execute(item);
                item = null;
            };
            Content = tokensList;

            // Declare our Progress Label
            var progressLabel = new Label()
            {
                FontSize                = 14,
                FontAttributes          = FontAttributes.Bold,
                TextColor               = Color.Black,
                HorizontalTextAlignment = TextAlignment.Center,
                Text = "Loading Chikwama Tokens..."
            };

            // Apply PlatformEffects to our Progress Label
            progressLabel.Effects.Add(Effect.Resolve("com.geniesoftstudios.LabelShadowEffect"));

            // Instantiate and initialise our Activity Indicator.
            var activityIndicator = new ActivityIndicator()
            {
                IsRunning = true
            };
            var progressIndicator = new StackLayout
            {
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                Children          =
                {
                    activityIndicator, progressLabel
                }
            };

            progressIndicator.SetBinding(StackLayout.IsVisibleProperty, "IsProcessBusy");



            // Set the Binding property for our walks Entries
            tokensList.SetBinding(ItemsView <Cell> .IsVisibleProperty, "IsProcessBusy", converter: new BooleanConverter());



            var mainLayout = new StackLayout
            {
                Children =
                {
                    tokensList,
                    progressIndicator
                }
            };

            Content = mainLayout;
        }
コード例 #25
0
ファイル: AddEditPage.xaml.cs プロジェクト: jamesalfei/mobile
        public AddEditPage(
            string cipherId       = null,
            CipherType?type       = null,
            string folderId       = null,
            string collectionId   = null,
            string name           = null,
            string uri            = null,
            bool fromAutofill     = false,
            AppOptions appOptions = null,
            bool cloneMode        = false,
            ViewPage viewPage     = null)
        {
            _storageService       = ServiceContainer.Resolve <IStorageService>("storageService");
            _deviceActionService  = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService");
            _appOptions           = appOptions;
            _fromAutofill         = fromAutofill;
            FromAutofillFramework = _appOptions?.FromAutofillFramework ?? false;
            InitializeComponent();
            _vm               = BindingContext as AddEditPageViewModel;
            _vm.Page          = this;
            _vm.CipherId      = cipherId;
            _vm.FolderId      = folderId == "none" ? null : folderId;
            _vm.CollectionIds = collectionId != null ? new HashSet <string>(new List <string> {
                collectionId
            }) : null;
            _vm.Type        = type;
            _vm.DefaultName = name ?? appOptions?.SaveName;
            _vm.DefaultUri  = uri ?? appOptions?.Uri;
            _vm.CloneMode   = cloneMode;
            _vm.ViewPage    = viewPage;
            _vm.Init();
            SetActivityIndicator();
            if (_vm.EditMode && !_vm.CloneMode && Device.RuntimePlatform == Device.Android)
            {
                ToolbarItems.Add(_attachmentsItem);
                ToolbarItems.Add(_deleteItem);
            }
            if (Device.RuntimePlatform == Device.iOS)
            {
                ToolbarItems.Add(_closeItem);
                if (_vm.EditMode && !_vm.CloneMode)
                {
                    ToolbarItems.Add(_moreItem);
                }
                _vm.ShowNotesSeparator = true;

                _typePicker.On <iOS>().SetUpdateMode(UpdateMode.WhenFinished);
                _ownershipPicker.On <iOS>().SetUpdateMode(UpdateMode.WhenFinished);
            }

            _typePicker.ItemDisplayBinding          = new Binding("Key");
            _cardBrandPicker.ItemDisplayBinding     = new Binding("Key");
            _cardExpMonthPicker.ItemDisplayBinding  = new Binding("Key");
            _identityTitlePicker.ItemDisplayBinding = new Binding("Key");
            _folderPicker.ItemDisplayBinding        = new Binding("Key");
            _ownershipPicker.ItemDisplayBinding     = new Binding("Key");

            _loginPasswordEntry.Keyboard = Keyboard.Create(KeyboardFlags.None);

            _nameEntry.ReturnType    = ReturnType.Next;
            _nameEntry.ReturnCommand = new Command(() =>
            {
                if (_vm.Cipher.Type == CipherType.Login)
                {
                    _loginUsernameEntry.Focus();
                }
                else if (_vm.Cipher.Type == CipherType.Card)
                {
                    _cardholderNameEntry.Focus();
                }
            });

            _loginUsernameEntry.ReturnType    = ReturnType.Next;
            _loginUsernameEntry.ReturnCommand = new Command(() => _loginPasswordEntry.Focus());
            _loginPasswordEntry.ReturnType    = ReturnType.Next;
            _loginPasswordEntry.ReturnCommand = new Command(() => _loginTotpEntry.Focus());

            _cardholderNameEntry.ReturnType    = ReturnType.Next;
            _cardholderNameEntry.ReturnCommand = new Command(() => _cardNumberEntry.Focus());
            _cardExpYearEntry.ReturnType       = ReturnType.Next;
            _cardExpYearEntry.ReturnCommand    = new Command(() => _cardCodeEntry.Focus());

            _identityFirstNameEntry.ReturnType         = ReturnType.Next;
            _identityFirstNameEntry.ReturnCommand      = new Command(() => _identityMiddleNameEntry.Focus());
            _identityMiddleNameEntry.ReturnType        = ReturnType.Next;
            _identityMiddleNameEntry.ReturnCommand     = new Command(() => _identityLastNameEntry.Focus());
            _identityLastNameEntry.ReturnType          = ReturnType.Next;
            _identityLastNameEntry.ReturnCommand       = new Command(() => _identityUsernameEntry.Focus());
            _identityUsernameEntry.ReturnType          = ReturnType.Next;
            _identityUsernameEntry.ReturnCommand       = new Command(() => _identityCompanyEntry.Focus());
            _identityCompanyEntry.ReturnType           = ReturnType.Next;
            _identityCompanyEntry.ReturnCommand        = new Command(() => _identitySsnEntry.Focus());
            _identitySsnEntry.ReturnType               = ReturnType.Next;
            _identitySsnEntry.ReturnCommand            = new Command(() => _identityPassportNumberEntry.Focus());
            _identityPassportNumberEntry.ReturnType    = ReturnType.Next;
            _identityPassportNumberEntry.ReturnCommand = new Command(() => _identityLicenseNumberEntry.Focus());
            _identityLicenseNumberEntry.ReturnType     = ReturnType.Next;
            _identityLicenseNumberEntry.ReturnCommand  = new Command(() => _identityEmailEntry.Focus());
            _identityEmailEntry.ReturnType             = ReturnType.Next;
            _identityEmailEntry.ReturnCommand          = new Command(() => _identityPhoneEntry.Focus());
            _identityPhoneEntry.ReturnType             = ReturnType.Next;
            _identityPhoneEntry.ReturnCommand          = new Command(() => _identityAddress1Entry.Focus());
            _identityAddress1Entry.ReturnType          = ReturnType.Next;
            _identityAddress1Entry.ReturnCommand       = new Command(() => _identityAddress2Entry.Focus());
            _identityAddress2Entry.ReturnType          = ReturnType.Next;
            _identityAddress2Entry.ReturnCommand       = new Command(() => _identityAddress3Entry.Focus());
            _identityAddress3Entry.ReturnType          = ReturnType.Next;
            _identityAddress3Entry.ReturnCommand       = new Command(() => _identityCityEntry.Focus());
            _identityCityEntry.ReturnType              = ReturnType.Next;
            _identityCityEntry.ReturnCommand           = new Command(() => _identityStateEntry.Focus());
            _identityStateEntry.ReturnType             = ReturnType.Next;
            _identityStateEntry.ReturnCommand          = new Command(() => _identityPostalCodeEntry.Focus());
            _identityPostalCodeEntry.ReturnType        = ReturnType.Next;
            _identityPostalCodeEntry.ReturnCommand     = new Command(() => _identityCountryEntry.Focus());
        }
コード例 #26
0
        public HomePage()
        {
            // Define command for the items in the TableView.

            ToolbarItems.Add(new ToolbarItem("", "five.png", () => System.Diagnostics.Debug.WriteLine("Tool Bar Item clicked")));

            var navigateCommand =
                new Command <Type>(async(Type pageType) =>
            {
                var page = (Page)Activator.CreateInstance(pageType);
                await this.Navigation.PushAsync(page);
                //await this.Navigation.PushModalAsync(page);  // PushModalAsync will cause popups not to work
            });

            this.Title   = "Forms Gallery";
            this.Content = new TableView
            {
                Intent = TableIntent.Menu,

                Root = new TableRoot {
                    new TableSection("User Pages")
                    {
                        new TextCell {
                            Text             = "User Pages",
                            Command          = navigateCommand,
                            CommandParameter = typeof(UserPagesHomePage)
                        },
                        new TextCell {
                            Text             = "Detailed Gesture Test Page",
                            Command          = navigateCommand,
                            CommandParameter = typeof(VariableWidthButtonPage)
                        },
                        new TextCell {
                            Text             = "Detailed Gesture Test Master Detail Page A",
                            Command          = navigateCommand,
                            CommandParameter = typeof(VariableWidthButtonMasterDetailPageA)
                        },
                        new TextCell {
                            Text             = "Detailed Gesture Test Master Detail Page B",
                            Command          = navigateCommand,
                            CommandParameter = typeof(VariableWidthButtonMasterDetailPageB)
                        },
                        new TextCell {
                            Text             = "Gestures Test Page",
                            Command          = navigateCommand,
                            CommandParameter = typeof(GestureTestPage)
                        },
                    },

                    new TableSection("XAML")
                    {
                        new TextCell {
                            Text             = "GridPage",
                            Command          = navigateCommand,
                            CommandParameter = typeof(GridPage)
                        },


                        new TextCell {
                            Text             = "XamlCDATA",
                            Command          = navigateCommand,
                            CommandParameter = typeof(XamlCDATA)
                        },

                        new TextCell {
                            Text             = "XamlContentViewDemoPage",
                            Command          = navigateCommand,
                            CommandParameter = typeof(XamlContentViewDemoPage)
                        },

                        new TextCell {
                            Text             = "XamlFrameDemoPage",
                            Command          = navigateCommand,
                            CommandParameter = typeof(XamlFrameDemoPage)
                        },

                        new TextCell {
                            Text             = "XamlSingleStateButton",
                            Command          = navigateCommand,
                            CommandParameter = typeof(XamlSingleStateButtonPage)
                        },

                        new TextCell {
                            Text             = "XamlStateButtonsPage",
                            Command          = navigateCommand,
                            CommandParameter = typeof(XamlStateButtonsPage)
                        },

                        new TextCell {
                            Text             = "XamlSegmentedControlPage ",
                            Command          = navigateCommand,
                            CommandParameter = typeof(XamlSegmentedControlPage)
                        },

                        new TextCell {
                            Text             = "XamlImagesPage",
                            Command          = navigateCommand,
                            CommandParameter = typeof(XamlImagesPage)
                        },

                        new TextCell {
                            Text             = "XamlHtmlLabelsAndButtonsPage",
                            Command          = navigateCommand,
                            CommandParameter = typeof(XamlHtmlLabelsAndButtonsPage)
                        },

                        new TextCell {
                            Text             = "XamlCapsInsetPage",
                            Command          = navigateCommand,
                            CommandParameter = typeof(XamlCapsInsetPage)
                        },
                    },

                    new TableSection("Code")
                    {
                        new TextCell
                        {
                            Text             = "Print HTML or Share/Copy as PNG/PDF",
                            Command          = navigateCommand,
                            CommandParameter = typeof(PngFromHtmlPage)
                        },

                        new TextCell {
                            Text             = "Flyout Popup Demo",
                            Command          = navigateCommand,
                            CommandParameter = typeof(FlyoutDemo)
                        },

                        new TextCell {
                            Text             = "Picker in Popup",
                            Command          = navigateCommand,
                            CommandParameter = typeof(PickerInPopup)
                        },

                        new TextCell {
                            Text             = "ListView Sandbox",
                            Command          = navigateCommand,
                            CommandParameter = typeof(ListViewSandbox)
                        },

                        new TextCell {
                            Text             = "ClipboardTest",
                            Command          = navigateCommand,
                            CommandParameter = typeof(ClipboardTest)
                        },

                        new TextCell {
                            Text             = "LabelAutoFitPage",
                            Command          = navigateCommand,
                            CommandParameter = typeof(LabelAutoFitPage)
                        },

                        new TextCell {
                            Text             = "ImageCodePage",
                            Command          = navigateCommand,
                            CommandParameter = typeof(ImageCodePage)
                        },

                        new TextCell {
                            Text             = "Layout CodePage",
                            Command          = navigateCommand,
                            CommandParameter = typeof(LayoutCodePage)
                        },

                        new TextCell {
                            Text             = "Button & Segment Alignments",
                            Command          = navigateCommand,
                            CommandParameter = typeof(ButtonAndSegmentAlignments)
                        },

                        new TextCell
                        {
                            Text             = "Button CodePage",
                            Command          = navigateCommand,
                            CommandParameter = typeof(ButtonCodePage)
                        },

                        new TextCell {
                            Text             = "HTML Formatted Labels",
                            Command          = navigateCommand,
                            CommandParameter = typeof(HtmlLabelPage)
                        },

                        new TextCell {
                            Text             = "HTML Formatted Buttons",
                            Command          = navigateCommand,
                            CommandParameter = typeof(HtmlButtonsPage)
                        },

                        new TextCell {
                            Text             = "PopupsPage",
                            Command          = navigateCommand,
                            CommandParameter = typeof(PopupsPage)
                        },

                        new TextCell {
                            Text             = "SVG ButtonBackgroundImage",
                            Command          = navigateCommand,
                            CommandParameter = typeof(SVG_ButtonBackgroundImage)
                        },

                        new TextCell {
                            Text             = "Simple Label Autofit test",
                            Command          = navigateCommand,
                            CommandParameter = typeof(SimpleLabelFitting)
                        },

                        new TextCell {
                            Text             = "Keyboard Height",
                            Command          = navigateCommand,
                            CommandParameter = typeof(KeyboardHeight)
                        },

                        new TextCell {
                            Text             = "Svg In ListView Cell",
                            Command          = navigateCommand,
                            CommandParameter = typeof(SvgInCell)
                        },
                    },

                    new TableSection("Single Examples")
                    {
                        new TextCell
                        {
                            Text             = "Single Button",
                            Command          = navigateCommand,
                            CommandParameter = typeof(SingleButton)
                        },

                        new TextCell
                        {
                            Text             = "State Button",
                            Command          = navigateCommand,
                            CommandParameter = typeof(StateButton)
                        },

                        new TextCell
                        {
                            Text             = "Single SegmentedControl",
                            Command          = navigateCommand,
                            CommandParameter = typeof(SingleSegmentedControl)
                        },

                        new TextCell
                        {
                            Text             = "Html Link",
                            Command          = navigateCommand,
                            CommandParameter = typeof(HtmlLink)
                        },

                        new TextCell {
                            Text             = "HardwareKeyPage",
                            Command          = navigateCommand,
                            CommandParameter = typeof(Forms9PatchDemo.HardwareKeyPage)
                        },


                        new TextCell {
                            Text             = "EmbeddedResource Font Effect",
                            Command          = navigateCommand,
                            CommandParameter = typeof(EmbeddedResourceFontEffectPage)
                        },

                        new TextCell {
                            Text             = "External EmbeddedResource Image",
                            Command          = navigateCommand,
                            CommandParameter = typeof(ExternalEmbeddedResourceImage)
                        },

                        new TextCell {
                            Text             = "Modal Popup",
                            Command          = navigateCommand,
                            CommandParameter = typeof(ModalPopupTestPage)
                        },

                        new TextCell {
                            Text             = "Bubble Popup",
                            Command          = navigateCommand,
                            CommandParameter = typeof(BubblePopupTestPage)
                        },

                        new TextCell {
                            Text             = "FontSizeTest",
                            Command          = navigateCommand,
                            CommandParameter = typeof(FontSizeTest)
                        },

                        new TextCell
                        {
                            Text             = "Segment Crowding",
                            Command          = navigateCommand,
                            CommandParameter = typeof(SegmentedCrowdingPage)
                        },

                        new TextCell {
                            Text             = "SegmentSelectedBackgroundPage",
                            Command          = navigateCommand,
                            CommandParameter = typeof(SegmentSelectedBackgroundPage)
                        },
                    }
                }
            };
        }
コード例 #27
0
        public UserListPageCS()
        {
            Title = "User";

            var toolbarItem = new ToolbarItem
            {
                Text = "+",
                Icon = Device.RuntimePlatform == Device.iOS ? null : "plus.png"
            };

            toolbarItem.Clicked += async(sender, e) =>
            {
                await Navigation.PushAsync(new UserItemPageCS
                {
                    BindingContext = new UserItem()
                });
            };
            ToolbarItems.Add(toolbarItem);

            listView = new ListView
            {
                Margin       = new Thickness(20),
                ItemTemplate = new DataTemplate(() =>
                {
                    var label = new Label
                    {
                        VerticalTextAlignment = TextAlignment.Center,
                        HorizontalOptions     = LayoutOptions.StartAndExpand
                    };
                    label.SetBinding(Label.TextProperty, "Name");
                    var Notelabel = new Label
                    {
                        VerticalTextAlignment = TextAlignment.Center,
                        HorizontalOptions     = LayoutOptions.StartAndExpand
                    };
                    Notelabel.SetBinding(Label.TextProperty, "Notes");


                    var stackLayout = new StackLayout
                    {
                        Margin            = new Thickness(20, 0, 0, 0),
                        Orientation       = StackOrientation.Vertical,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Children          = { label, Notelabel }
                    };

                    return(new ViewCell {
                        View = stackLayout
                    });
                })
            };
            listView.ItemSelected += async(sender, e) =>
            {
                if (e.SelectedItem != null)
                {
                    await Navigation.PushAsync(new UserItemPageCS
                    {
                        BindingContext = e.SelectedItem as UserItem
                    });
                }
            };

            Content = listView;
        }
コード例 #28
0
        private void Init()
        {
            ListView = new ExtendedListView(ListViewCachingStrategy.RecycleElement)
            {
                IsGroupingEnabled   = true,
                ItemsSource         = PresentationSections,
                HasUnevenRows       = true,
                GroupHeaderTemplate = new DataTemplate(() => new SectionHeaderViewCell(
                                                           nameof(Section <Grouping> .Name), nameof(Section <Grouping> .Count))),
                GroupShortNameBinding = new Binding(nameof(Section <Grouping> .NameShort)),
                ItemTemplate          = new GroupingOrCipherDataTemplateSelector(this)
            };

            if (Device.RuntimePlatform == Device.iOS)
            {
                ListView.RowHeight = -1;
            }

            Search = new SearchBar
            {
                Placeholder       = AppResources.Search,
                FontSize          = Device.GetNamedSize(NamedSize.Small, typeof(Button)),
                CancelButtonColor = Color.FromHex("3c8dbc")
            };
            // Bug with search bar on android 7, ref https://bugzilla.xamarin.com/show_bug.cgi?id=43975
            if (Device.RuntimePlatform == Device.Android && _deviceInfoService.Version >= 24)
            {
                Search.HeightRequest = 50;
            }

            var noDataLabel = new Label
            {
                Text = _favorites ? AppResources.NoFavorites : AppResources.NoItems,
                HorizontalTextAlignment = TextAlignment.Center,
                FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                Style    = (Style)Application.Current.Resources["text-muted"]
            };

            if (_folder || !string.IsNullOrWhiteSpace(_folderId))
            {
                noDataLabel.Text = AppResources.NoItemsFolder;
            }
            else if (!string.IsNullOrWhiteSpace(_collectionId))
            {
                noDataLabel.Text = AppResources.NoItemsCollection;
            }

            NoDataStackLayout = new StackLayout
            {
                Children        = { noDataLabel },
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Padding         = new Thickness(20, 0),
                Spacing         = 20
            };

            if (string.IsNullOrWhiteSpace(_collectionId) && !_favorites)
            {
                NoDataStackLayout.Children.Add(new ExtendedButton
                {
                    Text    = AppResources.AddAnItem,
                    Command = new Command(() => Helpers.AddCipher(this, _folderId)),
                    Style   = (Style)Application.Current.Resources["btn-primaryAccent"]
                });
            }

            ResultsStackLayout = new StackLayout
            {
                Children = { Search, ListView },
                Spacing  = 0
            };

            if (!string.IsNullOrWhiteSpace(_groupingName))
            {
                Title = _groupingName;
            }
            else if (_favorites)
            {
                Title = AppResources.Favorites;
            }
            else
            {
                Title = AppResources.SearchVault;

                if (Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.UWP)
                {
                    ToolbarItems.Add(new DismissModalToolBarItem(this));
                }
            }

            LoadingIndicator = new ActivityIndicator
            {
                IsRunning = true
            };

            if (Device.RuntimePlatform != Device.UWP)
            {
                LoadingIndicator.VerticalOptions   = LayoutOptions.CenterAndExpand;
                LoadingIndicator.HorizontalOptions = LayoutOptions.Center;
            }

            ContentView = new ContentView
            {
                Content = LoadingIndicator
            };

            var fabLayout = new FabLayout(ContentView);

            if (!string.IsNullOrWhiteSpace(_uri) || _folder || !string.IsNullOrWhiteSpace(_folderId))
            {
                if (Device.RuntimePlatform == Device.Android)
                {
                    ListView.BottomPadding = 170;
                    Fab = new Fab(fabLayout, "plus.png", (sender, args) => Helpers.AddCipher(this, _folderId));
                }
                else
                {
                    AddCipherItem = new AddCipherToolBarItem(this, _folderId);
                    ToolbarItems.Add(AddCipherItem);
                }
            }
            else if (Device.RuntimePlatform == Device.Android)
            {
                ListView.BottomPadding = 50;
            }

            Content = fabLayout;
        }
コード例 #29
0
        public ScriptInputsPage(InputGroup inputGroup, List <InputGroup> previousInputGroups)
        {
            Title = "Inputs";

            ListView inputsList = new ListView(ListViewCachingStrategy.RecycleElement);

            inputsList.ItemTemplate = new DataTemplate(typeof(TextCell));
            inputsList.ItemTemplate.SetBinding(TextCell.TextProperty, nameof(Input.Caption));
            inputsList.ItemsSource = inputGroup.Inputs;
            inputsList.ItemTapped += async(o, e) =>
            {
                if (inputsList.SelectedItem == null)
                {
                    return;
                }

                Input selectedInput = inputsList.SelectedItem as Input;
                int   selectedIndex = inputGroup.Inputs.IndexOf(selectedInput);

                List <string> actions = new List <string>();

                if (selectedIndex > 0)
                {
                    actions.Add("Move Up");
                }

                if (selectedIndex < inputGroup.Inputs.Count - 1)
                {
                    actions.Add("Move Down");
                }

                actions.Add("Edit");

                if (previousInputGroups != null && previousInputGroups.Select(previousInputGroup => previousInputGroup.Inputs.Count).Sum() > 0)
                {
                    actions.Add("Add Display Condition");
                }

                if (selectedInput.DisplayConditions.Count > 0)
                {
                    actions.AddRange(new string[] { "View Display Conditions" });
                }

                actions.Add("Delete");

                string selectedAction = await DisplayActionSheet(selectedInput.Name, "Cancel", null, actions.ToArray());

                if (selectedAction == "Move Up")
                {
                    inputGroup.Inputs.Move(selectedIndex, selectedIndex - 1);
                }
                else if (selectedAction == "Move Down")
                {
                    inputGroup.Inputs.Move(selectedIndex, selectedIndex + 1);
                }
                else if (selectedAction == "Edit")
                {
                    ScriptInputPage inputPage = new ScriptInputPage(selectedInput);
                    await Navigation.PushAsync(inputPage);

                    inputsList.SelectedItem = null;
                }
                else if (selectedAction == "Add Display Condition")
                {
                    string abortMessage = "Condition is not complete. Abort?";

                    List <Input> inputs = await SensusServiceHelper.Get().PromptForInputsAsync("Display Condition", new Input[]
                    {
                        new ItemPickerPageInput("Input:", previousInputGroups.SelectMany(previousInputGroup => previousInputGroup.Inputs.Cast <object>()).ToList()),
                        new ItemPickerPageInput("Condition:", Enum.GetValues(typeof(InputValueCondition)).Cast <object>().ToList()),
                        new ItemPickerPageInput("Conjunctive/Disjunctive:", new object[] { "Conjunctive", "Disjunctive" }.ToList())
                    }, null, true, null, null, abortMessage, null, false);

                    if (inputs == null)
                    {
                        return;
                    }

                    if (inputs.All(input => input.Valid))
                    {
                        Input conditionInput          = ((inputs[0] as ItemPickerPageInput).Value as IEnumerable <object>).First() as Input;
                        InputValueCondition condition = (InputValueCondition)((inputs[1] as ItemPickerPageInput).Value as IEnumerable <object>).First();
                        bool conjunctive = ((inputs[2] as ItemPickerPageInput).Value as IEnumerable <object>).First().Equals("Conjunctive");

                        if (condition == InputValueCondition.IsComplete)
                        {
                            selectedInput.DisplayConditions.Add(new InputDisplayCondition(conditionInput, condition, null, conjunctive));
                        }
                        else
                        {
                            Regex uppercaseSplitter = new Regex(@"
                                    (?<=[A-Z])(?=[A-Z][a-z]) |
                                    (?<=[^A-Z])(?=[A-Z]) |
                                    (?<=[A-Za-z])(?=[^A-Za-z])", RegexOptions.IgnorePatternWhitespace);

                            // show the user a required copy of the condition input and prompt for the condition value
                            Input conditionInputCopy = conditionInput.Copy(false);
                            conditionInputCopy.DisplayConditions.Clear();
                            conditionInputCopy.LabelText = "Value that " + conditionInputCopy.Name + " " + uppercaseSplitter.Replace(condition.ToString(), " ").ToLower() + ":";
                            conditionInputCopy.Required  = true;

                            // ensure that the copied input cannot define a variable
                            if (conditionInputCopy is IVariableDefiningInput)
                            {
                                (conditionInputCopy as IVariableDefiningInput).DefinedVariable = null;
                            }

                            Input input = await SensusServiceHelper.Get().PromptForInputAsync("Display Condition", conditionInputCopy, null, true, "OK", null, abortMessage, null, false);

                            if (input?.Valid ?? false)
                            {
                                selectedInput.DisplayConditions.Add(new InputDisplayCondition(conditionInput, condition, input.Value, conjunctive));
                            }
                        }
                    }
                }
                else if (selectedAction == "View Display Conditions")
                {
                    await Navigation.PushAsync(new ViewTextLinesPage("Display Conditions", selectedInput.DisplayConditions.Select(displayCondition => displayCondition.ToString()).ToList(), null, () =>
                    {
                        selectedInput.DisplayConditions.Clear();
                    }));
                }
                else if (selectedAction == "Delete")
                {
                    if (await DisplayAlert("Delete " + selectedInput.Name + "?", "This action cannot be undone.", "Delete", "Cancel"))
                    {
                        inputGroup.Inputs.Remove(selectedInput);
                        inputsList.SelectedItem = null;  // manually reset, since it isn't done automatically.
                    }
                }
            };

            ToolbarItems.Add(new ToolbarItem(null, "plus.png", async() =>
            {
                List <Input> inputs = Assembly.GetExecutingAssembly()
                                      .GetTypes()
                                      .Where(t => !t.IsAbstract && t.IsSubclassOf(typeof(Input)))
                                      .Select(t => Activator.CreateInstance(t))
                                      .Cast <Input>()
                                      .OrderBy(i => i.Name)
                                      .ToList();

                string cancelButtonName = "Cancel";
                string selected         = await DisplayActionSheet("Select Input Type", cancelButtonName, null, inputs.Select((input, index) => (index + 1) + ") " + input.Name).ToArray());
                if (!string.IsNullOrWhiteSpace(selected) && selected != cancelButtonName)
                {
                    Input input = inputs[int.Parse(selected.Substring(0, selected.IndexOf(")"))) - 1];

                    if (input is VoiceInput && inputGroup.Inputs.Count > 0 || !(input is VoiceInput) && inputGroup.Inputs.Any(i => i is VoiceInput))
                    {
                        await SensusServiceHelper.Get().FlashNotificationAsync("Voice inputs must reside in groups by themselves.");
                    }
                    else
                    {
                        inputGroup.Inputs.Add(input);
                        await Navigation.PushAsync(new ScriptInputPage(input));
                    }
                }
            }));

            Content = inputsList;
        }
コード例 #30
0
        private void Init()
        {
            CopyTotpCell = new ExtendedSwitchCell
            {
                Text = AppResources.DisableAutoTotpCopy,
                On   = _settings.GetValueOrDefault(Constants.SettingDisableTotpCopy, false)
            };

            var totpTable = new FormTableView(true)
            {
                Root = new TableRoot
                {
                    new TableSection(" ")
                    {
                        CopyTotpCell
                    }
                }
            };

            AnalyticsCell = new ExtendedSwitchCell
            {
                Text = AppResources.DisableGA,
                On   = _settings.GetValueOrDefault(Constants.SettingGaOptOut, false)
            };

            var analyticsTable = new FormTableView
            {
                Root = new TableRoot
                {
                    new TableSection(" ")
                    {
                        AnalyticsCell
                    }
                }
            };

            CopyTotpLabel = new FormTableLabel(this)
            {
                Text = AppResources.DisableAutoTotpCopyDescription
            };

            AnalyticsLabel = new FormTableLabel(this)
            {
                Text = AppResources.DisableGADescription
            };

            StackLayout = new StackLayout
            {
                Children = { totpTable, CopyTotpLabel, analyticsTable, AnalyticsLabel },
                Spacing  = 0
            };

            if (Device.RuntimePlatform == Device.Android)
            {
                AutofillAlwaysCell = new ExtendedSwitchCell
                {
                    Text = AppResources.AutofillAlways,
                    On   = !_appSettings.AutofillPersistNotification && !_appSettings.AutofillPasswordField
                };

                var autofillAlwaysTable = new FormTableView(true)
                {
                    Root = new TableRoot
                    {
                        new TableSection(AppResources.AutofillService)
                        {
                            AutofillAlwaysCell
                        }
                    }
                };

                AutofillAlwaysLabel = new FormTableLabel(this)
                {
                    Text = AppResources.AutofillAlwaysDescription
                };

                AutofillPersistNotificationCell = new ExtendedSwitchCell
                {
                    Text = AppResources.AutofillPersistNotification,
                    On   = _appSettings.AutofillPersistNotification
                };

                var autofillPersistNotificationTable = new FormTableView
                {
                    Root = new TableRoot
                    {
                        new TableSection(" ")
                        {
                            AutofillPersistNotificationCell
                        }
                    }
                };

                AutofillPersistNotificationLabel = new FormTableLabel(this)
                {
                    Text = AppResources.AutofillPersistNotificationDescription
                };

                AutofillPasswordFieldCell = new ExtendedSwitchCell
                {
                    Text = AppResources.AutofillPasswordField,
                    On   = _appSettings.AutofillPasswordField
                };

                var autofillPasswordFieldTable = new FormTableView
                {
                    Root = new TableRoot
                    {
                        new TableSection(" ")
                        {
                            AutofillPasswordFieldCell
                        }
                    }
                };

                AutofillPasswordFieldLabel = new FormTableLabel(this)
                {
                    Text = AppResources.AutofillPasswordFieldDescription
                };

                StackLayout.Children.Add(autofillAlwaysTable);
                StackLayout.Children.Add(AutofillAlwaysLabel);
                StackLayout.Children.Add(autofillPasswordFieldTable);
                StackLayout.Children.Add(AutofillPasswordFieldLabel);
                StackLayout.Children.Add(autofillPersistNotificationTable);
                StackLayout.Children.Add(AutofillPersistNotificationLabel);
            }

            var scrollView = new ScrollView
            {
                Content = StackLayout
            };

            if (Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows)
            {
                analyticsTable.RowHeight          = -1;
                analyticsTable.EstimatedRowHeight = 70;
                ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
            }

            Title   = AppResources.Features;
            Content = scrollView;
        }