コード例 #1
0
        public void AddToContext(View view, bool inputTransparent = true)
        {
            panelLayout.Children.RemoveAt(panelLayout.Children.Count - 1);

            if (inputTransparent)
            {
                var viewGestures = new ViewGestures();
                viewGestures.Content         = view;
                viewGestures.BackgroundColor = BackgroundColor;

                viewGestures.Tap += (s, e) => OnClick();
                if (PanelAlign == PanelAlignEnum.paLeft)
                {
                    viewGestures.SwipeLeft += (s, e) => OnClick();
                }
                else if (PanelAlign == PanelAlignEnum.paRight)
                {
                    viewGestures.SwipeRight += (s, e) => OnClick();
                }

                AddView(viewGestures);
                previousView = viewGestures;
            }
            else
            {
                AddView(view);
                previousView = view;
            }

            CloseContext();
        }
コード例 #2
0
        public void TxtUrlAddress_Click(object sender, EventArgs e)
        {
            var tag = ViewGestures.GetTagByChild(sender);

            var link = tag.NormalizeLink();

            if (!string.IsNullOrEmpty(link))
            {
                Functions.SafeCall(() => Device.OpenUri(new Uri(link)));
            }
        }
コード例 #3
0
        private void CloseContext()
        {
            var viewGestures = new ViewGestures();

            viewGestures.BackgroundColor = BackgroundColor;

            viewGestures.Tap += (s, e) => { OnClick(); };
            if (panelAlignEnum == PanelAlignEnum.paLeft)
            {
                viewGestures.SwipeLeft += (s, e) => { OnClick(); }
            }
            ;
            else if (panelAlignEnum == PanelAlignEnum.paRight)
            {
                viewGestures.SwipeRight += (s, e) => { OnClick(); }
            }
            ;

            if (previousView != null)
            {
                panelLayout.Children.Add(viewGestures,
                                         Constraint.Constant(0),
                                         Constraint.RelativeToView(previousView, (parent, sibling) =>
                {
                    return(sibling.Y + sibling.Height);
                }),
                                         Constraint.RelativeToParent(parent => { return(parent.Width); }),
                                         Constraint.RelativeToView(previousView, (parent, sibling) =>
                {
                    var h = parent.Height - (sibling.Y + sibling.Height);
                    return((h > 0) ? h : 0);
                }));
            }
            else
            {
                panelLayout.Children.Add(viewGestures,
                                         Constraint.Constant(0),
                                         Constraint.Constant(0),
                                         Constraint.RelativeToParent(parent => { return(parent.Width); }),
                                         Constraint.RelativeToParent(parent => { return(parent.Height); }));
            }
        }
    }
コード例 #4
0
        public DiscountDetailPage(DiscountDetailData discountDetailData)
            : base(typeof(DiscountDetailViewModel), typeof(DiscountDetailContentUI))
        {
            BackgroundColor         = MainStyles.StatusBarColor.FromResources <Color>();
            Content.BackgroundColor = MainStyles.MainLightBackgroundColor.FromResources <Color>();

            viewModel.SetDiscount(discountDetailData);

            var mainLayout = new AbsoluteLayout
            {
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            var appBar = new TitleBar(this, TitleBar.BarBtnEnum.bbBack)
            {
                BarColor   = Color.Transparent,
                BoxPadding =
                {
                    BackgroundColor = MainStyles.StatusBarColor.FromResources <Color>()
                },
                BtnBack =
                {
                    BackgroundColor = MainStyles.StatusBarColor.FromResources <Color>(),
                    Source          = contentUI.IconBack
                }
            };

            #region Photo

            var imageLayout = new RelativeLayout
            {
                HeightRequest = Device.Idiom == TargetIdiom.Phone ? 200 : 400
            };

            var fileNameConverter = new FileNameToImageConverter();
            var imgPhoto          = new Image
            {
                Aspect = Aspect.AspectFill
            };
            imgPhoto.SetBinding(Image.SourceProperty,
                                new Binding("ImageFileName", BindingMode.Default, fileNameConverter, true));

            imageLayout.Children.Add(imgPhoto,
                                     Constraint.Constant(0),
                                     Constraint.Constant(0),
                                     Constraint.RelativeToParent(parent => parent.Width),
                                     Constraint.RelativeToParent(parent => parent.Height));

            #endregion

            #region Label percent

            const int sizeImgLabel = 60;

            var imgLabel = new Image
            {
                HeightRequest = sizeImgLabel,
                WidthRequest  = sizeImgLabel,
                Source        = contentUI.ImgPercentLabel
            };

            var labelLayout = new AbsoluteLayout();
            AbsoluteLayout.SetLayoutFlags(imgLabel, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(imgLabel, new Rectangle(0f, 0f, 1f, 1f));
            labelLayout.Children.Add(imgLabel);

            imageLayout.Children.Add(labelLayout,
                                     Constraint.RelativeToParent(parent => parent.Width - sizeImgLabel - 5),
                                     Constraint.RelativeToView(imgPhoto,
                                                               (parent, sibling) => sibling.Y + sibling.Height - sizeImgLabel - 5));

            var spanDiscountPercent = new Span
            {
                Style = LabelStyles.LabelPercentStyle.FromResources <Style>()
            };
            spanDiscountPercent.SetBinding(Span.TextProperty, "DiscountPercent", BindingMode.OneWay);

            var spanDiscountType = new Span
            {
                Style = LabelStyles.LabelPercentSymbolStyle.FromResources <Style>()
            };
            spanDiscountType.SetBinding(Span.TextProperty, "DiscountType", BindingMode.OneWay);

            var txtPercent = new Label
            {
                Rotation      = -15,
                TranslationY  = -1,
                FormattedText = new FormattedString
                {
                    Spans =
                    {
                        spanDiscountPercent,
                        spanDiscountType
                    }
                }
            };

            AbsoluteLayout.SetLayoutFlags(txtPercent, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds(txtPercent,
                                           new Rectangle(0.5, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
            labelLayout.Children.Add(txtPercent);

            #endregion

            #region WebAddress & Category list

            var flexCategories = new FlexLayout
            {
                Direction      = FlexDirection.Row,
                Wrap           = FlexWrap.Wrap,
                JustifyContent = FlexJustify.Start,
                AlignItems     = FlexAlignItems.Center,
                AlignContent   = FlexAlignContent.Start,
                Margin         = new Thickness(20, 15, 15, 0)
            };

            foreach (var webAddress in viewModel.WebAddresses)
            {
                var imgWebAddress = new Image
                {
                    Source = webAddress.Type.GetWebAddressIcon()
                };

                var viewGesturesWebAddress = new ViewGestures
                {
                    Content         = imgWebAddress,
                    AnimationEffect = ViewGestures.AnimationType.atScaling,
                    AnimationScale  = -5,
                    Tag             = webAddress.Url,
                    Margin          = new Thickness(0, 0, 5, 5)
                };
                viewGesturesWebAddress.Tap += viewModel.TxtUrlAddress_Click;

                flexCategories.Children.Add(viewGesturesWebAddress);
            }

            var flexSeparator = new ContentView();
            FlexLayout.SetGrow(flexSeparator, 1);
            flexCategories.Children.Add(flexSeparator);

            foreach (var category in viewModel.Categories)
            {
                var categoryLayout = new CategoryItemTemplate
                {
                    Margin         = new Thickness(0, 0, 5, 5),
                    BindingContext = category
                };

                flexCategories.Children.Add(categoryLayout);
            }

            #endregion

            #region Name company

            var txtPartnerName = new Label
            {
                Style = LabelStyles.DetailTitleStyle.FromResources <Style>()
            };
            txtPartnerName.SetBinding(Label.TextProperty, "NameCompany");

            #endregion

            #region Description

            var txtDescription = new Label
            {
                Style         = LabelStyles.DescriptionStyle.FromResources <Style>(),
                LineBreakMode = LineBreakMode.WordWrap
            };
            txtDescription.SetBinding(Label.TextProperty, "Description");

            #endregion

            var stackDetails = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Padding     = new Thickness(20, 0),
                Children    =
                {
                    txtPartnerName,
                    txtDescription
                }
            };

            var discountLayout = new StackLayout
            {
                Spacing     = 0,
                Orientation = StackOrientation.Vertical,
                Children    =
                {
                    imageLayout,
                    flexCategories,
                    stackDetails
                }
            };

            foreach (var brachItem in viewModel.BranchItems)
            {
                var view = new BranchInfoViewTemplate(contentUI, viewModel).View;
                view.BindingContext = brachItem;

                discountLayout.Children.Add(view);
            }

            var scrollDiscount = new ScrollView
            {
                Content = discountLayout
            };

            AbsoluteLayout.SetLayoutFlags(scrollDiscount, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(scrollDiscount, new Rectangle(0f, 0f, 1f, 1f));
            mainLayout.Children.Add(scrollDiscount);

            AbsoluteLayout.SetLayoutFlags(appBar,
                                          AbsoluteLayoutFlags.PositionProportional | AbsoluteLayoutFlags.WidthProportional);
            AbsoluteLayout.SetLayoutBounds(appBar, new Rectangle(0f, 0f, 1f, AbsoluteLayout.AutoSize));
            mainLayout.Children.Add(appBar);

            var safeAreaHelper = new SafeAreaHelper();
            safeAreaHelper.UseSafeArea(this, SafeAreaHelper.CustomSafeAreaFlags.Top);
            safeAreaHelper.UseSafeArea(appBar.BtnBack, SafeAreaHelper.CustomSafeAreaFlags.Left);
            safeAreaHelper.UseSafeArea(scrollDiscount, SafeAreaHelper.CustomSafeAreaFlags.Horizontal);

            ContentLayout.Children.Add(mainLayout);
        }
コード例 #5
0
        public SettingsPage()
            : base(typeof(SettingsViewModel), typeof(SettingsContentUI))
        {
            BackgroundColor = (Color)App.Current.Resources[MainStyles.MainBackgroundColor];

            var appBar = new TitleBar(this, TitleBar.BarBtnEnum.bbBack)
            {
                BarColor   = (Color)App.Current.Resources[MainStyles.MainBackgroundColor],
                TitleStyle = (Style)App.Current.Resources[LabelStyles.PageTitleStyle]
            };

            appBar.SetBinding(TitleBar.TitleProperty, "Title");
            appBar.BtnBack.BackgroundColor = Color.Transparent;
            appBar.BtnBack.Source          = contentUI.IconBack;

            ContentLayout.Children.Add(appBar);

            var stackSettings = new StackLayout
            {
                Spacing = Device.OnPlatform(6, 6, 32),
                Padding = new Thickness(32)
            };

            #region Language setting
            var txtLangTitle = new LabelExtended
            {
                Style = (Style)App.Current.Resources[LabelStyles.SettingStyle]
            };
            txtLangTitle.SetBinding(Label.TextProperty, "CurrLanguageTitle");

            var txtLangValue = new LabelExtended
            {
                Style = (Style)App.Current.Resources[LabelStyles.SettingHintStyle]
            };
            txtLangValue.SetBinding(Label.TextProperty, "CurrLanguageName");

            var stackLang = new StackLayout
            {
                Children =
                {
                    txtLangTitle,
                    txtLangValue
                }
            };

            var viewGesturesLang = new ViewGestures
            {
                Content          = stackLang,
                DeformationValue = -5,
            };
            viewGesturesLang.BackgroundColor = this.BackgroundColor;
            viewGesturesLang.Tap            += viewModel.LangSetting_Click;

            stackSettings.Children.Add(viewGesturesLang);
            #endregion

            if (Device.OS == TargetPlatform.WinPhone)
            {
                #region Map setting
                var txtMapTitle = new LabelExtended
                {
                    Style = (Style)App.Current.Resources[LabelStyles.SettingStyle]
                };
                txtMapTitle.SetBinding(Label.TextProperty, "MapTitle");

                var txtMapValue = new LabelExtended
                {
                    Style = (Style)App.Current.Resources[LabelStyles.SettingHintStyle]
                };
                txtMapValue.SetBinding(Label.TextProperty, "MapName");

                var stackMap = new StackLayout
                {
                    Children =
                    {
                        txtMapTitle,
                        txtMapValue
                    }
                };

                var viewGesturesMap = new ViewGestures
                {
                    Content          = stackMap,
                    DeformationValue = -5,
                };
                viewGesturesMap.BackgroundColor = this.BackgroundColor;
                viewGesturesMap.Tap            += viewModel.MapSetting_Click;

                stackSettings.Children.Add(viewGesturesMap);
                #endregion
            }

            ContentLayout.Children.Add(stackSettings);
        }
コード例 #6
0
        public MapPinDetail()
        {
            #region Back box
            viewGestures = new ViewGestures()
            {
                BackgroundColor = new Color(0, 0, 0, 0.01)
            };

            SetLayoutFlags(viewGestures, AbsoluteLayoutFlags.All);
            SetLayoutBounds(viewGestures, new Rectangle(0f, 0f, 1f, 1f));
            Children.Add(viewGestures);

            viewGestures.Tap        += (s, e) => { Hide(); };
            viewGestures.SwipeLeft  += (s, e) => { Hide(); };
            viewGestures.SwipeRight += (s, e) => { Hide(); };
            viewGestures.SwipeUp    += (s, e) => { Hide(); };
            viewGestures.SwipeDown  += (s, e) => { Hide(); };

            #endregion

            Grid gridDetail = new Grid
            {
                Padding         = Device.OnPlatform(new Thickness(6), new Thickness(6), new Thickness(8)),
                BackgroundColor = InfoPanelForegroundColor,
                Opacity         = InfoPanelOpacity,

                RowDefinitions =
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    }
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(10, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                }
            };

            #region Header
            txtTitle = new Label
            {
                Text  = Title,
                Style = (Style)App.Current.Resources[LabelStyles.TitleStyle]
            };

            txtCategory = new Label
            {
                Style             = (Style)App.Current.Resources[LabelStyles.CategoryStyle],
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Text = CategoryName.ToUpper(),
            };

            stackCategory = new StackLayout
            {
                Padding           = Device.OnPlatform(new Thickness(4), new Thickness(4), new Thickness(6)),
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center,
                BackgroundColor   = CategoryColor,
                Children          =
                {
                    txtCategory
                }
            };

            Grid gridHeader = new Grid
            {
                BackgroundColor = Color.Transparent,

                RowDefinitions =
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = GridLength.Auto
                    }                                                   //new GridLength(1, GridUnitType.Star) },
                }
            };

            gridHeader.Children.Add(txtTitle, 0, 0);
            gridHeader.Children.Add(stackCategory, 1, 0);
            #endregion

            #region Info
            txtDiscountCaption = new Label
            {
                Text  = DiscountCaption,
                Style = (Style)App.Current.Resources[LabelStyles.DescriptionStyle]
            };

            txtPercentValue = new Label
            {
                Text  = DiscountValue,
                Style = (Style)App.Current.Resources[LabelStyles.DescriptionStyle]
            };

            imgDistanceIcon = new Image
            {
                Source = DistanceIcon
            };

            txtDistanceValue = new Label
            {
                Text  = DistanceValue,
                Style = (Style)App.Current.Resources[LabelStyles.DescriptionStyle]
            };

            txtDistanceCaption = new Label
            {
                Text  = DistanceCaption,
                Style = (Style)App.Current.Resources[LabelStyles.DescriptionStyle]
            };

            var stackInfo = new StackLayout
            {
                Spacing     = Device.OnPlatform(3, 3, 3),
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    txtDiscountCaption,
                    txtPercentValue,
                    imgDistanceIcon,
                    txtDistanceValue,
                    txtDistanceCaption
                }
            };

            #endregion

            var stackDetail = new StackLayout
            {
                Spacing  = Device.OnPlatform(2, 4, 8),
                Children =
                {
                    gridHeader,
                    stackInfo
                }
            };
            gridDetail.Children.Add(stackDetail, 0, 0);

            imgShowDetail = new Image
            {
                Source            = DetailIcon,
                HorizontalOptions = LayoutOptions.End
            };

            gridDetail.Children.Add(imgShowDetail, 1, 0);

            borderDetail = new BorderBox(BorderBox.BorderTypeEnum.btLabel);

            borderDetail.HeightRequest = Device.OnPlatform(50, 58, 84);
            borderDetail.WidthRequest  = Device.OnPlatform(210, 210, 280);
            borderDetail.BorderWidth   = 1;
            borderDetail.BorderColor   = (Color)App.Current.Resources[MainStyles.ListBorderColor];
            borderDetail.Content       = gridDetail;

            SetLayoutFlags(borderDetail, AbsoluteLayoutFlags.PositionProportional);
            SetLayoutBounds(borderDetail, Device.OnPlatform(
                                new Rectangle(0.5, 0.365, AutoSize, AutoSize),
                                new Rectangle(0.5, 0.360, AutoSize, AutoSize),
                                new Rectangle(0.5, 0.355, AutoSize, AutoSize))
                            );

            borderDetail.Scale   = 0;
            borderDetail.AnchorY = 1;

            Children.Add(borderDetail);
        }
コード例 #7
0
        public InputManager(DataSocket socket, Xamarin.Forms.AbsoluteLayout layout, RDPSessionPage rdpSessionPage)
        {
            this.socket         = socket;
            this.layout         = layout;
            this.rdpSessionPage = rdpSessionPage;

            tapViewGestures = new ViewGestures
            {
                BackgroundColor   = Color.Transparent,
                AnimationEffect   = ViewGestures.AnimationType.atNone,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill
            };


/*
 *          tapViewGestures.SwipeRight += (s, e) =>
 *          {
 *              Device.BeginInvokeOnMainThread(() =>
 *              {
 *                  Console.WriteLine("Swipe!");
 *
 *                  inputUpdate(MouseInteractionType.LEFT_DOUBLE_CLICK, -1, -1);
 *              });
 *          };
 *
 *          tapViewGestures.SwipeLeft += (s, e) =>
 *          {
 *              Device.BeginInvokeOnMainThread(() =>
 *              {
 *                  Console.WriteLine("Swipe!");
 *
 *                  inputUpdate(2, -1, -1); //DOWN
 *              });
 *          };
 *          tapViewGestures.SwipeUp += (s, e) =>
 *          {
 *              Device.BeginInvokeOnMainThread(() =>
 *              {
 *                  Console.WriteLine("Swipe!");
 *
 *                  inputUpdate(3, -1, -1); //LEFT
 *              });
 *          };
 *          tapViewGestures.SwipeDown += (s, e) =>
 *          {
 *              Device.BeginInvokeOnMainThread(() =>
 *              {
 *                  Console.WriteLine("Swipe!");
 *
 *                  inputUpdate(4, -1, -1); //RIGHT
 *              });
 *          };
 */
            tapViewGestures.Tap += (s, e) =>
            {
                long cur  = Utils.getUnixTime();
                long diff = cur - lastTapAtUnixTime;
                lastTapAtUnixTime = cur;
                Console.WriteLine("Tap_diff {0}", diff);
                if (diff <= 2) //短い間隔でタップが複数回行われていた場合
                {
                    Task.Run(() =>
                    {
                        Console.WriteLine("Double Tap!");

                        inputUpdate(MouseInteractionType.LEFT_DOUBLE_CLICK, -1, -1);
                    });
                }
                else
                {
                    Task.Run(() =>
                    {
                        Console.WriteLine("Tap!");

                        inputUpdate(MouseInteractionType.LEFT_CLICK, -1, -1); // left click
                    });
                }
            };
            tapViewGestures.LongTap += (s, e) =>
            {
                Task.Run(() =>
                {
                    Console.WriteLine("Long Tap!");

                    inputUpdate(MouseInteractionType.RIGHT_CLICK, -1, -1); // right click
                });
            };
            tapViewGestures.Drag += (s, e) =>
            {
                DragEventArgs moved = (DragEventArgs)e;
                Task.Run(() =>
                {
                    Console.WriteLine("Drag!");

                    inputUpdate(MouseInteractionType.POSITION_SET, (int)moved.DistanceX, (int)moved.DistanceY); // Drag
                });
            };

            tapViewGestures.TouchBegan += (s, e) =>
            {
                orgPosXDragStart = int.MaxValue;
                orgPosYDragStart = int.MaxValue;
            };
        }
コード例 #8
0
            public BranchInfoViewTemplate(ListView parentListView, DiscountDetailContentUI parentContentUI, DiscountDetailViewModel parentViewModel)
            {
                IsHighlightSelection = false;

                var stackBranch = new StackLayout
                {
                    Padding         = new Thickness(18, 0),
                    VerticalOptions = LayoutOptions.FillAndExpand
                };

                #region Location
                Grid gridLocation = new Grid
                {
                    RowDefinitions =
                    {
                        new RowDefinition {
                            Height = GridLength.Auto
                        }
                    },
                    ColumnDefinitions =
                    {
                        new ColumnDefinition  {
                            Width = GridLength.Auto
                        },
                        new ColumnDefinition  {
                            Width = GridLength.Auto
                        },
                        new ColumnDefinition  {
                            Width = new GridLength(1, GridUnitType.Star)
                        }
                    }
                };

                var txtDistanceValue = new Label
                {
                    VerticalOptions   = LayoutOptions.Center,
                    HorizontalOptions = LayoutOptions.Start,
                    Style             = (Style)App.Current.Resources[LabelStyles.DetailDistanceStyle]
                };
                txtDistanceValue.SetBinding(Label.TextProperty, "Distance");

                var distanceLabel = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    Spacing         = 0,
                    Children        =
                    {
                        new Image
                        {
                            Source = parentContentUI.ImgDistance
                        },
                        new Label
                        {
                            Text  = parentContentUI.TxtDistanceScaleValue,
                            Style = (Style)App.Current.Resources[LabelStyles.DescriptionStyle]
                        }
                    }
                };

                gridLocation.Children.Add(txtDistanceValue, 0, 0);
                gridLocation.Children.Add(distanceLabel, 1, 0);

                var txtPartnerAddress = new Label
                {
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                    Style           = (Style)App.Current.Resources[LabelStyles.DescriptionStyle]
                };
                txtPartnerAddress.SetBinding(Label.TextProperty, "Address");

                var txtShowOnMap = new LabelExtended
                {
                    Text        = parentContentUI.TxtShowOnMap,
                    Style       = (Style)App.Current.Resources[LabelStyles.LinkStyle],
                    IsUnderline = true
                };

                var locationLayout = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    Spacing         = 0,
                    Children        =
                    {
                        txtPartnerAddress,
                        txtShowOnMap
                    }
                };

                var viewGesturesShowOnMap = new ViewGestures
                {
                    Content          = locationLayout,
                    DeformationValue = -5,
                };
                viewGesturesShowOnMap.BackgroundColor = (Color)App.Current.Resources[MainStyles.MainLightBackgroundColor];
                viewGesturesShowOnMap.Tap            += parentViewModel.ShowOnMap_Click;
                viewGesturesShowOnMap.SetBinding(ViewGestures.TagProperty, "DocumentId");

                gridLocation.Children.Add(viewGesturesShowOnMap, 2, 0);

                stackBranch.Children.Add(gridLocation);

                #endregion

                #region Phone list
                var stackPhoneView = new StackLayout
                {
                    Padding = Device.OnPlatform(new Thickness(0, 4), new Thickness(0, 4), new Thickness(0, 4, -8, 4)),
                };

                #region phone1
                var phone1 = CreateCallButton(parentContentUI, "Phone1");
                phone1.SetBinding(BorderBox.TagProperty, "Phone1");

                var viewGesturesPhone1 = new ViewGestures
                {
                    Content          = phone1,
                    DeformationValue = -5,
                };
                viewGesturesPhone1.SetBinding(ViewGestures.IsVisibleProperty, "IsPhone1FillIn");
                viewGesturesPhone1.BackgroundColor = (Color)App.Current.Resources[MainStyles.MainLightBackgroundColor];
                viewGesturesPhone1.Tap            += parentViewModel.BtnCall_Click;
                stackPhoneView.Children.Add(viewGesturesPhone1);
                #endregion

                #region phone2
                var phone2 = CreateCallButton(parentContentUI, "Phone2");
                phone2.SetBinding(BorderBox.TagProperty, "Phone2");

                var viewGesturesPhone2 = new ViewGestures
                {
                    Content          = phone2,
                    DeformationValue = -5,
                };
                viewGesturesPhone2.SetBinding(ViewGestures.IsVisibleProperty, "IsPhone2FillIn");
                viewGesturesPhone2.BackgroundColor = (Color)App.Current.Resources[MainStyles.MainLightBackgroundColor];
                viewGesturesPhone2.Tap            += parentViewModel.BtnCall_Click;
                stackPhoneView.Children.Add(viewGesturesPhone2);
                #endregion

                stackBranch.Children.Add(stackPhoneView);
                #endregion

                View = stackBranch;
            }
コード例 #9
0
        public DiscountDetailPage(string discountID)
            : base(typeof(DiscountDetailViewModel), typeof(DiscountDetailContentUI))
        {
            viewModel.SetDiscount(discountID);
            var fileNameConverter = new FileNameToImageConverter();

            BackgroundColor = (Color)App.Current.Resources[MainStyles.MainLightBackgroundColor];

            var mainLayout = new AbsoluteLayout();

            var appBar = new TitleBar(this, TitleBar.BarBtnEnum.bbBack)
            {
                BarColor = Color.Transparent,
            };

            appBar.BoxPadding.BackgroundColor = (Color)App.Current.Resources[MainStyles.StatusBarColor];
            appBar.BoxPadding.Opacity         = 0.9;

            appBar.BtnBack.BackgroundColor = (Color)App.Current.Resources[MainStyles.StatusBarColor];
            appBar.BtnBack.Opacity         = 0.9;
            appBar.BtnBack.Source          = contentUI.IconBack;

            discountLayout = new StackLayout
            {
                Spacing = Device.OnPlatform(0, 0, 4),
            };

            #region Photo
            var imageLayout = new RelativeLayout
            {
                HeightRequest = Device.OnPlatform(200, 200, 240)
            };

            var imgPhoto = new Image
            {
                Aspect = Aspect.AspectFill,
            };
            imgPhoto.SetBinding(Image.SourceProperty, new Binding("ImageFileName", BindingMode.Default, fileNameConverter));

            //imgPhoto.SetBinding(Image.SourceProperty, new Binding("ImgPhoto", BindingMode.Default, new FileStreamToImageSource(), FileStreamToImageSource.SizeImage.siBig));

            imageLayout.Children.Add(imgPhoto,
                                     Constraint.Constant(0),
                                     Constraint.Constant(0),
                                     Constraint.RelativeToParent(parent => { return(parent.Width); }),
                                     Constraint.RelativeToParent(parent => { return(parent.Height); })
                                     );
            #endregion

            #region Label percent
            int sizeImgLabel = Device.OnPlatform(60, 60, 80);

            var imgLabel = new Image
            {
                HeightRequest = sizeImgLabel,
                WidthRequest  = sizeImgLabel,
                Source        = contentUI.ImgPercentLabel
            };

            var labelLayout = new AbsoluteLayout();
            AbsoluteLayout.SetLayoutFlags(imgLabel, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(imgLabel, new Rectangle(0f, 0f, 1f, 1f));
            labelLayout.Children.Add(imgLabel);

            imageLayout.Children.Add(labelLayout,
                                     Constraint.RelativeToParent(parent =>
            {
                return(parent.Width - sizeImgLabel - 5);
            }),
                                     Constraint.RelativeToView(imgPhoto, (parent, sibling) =>
            {
                return(sibling.Y + sibling.Height - sizeImgLabel - 5);
            }));

            // Percent
            var txtPercent = new Label
            {
                Style = (Style)App.Current.Resources[LabelStyles.LabelPercentStyle]
            };
            txtPercent.SetBinding(Label.TextProperty, "DiscountPercent");

            var percentLayout = new StackLayout
            {
                Spacing     = 0,
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    txtPercent,
                    new Label
                    {
                        Style           = (Style)App.Current.Resources[LabelStyles.LabelPercentSymbolStyle],
                        VerticalOptions = LayoutOptions.End
                    }
                }
            };

            percentLayout.Rotation = -15;
            AbsoluteLayout.SetLayoutFlags(percentLayout, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds(percentLayout,
                                           new Rectangle(0.6, 0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize)
                                           );
            labelLayout.Children.Add(percentLayout);

            discountLayout.Children.Add(imageLayout);
            #endregion

            #region Header
            Grid gridHeader = new Grid
            {
                VerticalOptions = LayoutOptions.Start,
                Padding         = new Thickness(10),
                RowDefinitions  =
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    }
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(4, GridUnitType.Star)
                    }
                }
            };

            #region Company logo
            var imgCompanyLogo = new Image
            {
                WidthRequest  = Device.OnPlatform(64, 64, 64),
                HeightRequest = Device.OnPlatform(64, 64, 64),
                Aspect        = Aspect.AspectFit
            };
            imgCompanyLogo.SetBinding(Image.SourceProperty, new Binding("LogoFileName", BindingMode.Default, fileNameConverter));
            //imgCompanyLogo.SetBinding(Image.SourceProperty, new Binding("ImgLogo", BindingMode.Default, new FileStreamToImageSource(), FileStreamToImageSource.SizeImage.siSmall));

            var stackCompanyLogo = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Children        = { imgCompanyLogo }
            };

            gridHeader.Children.Add(stackCompanyLogo, 0, 0);
            #endregion

            #region Category list
            var stackCategories = new StackLayout
            {
                Spacing           = 10,
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.End
            };

            for (var i = 0; i < viewModel.CategoriesCount; i++)
            {
                var txtCategory = new Label
                {
                    Style = (Style)App.Current.Resources[LabelStyles.CategoryStyle]
                };

                txtCategory.Text            = viewModel.CategoryIndexName(i);
                txtCategory.BackgroundColor = viewModel.CategoryIndexColor(i);

                var categoryLayout = new StackLayout
                {
                    Padding           = Device.OnPlatform(new Thickness(4), new Thickness(4), new Thickness(6)),
                    VerticalOptions   = LayoutOptions.Center,
                    HorizontalOptions = LayoutOptions.End,
                    Children          =
                    {
                        txtCategory
                    }
                };
                categoryLayout.BackgroundColor = viewModel.CategoryIndexColor(i);

                stackCategories.Children.Add(categoryLayout);
            }
            #endregion

            var titleDetailLayout = new StackLayout
            {
                Padding           = new Thickness(2, 0, 0, 0),
                Spacing           = Device.OnPlatform(0, 0, 4),
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            titleDetailLayout.Children.Add(stackCategories);

            #region Name company
            var txtPartnerName = new Label
            {
                Style             = (Style)App.Current.Resources[LabelStyles.DetailTitleStyle],
                HorizontalOptions = LayoutOptions.Start
            };
            txtPartnerName.SetBinding(Label.TextProperty, "NameCompany");
            titleDetailLayout.Children.Add(txtPartnerName);
            #endregion

            #region Url address
            var txtUrlAddress = new LabelExtended
            {
                Style             = (Style)App.Current.Resources[LabelStyles.LinkStyle],
                TextColor         = Color.FromHex("777"),
                HorizontalOptions = LayoutOptions.Start
            };
            txtUrlAddress.SetBinding(Label.TextProperty, "UrlAddress");

            var viewGesturesURL = new ViewGestures
            {
                Content          = txtUrlAddress,
                DeformationValue = -5,
            };
            viewGesturesURL.BackgroundColor = this.BackgroundColor;
            viewGesturesURL.Tap            += viewModel.txtUrlAddress_Click;
            titleDetailLayout.Children.Add(viewGesturesURL);
            #endregion

            gridHeader.Children.Add(titleDetailLayout, 1, 0);

            discountLayout.Children.Add(gridHeader);
            #endregion

            #region Description
            var txtDescription = new Label
            {
                Style         = (Style)App.Current.Resources[LabelStyles.DescriptionStyle],
                LineBreakMode = LineBreakMode.WordWrap
            };
            txtDescription.SetBinding(Label.TextProperty, "Description");

            var descriptionLayout = new StackLayout
            {
                Padding  = new Thickness(18, 0),
                Children =
                {
                    txtDescription
                }
            };
            discountLayout.Children.Add(descriptionLayout);
            #endregion

            discountLayout.VerticalOptions = LayoutOptions.Start;
            var scrollDiscount = new ScrollView
            {
                VerticalOptions = LayoutOptions.Start,
                Content         = discountLayout,
                HeightRequest   = Device.OnPlatform(600, 600, -1),
            };

            mainLayout.VerticalOptions = LayoutOptions.StartAndExpand;
            AbsoluteLayout.SetLayoutFlags(scrollDiscount, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutBounds(scrollDiscount, new Rectangle(0f, 0f, 1f, 1f));
            mainLayout.Children.Add(scrollDiscount);

            AbsoluteLayout.SetLayoutFlags(appBar, AbsoluteLayoutFlags.PositionProportional);
            AbsoluteLayout.SetLayoutBounds(appBar,
                                           new Rectangle(0, 0, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
            mainLayout.Children.Add(appBar);

            ContentLayout.Children.Add(mainLayout);

            if (Device.OS == TargetPlatform.iOS)
            {
                InitBranchListView();
            }
        }
コード例 #10
0
        public AboutPage()
            : base(typeof(AboutViewModel), typeof(AboutContentUI))
        {
            BackgroundColor = (Color)App.Current.Resources[MainStyles.MainBackgroundColor];

            var appBar = new TitleBar(this, TitleBar.BarBtnEnum.bbBack)
            {
                BarColor = (Color)App.Current.Resources[MainStyles.StatusBarColor]
            };

            appBar.BtnBack.BackgroundColor = Color.Transparent;
            appBar.BtnBack.Source          = contentUI.IconBack;

            ContentLayout.Children.Add(appBar);

            #region Logo
            var imgLogo = new Image
            {
                Source        = contentUI.ImgLogo,
                HeightRequest = Device.OnPlatform(-1, -1, 150),
            };
            #endregion

            #region Description info
            var txtDescription = new Label
            {
                Text  = contentUI.TxtDescription,
                Style = (Style)App.Current.Resources[LabelStyles.DescriptionLightStyle],
            };

            var txtDescriptionBullet1 = new Label
            {
                Text  = contentUI.TxtDescriptionBullet1,
                Style = (Style)App.Current.Resources[LabelStyles.DescriptionLightStyle],
            };

            var stackDescriptionBullet1 = new StackLayout
            {
                Padding     = new Thickness(12, 0, 0, 0),
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    new Label
                    {
                        VerticalOptions = LayoutOptions.Start,
                        Text            = contentUI.TxtDescriptionBulletSymbol,
                        Style           = (Style)App.Current.Resources[LabelStyles.DescriptionLightStyle],
                    },
                    new Label
                    {
                        Text  = contentUI.TxtDescriptionBullet1,
                        Style = (Style)App.Current.Resources[LabelStyles.DescriptionLightStyle],
                    },
                }
            };

            var stackDescriptionBullet2 = new StackLayout
            {
                Padding     = new Thickness(12, 0, 0, 0),
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    new Label
                    {
                        VerticalOptions = LayoutOptions.Start,
                        Text            = contentUI.TxtDescriptionBulletSymbol,
                        Style           = (Style)App.Current.Resources[LabelStyles.DescriptionLightStyle],
                    },
                    new Label
                    {
                        Text  = contentUI.TxtDescriptionBullet2,
                        Style = (Style)App.Current.Resources[LabelStyles.DescriptionLightStyle],
                    },
                }
            };

            var stackDescriptionBullet3 = new StackLayout
            {
                Padding     = new Thickness(12, 0, 0, 0),
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    new Label
                    {
                        VerticalOptions = LayoutOptions.Start,
                        Text            = contentUI.TxtDescriptionBulletSymbol,
                        Style           = (Style)App.Current.Resources[LabelStyles.DescriptionLightStyle],
                    },
                    new Label
                    {
                        Text  = contentUI.TxtDescriptionBullet3,
                        Style = (Style)App.Current.Resources[LabelStyles.DescriptionLightStyle],
                    },
                }
            };

            var stackDescription = new StackLayout
            {
                Children =
                {
                    txtDescription,
                    stackDescriptionBullet1,
                    stackDescriptionBullet2,
                    stackDescriptionBullet3
                }
            };

            //because apple might reject application
            if (Device.OS != TargetPlatform.iOS)
            {
                var txtDescriptionLink = new LabelExtended
                {
                    Text          = contentUI.TxtDescriptionLink,
                    Style         = (Style)App.Current.Resources[LabelStyles.LinkStyle],
                    TextColor     = (Color)App.Current.Resources[MainStyles.LightTextColor],
                    LineBreakMode = LineBreakMode.WordWrap,
                    IsUnderline   = true
                };

                var viewGesturesLink = new ViewGestures
                {
                    Content          = txtDescriptionLink,
                    DeformationValue = -5,
                };
                viewGesturesLink.BackgroundColor = this.BackgroundColor;
                viewGesturesLink.Tap            += viewModel.txtLink_Click;
                stackDescription.Children.Add(viewGesturesLink);
            }
            #endregion

            #region Version info
            var txtTitleVersion = new Label
            {
                Text      = contentUI.TitleVersion,
                Style     = (Style)App.Current.Resources[LabelStyles.DescriptionStyle],
                TextColor = (Color)App.Current.Resources[MainStyles.LightTextColor],
                Opacity   = 0.5
            };

            var txtNumberVersion = new Label
            {
                Text  = contentUI.TxtVersionValue,
                Style = (Style)App.Current.Resources[LabelStyles.DescriptionLightStyle],
            };

            var stackVersion = new StackLayout
            {
                Children =
                {
                    txtTitleVersion,
                    txtNumberVersion
                }
            };
            #endregion

            #region Developer info
            var stackDeveloper = new StackLayout();

            var txtTitleDeveloper = new Label
            {
                Text      = contentUI.TitleDeveloper,
                Style     = (Style)App.Current.Resources[LabelStyles.DescriptionStyle],
                TextColor = (Color)App.Current.Resources[MainStyles.LightTextColor],
                Opacity   = 0.5
            };
            stackDeveloper.Children.Add(txtTitleDeveloper);

            var txtPhone = new LabelExtended
            {
                Text      = String.Format("{0}: {1}", contentUI.TxtPhone, contentUI.TxtPhoneValue),
                Style     = (Style)App.Current.Resources[LabelStyles.DescriptionStyle],
                TextColor = (Color)App.Current.Resources[MainStyles.LightTextColor]
            };

            var viewGesturesPhone = new ViewGestures
            {
                Content          = txtPhone,
                DeformationValue = -5,
            };
            viewGesturesPhone.BackgroundColor = this.BackgroundColor;
            viewGesturesPhone.Tap            += viewModel.txtPhone_Click;
            stackDeveloper.Children.Add(viewGesturesPhone);

            var txtEmail = new Label
            {
                Text      = String.Format("{0}: {1}", contentUI.TxtEmail, contentUI.TxtEmailValue),
                Style     = (Style)App.Current.Resources[LabelStyles.DescriptionStyle],
                TextColor = (Color)App.Current.Resources[MainStyles.LightTextColor]
            };
            stackDeveloper.Children.Add(txtEmail);

            var txtHttp = new LabelExtended
            {
                Text        = contentUI.TxtHttpValue,
                Style       = (Style)App.Current.Resources[LabelStyles.LinkStyle],
                TextColor   = (Color)App.Current.Resources[MainStyles.LightTextColor],
                IsUnderline = true
            };

            var viewGesturesHTTP = new ViewGestures
            {
                Content          = txtHttp,
                DeformationValue = -5,
            };
            viewGesturesHTTP.BackgroundColor = this.BackgroundColor;
            viewGesturesHTTP.Tap            += viewModel.txtLink_Click;
            stackDeveloper.Children.Add(viewGesturesHTTP);

            #endregion

            var stackAbout = new StackLayout
            {
                Padding = new Thickness(24),
                Spacing = 20,

                Children =
                {
                    imgLogo,
                    stackDescription,
                    stackVersion,
                    stackDeveloper
                }
            };

            var scrollAbout = new ScrollView
            {
                Content = stackAbout
            };

            ContentLayout.Children.Add(scrollAbout);
        }
コード例 #11
0
            public FilterViewTemplate(MainViewModel parentViewModel)
            {
                IsHighlightSelection = false;
                SelectColor          = Color.Transparent;


                Grid gridFilterItem = new Grid
                {
                    BackgroundColor = (Color)App.Current.Resources[MainStyles.MainBackgroundColor],
                    Padding         = new Thickness(16, 0),
                    RowDefinitions  =
                    {
                        new RowDefinition {
                            Height = new GridLength(1, GridUnitType.Star)
                        }
                    },
                    ColumnDefinitions =
                    {
                        new ColumnDefinition {
                            Width = new GridLength(1, GridUnitType.Star)
                        },
                        new ColumnDefinition {
                            Width = GridLength.Auto
                        }
                    },
                };

                #region Title
                var stackTitle = new StackLayout
                {
                    Spacing           = 16,
                    Orientation       = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.Start,
                };
                var imgFilterItem = new Image();
                imgFilterItem.SetBinding(Image.SourceProperty, "Icon");
                stackTitle.Children.Add(imgFilterItem);

                var txtFilterItem = new Label
                {
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                };
                txtFilterItem.SetBinding(Label.StyleProperty, "NameStyle");
                txtFilterItem.SetBinding(Label.TextProperty, "Name");
                stackTitle.Children.Add(txtFilterItem);

                var filterTitleGestures = new ViewGestures();
                filterTitleGestures.Content         = stackTitle;
                filterTitleGestures.Tap            += parentViewModel.FilterGestures_Tap;
                filterTitleGestures.SwipeLeft      += parentViewModel.FilterGestures_Tap;
                filterTitleGestures.BackgroundColor = (Color)App.Current.Resources[MainStyles.MainBackgroundColor];

                gridFilterItem.Children.Add(filterTitleGestures, 0, 0);
                #endregion

                #region Toggle
                var switchFilter = new SwitchExtended
                {
                    HorizontalOptions = LayoutOptions.End,
                };
                switchFilter.SetBinding(SwitchExtended.TextOffProperty, "TurnOffValue");
                switchFilter.SetBinding(SwitchExtended.TextOnProperty, "TurnOnValue");

                if (Device.OS == TargetPlatform.iOS)
                {
                    switchFilter.TranslationY = 8;
                }

                switchFilter.SetBinding(Switch.IsToggledProperty, "IsToggle", BindingMode.TwoWay);
                switchFilter.Toggled += parentViewModel.SwitchFilter_Toggled;

                gridFilterItem.Children.Add(switchFilter, 1, 0);
                #endregion

                View = gridFilterItem;
            }