Пример #1
0
        void SetUpNewElement(IndicatorView newElement)
        {
            if (newElement == null)
            {
                IndicatorView = null;
                return;
            }

            IndicatorView = newElement;

            IndicatorView.PropertyChanged += OnElementPropertyChanged;

            if (Tracker == null)
            {
                _visualElementTracker = new VisualElementTracker(this);
            }

            this.EnsureId();

            UpdateBackgroundColor();

            if (IndicatorView.IndicatorTemplate != null)
            {
                UpdateIndicatorTemplate();
            }
            else
            {
                UpdateItemsSource();
            }

            ElevationHelper.SetElevation(this, newElement);

            UpdateSelectedIndicator();
            UpdateHidesForSinglePage();
        }
 public IndicatorsSample()
 {
     Device.SetFlags(new[] { ExperimentalFlags.CarouselViewExperimental, ExperimentalFlags.IndicatorViewExperimental });
     InitializeComponent();
     BindingContext = new GalleryPages.CollectionViewGalleries.CarouselViewGalleries.CarouselItemsGalleryViewModel();
     IndicatorView.SetItemsSourceBy(indicators, carousel);
 }
Пример #3
0
    public void Awake()
    {
        navMeshAgent = GetComponent <NavMeshAgent>();
        navMeshAgent.updateRotation = false;

        indicatorView = FindObjectOfType <IndicatorView>();
    }
Пример #4
0
        void ReleaseDesignerOutlets()
        {
            if (IndicatorView != null)
            {
                IndicatorView.Dispose();
                IndicatorView = null;
            }

            if (Label1 != null)
            {
                Label1.Dispose();
                Label1 = null;
            }

            if (Label2 != null)
            {
                Label2.Dispose();
                Label2 = null;
            }

            if (Label3 != null)
            {
                Label3.Dispose();
                Label3 = null;
            }
        }
Пример #5
0
        public void ThisTurnEnd()
        {
            IndicatorView.HideTileIndicator();
            //Viewer.battle.ThisTurnUnitInfo.CurrentPushedButton = null;
            Unit thisTurnUnit = BattleManager.instance.thisTurnUnit;

            if (thisTurnUnit != null)
            {
                thisTurnUnit.OnTurnEnd.before.Invoke(true);
                thisTurnUnit.OnTurnEnd.after.Invoke(false);
            }

            switch (BattleManager.CheckGameState())
            {
            case BattleManager.State.Continue:
                NextTurnStart();
                break;

            case BattleManager.State.Win:
                Win();
                break;

            case BattleManager.State.Defeat:
                Defeat();
                break;

            case BattleManager.State.Stop:
                break;
            }
        }
        void TearDownOldElement(IndicatorView oldElement)
        {
            if (oldElement == null)
            {
                return;
            }

            oldElement.PropertyChanged -= OnElementPropertyChanged;
        }
Пример #7
0
        protected override void Init()
        {
            var layout = new StackLayout();

            var instructions = new Label
            {
                Margin          = new Thickness(6),
                BackgroundColor = Color.Black,
                TextColor       = Color.White,
                Text            = "Press the Button to update the ItemsSource of the CarouselView below. After updating, verify that the IndicatorView is still visible. If it is visible, the test has passed."
            };

            var updateButton = new Button
            {
                Text = "Update ItemsSource"
            };

            var itemsLayout =
                new LinearItemsLayout(ItemsLayoutOrientation.Horizontal)
            {
                SnapPointsType      = SnapPointsType.MandatorySingle,
                SnapPointsAlignment = SnapPointsAlignment.Center
            };

            var carouselView = new CarouselView
            {
                ItemsLayout  = itemsLayout,
                ItemTemplate = GetCarouselTemplate()
            };

            carouselView.SetBinding(ItemsView.ItemsSourceProperty, "Items");

            var indicatorView = new IndicatorView
            {
                IndicatorColor         = Color.Red,
                SelectedIndicatorColor = Color.Green,
                IndicatorTemplate      = GetIndicatorTemplate(),
                HorizontalOptions      = LayoutOptions.Center,
                Margin = new Thickness(0, 0, 0, 24)
            };

            carouselView.IndicatorView = indicatorView;

            layout.Children.Add(instructions);
            layout.Children.Add(updateButton);
            layout.Children.Add(carouselView);
            layout.Children.Add(indicatorView);

            Content = layout;

            updateButton.Clicked += (sender, args) =>
            {
                var vm = (Issue8693ViewModel)BindingContext;
                vm.LoadItems();
            };
        }
        void ReleaseDesignerOutlets()
        {
            if (CloseButton != null)
            {
                CloseButton.Dispose();
                CloseButton = null;
            }

            if (ErrorView != null)
            {
                ErrorView.Dispose();
                ErrorView = null;
            }

            if (FeedbackPlaceholderTextView != null)
            {
                FeedbackPlaceholderTextView.Dispose();
                FeedbackPlaceholderTextView = null;
            }

            if (FeedbackTextView != null)
            {
                FeedbackTextView.Dispose();
                FeedbackTextView = null;
            }

            if (IndicatorView != null)
            {
                IndicatorView.Dispose();
                IndicatorView = null;
            }

            if (SendButton != null)
            {
                SendButton.Dispose();
                SendButton = null;
            }

            if (TitleLabel != null)
            {
                TitleLabel.Dispose();
                TitleLabel = null;
            }

            if (ErrorTitleLabel != null)
            {
                ErrorTitleLabel.Dispose();
                ErrorTitleLabel = null;
            }

            if (ErrorMessageLabel != null)
            {
                ErrorMessageLabel.Dispose();
                ErrorMessageLabel = null;
            }
        }
Пример #9
0
        protected override void Init()
        {
            var layout = new StackLayout
            {
                Padding = 12
            };

            var instructions = new Label
            {
                Padding         = 12,
                BackgroundColor = Color.Black,
                TextColor       = Color.White,
                Text            = "If you can't see the IndicatorView, the test has passed."
            };

            var settingsLayout = new StackLayout
            {
                Orientation = StackOrientation.Horizontal
            };

            var checkBox = new CheckBox
            {
                IsChecked       = true,
                VerticalOptions = LayoutOptions.Center
            };

            var infoLabel = new Label
            {
                Text            = "HideSingle",
                VerticalOptions = LayoutOptions.Center
            };

            settingsLayout.Children.Add(checkBox);
            settingsLayout.Children.Add(infoLabel);

            var indicatorView = new IndicatorView
            {
                HorizontalOptions      = LayoutOptions.Center,
                IndicatorColor         = Color.Black,
                SelectedIndicatorColor = Color.DarkGray,
                IndicatorSize          = 10,
                Count      = 1,
                HideSingle = true
            };

            layout.Children.Add(instructions);
            layout.Children.Add(settingsLayout);
            layout.Children.Add(indicatorView);

            Content = layout;

            checkBox.CheckedChanged += (sender, args) =>
            {
                indicatorView.HideSingle = checkBox.IsChecked;
            };
        }
Пример #10
0
        public void Init()
        {
            toggleOption = true;
            OnPushButton = () => View.IndicatorView.ShowTileIndicator(FieldManager.instance.allTilesPosition, (v) =>
            {
                currentItem.Use(FieldManager.GetTile(v));
                GameManager.Instance.itemBag.Remove(currentItem);

                UnitControlView.instance.UpdateItemButtons();
                IndicatorView.HideTileIndicator();
            });
            OnPopButton = () => View.IndicatorView.HideTileIndicator();
        }
        private Widget CreateEditorWidget()
        {
            // Create the text editor with the resulting buffer.
            editorView = new EditorView();
            editorView.Controller.PopulateContextMenu += OnPopulateContextMenu;

            // Update the theme with some additional colors.
            SetupTheme();

            // Wrap the text editor in a scrollbar.
            var scrolledWindow = new ScrolledWindow();

            scrolledWindow.VscrollbarPolicy = PolicyType.Always;
            scrolledWindow.Add(editorView);

            // Create the indicator bar that is 10 px wide.
            indicatorView = new IndicatorView(editorView);
            indicatorView.SetSizeRequest(20, 1);

            // Create the drop down list with the enumerations.
            var lineStyleCombo = new EnumComboBox(typeof(DemoLineStyleType));

            lineStyleCombo.Sensitive = false;

            // Add the editor and bar to the current tab.
            var editorBand = new HBox(false, 0);

            editorBand.PackStart(scrolledWindow, true, true, 0);
            editorBand.PackStart(indicatorView, false, false, 4);

            // Controls band
            var controlsBand = new HBox(false, 0);

            controlsBand.PackStart(lineStyleCombo, false, false, 0);
            controlsBand.PackStart(new Label(), true, true, 0);

            // Create a vbox and use it to add the combo boxes.
            var verticalLayout = new VBox(false, 4);

            verticalLayout.BorderWidth = 4;
            verticalLayout.PackStart(editorBand, true, true, 0);
            verticalLayout.PackStart(controlsBand, false, false, 4);

            // Create the first buffer.
            editorView.SetLineBuffer(CreateEditableLineBuffer());

            // Return the resulting layout.
            return(verticalLayout);
        }
        void ReleaseDesignerOutlets()
        {
            if (btnListView != null)
            {
                btnListView.Dispose();
                btnListView = null;
            }

            if (btnMapView != null)
            {
                btnMapView.Dispose();
                btnMapView = null;
            }

            if (btnSearch != null)
            {
                btnSearch.Dispose();
                btnSearch = null;
            }

            if (collectionViewPager != null)
            {
                collectionViewPager.Dispose();
                collectionViewPager = null;
            }

            if (IndicatorView != null)
            {
                IndicatorView.Dispose();
                IndicatorView = null;
            }

            if (lblTitle != null)
            {
                lblTitle.Dispose();
                lblTitle = null;
            }

            if (locationtabHeaderView != null)
            {
                locationtabHeaderView.Dispose();
                locationtabHeaderView = null;
            }
        }
Пример #13
0
        protected virtual void SetupLayoutConstraints()
        {
            this.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            this.AddConstraints(
                SearchBar.AtTopOfSafeArea(this),
                SearchBar.AtLeftOf(this),
                SearchBar.AtRightOf(this),
                SearchBar.Above(CollectionView));

            this.AddConstraints(
                IndicatorView.WithSameCenterX(this),
                IndicatorView.WithSameCenterY(this));

            this.AddConstraints(
                //CollectionView.Above(SearchBar),
                CollectionView.AtBottomOfSafeArea(this),
                CollectionView.AtLeftOf(this),
                CollectionView.AtRightOf(this));
        }
    protected void Awake()
    {
        _suspicionMultiplier = new TweakableFloat("AnimalSuspicionMultiplier", 0.0f, 1.0f, 0.5f);
        _animator = GetComponent<Animator>();

        GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
        if (players.Length != 1) {
            Debug.LogError("Weird number of players found: " + players.Length);
        }
        _player = players[0].GetComponent<PlayerMovementController>();

        IndicatorView[] indicatorViews = transform.GetComponentsInChildren<IndicatorView>();
        if (indicatorViews.Length != 1) {
            Debug.LogError("Weird number of indicator views found: " + indicatorViews.Length);
        }
        _indicatorView = indicatorViews[0];
        (transform.Find("Indicator").gameObject as GameObject).SetActive(false);

        SetUpStateMachine();
    }
Пример #15
0
        private Widget CreateGuiEditor()
        {
            // Create the editor for the user.
            commandController = new ProjectCommandController();

            editorView = new EditorView();
            editorView.Controller.CommandController = commandController;
            EditorViewTheme.SetupTheme(editorView.Theme);

            // Remove the default margins because they aren't helpful at this
            // point and whenever they load, it causes the document to reset.
            editorView.Margins.Clear();

            // Wrap the text editor in a scrollbar.
            var scrolledWindow = new ScrolledWindow();

            scrolledWindow.VscrollbarPolicy = PolicyType.Always;
            scrolledWindow.Add(editorView);

            // Create the indicator bar that is 10 px wide.
            indicatorView = new IndicatorView(editorView);
            indicatorView.SetSizeRequest(20, 1);

            var indicatorFrame = new Frame
            {
                BorderWidth = 2,
                ShadowType  = ShadowType.None,
                Shadow      = ShadowType.None
            };

            indicatorFrame.Add(indicatorView);

            // Add the editor and bar to the current tab.
            var editorBand = new HBox(false, 0);

            editorBand.PackStart(indicatorFrame, false, false, 0);
            editorBand.PackStart(scrolledWindow, true, true, 4);

            // Return the top-most frame.
            return(editorBand);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            prepareViews();
            prepareIndicatorView();

            this.Bind(CloseButton.Tapped(), ViewModel.CloseButtonTapped);
            this.Bind(FeedbackTextView.Text(), ViewModel.FeedbackText);
            this.Bind(ErrorView.Tapped(), ViewModel.ErrorViewTapped);

            this.Bind(SendButton.Tapped(), ViewModel.SendButtonTapped);
            SendButton.TouchUpInside += (sender, args) => { FeedbackTextView.ResignFirstResponder(); };

            this.Bind(ViewModel.IsFeedbackEmpty, FeedbackPlaceholderTextView.BindIsVisible());
            this.Bind(ViewModel.ErrorViewVisible, ErrorView.BindAnimatedIsVisible());
            this.Bind(ViewModel.SendEnabled, SendButton.BindEnabled());

            this.Bind(ViewModel.IsLoading.Invert(), SendButton.BindIsVisible());
            this.Bind(ViewModel.IsLoading, IndicatorView.BindIsVisible());
            this.Bind(ViewModel.IsLoading, UIApplication.SharedApplication.BindNetworkActivityIndicatorVisible());
        }
Пример #17
0
        void SetUpNewElement(IndicatorView newElement)
        {
            if (newElement == null)
            {
                IndicatorsView = null;
                return;
            }

            IndicatorsView = newElement;

            IndicatorsView.PropertyChanged += OnElementPropertyChanged;

            if (Tracker == null)
            {
                _visualElementTracker = new VisualElementTracker(this);
                //_visualElementPackager = new VisualElementPackager(this);
                //_visualElementPackager.Load();
            }

            this.EnsureId();

            UpdateBackgroundColor();

            if (IndicatorsView.IndicatorTemplate != null)
            {
                var control = IndicatorsView.IndicatorLayout.GetRenderer() ?? Platform.CreateRendererWithContext(IndicatorsView.IndicatorLayout, Context);
                Platform.SetRenderer(IndicatorsView.IndicatorLayout, control);
                AddView(control as AView);
            }
            else
            {
                UpdateItemsSource();
            }

            ElevationHelper.SetElevation(this, newElement);
        }
Пример #18
0
        public CarouselItemsGallery(bool startEmptyCollection   = false, bool setCollectionWithAsync   = false,
                                    bool useNativeIndicators    = false, bool setPositionOnConstructor = false,
                                    bool setPositionOnAppearing = false, bool useScrollAnimated        = true)
        {
            _viewModel             = new CarouselItemsGalleryViewModel(startEmptyCollection, setCollectionWithAsync);
            _setPositionOnAppering = setPositionOnAppearing;

            if (setPositionOnConstructor)
            {
                _viewModel.CarouselPosition = 3;
            }

            Title = $"CarouselView (Indicators)";

            var grid = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Star
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    }
                }
            };

            var itemsLayout =
                new LinearItemsLayout(ItemsLayoutOrientation.Horizontal)
            {
                SnapPointsType      = SnapPointsType.MandatorySingle,
                SnapPointsAlignment = SnapPointsAlignment.Center,
                ItemSpacing         = 8
            };

            var itemTemplate = GetCarouselTemplate();

            var carouselView = new CarouselView
            {
                ItemsLayout      = itemsLayout,
                ItemTemplate     = itemTemplate,
                IsScrollAnimated = useScrollAnimated,
                IsBounceEnabled  = true,
                EmptyView        = "This is the empty view",
                PeekAreaInsets   = new Thickness(50),
            };

            carouselView.SetBinding(CarouselView.ItemsSourceProperty, nameof(_viewModel.Items));
            carouselView.SetBinding(CarouselView.PositionProperty, nameof(_viewModel.CarouselPosition));

            var absolute = new AbsoluteLayout();

            absolute.Children.Add(carouselView, new Rectangle(0, 0, 1, 1), AbsoluteLayoutFlags.All);

            var indicators = new IndicatorView
            {
                Margin                 = new Thickness(15, 20),
                IndicatorColor         = Colors.Gray,
                SelectedIndicatorColor = Colors.Black,
                IndicatorsShape        = IndicatorShape.Square
            };

            if (!useNativeIndicators)
            {
                indicators.IndicatorTemplate = new DataTemplate(() =>
                {
                    return(new Image
                    {
                        Source = new FontImageSource
                        {
                            FontFamily = DefaultFontFamily(),
                            Glyph = "\uf30c",
                        },
                    });
                });
            }

            carouselView.IndicatorView = indicators;

            absolute.Children.Add(indicators, new Rectangle(.5, 1, -1, -1), AbsoluteLayoutFlags.PositionProportional);

            grid.Children.Add(absolute, 0, 0);

            var stacklayoutButtons = new StackLayout
            {
                Orientation = StackOrientation.Horizontal
            };

            var addItemButton = new Button
            {
                Text = "Add Item"
            };

            addItemButton.Clicked += (sender, e) =>
            {
                _viewModel.Items.Add(new CarouselData
                {
                    Color = Colors.Red,
                    Name  = $"{_viewModel.Items.Count + 1}"
                });
                _viewModel.CarouselPosition = _viewModel.Items.Count - 1;
            };

            var removeItemButton = new Button
            {
                Text = "Remove Item"
            };

            removeItemButton.Clicked += (sender, e) =>
            {
                if (_viewModel.Items.Any())
                {
                    _viewModel.Items.RemoveAt(_viewModel.Items.Count - 1);
                }

                if (_viewModel.Items.Count > 0)
                {
                    _viewModel.CarouselPosition = _viewModel.Items.Count - 1;
                }
            };

            var clearItemsButton = new Button
            {
                Text = "Clear Items"
            };

            clearItemsButton.Clicked += (sender, e) =>
            {
                _viewModel.Items.Clear();
            };

            var lbl = new Label
            {
                AutomationId = "lblPosition"
            };

            lbl.SetBinding(Label.TextProperty, nameof(CarouselView.Position));
            lbl.BindingContext = carouselView;

            stacklayoutButtons.Children.Add(addItemButton);
            stacklayoutButtons.Children.Add(removeItemButton);
            stacklayoutButtons.Children.Add(clearItemsButton);
            stacklayoutButtons.Children.Add(lbl);

            grid.Children.Add(stacklayoutButtons, 0, 1);

            Content        = grid;
            BindingContext = _viewModel;
        }
Пример #19
0
 public static IndicatorView SelectedIndicatorColor(this IndicatorView indicator, Color color)
 {
     indicator.SelectedIndicatorColor = color;
     return(indicator);
 }
Пример #20
0
        public IndicatorCodeGallery()
        {
            Title = "IndicatorView Gallery";

            On <iOS>().SetLargeTitleDisplay(LargeTitleDisplayMode.Never);

            var nItems = 10;

            var layout = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Star
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    }
                }
            };

            var itemsLayout = new LinearItemsLayout(ItemsLayoutOrientation.Horizontal)
            {
                SnapPointsType      = SnapPointsType.MandatorySingle,
                SnapPointsAlignment = SnapPointsAlignment.Center
            };

            var itemTemplate = ExampleTemplates.CarouselTemplate();

            var carouselView = new CarouselView
            {
                ItemsLayout     = itemsLayout,
                ItemTemplate    = itemTemplate,
                BackgroundColor = Color.LightGray,
                AutomationId    = "TheCarouselView"
            };

            layout.Children.Add(carouselView);

            var generator = new ItemsSourceGenerator(carouselView, nItems, ItemsSourceType.ObservableCollection);

            layout.Children.Add(generator);

            generator.GenerateItems();

            var indicatorView = new IndicatorView
            {
                HorizontalOptions      = LayoutOptions.Center,
                Margin                 = new Thickness(12, 6, 12, 12),
                IndicatorColor         = Color.Gray,
                SelectedIndicatorColor = Color.Black,
                IndicatorsShape        = IndicatorShape.Square,
                AutomationId           = "TheIndicatorView"
            };

            carouselView.IndicatorView = indicatorView;

            layout.Children.Add(indicatorView);

            var stckColors = new StackLayout {
                Orientation = StackOrientation.Horizontal
            };

            stckColors.Children.Add(new Label {
                VerticalOptions = LayoutOptions.Center, Text = "IndicatorColor"
            });

            var colors = new List <string>
            {
                "Black",
                "Blue",
                "Red"
            };

            var colorsPicker = new Picker
            {
                ItemsSource  = colors,
                WidthRequest = 150
            };

            colorsPicker.SelectedIndex = 0;

            colorsPicker.SelectedIndexChanged += (s, e) =>
            {
                var selectedIndex = colorsPicker.SelectedIndex;

                switch (selectedIndex)
                {
                case 0:
                    indicatorView.IndicatorColor = Color.Black;
                    break;

                case 1:
                    indicatorView.IndicatorColor = Color.Blue;
                    break;

                case 2:
                    indicatorView.IndicatorColor = Color.Red;
                    break;
                }
            };

            stckColors.Children.Add(colorsPicker);

            layout.Children.Add(stckColors);

            var stckTemplate = new StackLayout {
                Orientation = StackOrientation.Horizontal
            };

            stckTemplate.Children.Add(new Label {
                VerticalOptions = LayoutOptions.Center, Text = "IndicatorTemplate"
            });

            var templates = new List <string>
            {
                "Circle",
                "Square",
                "Template"
            };

            var templatePicker = new Picker
            {
                ItemsSource  = templates,
                WidthRequest = 150,
                TextColor    = Color.Black
            };

            templatePicker.SelectedIndexChanged += (s, e) =>
            {
                var selectedIndex = templatePicker.SelectedIndex;

                switch (selectedIndex)
                {
                case 0:
                    indicatorView.IndicatorTemplate = null;
                    indicatorView.IndicatorsShape   = IndicatorShape.Circle;
                    break;

                case 1:
                    indicatorView.IndicatorTemplate = null;
                    indicatorView.IndicatorsShape   = IndicatorShape.Square;
                    break;

                case 2:
                    indicatorView.IndicatorTemplate = ExampleTemplates.IndicatorTemplate();
                    break;
                }
            };

            templatePicker.SelectedIndex = 0;

            stckTemplate.Children.Add(templatePicker);

            layout.Children.Add(stckTemplate);

            var stckSize = new StackLayout {
                Orientation = StackOrientation.Horizontal
            };

            stckSize.Children.Add(new Label {
                VerticalOptions = LayoutOptions.Center, Text = "Indicator Size"
            });

            //indicatorView.IndicatorSize = 25;

            var sizeSlider = new Slider
            {
                WidthRequest = 150,
                Value        = indicatorView.IndicatorSize,
                Maximum      = 50,
            };

            sizeSlider.ValueChanged += (s, e) =>
            {
                var indicatorSize = sizeSlider.Value;
                indicatorView.IndicatorSize = indicatorSize;
            };

            stckSize.Children.Add(sizeSlider);

            layout.Children.Add(stckSize);

            Grid.SetRow(generator, 0);
            Grid.SetRow(stckColors, 1);
            Grid.SetRow(stckTemplate, 2);
            Grid.SetRow(stckSize, 3);
            Grid.SetRow(carouselView, 4);
            Grid.SetRow(indicatorView, 5);

            Content = layout;
        }
Пример #21
0
        private Widget CreateGuiEditor()
        {
            // Create the editor for the user.
            commandController = new ProjectCommandController();

            editorView = new EditorView();
            editorView.Controller.CommandController = commandController;
            EditorViewTheme.SetupTheme(editorView.Theme);

            // Remove the default margins because they aren't helpful at this
            // point and whenever they load, it causes the document to reset.
            editorView.Margins.Clear();

            // Wrap the text editor in a scrollbar.
            var scrolledWindow = new ScrolledWindow();
            scrolledWindow.VscrollbarPolicy = PolicyType.Always;
            scrolledWindow.Add(editorView);

            // Create the indicator bar that is 10 px wide.
            indicatorView = new IndicatorView(editorView);
            indicatorView.SetSizeRequest(20, 1);

            var indicatorFrame = new Frame
            {
                BorderWidth = 2,
                ShadowType = ShadowType.None,
                Shadow = ShadowType.None
            };
            indicatorFrame.Add(indicatorView);

            // Add the editor and bar to the current tab.
            var editorBand = new HBox(false, 0);
            editorBand.PackStart(indicatorFrame, false, false, 0);
            editorBand.PackStart(scrolledWindow, true, true, 4);

            // Return the top-most frame.
            return editorBand;
        }
Пример #22
0
 public static IndicatorView IndicatorTemplate(this IndicatorView indicator, DataTemplate template)
 {
     indicator.IndicatorTemplate = template;
     return(indicator);
 }
        public IndicatorViewDemoPage()
        {
            Label header = new Label
            {
                Text              = "IndicatorView",
                FontSize          = 50,
                FontAttributes    = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.Center
            };

            // Create the IndicatorView.
            IndicatorView indicatorView = new IndicatorView
            {
                Margin                 = new Thickness(0, 0, 0, 40),
                IndicatorColor         = Color.LightGray,
                SelectedIndicatorColor = Color.DarkGray,
                HorizontalOptions      = LayoutOptions.Center
            };

            // Create the CarouselView.
            CarouselView carouselView = new CarouselView
            {
                ItemTemplate = new DataTemplate(() =>
                {
                    StackLayout rootStackLayout = new StackLayout();

                    Frame frame = new Frame
                    {
                        HasShadow         = true,
                        BorderColor       = Color.Gray,
                        Margin            = new Thickness(20),
                        HeightRequest     = 300,
                        HorizontalOptions = LayoutOptions.Center,
                        VerticalOptions   = LayoutOptions.CenterAndExpand
                    };

                    StackLayout stackLayout = new StackLayout();

                    Label nameLabel = new Label
                    {
                        FontAttributes    = FontAttributes.Bold,
                        FontSize          = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                        HorizontalOptions = LayoutOptions.Center,
                        VerticalOptions   = LayoutOptions.Center
                    };
                    nameLabel.SetBinding(Label.TextProperty, "Name");

                    Image image = new Image
                    {
                        Aspect            = Aspect.AspectFill,
                        HeightRequest     = 150,
                        WidthRequest      = 150,
                        HorizontalOptions = LayoutOptions.Center
                    };
                    image.SetBinding(Image.SourceProperty, "ImageUrl");

                    Label locationLabel = new Label
                    {
                        HorizontalOptions = LayoutOptions.Center
                    };
                    locationLabel.SetBinding(Label.TextProperty, "Location");

                    Label detailsLabel = new Label
                    {
                        FontAttributes    = FontAttributes.Italic,
                        HorizontalOptions = LayoutOptions.Center,
                        MaxLines          = 5,
                        LineBreakMode     = LineBreakMode.TailTruncation
                    };
                    detailsLabel.SetBinding(Label.TextProperty, "Details");

                    stackLayout.Children.Add(nameLabel);
                    stackLayout.Children.Add(image);
                    stackLayout.Children.Add(locationLabel);
                    stackLayout.Children.Add(detailsLabel);

                    frame.Content = stackLayout;
                    rootStackLayout.Children.Add(frame);

                    return(rootStackLayout);
                }),
                IndicatorView = indicatorView
            };

            carouselView.SetBinding(ItemsView.ItemsSourceProperty, "Monkeys");

            // Build the page.
            Title   = "IndicatorView Demo";
            Content = new StackLayout
            {
                Margin   = new Thickness(20),
                Children =
                {
                    header,
                    carouselView,
                    indicatorView
                }
            };

            CreateMonkeyCollection();
            BindingContext = this;
        }
Пример #24
0
 public static IndicatorView ItemsSource(this IndicatorView indicator, IEnumerable source)
 {
     indicator.ItemsSource = source;
     return(indicator);
 }
 void OnElementChanged(IndicatorView oldElement, IndicatorView newElement)
 {
     ElementChanged?.Invoke(this, new VisualElementChangedEventArgs(oldElement, newElement));
     OnElementChanged(new ElementChangedEventArgs <IndicatorView>(oldElement, newElement));
 }
 public override void ViewWillAppear(bool animated)
 {
     base.ViewWillAppear(animated);
     IndicatorView.StartSpinning();
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            TitleLabel.Text = Resources.ContactUs;
            FeedbackPlaceholderTextView.Text = Resources.FeedbackFieldPlaceholder;
            ErrorTitleLabel.Text             = Resources.Oops.ToUpper();
            ErrorMessageLabel.Text           = Resources.SomethingWentWrongTryAgain;
            SendButton.SetTitle(Resources.Send, UIControlState.Normal);

            prepareViews();
            prepareIndicatorView();

            CloseButton.Rx()
            .BindAction(ViewModel.Close)
            .DisposedBy(DisposeBag);

            FeedbackTextView.Rx().Text()
            .Subscribe(ViewModel.FeedbackText)
            .DisposedBy(DisposeBag);

            ErrorView.Rx()
            .BindAction(ViewModel.DismissError)
            .DisposedBy(DisposeBag);

            SendButton.Rx()
            .BindAction(ViewModel.Send)
            .DisposedBy(DisposeBag);
            SendButton.TouchUpInside += (sender, args) => { FeedbackTextView.ResignFirstResponder(); };

            ViewModel.IsFeedbackEmpty
            .Subscribe(FeedbackPlaceholderTextView.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.Error
            .Select(NotNull)
            .Subscribe(ErrorView.Rx().AnimatedIsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.SendEnabled
            .Subscribe(SendButton.Rx().Enabled())
            .DisposedBy(DisposeBag);

            ViewModel.IsLoading
            .Invert()
            .Subscribe(SendButton.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.IsLoading
            .Invert()
            .Subscribe(CloseButton.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.IsLoading
            .Subscribe(IndicatorView.Rx().IsVisible())
            .DisposedBy(DisposeBag);

            ViewModel.IsLoading
            .Subscribe(UIApplication.SharedApplication.Rx().NetworkActivityIndicatorVisible())
            .DisposedBy(DisposeBag);
        }
Пример #28
0
 public static IndicatorView MaximumVisible(this IndicatorView indicator, int max)
 {
     indicator.MaximumVisible = max;
     return(indicator);
 }
Пример #29
0
 public static IndicatorView Position(this IndicatorView indicator, int position)
 {
     indicator.Position = position;
     return(indicator);
 }
Пример #30
0
        public IndicatorCodeGallery()
        {
            Title = "IndicatorView Gallery";

            On <iOS>().SetLargeTitleDisplay(LargeTitleDisplayMode.Never);

            var nItems = 10;

            var layout = new Grid
            {
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Star
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                    new RowDefinition {
                        Height = GridLength.Auto
                    }
                }
            };

            var itemsLayout = new LinearItemsLayout(ItemsLayoutOrientation.Horizontal)
            {
                SnapPointsType      = SnapPointsType.MandatorySingle,
                SnapPointsAlignment = SnapPointsAlignment.Center
            };

            var itemTemplate = ExampleTemplates.CarouselTemplate();

            _carouselView = new CarouselView
            {
                ItemsLayout     = itemsLayout,
                ItemTemplate    = itemTemplate,
                BackgroundColor = Colors.LightGray,
                AutomationId    = "TheCarouselView"
            };

            layout.Children.Add(_carouselView);
            var generator = new ItemsSourceGenerator(_carouselView, nItems, ItemsSourceType.ObservableCollection);

            layout.Children.Add(generator);

            generator.GenerateItems();

            _carouselView.PropertyChanged += CarouselViewPropertyChanged;
            (_carouselView.ItemsSource as ObservableCollection <CollectionViewGalleryTestItem>).CollectionChanged += IndicatorCodeGalleryCollectionChanged;

            var indicatorView = new IndicatorView
            {
                HorizontalOptions      = LayoutOptions.Center,
                Margin                 = new Thickness(12, 6, 12, 12),
                IndicatorColor         = Colors.Gray,
                SelectedIndicatorColor = Colors.Black,
                IndicatorsShape        = IndicatorShape.Square,
                AutomationId           = "TheIndicatorView",
                Count = 5,
            };

            _carouselView.IndicatorView = indicatorView;

            layout.Children.Add(indicatorView);

            var stckColors = new StackLayout {
                Orientation = StackOrientation.Horizontal
            };

            stckColors.Children.Add(new Label {
                VerticalOptions = LayoutOptions.Center, Text = "IndicatorColor"
            });

            var colors = new List <string>
            {
                "Black",
                "Blue",
                "Red"
            };

            var colorsPicker = new Picker
            {
                ItemsSource  = colors,
                WidthRequest = 150
            };

            colorsPicker.SelectedIndex = 0;

            colorsPicker.SelectedIndexChanged += (s, e) =>
            {
                var selectedIndex = colorsPicker.SelectedIndex;

                switch (selectedIndex)
                {
                case 0:
                    indicatorView.IndicatorColor = Colors.Black;
                    break;

                case 1:
                    indicatorView.IndicatorColor = Colors.Blue;
                    break;

                case 2:
                    indicatorView.IndicatorColor = Colors.Red;
                    break;
                }
            };

            stckColors.Children.Add(colorsPicker);

            layout.Children.Add(stckColors);

            var stckTemplate = new StackLayout {
                Orientation = StackOrientation.Horizontal
            };

            stckTemplate.Children.Add(new Label {
                VerticalOptions = LayoutOptions.Center, Text = "IndicatorTemplate"
            });

            var templates = new List <string>
            {
                "Circle",
                "Square",
                "Template"
            };

            var templatePicker = new Picker
            {
                ItemsSource  = templates,
                WidthRequest = 150,
                TextColor    = Colors.Black
            };

            templatePicker.SelectedIndexChanged += (s, e) =>
            {
                var selectedIndex = templatePicker.SelectedIndex;

                switch (selectedIndex)
                {
                case 0:
                    indicatorView.IndicatorTemplate = null;
                    indicatorView.IndicatorsShape   = IndicatorShape.Circle;
                    break;

                case 1:
                    indicatorView.IndicatorTemplate = null;
                    indicatorView.IndicatorsShape   = IndicatorShape.Square;
                    break;

                case 2:
                    indicatorView.IndicatorTemplate = ExampleTemplates.IndicatorTemplate();
                    break;
                }
            };

            templatePicker.SelectedIndex = 0;

            stckTemplate.Children.Add(templatePicker);

            layout.Children.Add(stckTemplate);

            var stckSize = new StackLayout {
                Orientation = StackOrientation.Horizontal
            };

            stckSize.Children.Add(new Label {
                VerticalOptions = LayoutOptions.Center, Text = "Indicator Size"
            });

            //indicatorView.IndicatorSize = 25;

            var sizeSlider = new Slider
            {
                WidthRequest = 150,
                Value        = indicatorView.IndicatorSize,
                Maximum      = 50,
            };

            sizeSlider.ValueChanged += (s, e) =>
            {
                var indicatorSize = sizeSlider.Value;
                indicatorView.IndicatorSize = indicatorSize;
            };

            stckSize.Children.Add(sizeSlider);

            layout.Children.Add(stckSize);

            Grid.SetRow(generator, 0);
            Grid.SetRow(stckColors, 1);
            Grid.SetRow(stckTemplate, 2);
            Grid.SetRow(stckSize, 3);
            Grid.SetRow(_carouselView, 4);
            Grid.SetRow(indicatorView, 6);

            var layoutBtn = new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Center,
            };

            var btnRemove = new Button
            {
                Text            = "DEL First",
                FontSize        = 8,
                AutomationId    = "btnRemoveFirst",
                BackgroundColor = Colors.LightGray,
                Padding         = new Thickness(5),
                Command         = new Command(() =>
                {
                    var items = (_carouselView.ItemsSource as ObservableCollection <CollectionViewGalleryTestItem>);
                    items.Remove(items[0]);
                })
            };

            _btnPrev = new Button
            {
                Text            = "Prev",
                FontSize        = 8,
                AutomationId    = "btnPrev",
                BackgroundColor = Colors.LightGray,
                Padding         = new Thickness(5),
                Command         = new Command(() =>
                {
                    _carouselView.Position--;
                }, () =>
                {
                    return(_carouselView.Position > 0);
                })
            };

            _btnNext = new Button
            {
                Text            = "Next",
                FontSize        = 8,
                AutomationId    = "btnNext",
                BackgroundColor = Colors.LightGray,
                Padding         = new Thickness(5),
                Command         = new Command(() =>
                {
                    _carouselView.Position++;
                }, () =>
                {
                    var items = (_carouselView.ItemsSource as ObservableCollection <CollectionViewGalleryTestItem>);
                    return(_carouselView.Position < items.Count - 1);
                })
            };

            var btnRemoveLast = new Button
            {
                Text            = "DEL Last",
                FontSize        = 8,
                AutomationId    = "btnRemoveLast",
                BackgroundColor = Colors.LightGray,
                Padding         = new Thickness(5),
                Command         = new Command(() =>
                {
                    var items         = (_carouselView.ItemsSource as ObservableCollection <CollectionViewGalleryTestItem>);
                    var indexToRemove = items.Count - 1;
                    items.Remove(items[indexToRemove]);
                })
            };

            layoutBtn.Children.Add(btnRemove);
            layoutBtn.Children.Add(_btnPrev);
            layoutBtn.Children.Add(_btnNext);
            layoutBtn.Children.Add(btnRemoveLast);

            layout.Children.Add(layoutBtn);
            Grid.SetRow(layoutBtn, 5);
            Content = layout;
        }
Пример #31
0
 public static IndicatorView Color(this IndicatorView indicator, Color indicatorColor, Color selectedColor)
 {
     indicator.IndicatorColor         = indicatorColor;
     indicator.SelectedIndicatorColor = selectedColor;
     return(indicator);
 }
Пример #32
0
 public static IndicatorView Count(this IndicatorView indicator, int count)
 {
     indicator.Count = count;
     return(indicator);
 }