void SetContent() { if (_contentView == null) { return; } _rootLayout = new RelativeLayout(); var animationWidth = App.ScreenWidth / 2; animationView = new AnimationView { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, AutoPlay = true, Speed = 0.5f, Duration = TimeSpan.FromMilliseconds(1500), }; _rootLayout.Children.Add(_contentView, xConstraint: Constraint.Constant(0), yConstraint: Constraint.Constant(0), widthConstraint: Constraint.RelativeToParent(p => Width), heightConstraint: Constraint.RelativeToParent(p => Height)); _rootLayout.Children.Add(animationView, xConstraint: Constraint.Constant(0), yConstraint: Constraint.Constant(0)); animationView.SetBinding(AnimationView.AnimationProperty, nameof(BaseViewModel.Animation), BindingMode.TwoWay); animationView.SetBinding(AnimationView.IsVisibleProperty, nameof(BaseViewModel.IsAnimationVisible), BindingMode.TwoWay); Content = _rootLayout; }
/// <summary> /// Set the loading control /// </summary> public void SetLoadingControl() { var backLoader = new BoxView { Opacity = 0.6, BackgroundColor = Color.Black }; var activityIndicator = new AnimationView { Animation = AnimationFile, Loop = true, IsEnabled = true, AutoPlay = true, IsVisible = false, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Margin = new Thickness(130, default(int)) }; layout.Children.Add(backLoader, left: default(int), top: default(int)); activityIndicator.SetBinding(IsVisibleProperty, nameof(IsBusy)); backLoader.SetBinding(IsVisibleProperty, nameof(IsBusy)); layout.Children.Add(activityIndicator, left: default(int), top: default(int)); }
public UploadingPage() { Title = ApplicationResource.PageUploadingTitle; BindingContext = new UploadingViewModel(Navigation); animationView = new AnimationView(); animationView.SetBinding(AnimationView.IsPlayingProperty, new Binding("ShowAnimation")); animationView.SetBinding(AnimationView.IsVisibleProperty, new Binding("ShowAnimation")); animationView.SetBinding(AnimationView.AnimationProperty, new Binding("Animation")); animationView.SetBinding(AnimationView.LoopProperty, new Binding("ShouldLoopAnimation")); animationView.AutoPlay = true; animationView.HeightRequest = animationView.WidthRequest = 200; animationView.Play(); var heroImage = new Image(); heroImage.HeightRequest = heroImage.WidthRequest = 200; heroImage.SetBinding(Image.SourceProperty, new Binding("HeroImage")); heroImage.SizeChanged += HeroImage_SizeChanged; var titleLabel = new Label() { WidthRequest = 300, FontAttributes = FontAttributes.Bold, TextColor = Color.Black, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center }; titleLabel.SetBinding(Label.TextProperty, new Binding("StatusTitle")); var messageLabel = new Label() { WidthRequest = 300, TextColor = Color.SlateGray, HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center }; messageLabel.SetBinding(Label.TextProperty, new Binding("StatusMessage")); var startButton = new Button() { HorizontalOptions = LayoutOptions.CenterAndExpand, FontAttributes = FontAttributes.Bold, WidthRequest = 180, HeightRequest = 40, CornerRadius = 20 }; startButton.SetBinding(Button.TextProperty, new Binding("UploadButtonText")); startButton.SetBinding(Button.TextColorProperty, new Binding("UploadButtonTextColor")); startButton.SetBinding(Button.BackgroundColorProperty, new Binding("UploadButtonColor")); startButton.SetBinding(Button.CommandProperty, new Binding("StartUploadCommand")); startButton.SetBinding(Button.IsEnabledProperty, new Binding("UploadButtonEnabled")); startButton.SetBinding(Button.IsVisibleProperty, new Binding("UploadEnabled")); AbsoluteLayout.SetLayoutBounds(startButton, new Rectangle(.5, 1, 180, 40)); AbsoluteLayout.SetLayoutFlags(startButton, AbsoluteLayoutFlags.PositionProportional); uploadingLayout = new RelativeLayout(); uploadingLayout.Margin = new Thickness(40); uploadingLayout.Children.Add(animationView, Constraint.RelativeToParent((parent) => { return((parent.Width * .5) - (heroImage.Width / 2)); }), Constraint.RelativeToParent((parent) => { return(parent.Height * .3 - (heroImage.Height / 2)); }) ); uploadingLayout.Children.Add(heroImage, Constraint.RelativeToParent((parent) => { return((parent.Width * .5) - (heroImage.Width / 2)); }), Constraint.RelativeToParent((parent) => { return(parent.Height * .3 - (heroImage.Height / 2)); }) ); uploadingLayout.Children.Add(startButton, Constraint.RelativeToParent((parent) => { return((parent.Width * .5) - (startButton.Width / 2)); }), Constraint.RelativeToParent((parent) => { return((parent.Height * .9) - startButton.Height); }) ); uploadingLayout.Children.Add(messageLabel, Constraint.RelativeToParent((parent) => { return((parent.Width * .5) - (messageLabel.Width / 2)); }), Constraint.RelativeToView(startButton, (parent, sibling) => { return(startButton.Y - messageLabel.Height - 40); }) ); uploadingLayout.Children.Add(titleLabel, Constraint.RelativeToParent((parent) => { return((parent.Width * .5) - (titleLabel.Width / 2)); }), Constraint.RelativeToView(messageLabel, (parent, sibling) => { return(messageLabel.Y - titleLabel.Height - 10); }) ); Content = uploadingLayout; }
public StockUpPage() { InitializeComponent(); isscan = false; scanbtn.Clicked += async delegate { isscan = true; await Navigation.PushAsync(new StockUpStep()); }; model = new ObservableCollection <StockUpPageModel>(); listview.ItemsSource = model; listview.IsPullToRefreshEnabled = true; DataTemplate template = new DataTemplate(() => { Grid grid = new Grid() { Margin = new Thickness(0, 5, 0, 5), BackgroundColor = Color.White }; grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(6, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(6, GridUnitType.Star) }); grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(30) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(20) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(20) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(20) }); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(20) }); grid.ColumnSpacing = 0; grid.RowSpacing = 0; AnimationView animation = new AnimationView { Animation = "more.json", HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand, WidthRequest = 30, HeightRequest = 30, }; Style titlestyle = new Style(typeof(Label)) { Setters = { new Setter { Property = Label.FontSizeProperty, Value = 11 }, new Setter { Property = Label.VerticalOptionsProperty, Value = LayoutOptions.End }, new Setter { Property = Label.HorizontalOptionsProperty, Value = LayoutOptions.Start }, new Setter { Property = Label.MarginProperty, Value = new Thickness(15, 0, 0, 0) }, } }; Style valuestyle = new Style(typeof(Label)) { Setters = { new Setter { Property = Label.FontSizeProperty, Value = 11 }, new Setter { Property = Label.VerticalOptionsProperty, Value = LayoutOptions.Start }, new Setter { Property = Label.HorizontalOptionsProperty, Value = LayoutOptions.Start }, new Setter { Property = Label.MarginProperty, Value = new Thickness(15, 0, 0, 0) }, new Setter { Property = Label.TextColorProperty, Value = Color.Black } } }; Label BillNoTitle = new Label { Text = "备货单号", Style = titlestyle }; Label CustomTitle = new Label { Text = "客户", Style = titlestyle }; Label PhoneTitle = new Label { Text = "联系电话", Style = titlestyle }; Label LogisticsTitle = new Label { Text = "物流公司", Style = titlestyle }; Label BillNo = new Label { Style = valuestyle }; Label Custom = new Label { Style = valuestyle }; Label Phone = new Label { Style = valuestyle }; Label Logistics = new Label { Style = valuestyle }; BillNo.SetBinding(Label.TextProperty, new Binding("BillNo")); Custom.SetBinding(Label.TextProperty, new Binding("Custom")); Phone.SetBinding(Label.TextProperty, new Binding("Phone")); Logistics.SetBinding(Label.TextProperty, new Binding("Logistics")); animation.SetBinding(AnimationView.ClassIdProperty, new Binding("Id")); bool clickstate = false; animation.OnClick += delegate { if (!clickstate) { string content = "{\"FormId\":\"9d0a72f2a1104fe1881969ad5a1fc22d\",\"FieldKeys\":\"F_XAY_FMATERIAL.FName,F_XAY_Count,F_XAY_MARK,F_XAY_MixMaterial\",\"FilterString\":\"FID =" + animation.ClassId + " and FBillStatus='A'\",\"OrderString\":\"\",\"TopRowCount\":\"0\",\"StartRow\":\"0\",\"Limit\":\"0\"}"; string[] lists = Jsonhelper.JsonToString(content); if (lists != null) { animation.PlayProgressSegment(0.15f, 0.3f); for (int i = 0; i < lists.Count(); i++) { string billstring = lists[i].Replace("[", ""); billstring = billstring.Replace("]", ""); string[] bill = billstring.Split(','); grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }); int rowcount = grid.RowDefinitions.Count; string labelstr; if (bill[0] == "物流散件") { labelstr = bill[3]; } else { labelstr = string.Format("{0} {1}{2}", bill[0], (Convert.ToSingle(bill[1])).ToString("f0"), bill[2]); } Label addrowlabel = new Label { Text = labelstr, FontSize = 10, Margin = new Thickness(15, 0, 0, 2) }; grid.Children.Add(addrowlabel, 0, rowcount - 1); Grid.SetColumnSpan(addrowlabel, 3); } clickstate = !clickstate; } } else { for (int i = grid.RowDefinitions.Count - 1; i >= 4; i--) { grid.Children.RemoveAt(i + 5); grid.RowDefinitions.RemoveAt(i); } animation.PlayProgressSegment(0.37f, 0.5f); clickstate = !clickstate; } }; grid.Children.Add(BillNoTitle, 0, 0); grid.Children.Add(CustomTitle, 0, 2); grid.Children.Add(PhoneTitle, 1, 2); grid.Children.Add(LogisticsTitle, 1, 0); grid.Children.Add(BillNo, 0, 1); grid.Children.Add(Custom, 0, 3); grid.Children.Add(Phone, 1, 3); grid.Children.Add(Logistics, 1, 1); grid.Children.Add(animation, 2, 0); Grid.SetRowSpan(animation, 4); return(new ViewCell { View = grid }); }); BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += async delegate { await modelrefresh(); }; listview.ItemTemplate = template; listview.Refreshing += delegate { worker.RunWorkerAsync(); }; listview.ItemTapped += async(sender, e) => { isscan = true; ScanPage scanPage = new ScanPage(3); scanPage.BindingContext = e.Item; scanPage.Title = "扫描物流单号条码"; await Navigation.PushAsync(scanPage); }; worker.RunWorkerCompleted += delegate { listview.EndRefresh(); }; }
public ProgressWheelView() { var progressWheel = new ProgressWheelAnimatedView() { Margin = new Thickness(10, 0), MillisecondsToCompleteWheel = 6000, SegmentCount = GoalToSegmentCountConverter.ToSegments(Settings.CurrentGoal), TotalProgress = Settings.CurrentGoal.RequiredMinutes(), }; progressWheel.SetBinding( ProgressWheelAnimatedView.TargetProgressProperty, nameof(ViewModel.MinutesBriskWalked)); progressWheel.Effects.Add(new ViewLifeCycleEffect(loaded: (sender, args) => { ViewModel.GoalCompleted = ViewModel.GoalCompleted == Settings.CurrentGoal.RequiredMinutes() >= progressWheel.TargetProgress; progressWheel.SetInitialProgress((float)ViewModel?.MinutesBriskWalked); })); var completeAnimation = new AnimationView() { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Fill, Animation = "check.json", Loop = false, Margin = new Thickness(0, 0, 0, 10), IsPlaying = true, }; completeAnimation.SetBinding(IsVisibleProperty, nameof(ViewModel.GoalCompleted)); progressWheel.OnAnimationFinished += () => { ViewModel.GoalCompleted = progressWheel.CurrentProgress >= Settings.CurrentGoal.RequiredMinutes(); if (ViewModel.GoalCompleted) { completeAnimation.Play(); } }; var incomplete = IncompleteContent(); incomplete.SetBinding(IsVisibleProperty, nameof(ViewModel.GoalCompleted), converter: new InvertedBooleanConverter()); var complete = CompleteContent(); complete.SetBinding(IsVisibleProperty, nameof(ViewModel.GoalCompleted)); Content = new Grid() { VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, RowDefinitions = new RowDefinitionCollection() { new RowDefinition() { Height = GridLength.Star }, new RowDefinition() { Height = GridLength.Star }, }, Children = { { progressWheel, 0, 1, 0, 2 }, { incomplete, 0, 1, 0, 2 }, { completeAnimation, 0, 1, 0, 2 }, // tmp while check.json is not cropped //{completeAnimation, 0, 0 }, { complete, 0,1 }, } }; }
private View ContentView() { var imgIcon = new SvgCachedImage() { HeightRequest = 140, WidthRequest = 140, Aspect = Aspect.AspectFit, }; imgIcon.SetBinding(CachedImage.SourceProperty, nameof(Bulletin.Icon)); imgIcon.SetBinding(SvgCachedImage.ReplaceStringMapProperty, nameof(Bulletin.Tier), converter: new TierToReplacementStringMapConverter()); imgIcon.SetBinding(IsVisibleProperty, nameof(Bulletin.Icon), converter: new NullToBooleanConverter()); var animationIcon = new AnimationView { HeightRequest = 140, WidthRequest = 140, Loop = false, IsPlaying = true, }; animationIcon.SetBinding(AnimationView.AnimationProperty, nameof(Bulletin.Animation)); animationIcon.SetBinding(IsVisibleProperty, nameof(Bulletin.Animation), converter: new NullToBooleanConverter()); var lblTitle = new Label() { HorizontalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, TextColor = Colors.TextSpecial, FontAttributes = FontAttributes.Bold, FontSize = Sizes.TextLarge, }; lblTitle.SetBinding(Label.TextProperty, nameof(Bulletin.Title)); var lblText = new Label() { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Center, HorizontalTextAlignment = TextAlignment.Center, TextColor = Colors.InfoPopupText, FontSize = Sizes.TextSmall, LineHeight = 1.2f, }; lblText.SetBinding(Label.TextProperty, nameof(Bulletin.Description)); var content = new StackLayout() { VerticalOptions = LayoutOptions.Center, Padding = new Thickness(40), Spacing = 20, Children = { imgIcon, //animationIcon, new StackLayout() { HorizontalOptions = LayoutOptions.Center, Spacing = 0, Children = { lblTitle, DefaultView.UnderLine, } }, lblText, } }; var cardView = new CardView(content) { TranslationY = 20, Scale = 0.90f, //BindingContext = item, AnchorY = 1, // anchor to bottom }; cardView.SetBinding(CardView.CloseButtonCommandProperty, nameof(Bulletin.CloseCommand)); return(cardView); }
public FavoritePageCellRenderer() { MyImageRenderer ImagePageModule = new MyImageRenderer { Source = "empresa", Foreground = Color.Transparent, HeightRequest = (double)Application.Current.Resources["MyMenuImageSize"], WidthRequest = (double)Application.Current.Resources["MyMenuImageSize"] }; Label LabelPageTitle = new Label { Style = (Style)Application.Current.Resources["MyContent"], HorizontalTextAlignment = TextAlignment.Start, }; LabelPageTitle.SetDynamicResource(Label.TextColorProperty, "StartColorGradientText"); Label LabelPageModule = new Label { Style = (Style)Application.Current.Resources["MyContent"], HorizontalTextAlignment = TextAlignment.Start, }; LabelPageModule.SetDynamicResource(Label.TextColorProperty, "EndColorGradientText"); AnimationView ImageBoxItsBeingUsed = new AnimationView { Animation = "favorite.json", Loop = false, IsPlaying = true, HeightRequest = (double)Application.Current.Resources["MyMenuImageSize"] / 1.5, WidthRequest = (double)Application.Current.Resources["MyMenuImageSize"] / 1.5 }; ImageBoxItsBeingUsed.SetDynamicResource(MyImageRenderer.ForegroundProperty, "EndColorGradientText"); //Binding LabelPageTitle.SetBinding(Label.TextProperty, "Title"); LabelPageModule.SetBinding(Label.TextProperty, "Module"); ImageBoxItsBeingUsed.SetBinding(VisualElement.IsVisibleProperty, "ItsBeingUsed"); Grid grid = new Grid { ColumnDefinitions = { new ColumnDefinition { Width = (double)Application.Current.Resources["MyMenuImageSize"] + 20 }, new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }, new ColumnDefinition { Width = (double)Application.Current.Resources["MyMenuImageSize"] }, }, ColumnSpacing = 20 }; grid.Children.Add(ImagePageModule, 0, 0); Grid.SetRowSpan(ImagePageModule, 2); grid.Children.Add(LabelPageTitle, 1, 0); grid.Children.Add(LabelPageModule, 1, 1); grid.Children.Add(ImageBoxItsBeingUsed, 2, 0); Grid.SetRowSpan(ImageBoxItsBeingUsed, 2); MyFrameRenderer myFrameRenderer = new MyFrameRenderer { Margin = new Thickness((int)Application.Current.Resources["MySideMargin"], (int)Application.Current.Resources["MyEndsMarginList"], (int)Application.Current.Resources["MySideMargin"], (int)Application.Current.Resources["MyEndsMarginList"]), TypeBorder = Enums.TypeBorder.All, IsGradient = false, BorderRadius = 20 }; myFrameRenderer.SetDynamicResource(MyFrameRenderer.StaticColorProperty, "ItemColor"); myFrameRenderer.Content = grid; View = myFrameRenderer; }