Exemplo n.º 1
0
 public void LoadSoPhongTam()
 {
     foreach (var num in NumberList)
     {
         RadBorder radBorder = new RadBorder()
         {
             HeightRequest   = 38,
             WidthRequest    = 38,
             BorderColor     = Color.Gray,
             BorderThickness = 1,
             BackgroundColor = Color.White,
             CornerRadius    = 19,
             Content         = new Label()
             {
                 TextColor               = Color.FromHex("#444444"),
                 VerticalTextAlignment   = TextAlignment.Center,
                 HorizontalTextAlignment = TextAlignment.Center,
                 Text = num.ToString()
             }
         };
         TapGestureRecognizer tap = new TapGestureRecognizer();
         tap.NumberOfTapsRequired = 1;
         tap.Tapped += SoPhongNgu_Tapped;
         radBorder.GestureRecognizers.Add(tap);
         StacklayoutSoPhongtam.Children.Add(radBorder);
     }
 }
        private async void GetHTML_Clicked(object sender, EventArgs e)
        {
            // >> richtexteditor-keyfeatures-gethtml
            var htmlString = await this.richTextEditor.GetHtmlAsync();

            // << richtexteditor-keyfeatures-gethtml

            var popup = new RadPopup {
                OutsideBackgroundColor = Color.FromHex("#6F000000")
            };

            popup.PlacementTarget = this;

            var containerGrid = new Grid {
                Padding = 20
            };

            containerGrid.Children.Add(new Label {
                Text = htmlString
            });

            var border = new RadBorder {
                CornerRadius = new Thickness(8), BackgroundColor = Color.Wheat
            };

            border.Content = containerGrid;
            popup.Content  = border;
            popup.IsOpen   = true;
        }
Exemplo n.º 3
0
        private View CreateAndroidAddAppointmentButton()
        {
            var border = new RadBorder
            {
                WidthRequest      = 56,
                HeightRequest     = 56,
                BackgroundColor   = Color.FromHex("#3F74D3"),
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.End,
                Margin            = new Thickness(0, 0, 16, 50),
                CornerRadius      = 28
            };

            border.GestureRecognizers.Add(new TapGestureRecognizer()
            {
                Command = new Command(() =>
                                      ((MultiDayViewAppointmentsViewModel)this.BindingContext).NavigateToAddAppointmentPage())
            });

            var label = new Label
            {
                Text              = "+",
                TextColor         = Color.White,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                FontSize          = 20
            };

            border.Content = label;

            return(border);
        }
Exemplo n.º 4
0
        private void BtnCompleteSimType_Clicked(object sender, EventArgs e)
        {
            SimTypeSelected.Children.Clear();
            var selectedList      = viewModel.NumberTypeOptions.Where(x => x.IsSelected).ToList();
            var selectedListCount = selectedList.Count();

            for (int i = 0; i < selectedListCount; i++)
            {
                var item = selectedList[i];

                StackLayout stackLayout = new StackLayout()
                {
                    BackgroundColor = Color.White,
                    Padding         = new Thickness(10, 5, 10, 5),
                    Orientation     = StackOrientation.Horizontal
                };

                Label label = new Label()
                {
                    Text      = item.Name,
                    TextColor = Color.FromHex("#3F51B5"),
                    FontSize  = 14
                };
                stackLayout.Children.Add(label);

                RadBorder radBorder = new RadBorder();
                radBorder.Margin       = 2;
                radBorder.CornerRadius = 5;
                radBorder.BorderColor  = Color.FromHex("#3F51B5");
                radBorder.Content      = stackLayout;

                SimTypeSelected.Children.Add(radBorder);
            }



            if (SimTypeSelected.Children.Any())
            {
                entryLoaiSim.IsVisible = false;
                //Button button = new Button()
                //{
                //    BackgroundColor = Color.FromHex("#3F51B5"),
                //    HeightRequest = 30,
                //    //Padding = 5,
                //    Text="Thêm",
                //    FontSize = 10,
                //    //Image = "plus_white.png"
                //};
                //button.Clicked += FlexSimTypeTapGes_Tapped;
                //SimTypeSelected.Children.Add(button);
            }
            else
            {
                entryLoaiSim.IsVisible = true;
            }

            ClearBackUpNumberType();
            modalContentView.IsVisible = false;
        }
Exemplo n.º 5
0
        public PopupGettingStartedCSharp()
        {
            // >> popup-getting-started-csharp
            var showPopupBtn = new Button {
                HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Start, Text = "Click here to rate"
            };

            showPopupBtn.Clicked += ShowPopup;

            popup = new RadPopup {
                IsModal = true, OutsideBackgroundColor = Color.FromHex("#6F000000")
            };
            popup.PlacementTarget = showPopupBtn;

            var containerGrid = new Grid {
                Padding = 20
            };

            containerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(30)
            });
            containerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(20)
            });
            containerGrid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(40)
            });
            containerGrid.Children.Add(new Label {
                Text = "Please rate your experience"
            });

            var rating = new RadShapeRating();

            rating.SetValue(Grid.RowProperty, 1);
            containerGrid.Children.Add(rating);

            var hidePopupBtn = new Button {
                Padding = new Thickness(2), HorizontalOptions = LayoutOptions.End, Text = "Send"
            };

            hidePopupBtn.SetValue(Grid.RowProperty, 2);
            hidePopupBtn.Clicked += ClosePopup;
            containerGrid.Children.Add(hidePopupBtn);

            var border = new RadBorder {
                CornerRadius = new Thickness(8), BackgroundColor = Color.Wheat
            };

            border.Content = containerGrid;
            popup.Content  = border;
            // << popup-getting-started-csharp

            this.Content = showPopupBtn;
        }
Exemplo n.º 6
0
        private async void Menh_Checked(object sender, EventArgs e)
        {
            foreach (RadBorder item in gridMenh.Children)
            {
                item.BorderColor = Color.Transparent;
                (item.Content as Label).FontAttributes = FontAttributes.None;
            }
            RadBorder radBorder = (RadBorder)sender;

            radBorder.BorderColor = Color.Black;
            (radBorder.Content as Label).FontAttributes = FontAttributes.Bold;
            this.Menh = short.Parse((radBorder.GestureRecognizers[0] as TapGestureRecognizer).CommandParameter.ToString());
        }
Exemplo n.º 7
0
        public void SetCategoryActiveStyle(RadBorder item)
        {
            //set style
            item.BorderColor = BorderColorActive;

            //set scroll position
            var    itemX     = item.X;
            var    itemWidth = item.Width;
            var    center    = Application.Current.MainPage.Width / 2;
            double x         = 0;

            if (itemX > center)
            {
                x = itemX - center + itemWidth / 2 + 10;
            }
            ImageListScroll.ScrollToAsync(x, ImageListScroll.ScrollY, true);
        }
        private void SegmentSelected_Tapped(object sender, EventArgs e)
        {
            foreach (RadBorder radBorder in Segment.Children)
            {
                radBorder.BackgroundColor = Color.FromHex("#fff");
                radBorder.BorderColor     = Color.FromHex("#c3c3c3");
            }

            RadBorder            radBorderSelected = sender as RadBorder;
            TapGestureRecognizer tap = radBorderSelected.GestureRecognizers[0] as TapGestureRecognizer;
            int index = int.Parse(tap.CommandParameter.ToString());


            radBorderSelected.BackgroundColor = Color.FromHex("#dadada");
            radBorderSelected.BorderColor     = Color.FromHex("#c3c3c3");

            if (index == 0)
            {
                ProjectContentView.IsVisible        = true;
                ListBatDongSanContentView.IsVisible = false;
                ProductContentViews.IsVisible       = false;
            }
            else if (index == 1)
            {
                if (CompanyPostListContentView == null)
                {
                    CompanyPostListContentView        = new CompanyPostListContentView(_id);
                    ListBatDongSanContentView.Content = CompanyPostListContentView;
                }

                ProjectContentView.IsVisible        = false;
                ListBatDongSanContentView.IsVisible = true;
                ProductContentViews.IsVisible       = false;
            }
            else if (index == 2)
            {
                if (productListContentView == null)
                {
                    productListContentView      = new ProductListContentView(_id, false);
                    ProductContentViews.Content = productListContentView;
                }
                ProjectContentView.IsVisible        = false;
                ListBatDongSanContentView.IsVisible = false;
                ProductContentViews.IsVisible       = true;
            }
        }
        public void SetList <T>(List <T> list, string Name) where T : class
        {
            lookUpListView = new ListView(ListViewCachingStrategy.RecycleElement);
            lookUpListView.BackgroundColor     = Color.White;
            lookUpListView.HasUnevenRows       = true;
            lookUpListView.SelectionMode       = ListViewSelectionMode.None;
            lookUpListView.SeparatorVisibility = SeparatorVisibility.None;
            var dataTemplate = new DataTemplate(() =>
            {
                RadBorder st       = new RadBorder();
                st.BorderThickness = new Thickness(0, 0, 0, 1);
                st.BorderColor     = Color.FromHex("#eeeeee");
                st.Padding         = 10;
                Label lb           = new Label();
                lb.TextColor       = Color.Black;
                lb.FontSize        = 16;
                lb.SetBinding(Label.TextProperty, Name);
                st.Content = lb;
                return(new ViewCell {
                    View = st
                });
            });

            lookUpListView.ItemTemplate = dataTemplate;
            lookUpListView.ItemsSource  = list;

            //this.Content = lookUpListView;

            Grid.SetRow(lookUpListView, 1);
            MainGrid.Children.Add(lookUpListView);


            searchBar.TextChanged += async(object sender, TextChangedEventArgs e) =>
            {
                var text = e.NewTextValue;
                if (string.IsNullOrWhiteSpace(text))
                {
                    lookUpListView.ItemsSource = list;
                }
                else
                {
                    lookUpListView.ItemsSource = list.Where(x => GetValObjDy(x, Name).ToString().ToLower().Contains(text.ToLower()));
                }
            };
        }
        public async void OnCategoryTapped(object sender, EventArgs e)
        {
            var categoryChoosed = sender as RadBorder;

            if (categoryChoosed.BackgroundColor == BGColorActive)
            {
                return;
            }

            loadingPopup.IsVisible = true;

            //set all category style to inactive
            RadBorder inactiveItem = (RadBorder)this.CategoriesStackLayout.Children[currentIndex];

            inactiveItem.BackgroundColor = BGColorInActive;
            inactiveItem.BorderColor     = BorderColorInActive;

            this.currentIndex = CategoriesStackLayout.Children.IndexOf(categoryChoosed);
            //set active style to category choosed
            SetCategoryActiveStyle(categoryChoosed);

            //get category choosed
            var  tap = categoryChoosed.GestureRecognizers[0] as TapGestureRecognizer;
            Guid categoryId;

            if (tap.CommandParameter != null)
            {
                categoryId = (Guid)tap.CommandParameter;
            }

            //get list product by category choosed
            if (tap.CommandParameter == null)
            {
                viewModel.FilterModel.ParentCategoryId = null;
            }
            else
            {
                viewModel.FilterModel.ParentCategoryId = categoryId;
            }
            await viewModel.LoadOnRefreshCommandAsync();

            loadingPopup.IsVisible = false;
        }
Exemplo n.º 11
0
        public void SetCategoryActiveStyle(RadBorder item)
        {
            //set style
            item.BackgroundColor = BGColorActive;
            item.BorderColor     = TextColorActive;
            (item.Content as Label).TextColor = TextColorActive;

            //set scroll position
            var    itemX     = item.X;
            var    itemWidth = item.Width;
            var    center    = Application.Current.MainPage.Width / 2;
            double x         = 0;

            if (itemX > center)
            {
                x = itemX - center + itemWidth / 2 + 10;
            }
            scroll.ScrollToAsync(x, scroll.ScrollY, true);
        }
        public void InitCategoriesLayout()
        {
            var rb = new RadBorder()
            {
                Style           = (Style)this.Resources["RadBorderCategories"],
                BorderColor     = BorderColorActive,
                BackgroundColor = BGColorActive,
                Content         = new Label()
                {
                    Style = (Style)Resources["Category"],
                    Text  = Language.tat_ca,
                }
            };

            var tapGestureRecognizer1 = new TapGestureRecognizer();

            tapGestureRecognizer1.Tapped += (s, e) => OnCategoryTapped(s, e);
            rb.GestureRecognizers.Add(tapGestureRecognizer1);
            CategoriesStackLayout.Children.Insert(0, rb);
        }
        private async void FilterByStatus_Clicked(object sender, EventArgs e)
        {
            RadBorder radBoder = sender as RadBorder;

            if (radBoder.BackgroundColor == Color.FromHex("#eeeeee"))
            {
                return;
            }

            TapGestureRecognizer tapGestureRecognizer = radBoder.GestureRecognizers[0] as TapGestureRecognizer;

            if (tapGestureRecognizer.CommandParameter != null)
            {
                int Status = int.Parse(tapGestureRecognizer.CommandParameter.ToString());
                viewModel.FilterModel.Status = Status;
            }
            else
            {
                viewModel.FilterModel.Status = null;
            }
            loadingPopup.IsVisible = true;


            // inactive
            foreach (RadBorder item in StackLayoutFilter.Children)
            {
                item.BorderColor     = Color.FromHex("#eeeeee");
                item.BackgroundColor = Color.White;
            }
            // active.
            radBoder.BackgroundColor = Color.FromHex("#eeeeee");
            radBoder.BorderColor     = Color.FromHex("#aaaaaa");



            await viewModel.LoadOnRefreshCommandAsync();

            loadingPopup.IsVisible = false;
        }
Exemplo n.º 14
0
        private void InitCategoriesLayout()
        {
            var rb = new RadBorder()
            {
                Style           = (Style)this.Resources["RadBorderCategories"],
                BorderColor     = BorderColorActive,
                BackgroundColor = BGColorActive,
                Content         = new Label()
                {
                    Style = (Style)Resources["Category"],
                    Text  = Language.see_all,
                }
            };

            var tapGestureRecognizer1 = new TapGestureRecognizer();

            tapGestureRecognizer1.Tapped += (s, e) => OnCategoryTapped(s, e);
            rb.GestureRecognizers.Add(tapGestureRecognizer1);
            CategoriesStackLayout.Children.Insert(0, rb);


            if (viewModel.FilterModel.CategoryId.HasValue) // set active
            {
                var category        = this.Categories.SingleOrDefault(x => x.Id == viewModel.FilterModel.CategoryId.Value);
                int countCategories = Categories.Count;
                for (int i = 1; i < countCategories + 1; i++) // +1 vi co them thang tat ca.
                {
                    RadBorder radBorder   = CategoriesStackLayout.Children[i] as RadBorder;
                    var       stackLayout = radBorder.Content as StackLayout;
                    var       label       = stackLayout.Children[1] as Label;
                    if (label.Text == category.Name)
                    {
                        Device.BeginInvokeOnMainThread(() => SetCategoryActiveStyle(radBorder));
                        break;
                    }
                }
            }
        }
Exemplo n.º 15
0
        public void SetCategoryActiveStyle(RadBorder item)
        {
            foreach (RadBorder rad in CategoriesStackLayout.Children)
            {
                rad.BackgroundColor = BGColorInActive;
                rad.BorderColor     = BorderColorInActive;
            }

            //set style
            item.BackgroundColor = BGColorActive;
            item.BorderColor     = BorderColorActive;

            //set scroll position
            var    itemX     = item.X;
            var    itemWidth = item.Width;
            var    center    = Application.Current.MainPage.Width / 2;
            double x         = 0;

            if (itemX > center)
            {
                x = itemX - center + itemWidth / 2 + 10;
            }
            scroll.ScrollToAsync(x, scroll.ScrollY, true);
        }
        public async Task LoadChildCategory()
        {
            List <FurnitureCategory> furnitureCategories = await viewModel.GetChildCategories();

            if (furnitureCategories == null)
            {
                await DisplayAlert("", Language.loi_load_danh_muc, Language.dong);

                return;
            }
            for (int i = 0; i < furnitureCategories.Count; i++)
            {
                Label lbl = new Label()
                {
                    Text      = furnitureCategories[i].Name,
                    FontSize  = 15,
                    TextColor = Color.FromHex("#444444")
                };

                var item = new RadBorder();
                item.Padding         = new Thickness(10, 5);
                item.Margin          = new Thickness(0, 0, 5, 5);
                item.BorderColor     = Color.Gray;
                item.BorderThickness = 1;
                item.BorderColor     = Color.Gray;
                item.CornerRadius    = 15;
                item.BackgroundColor = Color.White;

                var tap = new TapGestureRecognizer();
                tap.NumberOfTapsRequired = 1;
                tap.CommandParameter     = furnitureCategories[i];
                tap.Tapped += (o, e) =>
                {
                    foreach (RadBorder radBorder in Flexlayout_ChildCategory.Children.Where(x => x != item))
                    {
                        radBorder.BackgroundColor = Color.White;
                        (radBorder.Content as Label).TextColor = UnSelectedTextColor;
                    }

                    if (item.BackgroundColor == Color.White)
                    {
                        item.BackgroundColor = SelectedBGColor;
                        lbl.TextColor        = SelectedTextColor;


                        //
                        var selectedCateogry = ((o as RadBorder).GestureRecognizers[0] as TapGestureRecognizer).CommandParameter as FurnitureCategory;
                        viewModel.ChildCategory = selectedCateogry;
                    }
                    else
                    {
                        item.BackgroundColor = Color.White;
                        lbl.TextColor        = UnSelectedTextColor;
                    }
                };
                item.GestureRecognizers.Add(tap);
                item.Content = lbl;

                Flexlayout_ChildCategory.Children.Add(item);
            }
        }
        public async Task LoadParentCategory()
        {
            List <FurnitureCategory> furnitureCategories = await viewModel.GetParentCategories();

            for (int i = 0; i < furnitureCategories.Count; i++)
            {
                Label lbl = new Label()
                {
                    Text      = Language.ResourceManager.GetString(furnitureCategories[i].LanguageKey, Language.Culture),
                    FontSize  = 15,
                    TextColor = Color.FromHex("#444444")
                };

                var item = new RadBorder();
                item.Padding         = new Thickness(10, 5);
                item.Margin          = new Thickness(0, 0, 5, 5);
                item.BorderColor     = Color.Gray;
                item.BorderThickness = 1;
                item.BorderColor     = Color.Gray;
                item.CornerRadius    = 15;
                item.BackgroundColor = Color.White;

                var tap = new TapGestureRecognizer();
                tap.NumberOfTapsRequired = 1;
                tap.CommandParameter     = furnitureCategories[i];
                tap.Tapped += async(o, e) =>
                {
                    Flexlayout_ChildCategory.Children.Clear();
                    foreach (RadBorder radBorder in Flexlayout_ParentCategory.Children.Where(x => x != item))
                    {
                        radBorder.BackgroundColor = Color.White;
                        (radBorder.Content as Label).TextColor = UnSelectedTextColor;
                    }

                    if (item.BackgroundColor == Color.White) // dang inactive
                    {
                        item.BackgroundColor = SelectedBGColor;
                        lbl.TextColor        = SelectedTextColor;

                        //n eu co active thi load child theo parrent.

                        loadingPopup.IsVisible = true;
                        var selectedCateogry = ((o as RadBorder).GestureRecognizers[0] as TapGestureRecognizer).CommandParameter as FurnitureCategory;


                        viewModel.ChildCategory  = null;
                        viewModel.ParentCategory = selectedCateogry;

                        await LoadChildCategory();

                        loadingPopup.IsVisible = false;
                    }
                    else // dang active thi set unactive
                    {
                        // reset lai.
                        viewModel.ParentCategory = null;
                        viewModel.ChildCategory  = null;

                        item.BackgroundColor = Color.White;
                        lbl.TextColor        = UnSelectedTextColor;
                    }
                };
                item.GestureRecognizers.Add(tap);
                item.Content = lbl;

                Flexlayout_ParentCategory.Children.Add(item);
            }
        }
        private static Grid GeneratePieChart(IList <ChartDataPoint> dataPoints, List <Color> colors, bool showLegend = true)
        {
            // Root container to hold the chart and any legend
            var container = new Grid();

            container.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(3, GridUnitType.Star)
            });
            container.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });

            // ***** Part 1 - PIE SERIES GENERATION ***** //

            // Sum up all the values to be displayed
            var totalValue = dataPoints.Sum(d => d.Value);

            // Variable to keep track of where each slice ended.
            double currentPosition = 0;

            // Iterate over the data points to create slices.
            for (int i = 0; i < dataPoints.Count; i++)
            {
                // Determine the percentage of the whole the slice uses.
                double slicePercentage = dataPoints[i].Value / totalValue;

                // Calculate the sweep using that percentage
                double sweep = slicePercentage * 360;

                // Create the ArcSegment using the calculated values.
                var segment = new RadArcSegment
                {
                    Center     = new Point(0.5, 0.5),
                    Size       = new Size(1, 1),
                    StartAngle = currentPosition,
                    SweepAngle = sweep,
                };

                // Important - Calculate the last segment's ending angle in order to have a valid start angle for the next loop.
                currentPosition = currentPosition + sweep - 360;

                // Prepare the required PathFigure and add the ArcSegment
                var figure = new RadPathFigure {
                    StartPoint = new Point(0.5, 0.5)
                };
                figure.Segments.Add(segment);

                // Create the PathGeometry and add the PathFigure
                var geometry = new RadPathGeometry();
                geometry.Figures.Add(figure);

                // Construct the RadPath
                // - Select a Fill color from the brushes parameter (important: use a modulus to wrap to the beginning)
                // - Use the Geometry created from the value
                var slice = new RadPath
                {
                    Fill              = new RadSolidColorBrush(colors[i % colors.Count]),
                    Geometry          = geometry,
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions   = LayoutOptions.Center,
                    WidthRequest      = 100,
                    HeightRequest     = 100,
                    Margin            = new Thickness(0, 20, 0, 0)
                };

                // This isn't necessary, but added for completion.
                Grid.SetRow(slice, 0);

                // Finally, add it to the container.
                container.Children.Add(slice);
            }

            // ***** Part 2 - LEGEND GENERATION ***** //

            if (showLegend)
            {
                var legendPanel = new StackLayout();
                legendPanel.Orientation       = StackOrientation.Horizontal;
                legendPanel.HorizontalOptions = LayoutOptions.Center;
                legendPanel.VerticalOptions   = LayoutOptions.Center;
                legendPanel.Margin            = new Thickness(0, 16, 0, 0);
                legendPanel.Spacing           = 5;

                for (int i = 0; i < dataPoints.Count; i++)
                {
                    // Use a RadBorder with only a bottom thickness and match the color to the slice
                    var legendItem = new RadBorder();
                    legendItem.BorderColor     = colors[i % colors.Count];
                    legendItem.BorderThickness = new Thickness(0, 0, 0, 2);

                    // Create a Label for each data point and use the Title property
                    var label = new Label
                    {
                        Text      = dataPoints[i].Title,
                        FontSize  = 12,
                        Margin    = new Thickness(0, 0, 0, 2),
                        TextColor = (Color)Application.Current.Resources["LightGrayTextColor"]
                    };

                    legendItem.Content = label;

                    legendPanel.Children.Add(legendItem);
                }

                Grid.SetRow(legendPanel, 1);

                container.Children.Add(legendPanel);
            }

            return(container);
        }
Exemplo n.º 19
0
        public void LoadCategories()
        {
            List <LiquidationCategory> furnitureCategories = DependencyService.Get <ILiquidationCategoryService>().GetLiquidations();

            for (int i = 0; i < furnitureCategories.Count; i++)
            {
                Label lbl = new Label()
                {
                    Text      = furnitureCategories[i].Name,
                    FontSize  = 15,
                    TextColor = Color.FromHex("#444444")
                };

                var item = new RadBorder();
                item.Padding         = new Thickness(10, 5);
                item.BorderColor     = Color.Gray;
                item.BorderThickness = 1;
                item.BorderColor     = Color.Gray;
                item.CornerRadius    = 15;
                item.BackgroundColor = Color.White;

                var tap = new TapGestureRecognizer();
                tap.NumberOfTapsRequired = 1;
                tap.CommandParameter     = furnitureCategories[i];
                tap.Tapped += async(o, e) =>
                {
                    foreach (RadBorder radBorder in Flexlayout_ParentCategory.Children.Where(x => x != item))
                    {
                        radBorder.BackgroundColor = Color.White;
                        (radBorder.Content as Label).TextColor = UnSelectedTextColor;
                    }

                    if (item.BackgroundColor == Color.White) // dang inactive
                    {
                        item.BackgroundColor = SelectedBGColor;
                        lbl.TextColor        = SelectedTextColor;

                        //n eu co active thi load child theo parrent.

                        loadingPopup.IsVisible = true;
                        var selectedCateogry = ((o as RadBorder).GestureRecognizers[0] as TapGestureRecognizer).CommandParameter as LiquidationCategory;


                        viewModel.Category     = null;
                        viewModel.Category     = selectedCateogry;
                        loadingPopup.IsVisible = false;
                    }
                    else // dang active thi set unactive
                    {
                        // reset lai.
                        viewModel.Category = null;

                        item.BackgroundColor = Color.White;
                        lbl.TextColor        = UnSelectedTextColor;
                    }
                };
                item.GestureRecognizers.Add(tap);
                item.Content = lbl;

                Flexlayout_ParentCategory.Children.Add(item);
            }
        }
Exemplo n.º 20
0
        private void InitializeComponent()
        {
            if (ResourceLoader.CanProvideContentFor(new ResourceLoader.ResourceLoadingQuery
            {
                AssemblyName = typeof(ModalPopupPage).GetTypeInfo().Assembly.GetName(),
                ResourcePath = "Views/ModalPopupPage.xaml",
                Instance = this
            }))
            {
                __InitComponentRuntime();
                return;
            }
            if (XamlLoader.XamlFileProvider != null && XamlLoader.XamlFileProvider(GetType()) != null)
            {
                __InitComponentRuntime();
                return;
            }
            ScaleAnimation          scaleAnimation          = new ScaleAnimation();
            BindingExtension        bindingExtension        = new BindingExtension();
            TapGestureRecognizer    tapGestureRecognizer    = new TapGestureRecognizer();
            BindingExtension        bindingExtension2       = new BindingExtension();
            StaticResourceExtension staticResourceExtension = new StaticResourceExtension();
            Label          label       = new Label();
            RadBorder      radBorder   = new RadBorder();
            StackLayout    stackLayout = new StackLayout();
            ModalPopupPage modalPopupPage;
            NameScope      nameScope = (NameScope)(NameScope.GetNameScope(modalPopupPage = this) ?? new NameScope());

            NameScope.SetNameScope(modalPopupPage, nameScope);
            modalPopupPage.SetValue(VisualElement.BackgroundColorProperty, Color.Transparent);
            scaleAnimation.PositionIn             = MoveAnimationOptions.Center;
            scaleAnimation.PositionOut            = MoveAnimationOptions.Center;
            scaleAnimation.ScaleIn                = 0.5;
            scaleAnimation.ScaleOut               = 0.5;
            scaleAnimation.DurationIn             = (uint)new UintTypeConverter().ConvertFromInvariantString("400");
            scaleAnimation.DurationOut            = (uint)new UintTypeConverter().ConvertFromInvariantString("300");
            scaleAnimation.EasingIn               = (Easing) new EasingTypeConverter().ConvertFromInvariantString("SinOut");
            scaleAnimation.EasingOut              = (Easing) new EasingTypeConverter().ConvertFromInvariantString("SinIn");
            scaleAnimation.HasBackgroundAnimation = true;
            modalPopupPage.SetValue(Rg.Plugins.Popup.Pages.PopupPage.AnimationProperty, scaleAnimation);
            VisualDiagnostics.RegisterSourceInfo(scaleAnimation, new Uri("Views\\ModalPopupPage.xaml", UriKind.RelativeOrAbsolute), 12, 10);
            stackLayout.SetValue(View.VerticalOptionsProperty, LayoutOptions.Center);
            stackLayout.SetValue(View.HorizontalOptionsProperty, LayoutOptions.Center);
            stackLayout.SetValue(Xamarin.Forms.Layout.PaddingProperty, new Thickness(20.0));
            bindingExtension.Path = "ContentTapCommand";
            BindingBase binding = ((IMarkupExtension <BindingBase>)bindingExtension).ProvideValue((IServiceProvider)null);

            tapGestureRecognizer.SetBinding(TapGestureRecognizer.CommandProperty, binding);
            stackLayout.GestureRecognizers.Add(tapGestureRecognizer);
            VisualDiagnostics.RegisterSourceInfo(tapGestureRecognizer, new Uri("Views\\ModalPopupPage.xaml", UriKind.RelativeOrAbsolute), 28, 14);
            radBorder.SetValue(RadBorder.BorderColorProperty, new Color(0.18823529779911041, 0.18823529779911041, 0.18431372940540314, 0.93333333730697632));
            radBorder.SetValue(VisualElement.BackgroundColorProperty, new Color(0.18823529779911041, 0.18823529779911041, 0.18431372940540314, 0.93333333730697632));
            radBorder.SetValue(RadBorder.BorderThicknessProperty, new Thickness(2.0));
            radBorder.SetValue(RadBorder.CornerRadiusProperty, new Thickness(10.0));
            radBorder.SetValue(VisualElement.WidthRequestProperty, 300.0);
            bindingExtension2.Path = "Text";
            BindingBase binding2 = ((IMarkupExtension <BindingBase>)bindingExtension2).ProvideValue((IServiceProvider)null);

            label.SetBinding(Label.TextProperty, binding2);
            label.SetValue(Label.TextColorProperty, Color.White);
            staticResourceExtension.Key = "TCLRegular";
            XamlServiceProvider xamlServiceProvider = new XamlServiceProvider();
            Type typeFromHandle = typeof(IProvideValueTarget);

            object[] array = new object[0 + 4];
            array[0] = label;
            array[1] = radBorder;
            array[2] = stackLayout;
            array[3] = modalPopupPage;
            object service;

            xamlServiceProvider.Add(typeFromHandle, service = new SimpleValueTargetProvider(array, Label.FontFamilyProperty, nameScope));
            xamlServiceProvider.Add(typeof(IReferenceProvider), service);
            Type typeFromHandle2 = typeof(IXamlTypeResolver);
            XmlNamespaceResolver xmlNamespaceResolver = new XmlNamespaceResolver();

            xmlNamespaceResolver.Add("", "http://xamarin.com/schemas/2014/forms");
            xmlNamespaceResolver.Add("x", "http://schemas.microsoft.com/winfx/2009/xaml");
            xmlNamespaceResolver.Add("animations", "clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup");
            xmlNamespaceResolver.Add("pages", "clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup");
            xmlNamespaceResolver.Add("telerikPrimitives", "clr-namespace:Telerik.XamarinForms.Primitives;assembly=Telerik.XamarinForms.Primitives");
            xamlServiceProvider.Add(typeFromHandle2, new XamlTypeResolver(xmlNamespaceResolver, typeof(ModalPopupPage).GetTypeInfo().Assembly));
            xamlServiceProvider.Add(typeof(IXmlLineInfoProvider), new XmlLineInfoProvider(new XmlLineInfo(40, 17)));
            object target = label.FontFamily = (string)((IMarkupExtension)staticResourceExtension).ProvideValue((IServiceProvider)xamlServiceProvider);

            VisualDiagnostics.RegisterSourceInfo(target, new Uri("Views\\ModalPopupPage.xaml", UriKind.RelativeOrAbsolute), 40, 17);
            BindableProperty    fontSizeProperty     = Label.FontSizeProperty;
            FontSizeConverter   fontSizeConverter    = new FontSizeConverter();
            XamlServiceProvider xamlServiceProvider2 = new XamlServiceProvider();
            Type typeFromHandle3 = typeof(IProvideValueTarget);

            object[] array2 = new object[0 + 4];
            array2[0] = label;
            array2[1] = radBorder;
            array2[2] = stackLayout;
            array2[3] = modalPopupPage;
            object service2;

            xamlServiceProvider2.Add(typeFromHandle3, service2 = new SimpleValueTargetProvider(array2, Label.FontSizeProperty, nameScope));
            xamlServiceProvider2.Add(typeof(IReferenceProvider), service2);
            Type typeFromHandle4 = typeof(IXamlTypeResolver);
            XmlNamespaceResolver xmlNamespaceResolver2 = new XmlNamespaceResolver();

            xmlNamespaceResolver2.Add("", "http://xamarin.com/schemas/2014/forms");
            xmlNamespaceResolver2.Add("x", "http://schemas.microsoft.com/winfx/2009/xaml");
            xmlNamespaceResolver2.Add("animations", "clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup");
            xmlNamespaceResolver2.Add("pages", "clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup");
            xmlNamespaceResolver2.Add("telerikPrimitives", "clr-namespace:Telerik.XamarinForms.Primitives;assembly=Telerik.XamarinForms.Primitives");
            xamlServiceProvider2.Add(typeFromHandle4, new XamlTypeResolver(xmlNamespaceResolver2, typeof(ModalPopupPage).GetTypeInfo().Assembly));
            xamlServiceProvider2.Add(typeof(IXmlLineInfoProvider), new XmlLineInfoProvider(new XmlLineInfo(41, 17)));
            label.SetValue(fontSizeProperty, ((IExtendedTypeConverter)fontSizeConverter).ConvertFromInvariantString("Default", (IServiceProvider)xamlServiceProvider2));
            label.SetValue(View.HorizontalOptionsProperty, LayoutOptions.FillAndExpand);
            label.SetValue(View.VerticalOptionsProperty, LayoutOptions.FillAndExpand);
            label.SetValue(Label.HorizontalTextAlignmentProperty, new TextAlignmentConverter().ConvertFromInvariantString("Center"));
            label.SetValue(Label.VerticalTextAlignmentProperty, new TextAlignmentConverter().ConvertFromInvariantString("Center"));
            label.SetValue(View.MarginProperty, new Thickness(10.0));
            radBorder.SetValue(ContentView.ContentProperty, label);
            VisualDiagnostics.RegisterSourceInfo(label, new Uri("Views\\ModalPopupPage.xaml", UriKind.RelativeOrAbsolute), 37, 14);
            stackLayout.Children.Add(radBorder);
            VisualDiagnostics.RegisterSourceInfo(radBorder, new Uri("Views\\ModalPopupPage.xaml", UriKind.RelativeOrAbsolute), 31, 10);
            modalPopupPage.SetValue(ContentPage.ContentProperty, stackLayout);
            VisualDiagnostics.RegisterSourceInfo(stackLayout, new Uri("Views\\ModalPopupPage.xaml", UriKind.RelativeOrAbsolute), 23, 6);
            VisualDiagnostics.RegisterSourceInfo(modalPopupPage, new Uri("Views\\ModalPopupPage.xaml", UriKind.RelativeOrAbsolute), 2, 2);
        }
Exemplo n.º 21
0
        private async void Save_Clicked(object sender, EventArgs e)
        {
            // truong hop dang them tu bên post .
            if (CheckLastPost)
            {
                if (postItemService == null)
                {
                    postItemService = DependencyService.Get <IPostItemService>();
                }

                DateTime?lastTime = postItemService.GatLastPostTime(UserLogged.Id);
                if (lastTime.HasValue)
                {
                    var      now      = DateTime.Now;
                    TimeSpan timeSpan = now.Subtract(lastTime.Value);
                    if (timeSpan.TotalMinutes >= 120)
                    {
                    }
                    else
                    {
                        //Mỗi bài đăng từ tin đăng phải cách 2 tiếng! Vui lòng thử lại.
                        await DisplayAlert("", Language.moi_bai_dang_phai_tu_it_nhat_x_tieng, Language.dong);

                        return;
                    }
                }
            }
            if (string.IsNullOrWhiteSpace(EntryTitle.Text))
            {
                await DisplayAlert("", Language.vui_long_nhap_tieu_de, Language.dong);

                return;
            }

            if (string.IsNullOrWhiteSpace(editor.Text))
            {
                await DisplayAlert("", Language.vui_long_nhap_noi_dung, Language.dong);

                return;
            }

            loadingPopup.IsVisible = true;
            // kiem tra co hinh thi upload.
            if (viewModel.Media.Count > 0)
            {
                if (viewModel.Media.Count > 9)
                {
                    loadingPopup.IsVisible = false;
                    await DisplayAlert("", Language.vui_long_chon_toi_da_9_anh, Language.dong);

                    return;
                }

                List <MediaFile> listUploadMedia = viewModel.Media.Where(x => x.Path != null).ToList();
                if (listUploadMedia.Any())
                {
                    MultipartFormDataContent form = new MultipartFormDataContent();
                    for (int i = 0; i < listUploadMedia.Count; i++)
                    {
                        string imageName = $"postitem_{Guid.NewGuid().ToString()}.jpg";
                        ImageList.Add(imageName);

                        var media   = listUploadMedia[i];
                        var stream  = new MemoryStream(File.ReadAllBytes(media.Path));
                        var content = new StreamContent(stream);
                        content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")
                        {
                            Name     = "files" + i,
                            FileName = imageName
                        };
                        form.Add(content);
                    }

                    var uploadResonse = await UploadImage(form);

                    if (!uploadResonse.IsSuccess)
                    {
                        loadingPopup.IsVisible = false;
                        await DisplayAlert("", uploadResonse.Message, Language.dong);

                        return;
                    }
                }
            }


            PostItem item = new PostItem();

            item.Title       = EntryTitle.Text.Trim();
            item.Type        = ControlSegment.GetCurrentIndex();
            item.Description = editor.Text;
            item.Images      = ImageList.Any() ? ImageList.ToArray() : null;
            item.CreatedById = UserLogged.Id;
            item.CreatedBy   = new PostItemUser()
            {
                UserId   = UserLogged.Id,
                FullName = UserLogged.FullName,
                Avatar   = UserLogged.AvatarUrl.Replace(ApiConfig.IP2, "")
            };
            item.CreatedDate = DateTime.Now;
            item.HasImage    = ImageList != null && ImageList.Count() > 0;

            // gia
            if (EntryPrice.Text.HasValue)
            {
                item.HasPrice = true;
                item.Price    = DecimalHelper.ToCurrency(EntryPrice.Text.Value) + " " + (pickerUnitPrice.SelectedItem != null ? ((PriceOption)pickerUnitPrice.SelectedItem).Name.ToLower() : "");
            }
            // dien tich
            if (!string.IsNullOrWhiteSpace(EntryArea.Text))
            {
                item.HasArea = true;
                item.Area    = EntryArea.Text + "m2";
            }

            if (!string.IsNullOrWhiteSpace(viewModel.Address))
            {
                item.HasAddress = true;
                item.Address    = viewModel.Address;
            }

            if (viewModel.Province != null)
            {
                item.ProvinceId = viewModel.Province.Id;

                if (viewModel.District != null)
                {
                    item.DistrictId = viewModel.District.Id;

                    if (viewModel.Ward != null)
                    {
                        item.WardId = viewModel.Ward.Id;
                    }
                }
            }

            if (LookUpType.SelectedItem != null)
            {
                var loaiBatDongSan = LookUpType.SelectedItem as LoaiBatDongSanModel;
                item.HasLoaiBatDongSan = true;
                item.BDSTypeId         = loaiBatDongSan.Id;
            }

            if (CheckSelected(StacklayoutSoPhongtam))
            {
                item.HasSoPhongTam = true;
                RadBorder radBorder = GetRadBorder(StacklayoutSoPhongtam);
                var       label     = radBorder.Content as Label;
                item.SoPhongTam = int.Parse(label.Text);
            }

            if (CheckSelected(StacklayoutSophongngu))
            {
                item.HasSoPhongNgu = true;
                RadBorder radBorder = GetRadBorder(StacklayoutSophongngu);
                var       label     = radBorder.Content as Label;
                item.SoPhongNgu = int.Parse(label.Text);
            }

            if (postItemService == null)
            {
                postItemService = DependencyService.Get <IPostItemService>();
            }

            postItemService.AddPostItem(item);
            MessagingCenter.Send <AddPostItemPage, PostItem>(this, "AddPostItemSuccess", item);
            loadingPopup.IsVisible = false;
            await Navigation.PopAsync();

            ToastMessageHelper.ShortMessage(Language.luu_thanh_cong);
        }