Пример #1
0
        public ProfilesListPage(TeslaVehicle vehicle, IProfileService profileService, ITeslaAPIWrapper teslaAPIWrapper)
        {
            NavigationPage.SetHasNavigationBar(this, false);
            var listView = new CircleListView
            {
                Header       = UIUtil.CreateHeaderLabel(vehicle.Name),
                ItemTemplate = new DataTemplate(() =>
                {
                    Label nameLabel = new Label
                    {
                        HeightRequest     = 120,
                        HorizontalOptions = LayoutOptions.Center,
                        VerticalOptions   = LayoutOptions.Center,
                    };
                    nameLabel.SetBinding(Label.TextProperty, "Name");
                    return(new ViewCell
                    {
                        View = new StackLayout
                        {
                            Children =
                            {
                                nameLabel,
                            }
                        }
                    });
                }),
            };

            listView.ItemTapped += async(sender, e) => {
                var binder = (ProfileBinder)e.Item;
                await Navigation.PushAsync(new ProfileActionPage(binder.Profile, vehicle, profileService, teslaAPIWrapper));
            };

            ActionButton = new ActionButtonItem
            {
                Text    = "Create",
                Command = new Command(async() =>
                {
                    await Navigation.PushAsync(new EditProfilePage(profileService));
                })
            };

            Content = listView;

            Disposable = profileService
                         .GetProfiles()
                         .Subscribe(updatedList => {
                LogUtil.Debug("New profiles list count = " + updatedList.Count);
                listView.ItemsSource = updatedList.Select(p => new ProfileBinder(p));
            });
        }
Пример #2
0

        
Пример #3
0
        public AddRecord()
        {
            ActionButtonItem abi = new ActionButtonItem()
            {
                Text = "OK"
            };

            inBtn.IsVisible   = false;
            outBtn.IsVisible  = false;
            b.IsEnabled       = false;
            OnButtonClicked  += new EventHandler(OnButtonClick);
            inBtnClicked     += inClickedFunc;
            outBtnClicked    += outClickedFunc;
            tagBtnClicked    += tagClickedFunc;
            submitBtnClicked += submitClickedFunc;
            b.Clicked        += OnButtonClicked;
            inBtn.Clicked    += inBtnClicked;
            outBtn.Clicked   += outBtnClicked;
            tagBtn.Clicked   += new EventHandler(tagBtnClicked);
            submit.Clicked   += submitBtnClicked;
            StackLayout inOutBtnLayout = new StackLayout()
            {
                HorizontalOptions = LayoutOptions.Center,
                Orientation       = StackOrientation.Horizontal,
                Children          = { inBtn, outBtn }
            };

            Content = new StackLayout {
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                Orientation       = StackOrientation.Vertical,
                Children          = { pex, tagBtn,         new Label()
                                      {
                                          Text = "  "
                                      },            inOutBtnLayout, b, },
            };
        }
Пример #4
0
        void UpdateActionButton(bool init)
        {
            if (_actionButtonItem != null)
            {
                _actionButtonItem.PropertyChanged -= OnActionButtonItemChanged;
                _actionButtonItem = null;
            }

            if (Element.ActionButton != null)
            {
                if (_actionButton == null)
                {
                    InitializeActionButton();
                }

                UpdateActionButtonVisible(Element.ActionButton.IsVisible);
                UpdateActionButtonText(Element.ActionButton.Text);
                UpdateActionButtonIcon(Element.ActionButton.IconImageSource);
                _actionButton.IsEnabled       = Element.ActionButton.IsEnable;
                _actionButton.BackgroundColor = Element.ActionButton.BackgroundColor.ToNative();

                _actionButtonItem = Element.ActionButton;
                _actionButtonItem.PropertyChanged += OnActionButtonItemChanged;
            }
            else
            {
                if (_actionButton != null)
                {
                    DeinitializeActionButton();
                }
            }
            if (!init)
            {
                Device.BeginInvokeOnMainThread(() => OnLayout());
            }
        }
Пример #5
0
        public EditProfilePage(Profile profile, IProfileService profileService)
        {
            Profile        = profile;
            ProfileService = profileService;

            // Insert immediately so we can monitor it's actions.
            profileService.UpsertProfileAsync(Profile);

            NavigationPage.SetHasNavigationBar(this, false);

            var listView = new CircleListView
            {
                Header       = UIUtil.CreateHeaderLabel(profile.Name),
                ItemTemplate = new DataTemplate(() =>
                {
                    Label nameLabel = new Label
                    {
                        HeightRequest     = 120,
                        HorizontalOptions = LayoutOptions.Center,
                        VerticalOptions   = LayoutOptions.Center,
                    };
                    nameLabel.SetBinding(Label.TextProperty, "Name");
                    return(new ViewCell
                    {
                        View = new StackLayout
                        {
                            Children =
                            {
                                nameLabel,
                            }
                        }
                    });
                }),
            };

            listView.ItemTapped += async(sender, e) =>
            {
                var binder = (VehicleAction)e.Item;
                if (binder.Type.IsRequired())
                {
                    // if the action is required you can't edit or delete it.
                    return;
                }
                await Navigation.PushAsync(new EditActionPage(profile, binder, profileService));
            };

            Content = listView;

            Disposable = ProfileService
                         .GetProfile(Profile.Id)
                         .Subscribe(updatedProfile => {
                LogUtil.Debug("New actions list count = " + updatedProfile.Actions.Count);
                // It wasn't refreshing without this.
                listView.ItemsSource = null;
                listView.ItemsSource = updatedProfile.Actions;
                listView.ScrollTo(updatedProfile.Actions.Last(), ScrollToPosition.Center, true);
                listView.Header = UIUtil.CreateHeaderLabel(updatedProfile.Name);
            });

            ToolbarItems.Add(new CircleToolbarItem
            {
                Text    = "Rename",
                Icon    = new FileImageSource(),
                Command = new Command(async() =>
                {
                    await Navigation.PushModalAsync(new RenameProfilePage(profile, profileService));
                })
            });

            ActionButton = new ActionButtonItem
            {
                Text    = "+",
                Command = new Command(async() =>
                {
                    await Navigation.PushAsync(new AddActionPage(profile, profileService));
                })
            };
        }
Пример #6
0

        
        /// <summary>
        /// Initialize main page.
        /// Add components and events.
        /// </summary>
        private void InitializeComponent()
        {
            downloadButton = CreateDownloadButton();
            progressBar    = CreateProgressbar();

            urlEntryLabel = CreateEntryLabel();
            urlEntry      = CreateEntry();
            progressLabel = CreateProgressLabel();
            headerLabel   = CreateHeaderLabel();

            headerLabel.SetValue(Grid.RowProperty, 0);
            headerLabel.SetValue(Grid.ColumnSpanProperty, 2);

            urlEntryLabel.SetValue(Grid.RowProperty, 1);
            urlEntryLabel.SetValue(Grid.ColumnProperty, 0);

            urlEntry.SetValue(Grid.RowProperty, 1);
            urlEntry.SetValue(Grid.ColumnProperty, 1);

            progressLabel.SetValue(Grid.RowProperty, 2);
            progressLabel.SetValue(Grid.ColumnSpanProperty, 2);

            Content = new Grid()
            {
                ColumnDefinitions =
                {
                    new ColumnDefinition()
                    {
                        Width = new GridLength(2, GridUnitType.Star)
                    },
                    new ColumnDefinition()
                    {
                        Width = new GridLength(12, GridUnitType.Star)
                    },
                },
                RowDefinitions =
                {
                    new RowDefinition()
                    {
                        Height = new GridLength(100, GridUnitType.Absolute)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(100, GridUnitType.Absolute)
                    },
                    new RowDefinition()
                    {
                        Height = new GridLength(50, GridUnitType.Absolute)
                    }
                },
                Children =
                {
                    headerLabel,
                    urlEntryLabel,
                    urlEntry,
                    progressLabel
                },
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
            };

            CircleSurfaceItems.Add(progressBar);
            ActionButton = downloadButton;

            AddEvent();
        }
 void OnClickSetIcon(object sender, EventArgs args)
 {
     ActionButton = new ActionButtonItem {
         IconImageSource = ImageSource.FromFile("image/b_option_list_icon_share.png")
     };
 }
 void OnClickChangeColor(object sender, EventArgs args)
 {
     ActionButton = new ActionButtonItem {
         Text = "~!@#$%^&" + Environment.NewLine + "*()@+-", BackgroundColor = Color.Green
     };
 }