コード例 #1
0
ファイル: App.cs プロジェクト: jc150584/StartSample
        public StartPage()
        {
            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "検索",
                Icon    = "Search.png",
                Command = new Command(() => DisplayAlert("Search", "Search is tapped.", "OK")),
            });
            ToolbarItems.Add(new ToolbarItem
            {
                Text    = "設定",
                Icon    = "Setting.png",
                Command = new Command(() => DisplayAlert("Setting", "Setting is tapped.", "OK")),
            });

            AbsoluteLayout abs = new AbsoluteLayout {
            };

            ml = new StackLayout
            {
                BackgroundColor = Color.White,
                Padding         = 15,
                Children        =
                {
                    new Label  {
                        XAlign    = TextAlignment.Center,
                        Text      = "Welcome to Xamarin Forms!",
                        TextColor = Color.Black,
                    },
                    new Button {
                        Text            = "Show QuickStart",
                        TextColor       = Color.Black,
                        BackgroundColor = Color.FromHex("CCC"),
                        BorderColor     = Color.Gray,
                        BorderRadius    = 5,
                        BorderWidth     = 1,
                        Command         = new Command(() => {
                            qslVisible = true;
                            Application.Current.Properties["qsl"] = qslVisible;
                            DisplayAlert("Show QuickStart", "Show QuickStart when you re-launch this app.", "OK");
                        }),
                    },
                },
            };

            bl = new ContentView
            {
                BackgroundColor = Color.Black,
                Opacity         = 0.65d,
            };

            qsl = new ContentView
            {
                Content = new StackLayout
                {
                    Padding         = new Thickness(10, 0, 10, 10),
                    VerticalOptions = LayoutOptions.FillAndExpand,
                    Children        =
                    {
                        new Image  {
                            Source            = "QuickStart.png",
                            WidthRequest      = 250,
                            HorizontalOptions = LayoutOptions.End,
                        },
                        new Image  {
                            Source       = "QuickStartSwipe.png",
                            WidthRequest = 340,
                        },
                        new Button {
                            Text            = "閉じる",
                            TextColor       = Color.White,
                            BackgroundColor = Color.FromHex("49d849"),
                            BorderRadius    = 5,
                            VerticalOptions = LayoutOptions.EndAndExpand,
                            Command         = new Command(() => {
                                qsl.IsVisible = false;
                                bl.IsVisible  = false;
                                qslVisible    = false;
                                Application.Current.Properties["qsl"] = qslVisible;
                            }),
                        },
                    },
                },
            };


            abs.Children.Add(ml);
            if (Application.Current.Properties.ContainsKey("qsl"))
            {
                var bqsl = (bool)Application.Current.Properties["qsl"];
                if (bqsl)
                {
                    abs.Children.Add(bl);
                    if (Device.OS == TargetPlatform.WinPhone)
                    {
                    }
                    else
                    {
                        abs.Children.Add(qsl);
                    }
                }
            }
            else
            {
                abs.Children.Add(bl);
                if (Device.OS == TargetPlatform.WinPhone)
                {
                }
                else
                {
                    abs.Children.Add(qsl);
                }
            }


            Title   = "QuickStartLayer";
            Content = abs;

            SizeChanged += OnPageSizeChanged;
        }
コード例 #2
0
ファイル: LockPasswordPage.cs プロジェクト: whjvenyl/mobile
        public void Init()
        {
            var padding = Helpers.OnPlatform(
                iOS: new Thickness(15, 20),
                Android: new Thickness(15, 8),
                Windows: new Thickness(10, 8));

            PasswordCell = new FormEntryCell(AppResources.MasterPassword, isPassword: true,
                                             useLabelAsPlaceholder: true, imageSource: "lock.png", containerPadding: padding);

            PasswordCell.Entry.ReturnType = Enums.ReturnType.Go;

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

            var logoutButton = new ExtendedButton
            {
                Text            = AppResources.LogOut,
                Command         = new Command(async() => await LogoutAsync()),
                VerticalOptions = LayoutOptions.End,
                Style           = (Style)Application.Current.Resources["btn-primaryAccent"],
                BackgroundColor = Color.Transparent,
                Uppercase       = false
            };

            var stackLayout = new StackLayout
            {
                Spacing  = 10,
                Children = { table, logoutButton }
            };

            var scrollView = new ScrollView {
                Content = stackLayout
            };

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

            var loginToolbarItem = new ToolbarItem(AppResources.Submit, Helpers.ToolbarImage("login.png"), async() =>
            {
                await CheckPasswordAsync();
            }, ToolbarItemOrder.Default, 0);

            ToolbarItems.Add(loginToolbarItem);
            Title   = AppResources.VerifyMasterPassword;
            Content = scrollView;
        }
コード例 #3
0
 public void SetupPage()
 {
     ToolbarItems.Add(new ToolbarItem("ADD", string.Empty, AddUser));
     ListView.ItemsSource = ItemsList;
     ListView.ItemTapped += ItemTapped;
 }
コード例 #4
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);
        }
コード例 #5
0
        public void Init()
        {
            // Not Started

            var notStartedLabel = new Label
            {
                Text                    = AppResources.ExtensionInstantAccess,
                VerticalOptions         = LayoutOptions.Start,
                HorizontalOptions       = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                LineBreakMode           = LineBreakMode.WordWrap,
                FontSize                = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };

            var notStartedSublabel = new Label
            {
                Text                    = AppResources.ExtensionTurnOn,
                VerticalOptions         = LayoutOptions.Start,
                HorizontalOptions       = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                LineBreakMode           = LineBreakMode.WordWrap
            };

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

            var notStartedButton = new ExtendedButton
            {
                Text              = AppResources.ExtensionEnable,
                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(IsVisibleProperty, nameof(AppExtensionPageModel.NotStarted));

            // Not Activated

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

            var notActivatedSublabel = new Label
            {
                Text                    = AppResources.ExtensionTapIcon,
                VerticalOptions         = LayoutOptions.Start,
                HorizontalOptions       = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                LineBreakMode           = LineBreakMode.WordWrap
            };

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

            var notActivatedButton = new ExtendedButton
            {
                Text              = AppResources.ExtensionEnable,
                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(IsVisibleProperty, nameof(AppExtensionPageModel.StartedAndNotActivated));

            // Activated

            var activatedLabel = new Label
            {
                Text                    = AppResources.ExtensionReady,
                VerticalOptions         = LayoutOptions.Start,
                HorizontalOptions       = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                LineBreakMode           = LineBreakMode.WordWrap,
                FontSize                = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };

            var activatedSublabel = new Label
            {
                Text                    = AppResources.ExtensionInSafari,
                VerticalOptions         = LayoutOptions.Start,
                HorizontalOptions       = LayoutOptions.Center,
                HorizontalTextAlignment = TextAlignment.Center,
                LineBreakMode           = LineBreakMode.WordWrap,
                Margin                  = new Thickness(0, 10, 0, 0)
            };

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

            var activatedButton = new ExtendedButton
            {
                Text    = AppResources.ExtensionSeeApps,
                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              = AppResources.ExntesionReenable,
                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(IsVisibleProperty, nameof(AppExtensionPageModel.StartedAndActivated));

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

            if (Device.RuntimePlatform == Device.iOS)
            {
                ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close));
            }

            Title   = AppResources.AppExtension;
            Content = new ScrollView {
                Content = stackLayout
            };
            BindingContext = Model;
        }
コード例 #6
0
        private void Init()
        {
            ListView = new ExtendedListView(ListViewCachingStrategy.RecycleElement)
            {
                IsGroupingEnabled   = true,
                ItemsSource         = PresentationSections,
                HasUnevenRows       = true,
                GroupHeaderTemplate = new DataTemplate(() => new SectionHeaderViewCell(nameof(Section <Cipher> .Name),
                                                                                       nameof(Section <Cipher> .Count))),
                GroupShortNameBinding = new Binding(nameof(Section <Cipher> .Name)),
                ItemTemplate          = new DataTemplate(() => new VaultListViewCell(
                                                             (Cipher c) => Helpers.CipherMoreClickedAsync(this, c, !string.IsNullOrWhiteSpace(_uri))))
            };

            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;
        }
コード例 #7
0
        public AddPhotoPage(int inspectionId)
        {
            _viewModel     = new AddPhotoViewModel(inspectionId);
            BindingContext = _viewModel;

            _saveButton = new ToolbarItem();
            switch (Device.RuntimePlatform)
            {
            case Device.iOS:
            case Device.Android:
                _saveButton.Icon = "Save";
                break;

            case Device.Windows:
                _saveButton.Icon = "Assets/Save.png";
                break;

            default:
                throw new Exception("Runtime Platform Not Supported");
            }
            _saveButton.SetBinding(ToolbarItem.CommandProperty, nameof(_viewModel.SaveButtonCommand));
            ToolbarItems.Add(_saveButton);

            var cancelButton = new ToolbarItem();

            switch (Device.RuntimePlatform)
            {
            case Device.iOS:
            case Device.Android:
                cancelButton.Icon = "Cancel";
                break;

            case Device.Windows:
                cancelButton.Icon = "Assets/Cancel.png";
                break;

            default:
                throw new Exception("Runtime Platform Not Supported");
            }
            cancelButton.Clicked += (sender, e) => DismissPage();
            ToolbarItems.Add(cancelButton);


            var photoImage = new Image();

            photoImage.SetBinding(Image.SourceProperty, nameof(_viewModel.PhotoImageSource));

            _photoImageNameEntry = new Entry();
            _photoImageNameEntry.SetBinding(Entry.TextProperty, nameof(_viewModel.PhotoImageNameText));

            var takePhotoButton = new Button
            {
                Text = "New Photo"
            };

            takePhotoButton.SetBinding(Button.CommandProperty, nameof(_viewModel.TakePhotoButtonCommand));

            Padding = new Thickness(40, 10);

            this.SetBinding(TitleProperty, nameof(_viewModel.PhotoImageNameText));

            Content = new ScrollView
            {
                Content = new StackLayout
                {
                    Children =
                    {
                        photoImage,
                        _photoImageNameEntry,
                        takePhotoButton
                    }
                }
            };
        }
コード例 #8
0
        public ItemsListPage()
        {
            Title = "Todo";


            listView = new ListView();
            listView.ItemTemplate = new DataTemplate
                                        (typeof(ItemCell));

            //listView.ItemSelected += (sender, e) =>
            //{
            //	var todoItem = (ItemsList)e.SelectedItem;
            //	//var todoPage = new ItemsPageX();
            //	todoPage.BindingContext = todoItem;

            //	((App)App.Current).ResumeAtItemsID = todoItem.ItemsID;
            //	Debug.WriteLine("setting ResumeAtTodoId = " + todoItem.ItemsID);

            //	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",
                    FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
                });
            }
            layout.Children.Add(listView);
            layout.VerticalOptions = LayoutOptions.FillAndExpand;
            Content = layout;

            #region toolbar
            ToolbarItem tbi = null;
            if (Device.OS == TargetPlatform.iOS)
            {
                tbi = new ToolbarItem("+", null, () =>
                {
                    var todoItem            = new ItemsList();
                    var todoPage            = new ItemsInsertPage();
                    todoPage.BindingContext = todoItem;
                    Navigation.PushAsync(todoPage);
                }, 0, 0);
            }
            if (Device.OS == TargetPlatform.Android)
            {             // BUG: Android doesn't support the icon being null
                tbi = new ToolbarItem("+", "plus", () =>
                {
                    var todoItem            = new ItemsList();
                    var todoPage            = new ItemsInsertPage();
                    todoPage.BindingContext = todoItem;
                    Navigation.PushAsync(todoPage);
                }, 0, 0);
            }

            ToolbarItems.Add(tbi);
            #endregion
        }
コード例 #9
0
ファイル: RegisterPage.cs プロジェクト: snellegast/mobile
        private void Init()
        {
            MessagingCenter.Send(Application.Current, "ShowStatusBar", true);

            var padding = Helpers.OnPlatform(
                iOS: new Thickness(15, 20),
                Android: new Thickness(15, 8),
                Windows: new Thickness(10, 8));

            PasswordHintCell = new FormEntryCell(AppResources.MasterPasswordHint, useLabelAsPlaceholder: true,
                                                 imageSource: "lightbulb.png", containerPadding: padding);
            ConfirmPasswordCell = new FormEntryCell(AppResources.RetypeMasterPassword, isPassword: true,
                                                    nextElement: PasswordHintCell.Entry, useLabelAsPlaceholder: true, imageSource: "lock.png",
                                                    containerPadding: padding);
            PasswordCell = new FormEntryCell(AppResources.MasterPassword, isPassword: true,
                                             nextElement: ConfirmPasswordCell.Entry, useLabelAsPlaceholder: true, imageSource: "lock.png",
                                             containerPadding: padding);
            EmailCell = new FormEntryCell(AppResources.EmailAddress, nextElement: PasswordCell.Entry,
                                          entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true, imageSource: "envelope.png",
                                          containerPadding: padding);

            PasswordHintCell.Entry.ReturnType = Enums.ReturnType.Done;

            var table = new FormTableView(this)
            {
                Root = new TableRoot
                {
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                    {
                        EmailCell,
                        PasswordCell
                    }
                }
            };

            PasswordLabel = new Label
            {
                Text          = AppResources.MasterPasswordDescription,
                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 table2 = new FormTableView(this)
            {
                NoHeader = true,
                Root     = new TableRoot
                {
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                    {
                        ConfirmPasswordCell,
                        PasswordHintCell
                    }
                }
            };

            HintLabel = new Label
            {
                Text          = AppResources.MasterPasswordHintDescription,
                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)
            };

            StackLayout = new RedrawableStackLayout
            {
                Children = { table, PasswordLabel, table2, HintLabel },
                Spacing  = 0
            };

            var scrollView = new ScrollView
            {
                Content = StackLayout
            };

            var loginToolbarItem = new ToolbarItem(AppResources.Submit, Helpers.ToolbarImage("ion_chevron_right.png"), async() =>
            {
                await Register();
            }, ToolbarItemOrder.Default, 0);

            if (Device.RuntimePlatform == Device.iOS)
            {
                table.RowHeight          = table2.RowHeight = -1;
                table.EstimatedRowHeight = table2.EstimatedRowHeight = 70;
                ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel, () =>
                {
                    MessagingCenter.Send(Application.Current, "ShowStatusBar", false);
                }));
            }

            ToolbarItems.Add(loginToolbarItem);
            Title   = AppResources.CreateAccount;
            Content = scrollView;
        }
コード例 #10
0
        private void Init()
        {
            var login = _loginService.GetByIdAsync(_loginId).GetAwaiter().GetResult();

            if (login == null)
            {
                // TODO: handle error. navigate back? should never happen...
                return;
            }

            NotesCell = new FormEditorCell(height: 300);
            NotesCell.Editor.Keyboard = Keyboard.Text;
            NotesCell.Editor.Text     = login.Notes?.Decrypt(login.OrganizationId);

            TotpCell = new FormEntryCell(AppResources.AuthenticatorKey, nextElement: NotesCell.Editor,
                                         useButton: _deviceInfo.HasCamera);
            if (_deviceInfo.HasCamera)
            {
                TotpCell.Button.Image = "camera";
            }
            TotpCell.Entry.Text = login.Totp?.Decrypt(login.OrganizationId);
            TotpCell.Entry.DisableAutocapitalize = true;
            TotpCell.Entry.Autocorrect           = false;
            TotpCell.Entry.FontFamily            = Helpers.OnPlatform(iOS: "Menlo-Regular", Android: "monospace", WinPhone: "Courier");

            PasswordCell = new FormEntryCell(AppResources.Password, isPassword: true, nextElement: TotpCell.Entry,
                                             useButton: true);
            PasswordCell.Entry.Text   = login.Password?.Decrypt(login.OrganizationId);
            PasswordCell.Button.Image = "eye";
            PasswordCell.Entry.DisableAutocapitalize = true;
            PasswordCell.Entry.Autocorrect           = false;
            PasswordCell.Entry.FontFamily            = Helpers.OnPlatform(iOS: "Menlo-Regular", Android: "monospace", WinPhone: "Courier");

            UsernameCell            = new FormEntryCell(AppResources.Username, nextElement: PasswordCell.Entry);
            UsernameCell.Entry.Text = login.Username?.Decrypt(login.OrganizationId);
            UsernameCell.Entry.DisableAutocapitalize = true;
            UsernameCell.Entry.Autocorrect           = false;

            UriCell             = new FormEntryCell(AppResources.URI, Keyboard.Url, nextElement: UsernameCell.Entry);
            UriCell.Entry.Text  = login.Uri?.Decrypt(login.OrganizationId);
            NameCell            = new FormEntryCell(AppResources.Name, nextElement: UriCell.Entry);
            NameCell.Entry.Text = login.Name?.Decrypt(login.OrganizationId);

            GenerateCell = new ExtendedTextCell
            {
                Text            = AppResources.GeneratePassword,
                ShowDisclousure = true
            };

            var folderOptions = new List <string> {
                AppResources.FolderNone
            };
            var folders = _folderService.GetAllAsync().GetAwaiter().GetResult()
                          .OrderBy(f => f.Name?.Decrypt()).ToList();
            int selectedIndex = 0;
            int i             = 0;

            foreach (var folder in folders)
            {
                i++;
                if (folder.Id == login.FolderId)
                {
                    selectedIndex = i;
                }

                folderOptions.Add(folder.Name.Decrypt());
            }
            FolderCell = new FormPickerCell(AppResources.Folder, folderOptions.ToArray());
            FolderCell.Picker.SelectedIndex = selectedIndex;

            var favoriteCell = new ExtendedSwitchCell
            {
                Text = AppResources.Favorite,
                On   = login.Favorite
            };

            AttachmentsCell = new ExtendedTextCell
            {
                Text            = AppResources.Attachments,
                ShowDisclousure = true
            };

            CustomFieldsCell = new ExtendedTextCell
            {
                Text            = AppResources.CustomFields,
                ShowDisclousure = true
            };

            DeleteCell = new ExtendedTextCell {
                Text = AppResources.Delete, TextColor = Color.Red
            };

            var table = new ExtendedTableView
            {
                Intent          = TableIntent.Settings,
                EnableScrolling = true,
                HasUnevenRows   = true,
                Root            = new TableRoot
                {
                    new TableSection(AppResources.LoginInformation)
                    {
                        NameCell,
                        UriCell,
                        UsernameCell,
                        PasswordCell,
                        GenerateCell
                    },
                    new TableSection(" ")
                    {
                        TotpCell,
                        FolderCell,
                        favoriteCell,
                        AttachmentsCell,
                        CustomFieldsCell
                    },
                    new TableSection(AppResources.Notes)
                    {
                        NotesCell
                    },
                    new TableSection(" ")
                    {
                        DeleteCell
                    }
                }
            };

            if (Device.RuntimePlatform == Device.iOS)
            {
                table.RowHeight          = -1;
                table.EstimatedRowHeight = 70;
            }
            else if (Device.RuntimePlatform == Device.Android)
            {
                PasswordCell.Button.WidthRequest = 40;

                if (TotpCell.Button != null)
                {
                    TotpCell.Button.WidthRequest = 40;
                }
            }

            var saveToolBarItem = new ToolbarItem(AppResources.Save, null, async() =>
            {
                if (_lastAction.LastActionWasRecent())
                {
                    return;
                }
                _lastAction = DateTime.UtcNow;

                if (!_connectivity.IsConnected)
                {
                    AlertNoConnection();
                    return;
                }

                if (string.IsNullOrWhiteSpace(NameCell.Entry.Text))
                {
                    await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired,
                                                                                      AppResources.Name), AppResources.Ok);
                    return;
                }

                login.Name = NameCell.Entry.Text.Encrypt(login.OrganizationId);
                login.Uri  = string.IsNullOrWhiteSpace(UriCell.Entry.Text) ? null :
                             UriCell.Entry.Text.Encrypt(login.OrganizationId);
                login.Username = string.IsNullOrWhiteSpace(UsernameCell.Entry.Text) ? null :
                                 UsernameCell.Entry.Text.Encrypt(login.OrganizationId);
                login.Password = string.IsNullOrWhiteSpace(PasswordCell.Entry.Text) ? null :
                                 PasswordCell.Entry.Text.Encrypt(login.OrganizationId);
                login.Notes = string.IsNullOrWhiteSpace(NotesCell.Editor.Text) ? null :
                              NotesCell.Editor.Text.Encrypt(login.OrganizationId);
                login.Totp = string.IsNullOrWhiteSpace(TotpCell.Entry.Text) ? null :
                             TotpCell.Entry.Text.Encrypt(login.OrganizationId);
                login.Favorite = favoriteCell.On;

                if (FolderCell.Picker.SelectedIndex > 0)
                {
                    login.FolderId = folders.ElementAt(FolderCell.Picker.SelectedIndex - 1).Id;
                }
                else
                {
                    login.FolderId = null;
                }

                _userDialogs.ShowLoading(AppResources.Saving, MaskType.Black);
                var saveTask = await _loginService.SaveAsync(login);

                _userDialogs.HideLoading();

                if (saveTask.Succeeded)
                {
                    _userDialogs.Toast(AppResources.LoginUpdated);
                    _googleAnalyticsService.TrackAppEvent("EditedLogin");
                    await Navigation.PopForDeviceAsync();
                }
                else if (saveTask.Errors.Count() > 0)
                {
                    await _userDialogs.AlertAsync(saveTask.Errors.First().Message, AppResources.AnErrorHasOccurred);
                }
                else
                {
                    await _userDialogs.AlertAsync(AppResources.AnErrorHasOccurred);
                }
            }, ToolbarItemOrder.Default, 0);

            Title   = AppResources.EditLogin;
            Content = table;
            ToolbarItems.Add(saveToolBarItem);
            if (Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows)
            {
                ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
            }
        }
コード例 #11
0
        public AddPersonPage()
        {
            var saveButtonToolBar = new ToolbarItem
            {
                Text     = _saveButtonToolBarItemText,
                Priority = 0,
            };

            saveButtonToolBar.SetBinding(ToolbarItem.CommandProperty, nameof(ViewModel.SaveButtonCommand));
            ToolbarItems.Add(saveButtonToolBar);

            _cancelButtonToolbarItem = new ToolbarItem
            {
                Text     = _cancelButtonToolBarItemText,
                Priority = 1
            };
            ToolbarItems.Add(_cancelButtonToolbarItem);

            var ageLabel = new Label {
                Text = "Age"
            };

            var ageEntry = new AddPersonPageEntry
            {
                Placeholder = "Age",
                Keyboard    = Keyboard.Numeric
            };

            ageEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.AgeEntryText));
            ageEntry.SetBinding(CustomReturnEffect.ReturnCommandProperty, nameof(ViewModel.SaveButtonCommand));
            ageEntry.SetBinding(IsEnabledProperty, new Binding(nameof(ViewModel.IsInternetConnectionActive), BindingMode.Default, new InverseBooleanConverter(), ViewModel.IsInternetConnectionActive));
            CustomReturnEffect.SetReturnType(ageEntry, ReturnType.Go);

            var nameLabel = new Label {
                Text = "Name"
            };

            _nameEntry = new AddPersonPageEntry {
                Placeholder = "Name"
            };
            _nameEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.NameEntryText));
            _nameEntry.SetBinding(IsEnabledProperty, new Binding(nameof(ViewModel.IsInternetConnectionActive), BindingMode.Default, new InverseBooleanConverter(), ViewModel.IsInternetConnectionActive));
            CustomReturnEffect.SetReturnCommand(_nameEntry, new Command(() => ageEntry.Focus()));
            CustomReturnEffect.SetReturnType(_nameEntry, ReturnType.Next);

            var activityIndicator = new ActivityIndicator();

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

            Padding = GetPageThickness();

            var stackLayout = new StackLayout
            {
                Children =
                {
                    nameLabel,
                    _nameEntry,
                    ageLabel,
                    ageEntry,
                    activityIndicator
                }
            };

            Title = "Add Person";

            Content = new ScrollView {
                Content = stackLayout
            };
        }
コード例 #12
0
        public ProtocolsPage()
        {
            Title = "Protocols";

            _protocolsList = new ListView();
            _protocolsList.ItemTemplate = new DataTemplate(typeof(TextCell));
            _protocolsList.ItemTemplate.SetBinding(TextCell.TextProperty, "Name");

            Bind();

            Content = _protocolsList;

            #region toolbar
            ToolbarItems.Add(new ToolbarItem("Open", null, () =>
            {
                if (_protocolsList.SelectedItem != null)
                {
                    Protocol protocol = _protocolsList.SelectedItem as Protocol;

                    Action openProtocol = new Action(async() =>
                    {
                        ProtocolPage protocolPage  = new ProtocolPage(protocol);
                        protocolPage.Disappearing += (o, e) => Bind();
                        await Navigation.PushAsync(protocolPage);
                        _protocolsList.SelectedItem = null;
                    });

                    if (protocol.LockPasswordHash == "")
                    {
                        openProtocol();
                    }
                    else
                    {
                        UiBoundSensusServiceHelper.Get(true).PromptForInputAsync("Enter protocol password to open:", false, password =>
                        {
                            if (password == null)
                            {
                                return;
                            }

                            if (UiBoundSensusServiceHelper.Get(true).GetMd5Hash(password) == protocol.LockPasswordHash)
                            {
                                Device.BeginInvokeOnMainThread(openProtocol);
                            }
                            else
                            {
                                UiBoundSensusServiceHelper.Get(true).FlashNotificationAsync("Incorrect password");
                            }
                        });
                    }
                }
            }));

            ToolbarItems.Add(new ToolbarItem("+", null, () =>
            {
                UiBoundSensusServiceHelper.Get(true).RegisterProtocol(new Protocol("New Protocol"));

                _protocolsList.ItemsSource = null;
                _protocolsList.ItemsSource = UiBoundSensusServiceHelper.Get(true).RegisteredProtocols;
            }));

            ToolbarItems.Add(new ToolbarItem("-", null, () =>
            {
                if (_protocolsList.SelectedItem != null)
                {
                    Protocol protocolToDelete = _protocolsList.SelectedItem as Protocol;

                    Action deleteProtocol = new Action(async() =>
                    {
                        if (await DisplayAlert("Delete " + protocolToDelete.Name + "?", "This action cannot be undone.", "Delete", "Cancel"))
                        {
                            protocolToDelete.StopAsync(() =>
                            {
                                UiBoundSensusServiceHelper.Get(true).UnregisterProtocol(protocolToDelete);

                                try { Directory.Delete(protocolToDelete.StorageDirectory, true); }
                                catch (Exception ex) { UiBoundSensusServiceHelper.Get(true).Logger.Log("Failed to delete protocol storage directory \"" + protocolToDelete.StorageDirectory + "\":  " + ex.Message, LoggingLevel.Normal, GetType()); }

                                Device.BeginInvokeOnMainThread(() =>
                                {
                                    _protocolsList.ItemsSource  = _protocolsList.ItemsSource.Cast <Protocol>().Where(p => p != protocolToDelete);
                                    _protocolsList.SelectedItem = null;
                                });
                            });
                        }
                    });

                    if (protocolToDelete.LockPasswordHash == "")
                    {
                        deleteProtocol();
                    }
                    else
                    {
                        UiBoundSensusServiceHelper.Get(true).PromptForInputAsync("Enter protocol password to delete:", false, password =>
                        {
                            if (password == null)
                            {
                                return;
                            }

                            if (UiBoundSensusServiceHelper.Get(true).GetMd5Hash(password) == protocolToDelete.LockPasswordHash)
                            {
                                Device.BeginInvokeOnMainThread(deleteProtocol);
                            }
                            else
                            {
                                UiBoundSensusServiceHelper.Get(true).FlashNotificationAsync("Incorrect password");
                            }
                        });
                    }
                }
            }));
            #endregion
        }
コード例 #13
0
        //private EventPage lastEventPage;

        public DayPage()
        {
            //InitializeComponent();
            //myList();

            ToolbarItem toolbarItem = new ToolbarItem
            {
                Text = "Back"
            };

            ToolbarItems.Add(toolbarItem);
            toolbarItem.Clicked += (object sender, EventArgs e) =>
            {
                Navigation.PushAsync(new YearPage());
            };

            TableView tableView = new TableView {
            };

            tableView.Root = new TableRoot();
            TableSection tableSection = new TableSection("Events");

            tableView.Root.Add(tableSection);

            // Add create event button
            StackLayout staticStackLayout = new StackLayout {
                Orientation = StackOrientation.Horizontal, Padding = new Thickness(13, 0)
            };
            Button createEventButton = new Button {
                Text = "Add a new Event"
            };

            createEventButton.Clicked += OnCreateEventButtonClicked;
            staticStackLayout.Children.Add(createEventButton);
            tableSection.Add(new ViewCell {
                View = staticStackLayout
            });
            // Add 24 hours
            for (int hour = 0; hour < 24; hour++)
            {
                StackLayout stackLayout = new StackLayout {
                    Orientation = StackOrientation.Horizontal, Padding = new Thickness(13, 0)
                };
                Label hourLabel = new Label {
                    Text = string.Format("{00}:00", hour), VerticalOptions = LayoutOptions.Center
                };

                stackLayout.Children.Add(hourLabel);
                // Add events

                List <Event> userEvents = User.CurrentUser.Events;
                for (int j = 0; j < userEvents.Count; j++)
                {
                    if (userEvents[j].StartTime().Year == Time.CurrentTime.Year &&
                        userEvents[j].StartTime().Month == Time.CurrentTime.Month &&
                        userEvents[j].StartTime().Day == Time.CurrentTime.Day)
                    {
                        if (userEvents[j].StartTime().Hour <= hour &&
                            userEvents[j].EndTime().Hour >= hour
                            )
                        {
                            stackLayout.Children.Add(AddEvent(userEvents[j]));
                        }
                    }
                }

                ViewCell cell = new ViewCell {
                    View = stackLayout
                };
                tableSection.Add(cell);
            }

            this.Content = new StackLayout
            {
                Children =
                {
                    tableView
                }
            };
        }
コード例 #14
0
ファイル: StorePage.cs プロジェクト: vkoppaka/MyShoppe
        public StorePage(Store store)
        {
            dataStore = DependencyService.Get <IDataStore> ();
            Store     = store;
            if (Store == null)
            {
                Store                = new Store();
                Store.MondayOpen     = "9am";
                Store.TuesdayOpen    = "9am";
                Store.WednesdayOpen  = "9am";
                Store.ThursdayOpen   = "9am";
                Store.FridayOpen     = "9am";
                Store.SaturdayOpen   = "9am";
                Store.SundayOpen     = "12pm";
                Store.MondayClose    = "8pm";
                Store.TuesdayClose   = "8pm";
                Store.WednesdayClose = "8pm";
                Store.ThursdayClose  = "8pm";
                Store.FridayClose    = "8pm";
                Store.SaturdayClose  = "8pm";
                Store.SundayClose    = "6pm";
                isNew                = true;
            }

            Title = isNew ? "New Store" : "Edit Store";

            ToolbarItems.Add(new ToolbarItem {
                Text    = "Save",
                Command = new Command(async(obj) =>
                {
                    Store.Name          = name.Text.Trim();
                    Store.LocationHint  = locationHint.Text.Trim();
                    Store.City          = city.Text.Trim();
                    Store.PhoneNumber   = phoneNumber.Text.Trim();
                    Store.Image         = imageUrl.Text.Trim();
                    Store.StreetAddress = streetAddress.Text.Trim();
                    Store.State         = state.Text.Trim();
                    Store.ZipCode       = zipCode.Text.Trim();
                    Store.LocationCode  = locationCode.Text.Trim();
                    Store.Country       = country.Text.Trim();
                    double lat;
                    double lng;

                    var parse1           = double.TryParse(latitude.Text.Trim(), out lat);
                    var parse2           = double.TryParse(longitude.Text.Trim(), out lng);
                    Store.Longitude      = lng;
                    Store.Latitude       = lat;
                    Store.MondayOpen     = mondayOpen.Text.Trim();
                    Store.MondayClose    = mondayClose.Text.Trim();
                    Store.TuesdayOpen    = tuesdayOpen.Text.Trim();
                    Store.TuesdayClose   = tuesdayClose.Text.Trim();
                    Store.WednesdayOpen  = wednesdayOpen.Text.Trim();
                    Store.WednesdayClose = wednesdayClose.Text.Trim();
                    Store.ThursdayOpen   = thursdayOpen.Text.Trim();
                    Store.ThursdayClose  = thursdayClose.Text.Trim();
                    Store.FridayOpen     = fridayOpen.Text.Trim();
                    Store.FridayClose    = fridayClose.Text.Trim();
                    Store.SaturdayOpen   = saturdayOpen.Text.Trim();
                    Store.SaturdayClose  = saturdayClose.Text.Trim();
                    Store.SundayOpen     = sundayOpen.Text.Trim();
                    Store.SundayClose    = sundayClose.Text.Trim();



                    bool isAnyPropEmpty = Store.GetType().GetTypeInfo().DeclaredProperties
                                          .Where(p => p.GetValue(Store) is string && p.CanRead && p.CanWrite && p.Name != "State")               // selecting only string props
                                          .Any(p => string.IsNullOrWhiteSpace((p.GetValue(Store) as string)));

                    if (isAnyPropEmpty || !parse1 || !parse2)
                    {
                        DisplayAlert("Not Valid", "Some fields are not valid, please check", "OK");
                        return;
                    }
                    Title = "SAVING...";
                    if (isNew)
                    {
                        await dataStore.AddStoreAsync(Store);
                    }
                    else
                    {
                        await dataStore.UpdateStoreAsync(Store);
                    }

                    await DisplayAlert("Saved", "Please refresh store list", "OK");
                    Navigation.PopAsync();
                })
            });


            Content = new TableView {
                HasUnevenRows = true,
                Intent        = TableIntent.Form,
                Root          = new TableRoot {
                    new TableSection("Information")
                    {
                        (name = new EntryCell {
                            Label = "Name", Text = Store.Name
                        }),
                        (locationHint = new EntryCell {
                            Label = "Location Hint", Text = Store.LocationHint
                        }),
                        (phoneNumber = new EntryCell {
                            Label = "Phone Number", Text = Store.PhoneNumber, Placeholder = "555-555-5555"
                        }),
                        (locationCode = new EntryCell {
                            Label = "Location Code", Text = Store.LocationCode
                        }),
                    },
                    new TableSection("Image")
                    {
                        (imageUrl = new EntryCell {
                            Label = "Image URL", Text = Store.Image, Placeholder = ".png or .jpg image link"
                        }),
                        (refreshImage = new TextCell()
                        {
                            Text = "Refresh Image"
                        }),
                        new ViewCell {
                            View = (image = new Image
                            {
                                HeightRequest = 400,
                                VerticalOptions = LayoutOptions.FillAndExpand
                            })
                        }
                    },
                    new TableSection("Address")
                    {
                        (streetAddress = new EntryCell {
                            Label = "Street Address", Text = Store.StreetAddress
                        }),
                        (city = new EntryCell {
                            Label = "City", Text = Store.City
                        }),
                        (state = new EntryCell {
                            Label = "State", Text = Store.State
                        }),
                        (zipCode = new EntryCell {
                            Label = "Zipcode", Text = Store.ZipCode
                        }),
                        (country = new EntryCell {
                            Label = "Country", Text = Store.Country
                        }),
                        (detectLatLong = new TextCell()
                        {
                            Text = "Detect Lat/Long"
                        }),
                        (latitude = new TextCell {
                            Text = Store.Latitude.ToString()
                        }),
                        (longitude = new TextCell {
                            Text = Store.Longitude.ToString()
                        }),
                    },


                    new TableSection("Hours")
                    {
                        (mondayOpen = new EntryCell {
                            Label = "Monday Open", Text = Store.MondayOpen
                        }),
                        (mondayClose = new EntryCell {
                            Label = "Monday Close", Text = Store.MondayClose
                        }),
                        (tuesdayOpen = new EntryCell {
                            Label = "Tuesday Open", Text = Store.TuesdayOpen
                        }),
                        (tuesdayClose = new EntryCell {
                            Label = "Tuesday Close", Text = Store.TuesdayClose
                        }),
                        (wednesdayOpen = new EntryCell {
                            Label = "Wedneday Open", Text = Store.WednesdayOpen
                        }),
                        (wednesdayClose = new EntryCell {
                            Label = "Wedneday Close", Text = Store.WednesdayClose
                        }),
                        (thursdayOpen = new EntryCell {
                            Label = "Thursday Open", Text = Store.ThursdayOpen
                        }),
                        (thursdayClose = new EntryCell {
                            Label = "Thursday Close", Text = Store.ThursdayClose
                        }),
                        (fridayOpen = new EntryCell {
                            Label = "Friday Open", Text = Store.FridayOpen
                        }),
                        (fridayClose = new EntryCell {
                            Label = "Friday Close", Text = Store.FridayClose
                        }),
                        (saturdayOpen = new EntryCell {
                            Label = "Saturday Open", Text = Store.SaturdayOpen
                        }),
                        (saturdayClose = new EntryCell {
                            Label = "Saturday Close", Text = Store.SaturdayClose
                        }),
                        (sundayOpen = new EntryCell {
                            Label = "Sunday Open", Text = Store.SundayOpen
                        }),
                        (sundayClose = new EntryCell {
                            Label = "Sunday Close", Text = Store.SundayClose
                        }),
                    },
                },
            };

            refreshImage.Tapped += (sender, e) =>
            {
                image.Source = ImageSource.FromUri(new Uri(imageUrl.Text));
            };

            detectLatLong.Tapped += async(sender, e) =>
            {
                var coder    = new Xamarin.Forms.Maps.Geocoder();
                var oldTitle = Title;
                Title = "Please wait...";
                var locations = await coder.GetPositionsForAddressAsync(streetAddress.Text + " " + city.Text + ", " + state.Text + " " + zipCode.Text + " " + country.Text);

                Title = oldTitle;
                foreach (var location in locations)
                {
                    latitude.Text  = location.Latitude.ToString();
                    longitude.Text = location.Longitude.ToString();
                    break;
                }
            };

            SetBinding(Page.IsBusyProperty, new Binding("IsBusy"));
        }
コード例 #15
0
        public HomePage()
        {
            selectedPlayers = new List <Player>();

            Label header = new Label
            {
                Text              = "Piłkarzyki",
                FontSize          = 50,
                FontAttributes    = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.Center
            };

            //https://gist.github.com/yuv4ik/c7137c4ea89ededa99dfee51bfb1de4e http://stackoverflow.com/questions/35931470/timepicker-with-seconds
            //TimePicker timePicker = new TimePicker
            //{
            //	Format = @"mm\:ss",
            //	Time = TimeSpan.FromMinutes(5),
            //	TextColor = Color.Green,
            //	HeightRequest = 200
            //};

            Button choosePlayersButton = new Button
            {
                Text = "Wybierz graczy",
                Font = Font.SystemFontOfSize(NamedSize.Large),
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.CenterAndExpand
            };

            choosePlayersButton.Clicked += SelectPlayers;

            PlayerImg1 = new CircleImage
            {
                WidthRequest      = 200,
                HeightRequest     = 200,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                Aspect            = Aspect.AspectFill,
                Source            = ImageSource.FromFile("anon1.png")
            };
            PlayerImg2 = new CircleImage
            {
                WidthRequest      = 200,
                HeightRequest     = 200,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                Aspect            = Aspect.AspectFill,
                Source            = ImageSource.FromFile("anon2.png")
            };
            PlayerImg3 = new CircleImage
            {
                WidthRequest      = 200,
                HeightRequest     = 200,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                Aspect            = Aspect.AspectFill,
                Source            = ImageSource.FromFile("anon3.png")
            };
            PlayerImg4 = new CircleImage
            {
                WidthRequest      = 200,
                HeightRequest     = 200,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                Aspect            = Aspect.AspectFill,
                Source            = ImageSource.FromFile("anon4.png")
            };

            Grid playersGrid = new Grid
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                RowDefinitions    =
                {
                    new RowDefinition {
                        Height = new GridLength(150)
                    },
                    new RowDefinition {
                        Height = new GridLength(150)
                    },
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

            playersGrid.Children.Add(PlayerImg1, 0, 0);
            playersGrid.Children.Add(PlayerImg2, 0, 1);

            playersGrid.Children.Add(PlayerImg3, 1, 0);
            playersGrid.Children.Add(PlayerImg4, 1, 1);

            letsPlayButton = new Button
            {
                Text = "Gramy!",
                Font = Font.SystemFontOfSize(NamedSize.Large),
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                IsVisible         = false
            };

            letsPlayButton.Clicked += StartGame;

            ToolbarItem settingsToolbarItem = new ToolbarItem();

            settingsToolbarItem.Order = ToolbarItemOrder.Primary;
            settingsToolbarItem.Icon  = "settingsIcon.png";
            settingsToolbarItem.SetBinding(ToolbarItem.CommandProperty, new Binding("ShowSettingsPage"));
            settingsToolbarItem.Clicked += ShowSettingsPage;

            ToolbarItems.Add(settingsToolbarItem);

            Content = new StackLayout
            {
                Children =
                {
                    header,
                    choosePlayersButton,
                    playersGrid,
                    letsPlayButton
                }
            };
        }
コード例 #16
0
        public QuestionsDetailsPage(Questions questions)
        {
            this.questions = questions;
            InitializeComponent();
            BindingContext = new QuestionsDetailsViewModel(questions);

            var cancel = new ToolbarItem
            {
                Text    = "分享",
                Command = new Command(() =>
                {
                    DependencyService.Get <IShares>().Shares("https://q.cnblogs.com/q/" + questions.Qid + "/", questions.Title);
                })
            };

            ToolbarItems.Add(cancel);

            if (Device.Android == Device.RuntimePlatform)
            {
                cancel.Icon = "toolbar_share.png";
            }

            formsWebView.OnContentLoaded += delegate(object sender, EventArgs e)
            {
                RefreshQuestions();
            };

            formsWebView.AddLocalCallback("reload", async delegate(string obj)
            {
                if (formsWebView.LoadStatus == LoadMoreStatus.StausDefault || formsWebView.LoadStatus == LoadMoreStatus.StausError || formsWebView.LoadStatus == LoadMoreStatus.StausFail)
                {
                    var questionsComments = JsonConvert.SerializeObject(await ViewModel.ReloadAnswersAsync());
                    await formsWebView.InjectJavascriptAsync("updateComments(" + questionsComments + ");");
                }
            });
            formsWebView.AddLocalCallback("editItem", delegate(string id)
            {
                var questionsAnswers = ViewModel.QuestionsAnswers.Where(n => n.AnswerID == int.Parse(id)).FirstOrDefault();
                Device.BeginInvokeOnMainThread(async() =>
                {
                    var page = new QuestionsAnswersPopupPage(questions, new Action <QuestionsAnswers>(OnResult), questionsAnswers);
                    await Navigation.PushPopupAsync(page);
                });
            });
            formsWebView.AddLocalCallback("deleteItem", async delegate(string id)
            {
                var result = await ViewModel.DeleteQuestionAnswersAsync(int.Parse(id));
                await formsWebView.InjectJavascriptAsync("deleteComment(" + id + "," + result.ToString().ToLower() + ");");
            });
            formsWebView.AddLocalCallback("itemSelected", delegate(string id)
            {
                var questionsAnswers = ViewModel.QuestionsAnswers.Where(n => n.AnswerID == int.Parse(id)).FirstOrDefault();
                Device.BeginInvokeOnMainThread(async() =>
                {
                    var answersDetails = new AnswersDetailsPage(questionsAnswers);
                    if (questionsAnswers.AnswerID > 0)
                    {
                        await NavigationService.PushAsync(Navigation, answersDetails);
                    }
                });
            });
        }
コード例 #17
0
        public void Init()
        {
            var logo = new CachedImage
            {
                Source            = "logo.png",
                HorizontalOptions = LayoutOptions.Center,
                WidthRequest      = 282,
                HeightRequest     = 44
            };

            var versionLabel = new Label
            {
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                Text     = $@"{AppResources.Version} {_appInfoService.Version} ({_appInfoService.Build})
© 8bit Solutions LLC 2015-{DateTime.Now.Year}",
                HorizontalTextAlignment = TextAlignment.Center
            };

            var logoVersionStackLayout = new StackLayout
            {
                Children = { logo, versionLabel },
                Spacing  = 20,
                Padding  = new Thickness(0, 40, 0, 0)
            };

            CreditsCell = new ExtendedTextCell
            {
                Text            = AppResources.Credits,
                ShowDisclousure = true
            };

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

            if (Device.RuntimePlatform == Device.iOS)
            {
                table.RowHeight          = -1;
                table.EstimatedRowHeight = 44;
            }

            var stackLayout = new StackLayout
            {
                Children = { logoVersionStackLayout, table },
                Spacing  = 0
            };

            if (Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.Windows)
            {
                ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Close));
            }

            Title   = AppResources.About;
            Content = new ScrollView {
                Content = stackLayout
            };
        }
コード例 #18
0
        private void Init()
        {
            NameCell = new FormEntryCell(AppResources.Name);

            var table = new ExtendedTableView
            {
                Intent          = TableIntent.Settings,
                EnableScrolling = false,
                HasUnevenRows   = true,
                Root            = new TableRoot
                {
                    new TableSection(Helpers.GetEmptyTableSectionTitle())
                    {
                        NameCell
                    }
                }
            };

            if (Device.RuntimePlatform == Device.iOS)
            {
                table.RowHeight          = -1;
                table.EstimatedRowHeight = 70;
            }
            else if (Device.RuntimePlatform == Device.Android)
            {
                table.BottomPadding = 50;
            }

            var saveToolBarItem = new ToolbarItem(AppResources.Save, Helpers.ToolbarImage("save.png"), async() =>
            {
                if (_lastAction.LastActionWasRecent())
                {
                    return;
                }
                _lastAction = DateTime.UtcNow;

                if (!_connectivity.IsConnected)
                {
                    AlertNoConnection();
                    return;
                }

                if (string.IsNullOrWhiteSpace(NameCell.Entry.Text))
                {
                    await DisplayAlert(AppResources.AnErrorHasOccurred, string.Format(AppResources.ValidationFieldRequired,
                                                                                      AppResources.Name), AppResources.Ok);
                    return;
                }

                var folder = new Folder
                {
                    Name = NameCell.Entry.Text.Encrypt()
                };

                await _deviceActionService.ShowLoadingAsync(AppResources.Saving);
                var saveResult = await _folderService.SaveAsync(folder);
                await _deviceActionService.HideLoadingAsync();

                if (saveResult.Succeeded)
                {
                    _deviceActionService.Toast(AppResources.FolderCreated);
                    _googleAnalyticsService.TrackAppEvent("CreatedFolder");
                    await Navigation.PopForDeviceAsync();
                }
                else if (saveResult.Errors.Count() > 0)
                {
                    await DisplayAlert(AppResources.AnErrorHasOccurred, saveResult.Errors.First().Message, AppResources.Ok);
                }
                else
                {
                    await DisplayAlert(null, AppResources.AnErrorHasOccurred, AppResources.Ok);
                }
            }, ToolbarItemOrder.Default, 0);

            Title   = AppResources.AddFolder;
            Content = table;
            ToolbarItems.Add(saveToolBarItem);
            if (Device.RuntimePlatform == Device.iOS || Device.RuntimePlatform == Device.UWP)
            {
                ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel));
            }
        }
コード例 #19
0
        public CardsSampleView()
        {
            var cardsView = new CardsView
            {
                ItemTemplate    = new DataTemplate(() => new DefaultCardItemView()),
                BackgroundColor = Color.Black.MultiplyAlpha(.9)
            };

            AbsoluteLayout.SetLayoutFlags(cardsView, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(cardsView, new Rectangle(0, 0, 1, 1));

            //cardsView.GestureRecognizers.
            //AbsoluteLayout.SetLayoutBounds(cardsView, new Rectangle(0, 0, HeightRequest = 50, WidthRequest = 100));

            var prevItem = new ToolbarItem
            {
                Text             = "**Prev**",
                Icon             = "prev",
                CommandParameter = false
            };

            prevItem.SetBinding(MenuItem.CommandProperty, nameof(CardsSampleViewModel.PanPositionChangedCommand));

            var nextItem = new ToolbarItem
            {
                Text             = "**Next**",
                Icon             = "next",
                CommandParameter = true
            };

            nextItem.SetBinding(MenuItem.CommandProperty, nameof(CardsSampleViewModel.PanPositionChangedCommand));

            ToolbarItems.Add(prevItem);
            ToolbarItems.Add(nextItem);

            cardsView.SetBinding(CardsView.ItemsSourceProperty, nameof(CardsSampleViewModel.Items));
            cardsView.SetBinding(CardsView.SelectedIndexProperty, nameof(CardsSampleViewModel.CurrentIndex));

            Title = "Tips for a Happy Classroom";


            //var removeButton = new Button
            //{
            //	Text = "Remove current",
            //	FontAttributes = FontAttributes.Bold,
            //	TextColor = Color.Black,
            //	BackgroundColor = Color.Yellow.MultiplyAlpha(.7),
            //	Margin = new Thickness(0, 0, 0, 10)
            //};

            //removeButton.SetBinding(Button.CommandProperty, nameof(CardsSampleViewModel.RemoveCurrentItemCommand));

            //AbsoluteLayout.SetLayoutFlags(removeButton, AbsoluteLayoutFlags.PositionProportional);
            //AbsoluteLayout.SetLayoutBounds(removeButton, new Rectangle(.5, 1, 150, 40));



            Content = new AbsoluteLayout()
            {
                Children =
                {
                    cardsView
                    //removeButton
                }
            };

            BindingContext = new CardsSampleViewModel();
        }
コード例 #20
0
ファイル: LoginPage.cs プロジェクト: whjvenyl/mobile
        private void Init()
        {
            MessagingCenter.Send(Application.Current, "ShowStatusBar", true);

            var padding = Helpers.OnPlatform(
                iOS: new Thickness(15, 20),
                Android: new Thickness(15, 8),
                Windows: new Thickness(10, 8));

            PasswordCell = new FormEntryCell(AppResources.MasterPassword, isPassword: true,
                                             useLabelAsPlaceholder: true, imageSource: "lock.png", containerPadding: padding);
            EmailCell = new FormEntryCell(AppResources.EmailAddress, nextElement: PasswordCell.Entry,
                                          entryKeyboard: Keyboard.Email, useLabelAsPlaceholder: true, imageSource: "envelope.png",
                                          containerPadding: padding);

            var lastLoginEmail = _settings.GetValueOrDefault(Constants.LastLoginEmail, string.Empty);

            if (!string.IsNullOrWhiteSpace(_email))
            {
                EmailCell.Entry.Text = _email;
            }
            else if (!string.IsNullOrWhiteSpace(lastLoginEmail))
            {
                EmailCell.Entry.Text = lastLoginEmail;
            }

            PasswordCell.Entry.ReturnType = Enums.ReturnType.Go;

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

            var forgotPasswordButton = new ExtendedButton
            {
                Text            = AppResources.GetPasswordHint,
                Style           = (Style)Application.Current.Resources["btn-primaryAccent"],
                Margin          = new Thickness(15, 0, 15, 25),
                Command         = new Command(async() => await ForgotPasswordAsync()),
                Uppercase       = false,
                BackgroundColor = Color.Transparent
            };

            var layout = new StackLayout
            {
                Children = { table, forgotPasswordButton },
                Spacing  = Helpers.OnPlatform(iOS: 0, Android: 10, Windows: 0)
            };

            var scrollView = new ScrollView {
                Content = layout
            };

            if (Device.RuntimePlatform == Device.iOS)
            {
                table.RowHeight          = -1;
                table.EstimatedRowHeight = 70;
                ToolbarItems.Add(new DismissModalToolBarItem(this, AppResources.Cancel, () =>
                {
                    MessagingCenter.Send(Application.Current, "ShowStatusBar", false);
                }));
            }

            var loginToolbarItem = new ToolbarItem(AppResources.LogIn, Helpers.ToolbarImage("login.png"), async() =>
            {
                await LogIn();
            }, ToolbarItemOrder.Default, 0);

            ToolbarItems.Add(loginToolbarItem);
            Title   = AppResources.Bitwarden;
            Content = scrollView;
            NavigationPage.SetBackButtonTitle(this, AppResources.LogIn);
        }
コード例 #21
0
        public ContractInstancePage(Contract contractInstance)
        {
            //TODO: FOR NOW JUST TAKING THE NAME OF THE WORKFLOW
            Title = App.ViewModel.Contract.DisplayName + $" ({contractInstance?.Id})";
            ViewModel.ContractInstance = contractInstance;
            NavigationPage.SetBackButtonTitle(this, "Back");

            var loadingIndicator = new ActivityIndicator {
                AutomationId = "LoadingIndicator"
            };

            actionButton = new Button
            {
                Text              = "TAKE ACTION",
                CornerRadius      = 0,
                BackgroundColor   = Color.White,
                TextColor         = Constants.NavBarBackgroundColor,
                FontSize          = 18,
                FontAttributes    = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            var contractDetails  = new ContractDetailsView();
            var contractProgress = new ContractProgressView();
            var contactsView     = new ScrollingContactsView();

            var transactionHeader = new Label
            {
                Text           = "ACTIVITY",
                FontSize       = 18,
                FontAttributes = FontAttributes.Bold,
            };

            transactionsList = new NestedListView(ListViewCachingStrategy.RecycleElement)
            {
                Header = new ContentView
                {
                    Content = transactionHeader,
                    Padding = new Thickness(10, 10, 10, 0),
                },
                ItemTemplate        = new DataTemplate(typeof(BlockTransactionViewCell)),
                SeparatorVisibility = SeparatorVisibility.None,
                HasUnevenRows       = true,
                VerticalOptions     = LayoutOptions.FillAndExpand
            };

            BackgroundColor = Color.FromHex("#E3E3E3");

            var gridLayout = new Grid
            {
                Padding        = new Thickness(10, 10, 10, 0),
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    }
                },
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition {
                        Width = GridLength.Star
                    }
                }
            };

            var stacklayout = new StackLayout
            {
                Padding = new Thickness(10, 10, 10, 10)
            };

            stacklayout.Children.Add(loadingIndicator);
            stacklayout.Children.Add(actionButton);

            stacklayout.Children.Add(new MaterialFrame {
                Content = contractProgress, Padding = Device.RuntimePlatform.Equals(Device.iOS) ? 0 : 5
            });
            stacklayout.Children.Add(new MaterialFrame {
                Content = contractDetails, Padding = Device.RuntimePlatform.Equals(Device.iOS) ? 0 : 5
            });


            var contactsLabel = new Label
            {
                FontAttributes          = FontAttributes.Bold,
                FontSize                = 18,
                HorizontalTextAlignment = TextAlignment.Start,
                Text = "MEMBERS"
            };

            gridLayout.Children.Add(contactsLabel, 0, 0);
            gridLayout.Children.Add(contactsView, 0, 1);

            stacklayout.Children.Add(new MaterialFrame {
                Content = gridLayout, Padding = Device.RuntimePlatform.Equals(Device.iOS) ? 0 : 5
            });                                                                                                                                           //, 0, 2);
            stacklayout.Children.Add(new MaterialFrame {
                Content = transactionsList, Padding = Device.RuntimePlatform.Equals(Device.iOS) ? 0 : 5
            });                                                                                                                                                 //, 0, 3);

            if (Device.RuntimePlatform.Equals(Device.Android))
            {
                actionButton.HeightRequest     = 50;
                loadingIndicator.HeightRequest = 50;
            }

            contractProgress.SetBinding(ContractProgressView.ContractProperty, nameof(ContractInstanceViewModel.ContractInstance));
            contractDetails.SetBinding(ContractDetailsView.ContractProperty, nameof(ContractInstanceViewModel.ContractInstance));
            contactsView.SetBinding(ScrollingContactsView.ContactsProperty, nameof(ContractInstanceViewModel.UserList));
            actionButton.SetBinding(Button.IsVisibleProperty, nameof(ContractInstanceViewModel.DisplayActions));
            //actionButton.SetBinding(Button.IsEnabledProperty, nameof(ContractInstanceViewModel.DisplayActions));
            loadingIndicator.SetBinding(ActivityIndicator.IsRunningProperty, nameof(BaseViewModel.IsBusy));
            loadingIndicator.SetBinding(ActivityIndicator.IsVisibleProperty, nameof(BaseViewModel.IsBusy));
            transactionsList.SetBinding(ListView.ItemsSourceProperty, nameof(ContractInstanceViewModel.Blocks));

            ToolbarItems.Add(new ToolbarItem("Refresh", null, async() => await ViewModel.LoadContractInstanceAsync()));

            RootContent = new ScrollView()
            {
                Content = stacklayout, Padding = 5
            };
        }
コード例 #22
0
ファイル: SketchPage.cs プロジェクト: xeterixon/Sketching
        public SketchPage()
        {
            Title       = "Sketching";
            SaveCommand = new Command(async() => { await SaveImage(); });
            _sketchView = new SketchView
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };
            _sketchView.CanDrawOutsideImageBounds = false;
            _sketchView.EnableGrid = false;

            // How to remove all tools
            //_sketchView.RemoveAllToolbarItems();

            // How to add all tools
            //_sketchView.AddAllToolbarItems();

            // How to remove selected tools
            //_sketchView.RemoveToolbarItemByIndex(2); // Highlight
            //_sketchView.RemoveToolbarItemByName(ToolNames.HighlightTool); // Highlight

            // Setup custom toolbar with title, colors and color descriptions
            _sketchView.AddToolbarItem(ImageSource.FromResource("SketchUpp.Resources.ruler.png", typeof(RulerTool.RulerTool).GetTypeInfo().Assembly), new RulerTool.RulerTool(Navigation), null);

            var customToolbarName   = "Fuktmarkering";
            var customToolbarColors = new List <KeyValuePair <string, Color> >
            {
                new KeyValuePair <string, Color>("Dry", Color.FromHex("#FBD447")),
                new KeyValuePair <string, Color>("Moist", Color.FromHex("#FFB678")),
                new KeyValuePair <string, Color>("Wet", Color.FromHex("#FF5149")),
                new KeyValuePair <string, Color>("Leaking place", Color.FromHex("#54A7D4")),
                new KeyValuePair <string, Color>("Rot", Color.FromHex("#4BD47B"))
            };

            // How to add custom tools
            //_sketchView.AddToolbarItem(ImageSource.FromResource("Sketching.Resources.Line.png", typeof(LineTool).GetTypeInfo().Assembly), new LineTool(ToolNames.LineTool, customToolbarName, customToolbarColors), null);
            //_sketchView.AddToolbarItem(ImageSource.FromResource("Sketching.Resources.Curve.png", typeof(CurveTool).GetTypeInfo().Assembly), new CurveTool(ToolNames.CurveTool, customToolbarName, customToolbarColors), null);
            //_sketchView.AddToolbarItem(ImageSource.FromResource("Sketching.Resources.Highlight.png", typeof(HighlightTool).GetTypeInfo().Assembly), new HighlightTool(ToolNames.HighlightTool, customToolbarName, customToolbarColors), null);
            //_sketchView.AddToolbarItem(ImageSource.FromResource("Sketching.Resources.Circle.png", typeof(CircleTool).GetTypeInfo().Assembly), new CircleTool(ToolNames.CircleTool, customToolbarName, customToolbarColors), null);
            //_sketchView.AddToolbarItem(ImageSource.FromResource("Sketching.Resources.Oval.png", typeof(OvalTool).GetTypeInfo().Assembly), new OvalTool(ToolNames.OvalTool, customToolbarName, customToolbarColors), null);
            //_sketchView.AddToolbarItem(ImageSource.FromResource("Sketching.Resources.Rectangle.png", typeof(RectangleTool).GetTypeInfo().Assembly), new RectangleTool(ToolNames.RectangleTool, customToolbarName, customToolbarColors), null);
            //_sketchView.AddToolbarItem(ImageSource.FromResource("Sketching.Resources.Arrow.png", typeof(ArrowTool).GetTypeInfo().Assembly), new ArrowTool(ToolNames.ArrowTool, customToolbarName, customToolbarColors), null);
            //_sketchView.AddToolbarItem(ImageSource.FromResource("Sketching.Resources.Point.png", typeof(MarkTool).GetTypeInfo().Assembly), new MarkTool(ToolNames.PointTool, customToolbarName, customToolbarColors), null);
            //_sketchView.AddToolbarItem(ImageSource.FromResource("Sketching.Resources.Text.png", typeof(TextTool).GetTypeInfo().Assembly), new TextTool(Navigation, ToolNames.TextTool, customToolbarName, customToolbarColors), null);

            // Text with rounded corners if fill is active
            //_sketchView.AddToolbarItem(ImageSource.FromResource("Sketching.Resources.Text.png", typeof(TextTool).GetTypeInfo().Assembly), new TextTool(Navigation, "RoundedFill", customToolbarName, customToolbarColors, true), null);

            // Create a custom MoistMeasure tool
            var moistColors = new List <KeyValuePair <string, Color> >
            {
                new KeyValuePair <string, Color>("MP1", Color.FromHex("#FBD447")),
                new KeyValuePair <string, Color>("MP2", Color.FromHex("#FFB678")),
                new KeyValuePair <string, Color>("MP3", Color.FromHex("#FFB678")),
                new KeyValuePair <string, Color>("MP4", Color.FromHex("#FF5149"))
            };
            var moistTool = new MoistTool("Moisture", "Mätpunkter", moistColors)
            {
                ShowDefaultToolbar = false
            };
            var assembly = typeof(SketchPage).GetTypeInfo().Assembly;

            _sketchView.AddToolbarItem(ImageSource.FromResource("SketchUpp.Resources.Moist.png", assembly), moistTool, null);
            GeometryRenderer.AddRenderer(new MoistRenderer());

            // Add default tools
            _sketchView.AddDefaultToolbarItems();

            // How to add the undo buttons
            //_sketchView.AddUndoTools();

            ToolbarItems.Add(new ToolbarItem {
                Text = "Save", Command = SaveCommand
            });
            ToolbarItems.Add(new ToolbarItem {
                Text = "Photo", Command = new Command(async() => { await TakePhoto(); })
            });
            ToolbarItems.Add(new ToolbarItem {
                Text = "Album", Command = new Command(async() => { await SelectImage(); })
            });
            Content = _sketchView;
        }
コード例 #23
0
        public VenuePage()
        {
            InitializeComponent();
            BindingContext = vm = new VenueViewModel();

            if (Device.OS == TargetPlatform.Android)
            {
                ToolbarItems.Add(new ToolbarItem
                {
                    Order   = ToolbarItemOrder.Secondary,
                    Text    = "Get Directions",
                    Command = vm.NavigateCommand
                });

                if (vm.CanMakePhoneCall)
                {
                    ToolbarItems.Add(new ToolbarItem
                    {
                        Order   = ToolbarItemOrder.Secondary,
                        Text    = "Call Hotel",
                        Command = vm.CallCommand
                    });
                }
            }
            else if (Device.OS == TargetPlatform.iOS)
            {
                ToolbarItems.Add(new ToolbarItem
                {
                    Text    = "More",
                    Icon    = "toolbar_overflow.png",
                    Command = new Command(async() =>
                    {
                        string[] items = null;
                        if (!vm.CanMakePhoneCall)
                        {
                            items = new[] { "Get Directions" };
                        }
                        else
                        {
                            items = new[] { "Get Directions", "Call +1 (407) 284-1234" };
                        }
                        var action = await DisplayActionSheet("Hyatt Regency", "Cancel", null, items);
                        if (action == items[0])
                        {
                            vm.NavigateCommand.Execute(null);
                        }
                        else if (items.Length > 1 && action == items[1] && vm.CanMakePhoneCall)
                        {
                            vm.CallCommand.Execute(null);
                        }
                    })
                });
            }
            else
            {
                ToolbarItems.Add(new ToolbarItem
                {
                    Text    = "Directions",
                    Command = vm.NavigateCommand,
                    Icon    = "toolbar_navigate.png"
                });

                if (vm.CanMakePhoneCall)
                {
                    ToolbarItems.Add(new ToolbarItem
                    {
                        Text    = "Call",
                        Command = vm.CallCommand,
                        Icon    = "toolbar_call.png"
                    });
                }
            }
        }
コード例 #24
0
        public TodoListPageCS()
        {
            Title = "Todo";

            var toolbarItem = new ToolbarItem
            {
                Text = "+",
                Icon = "plus.png"
            };

            toolbarItem.Clicked += async(sender, e) =>
            {
                await Navigation.PushAsync(new TodoItemPageCS
                {
                    BindingContext = new TodoItem()
                });
            };
            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 TodoItemPageCS
                    {
                        BindingContext = e.SelectedItem as TodoItem
                    });
                }
            };

            Content = listView;
        }
コード例 #25
0
        public void Init()
        {
            Password = new Label
            {
                FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                Margin   = new Thickness(15, 40, 15, 40),
                HorizontalTextAlignment = TextAlignment.Center,
                FontFamily      = Device.OnPlatform(iOS: "Courier", Android: "monospace", WinPhone: "Courier"),
                LineBreakMode   = LineBreakMode.TailTruncation,
                VerticalOptions = LayoutOptions.Start
            };

            var tgr = new TapGestureRecognizer();

            tgr.Tapped += Tgr_Tapped;
            Password.GestureRecognizers.Add(tgr);
            Password.SetBinding <PasswordGeneratorPageModel>(Label.TextProperty, m => m.Password);

            SliderCell = new SliderViewCell(this, _passwordGenerationService, _settings);
            var settingsCell = new ExtendedTextCell {
                Text = AppResources.MoreSettings, ShowDisclousure = true
            };

            settingsCell.Tapped += SettingsCell_Tapped;

            var buttonColor    = Color.FromHex("3c8dbc");
            var regenerateCell = new ExtendedTextCell {
                Text = AppResources.RegeneratePassword, TextColor = buttonColor
            };

            regenerateCell.Tapped += RegenerateCell_Tapped;;
            var copyCell = new ExtendedTextCell {
                Text = AppResources.CopyPassword, TextColor = buttonColor
            };

            copyCell.Tapped += CopyCell_Tapped;

            var table = new ExtendedTableView
            {
                VerticalOptions = LayoutOptions.Start,
                EnableScrolling = false,
                Intent          = TableIntent.Settings,
                HasUnevenRows   = true,
                NoHeader        = true,
                Root            = new TableRoot
                {
                    new TableSection
                    {
                        regenerateCell,
                        copyCell
                    },
                    new TableSection(AppResources.Options)
                    {
                        SliderCell,
                        settingsCell
                    }
                }
            };

            if (Device.OS == TargetPlatform.iOS)
            {
                table.RowHeight          = -1;
                table.EstimatedRowHeight = 44;
                ToolbarItems.Add(new DismissModalToolBarItem(this,
                                                             _passwordValueAction == null ? AppResources.Close : AppResources.Cancel));
            }

            var stackLayout = new StackLayout
            {
                Orientation     = StackOrientation.Vertical,
                Children        = { Password, table },
                VerticalOptions = LayoutOptions.FillAndExpand,
                Spacing         = 0
            };

            var scrollView = new ScrollView
            {
                Content         = stackLayout,
                Orientation     = ScrollOrientation.Vertical,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            if (_passwordValueAction != null)
            {
                var selectToolBarItem = new ToolbarItem(AppResources.Select, null, async() =>
                {
                    _googleAnalyticsService.TrackAppEvent("SelectedGeneratedPassword");
                    _passwordValueAction(Password.Text);
                    await Navigation.PopForDeviceAsync();
                }, ToolbarItemOrder.Default, 0);

                ToolbarItems.Add(selectToolBarItem);
            }

            Title          = AppResources.GeneratePassword;
            Content        = scrollView;
            BindingContext = Model;
        }
コード例 #26
0
ファイル: ProtocolsPage.cs プロジェクト: ankit011094/sensus
        public ProtocolsPage()
        {
            Title = "Protocols";

            _protocolsList = new ListView();
            _protocolsList.ItemTemplate = new DataTemplate(typeof(TextCell));
            _protocolsList.ItemTemplate.SetBinding(TextCell.TextProperty, "Name");
            _protocolsList.ItemTapped += async(o, e) =>
            {
                if (_protocolsList.SelectedItem == null)
                {
                    return;
                }

                Protocol selectedProtocol = _protocolsList.SelectedItem as Protocol;

                string selectedAction = await DisplayActionSheet(selectedProtocol.Name, "Cancel", null, selectedProtocol.Running? "Stop" : "Start", "Edit", "Status", "Share", "Delete");

                if (selectedAction == "Start")
                {
                    selectedProtocol.StartWithUserAgreement(null);
                }
                else if (selectedAction == "Stop")
                {
                    if (await DisplayAlert("Confirm Stop", "Are you sure you want to stop " + selectedProtocol.Name + "?", "Yes", "No"))
                    {
                        selectedProtocol.Running = false;
                    }
                }
                else if (selectedAction == "Edit")
                {
                    Action editAction = new Action(async() =>
                    {
                        ProtocolPage protocolPage  = new ProtocolPage(selectedProtocol);
                        protocolPage.Disappearing += (oo, ee) => Bind();      // rebind to pick up name changes
                        await Navigation.PushAsync(protocolPage);
                        _protocolsList.SelectedItem = null;
                    });

                    ExecuteActionUponProtocolAuthentication(selectedProtocol, editAction);
                }
                else if (selectedAction == "Status")
                {
                    if (UiBoundSensusServiceHelper.Get(true).ProtocolShouldBeRunning(selectedProtocol))
                    {
                        selectedProtocol.TestHealthAsync(true, () =>
                        {
                            Device.BeginInvokeOnMainThread(async() =>
                            {
                                if (selectedProtocol.MostRecentReport == null)
                                {
                                    await DisplayAlert("No Report", "Status check failed.", "OK");
                                }
                                else
                                {
                                    await Navigation.PushAsync(new ViewTextLinesPage("Protocol Report", selectedProtocol.MostRecentReport.ToString().Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList(), null));
                                }
                            });
                        });
                    }
                    else
                    {
                        await DisplayAlert("Protocol Not Running", "Cannot check status of protocol when protocol is not running.", "OK");
                    }
                }
                else if (selectedAction == "Share")
                {
                    Action shareAction = new Action(() =>
                    {
                        string path = null;
                        try
                        {
                            path = UiBoundSensusServiceHelper.Get(true).GetSharePath(".sensus");
                            selectedProtocol.Save(path);
                        }
                        catch (Exception ex)
                        {
                            UiBoundSensusServiceHelper.Get(true).Logger.Log("Failed to save protocol to file for sharing:  " + ex.Message, LoggingLevel.Normal, GetType());
                            path = null;
                        }

                        if (path != null)
                        {
                            UiBoundSensusServiceHelper.Get(true).ShareFileAsync(path, "Sensus Protocol:  " + selectedProtocol.Name);
                        }
                    });

                    // don't authenticate if the protocol was declared shareable -- participants might require the ability to share without the password.
                    if (selectedProtocol.Shareable)
                    {
                        shareAction();
                    }
                    // if the protocol isn't declared shareable, require authentication, since sharing is equivalent to editing the protocol.
                    else
                    {
                        ExecuteActionUponProtocolAuthentication(selectedProtocol, shareAction);
                    }
                }
                else if (selectedAction == "Delete")
                {
                    if (await DisplayAlert("Delete " + selectedProtocol.Name + "?", "This action cannot be undone.", "Delete", "Cancel"))
                    {
                        selectedProtocol.StopAsync(() =>
                        {
                            UiBoundSensusServiceHelper.Get(true).UnregisterProtocol(selectedProtocol);

                            try
                            {
                                Directory.Delete(selectedProtocol.StorageDirectory, true);
                            }
                            catch (Exception ex)
                            {
                                UiBoundSensusServiceHelper.Get(true).Logger.Log("Failed to delete protocol storage directory \"" + selectedProtocol.StorageDirectory + "\":  " + ex.Message, LoggingLevel.Normal, GetType());
                            }

                            Device.BeginInvokeOnMainThread(() =>
                            {
                                _protocolsList.SelectedItem = null;          // must reset this manually, since it isn't reset automatically
                            });
                        });
                    }
                }
            };

            Bind();

            Content = _protocolsList;

            ToolbarItems.Add(new ToolbarItem(null, "plus.png", () =>
            {
                Protocol.CreateAsync("New Protocol", protocol =>
                {
                    UiBoundSensusServiceHelper.Get(true).RegisterProtocol(protocol);
                });
            }));
        }
コード例 #27
0
 private void CancelChangeCoverPicToolbarItem_Clicked(object sender, EventArgs e)
 {
     _mediaFileCover = null;
     ToolbarItems.Remove(cancelChangeCoverPicToolbarItem);
     ToolbarItems.Add(changeCoverPicToolbarItem);
 }
コード例 #28
0
        public SettingsPage()
        {
            Title = "Settings";

            Settings = new TableView()
            {
                Intent = TableIntent.Settings,

                Root = new TableRoot
                {
                    new TableSection("Main Activity Theming")
                    {
                        new ColorPickerCell()
                        {
                            Title      = "Background:", Placeholder = "Select Color for Background",
                            StorageKey = "backColor", Message = "ChangeBackColor",
                            Command    = new Command(() => Done())
                        },

                        new ColorPickerCell()
                        {
                            Title      = "All Text:", Placeholder = "Select Color for Text",
                            StorageKey = "textColor", Message = "ChangeTextColor",
                            Command    = new Command(() => Done())
                        },

                        new ColorPickerCell()
                        {
                            Title      = "Calories Text:", Placeholder = "Select Color for Calories",
                            StorageKey = "caloriesColor", Message = "ChangeCaloriesColor",
                            Command    = new Command(() => Done())
                        }
                    },
                    new TableSection("Available Calories")
                    {
                        new SettingsEntryCell()
                        {
                            Placeholder = "Enter Maximum Calories",
                            StorageKey  = "maxCalories", Message = "NewMaxCalories",
                            Command     = new Command(() => GoBack())
                        }
                    },
                    new TableSection("Reset")
                    {
                        new SwitchCell()
                        {
                            Text = "Reset Calories", On = false
                        },
                        new SwitchCell()
                        {
                            Text = "Reset All", On = false
                        }
                    }
                }
            };

            Close = new ToolbarItem()
            {
                Order = ToolbarItemOrder.Primary,
                Icon  = "@drawable /close"
            };

            ToolbarItems.Add(Close);

            (Settings.Root.ElementAt(2).First() as SwitchCell).PropertyChanged      += SwitchChanged;
            (Settings.Root.ElementAt(2).ElementAt(1) as SwitchCell).PropertyChanged += SwitchChanged;

            StackLayout layout = new StackLayout()
            {
                Children =
                {
                    Settings
                },

                Padding = new Thickness(15, 5, 15, 0)
            };

            Content        = layout;
            Close.Clicked += CloseClicked;
        }
コード例 #29
0
ファイル: MarcasView.cs プロジェクト: JoanP/eolymp
        public MarcasView(string name, Dictionary <string, object> info)
        {
            Title              = name;
            mainStackL         = new StackLayout();
            mainStackL.Spacing = 0;
            ToolbarItems.Add(new ToolbarItem {
                Text    = "Modifica",
                Command = new Command(async o => {
                    ((MasterDetailPage)App.Current.MainPage).Detail.Navigation.PushAsync(new ModificarView(info));
                }),
            });
            var picture = new Image()
            {
                Aspect = Aspect.AspectFill,
                Source = ImageSource.FromFile("marcasmainfoto.jpg")
            };

            Device.OnPlatform(iOS: () => {
                picture.HeightRequest = 150;
            });

            Grid structInfo = new Grid {
                //HeightRequest = 70,
                Padding        = new Thickness(5, 10, 0, 0),
                RowSpacing     = 8,
                ColumnSpacing  = 5,
                RowDefinitions = new RowDefinitionCollection {
                    new RowDefinition(),
                    new RowDefinition(),
                    new RowDefinition(),
                    new RowDefinition(),
                    new RowDefinition(),
                    new RowDefinition(),
                    new RowDefinition(),
                    new RowDefinition(),
                    new RowDefinition(),
                },
                ColumnDefinitions = new ColumnDefinitionCollection {
                    //new ColumnDefinition{ Width = new GridLength(70) },
                    new ColumnDefinition(),
                    new ColumnDefinition()
                    //new ColumnDefinition{ Width = new GridLength(50) },
                },
            };
            Label nom = new Label {
                Text              = info ["nom"].ToString(),
                BackgroundColor   = Color.Black.WithLuminosity(0.2),
                TextColor         = Color.White,
                HorizontalOptions = LayoutOptions.Fill
            };
            Label cat = new Label {
                Text = "Categoria: " + info ["categoria"].ToString()
            };
            Label dist = new Label {
                Text = "Distancia: " + info ["distancia"].ToString() + " Km"
            };
            Label club = new Label {
                Text = "Club: " + info ["club"].ToString()
            };
            Label dor = new Label {
                Text = "Dorsal: " + info ["dorsal"].ToString()
            };
            Label hm = new Label {
                Text = "Hora Meta: " + info ["horaMeta"].ToString()
            };
            Label iniciCursa = new Label {
                Text = "Inici Cursa: " + info ["iniciCursa"].ToString()
            };
            Label iniciReal = new Label {
                Text = "IniciReal: " + info ["iniciReal"].ToString()
            };
            Label k10 = new Label {
                Text = "kilometre 10: " + info ["k10"].ToString()
            };
            Label k59 = new Label {
                Text = "kilometre 5: " + info ["k59"].ToString()
            };
            Label mod = new Label {
                Text = "Modalitat: " + info ["modalitat"].ToString()
            };
            Label pos = new Label {
                Text = "Posicio: " + info ["posicio"].ToString()
            };
            Label posc = new Label {
                Text = "Posicio Categoria: " + info ["posicioCategoria"].ToString()
            };
            Label rit = new Label {
                Text = "Ritme: " + info ["ritme"].ToString()
            };
            Label tO = new Label {
                Text = "Temps Oficial: " + info ["tempsOficial"].ToString()
            };
            Label tR = new Label {
                Text = "Temps Real: " + info ["tempsReal"].ToString()
            };
            Label h10 = new Label {
                Text = "Hora km 10: " + info ["h10"].ToString()
            };
            Label h59 = new Label {
                Text = "Hora km 5: " + info ["h59"].ToString()
            };

            nom.FontAttributes = FontAttributes.Bold;
            Device.OnPlatform(iOS: () => {
                nom.FontSize        = Device.GetNamedSize(NamedSize.Large, typeof(Label));
                cat.FontSize        = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
                dist.FontSize       = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
                club.FontSize       = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
                dor.FontSize        = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
                hm.FontSize         = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
                iniciCursa.FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
                iniciReal.FontSize  = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
                k10.FontSize        = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
                k59.FontSize        = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
                mod.FontSize        = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
                pos.FontSize        = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
                posc.FontSize       = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
                rit.FontSize        = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
                tO.FontSize         = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
                tR.FontSize         = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
                h10.FontSize        = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
                h59.FontSize        = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
            });
            Device.OnPlatform(Android: () => {
                nom.FontSize        = Device.GetNamedSize(NamedSize.Large, typeof(Label));
                cat.FontSize        = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                dist.FontSize       = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                club.FontSize       = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                dor.FontSize        = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                hm.FontSize         = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                iniciCursa.FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                iniciReal.FontSize  = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                k10.FontSize        = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                k59.FontSize        = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                mod.FontSize        = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                pos.FontSize        = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                posc.FontSize       = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                rit.FontSize        = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                tO.FontSize         = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                tR.FontSize         = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                h10.FontSize        = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
                h59.FontSize        = Device.GetNamedSize(NamedSize.Medium, typeof(Label));
            });



            structInfo.Children.Add(dist, 0, 0);
            structInfo.Children.Add(pos, 0, 1);
            structInfo.Children.Add(tO, 0, 2);
            structInfo.Children.Add(tR, 0, 3);
            structInfo.Children.Add(rit, 0, 4);
            structInfo.Children.Add(hm, 0, 5);
            structInfo.Children.Add(posc, 0, 6);
            structInfo.Children.Add(club, 0, 7);
            structInfo.Children.Add(dor, 0, 8);
            structInfo.Children.Add(iniciCursa, 1, 0);
            structInfo.Children.Add(iniciReal, 1, 1);
            structInfo.Children.Add(k10, 1, 2);
            structInfo.Children.Add(k59, 1, 3);
            structInfo.Children.Add(h10, 1, 4);
            structInfo.Children.Add(h59, 1, 5);
            structInfo.Children.Add(cat, 1, 6);
            structInfo.Children.Add(mod, 1, 7);


            mainStackL.Children.Add(picture);
            mainStackL.Children.Add(nom);
            mainStackL.Children.Add(structInfo);
            Content = mainStackL;
        }
コード例 #30
0
        public AddPersonPage()
        {
            ViewModel.SaveErrored   += HandleError;
            ViewModel.SaveCompleted += HandleSaveCompleted;

            ToolbarItems.Add(new ToolbarItem
            {
                Text         = _saveButtonToolBarItemText,
                Priority     = 0,
                AutomationId = AutomationIdConstants.AddPersonPage_SaveButton
            }.Bind(ToolbarItem.CommandProperty, nameof(AddPersonViewModel.SaveButtonCommand)));

            ToolbarItems.Add(new ToolbarItem
            {
                Text         = _cancelButtonToolBarItemText,
                Priority     = 1,
                AutomationId = AutomationIdConstants.AddPersonPage_CancelButton
            }.Invoke(cancelButton => cancelButton.Clicked += HandleCancelButtonToolbarItemClicked));

            Padding = new Thickness(20, 20, 20, 0);

            Title = PageTitles.AddPersonPage;

            Content = new ScrollView
            {
                Content = new StackLayout
                {
                    Children =
                    {
                        new Label {
                            Text = "Name"
                        },

                        new AddPersonPageEntry
                        {
                            Placeholder  = "Name",
                            AutomationId = AutomationIdConstants.AddPersonPage_NameEntry,
                            ReturnType   = ReturnType.Next
                        }.Bind(Entry.TextProperty, nameof(AddPersonViewModel.NameEntryText))
                        .Bind <AddPersonPageEntry, bool, bool>(IsEnabledProperty, nameof(AddPersonViewModel.IsBusy), convert: isBusy => !isBusy)
                        .Assign(out _nameEntry),

                        new Label {
                            Text = "Age"
                        },

                        new AddPersonPageEntry
                        {
                            Placeholder  = "Age",
                            Keyboard     = Keyboard.Numeric,
                            AutomationId = AutomationIdConstants.AddPersonPage_AgeEntry,
                            ReturnType   = ReturnType.Go,
                        }.Bind(Entry.TextProperty, nameof(AddPersonViewModel.AgeEntryText))
                        .Bind(Entry.ReturnCommandProperty, nameof(AddPersonViewModel.SaveButtonCommand))
                        .Bind <Entry, bool, bool>(IsEnabledProperty, nameof(AddPersonViewModel.IsBusy), convert: isBusy => !isBusy),

                        new ActivityIndicator
                        {
                            AutomationId = AutomationIdConstants.AddPersonPage_ActivityIndicator
                        }.Bind(IsVisibleProperty, nameof(AddPersonViewModel.IsBusy))
                        .Bind(ActivityIndicator.IsRunningProperty, nameof(AddPersonViewModel.IsBusy))
                        .Assign(out _activityIndicator)
                    }
                }
            };
        }