// 주소 리스트 갱신 private void UpdateAdressList() { AdrListParentGrid.RowDefinitions.Clear(); AdrListParentGrid.Children.Clear(); for (int i = 0; i < adl.Count; i++) { //AdrListParentGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); Grid grid = new Grid // 주소 라벨을 묶는 그리드 생성 { RowSpacing = 10, ColumnSpacing = 0, BindingContext = i, RowDefinitions = { new RowDefinition { Height = 3 }, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition { Height = 3 }, } }; AdrListParentGrid.Children.Add(grid, 0, i); // BoxView borderLine = new BoxView { BackgroundColor = Color.LightGray }; if (i != 0) // 구분선 첫줄은 배제. { grid.Children.Add(borderLine, 0, 0); // } #region 도로명 구역 Grid roadGrid = new Grid { ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(3, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(7, GridUnitType.Star) }, } }; CustomButton roadButton = new CustomButton { Text = "도로명", Size = 14, BackgroundColor = Color.CornflowerBlue, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, HeightRequest = 25, TextColor = Color.White, }; // 리스트 내용은 라벨로 설정 CustomLabel roadLabel = new CustomLabel { Text = adl[i].roadAddr + " ( " + adl[i].zipNo + " )", Size = 14, TextColor = Color.Gray, VerticalOptions = LayoutOptions.Center, }; roadGrid.Children.Add(roadButton, 0, 0); roadGrid.Children.Add(roadLabel, 1, 0); #endregion #region 지번 구역 Grid jibunGrid = new Grid { ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(3, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(7, GridUnitType.Star) }, } }; CustomButton jibunButton = new CustomButton { Text = "지번", Size = 14, BackgroundColor = Color.CornflowerBlue, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, HeightRequest = 30, TextColor = Color.White, }; CustomLabel jibunLabel = new CustomLabel { Text = adl[i].jibunAddr, Size = 14, TextColor = Color.Gray, VerticalOptions = LayoutOptions.Center, }; jibunGrid.Children.Add(jibunButton, 0, 0); jibunGrid.Children.Add(jibunLabel, 1, 0); #endregion #region 그리드에 추가 grid.Children.Add(roadGrid, 0, 1); // grid.Children.Add(jibunGrid, 0, 2); // #endregion AdrListBackColor.BackgroundColor = Color.LightGray; // 버튼 클릭시 검색결과 색상 처리 #region 리스트 내용 클릭 이벤트 grid.GestureRecognizers.Add( new TapGestureRecognizer() { Command = new Command(() => { var s = grid.BindingContext; // ADRESS 객체에 도로명,지번,우편번호 초기화 myAdress.ROADADDR = adl[int.Parse(s.ToString())].roadAddr; myAdress.JIBUNADDR = adl[int.Parse(s.ToString())].jibunAddr; myAdress.ZIPNO = int.Parse(adl[int.Parse(s.ToString())].zipNo); // xaml UI에 도로명,지번,우편번호 초기화 EntryAdress.Text = adl[int.Parse(s.ToString())].roadAddr; roadAddr = adl[int.Parse(s.ToString())].roadAddr; jibunAddr = adl[int.Parse(s.ToString())].jibunAddr; zipNo = adl[int.Parse(s.ToString())].zipNo; DetailEntry.IsEnabled = true; if (adl_queue.Count < 2) { if (adl_queue.Count != 0) { Grid tempGrid = adl_queue.Dequeue(); if (tempGrid.Children.Count != 3) // 첫줄 구분선 제어 { ((CustomButton)((Grid)tempGrid.Children.ElementAt(0)).Children.ElementAt(0)).BackgroundColor = Color.CornflowerBlue; ((CustomButton)((Grid)tempGrid.Children.ElementAt(1)).Children.ElementAt(0)).BackgroundColor = Color.CornflowerBlue; } else { ((CustomButton)((Grid)tempGrid.Children.ElementAt(1)).Children.ElementAt(0)).BackgroundColor = Color.CornflowerBlue; ((CustomButton)((Grid)tempGrid.Children.ElementAt(2)).Children.ElementAt(0)).BackgroundColor = Color.CornflowerBlue; } } if (int.Parse(s.ToString()) != 0) // 첫줄 구분선 제어 { ((CustomButton)((Grid)grid.Children.ElementAt(1)).Children.ElementAt(0)).BackgroundColor = Color.Blue; ((CustomButton)((Grid)grid.Children.ElementAt(2)).Children.ElementAt(0)).BackgroundColor = Color.Blue; } else { ((CustomButton)((Grid)grid.Children.ElementAt(0)).Children.ElementAt(0)).BackgroundColor = Color.Blue; ((CustomButton)((Grid)grid.Children.ElementAt(1)).Children.ElementAt(0)).BackgroundColor = Color.Blue; } adl_queue.Enqueue(grid); MainScroll.ScrollToAsync(0, 0, true); } }) } ); #endregion } }
private void Init() { if (Global.b_user_login == false) // 비회원 상태일 경우 { CustomLabel errorLabel = new CustomLabel { Text = "최근 주소를 찾을 수 없습니다!", Size = 14, TextColor = Color.Gray, VerticalOptions = LayoutOptions.Center, }; RecentAdressGrid.Children.Add(errorLabel); return; } RecentAdressGrid.RowDefinitions.Clear(); RecentAdressGrid.Children.Clear(); for (int i = 0; i < recentList.Count; i++) { Grid grid = new Grid // 주소 라벨을 묶는 그리드 생성 { RowSpacing = 10, ColumnSpacing = 0, BindingContext = i, RowDefinitions = { new RowDefinition { Height = 3 }, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, new RowDefinition { Height = 3 }, } }; RecentAdressGrid.Children.Add(grid, 0, i); // BoxView borderLine = new BoxView { BackgroundColor = Color.LightGray, Margin = new Thickness(10, 0, 10, 0) }; if (i != 0) // 구분선 첫줄은 배제. { grid.Children.Add(borderLine, 0, 0); // } #region 도로명 구역 Grid roadGrid = new Grid { ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(3, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(7, GridUnitType.Star) }, } }; CustomButton roadButton = new CustomButton { Text = "도로명", Size = 14, BackgroundColor = Color.CornflowerBlue, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, HeightRequest = 25, TextColor = Color.White, }; // 리스트 내용은 라벨로 설정 CustomLabel roadLabel = new CustomLabel { Text = recentList[i].ROADADDR + " ( " + recentList[i].ZIPNO + " )", Size = 14, TextColor = Color.Gray, VerticalOptions = LayoutOptions.Center, }; roadGrid.Children.Add(roadButton, 0, 0); roadGrid.Children.Add(roadLabel, 1, 0); #endregion #region 지번 구역 Grid jibunGrid = new Grid { ColumnDefinitions = { new ColumnDefinition { Width = new GridLength(3, GridUnitType.Star) }, new ColumnDefinition { Width = new GridLength(7, GridUnitType.Star) }, } }; CustomButton jibunButton = new CustomButton { Text = "지번", Size = 14, BackgroundColor = Color.CornflowerBlue, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center, HeightRequest = 30, TextColor = Color.White, }; CustomLabel jibunLabel = new CustomLabel { Text = recentList[i].JIBUNADDR, Size = 14, TextColor = Color.Gray, VerticalOptions = LayoutOptions.Center, }; jibunGrid.Children.Add(jibunButton, 0, 0); jibunGrid.Children.Add(jibunLabel, 1, 0); #endregion #region 그리드에 추가 grid.Children.Add(roadGrid, 0, 1); // grid.Children.Add(jibunGrid, 0, 2); // #endregion #region 리스트 내용 클릭 이벤트 grid.GestureRecognizers.Add( new TapGestureRecognizer() { Command = new Command(() => { isClicked = true; // 주소 하나라도 클릭했을 경우 최근 주소 데이터를 -> 인풋 어드레스로 이동 var s = grid.BindingContext; // ADRESS 객체에 도로명,지번,우편번호 초기화 myAdress.ROADADDR = recentList[int.Parse(s.ToString())].ROADADDR; myAdress.JIBUNADDR = recentList[int.Parse(s.ToString())].JIBUNADDR; myAdress.ZIPNO = recentList[int.Parse(s.ToString())].ZIPNO; if (adl_queue.Count < 2) { if (adl_queue.Count != 0) { Grid tempGrid = adl_queue.Dequeue(); if (tempGrid.Children.Count != 3) // 첫줄 구분선 제어 { ((CustomButton)((Grid)tempGrid.Children.ElementAt(0)).Children.ElementAt(0)).BackgroundColor = Color.CornflowerBlue; ((CustomButton)((Grid)tempGrid.Children.ElementAt(1)).Children.ElementAt(0)).BackgroundColor = Color.CornflowerBlue; } else { ((CustomButton)((Grid)tempGrid.Children.ElementAt(1)).Children.ElementAt(0)).BackgroundColor = Color.CornflowerBlue; ((CustomButton)((Grid)tempGrid.Children.ElementAt(2)).Children.ElementAt(0)).BackgroundColor = Color.CornflowerBlue; } } if (int.Parse(s.ToString()) != 0) // 첫줄 구분선 제어 { ((CustomButton)((Grid)grid.Children.ElementAt(1)).Children.ElementAt(0)).BackgroundColor = Color.Blue; ((CustomButton)((Grid)grid.Children.ElementAt(2)).Children.ElementAt(0)).BackgroundColor = Color.Blue; } else { ((CustomButton)((Grid)grid.Children.ElementAt(0)).Children.ElementAt(0)).BackgroundColor = Color.Blue; ((CustomButton)((Grid)grid.Children.ElementAt(1)).Children.ElementAt(0)).BackgroundColor = Color.Blue; } adl_queue.Enqueue(grid); } }) } ); #endregion } }