private void OnNodeDoubleClick(object sender, MouseButtonEventArgs e) { var circle = sender as Circle; var vm = circle.DataContext as CircleViewModel; if (node1 == null) { node1 = vm; vm.Selected = true; node1.AllChanged(); } else if (node2 == null && vm.NodeNumber != node1.NodeNumber) { node2 = vm; if (OnTwoNodeClickEvent != null) { OnTwoNodeClickEvent(node1.NodeNumber, node2.NodeNumber); } } else { if (node1 != null) { node1.Selected = false; node1.AllChanged(); } node1 = node2 = null; } }
public void CircleViewModel_ThrowsException9() { var circleVM = new CircleViewModel(); circleVM.Point1Formatted = "0 0"; circleVM.DistanceString = "20000001"; }
public void CircleViewModel_IsDistanceCalcExpanded() { var circleVM = new CircleViewModel(); // test points circleVM.Point1 = new Point() { X = -119.8, Y = 34.4 }; Assert.AreEqual(circleVM.Point1Formatted, "34.4N 119.8W"); circleVM.LineDistanceType = DistanceTypes.Miles; circleVM.IsDistanceCalcExpanded = true; circleVM.TravelRate = 10; circleVM.RateTimeUnit = RateTimeTypes.MilesHour; circleVM.TravelTime = 5; circleVM.TimeUnit = TimeUnits.Hours; // verify rate calculated correctly circleVM.CircleType = CircleFromTypes.Radius; Assert.AreEqual(circleVM.Distance, 50.0); Assert.AreEqual(circleVM.DistanceString, "50"); // verify that the distances double when the circle type changes circleVM.CircleType = CircleFromTypes.Diameter; Assert.AreEqual(circleVM.Distance, 100.0); Assert.AreEqual(circleVM.DistanceString, "100"); }
public void CircleViewModel() { var circleVM = new CircleViewModel(); // can we create an element Assert.IsFalse(circleVM.CanCreateElement); circleVM.Distance = 1000.0; // test points circleVM.Point1 = new Point() { X = -119.8, Y = 34.4 }; Assert.AreEqual(circleVM.Point1Formatted, "34.4N 119.8W"); // Check that Distance is not converted when LineDistanceType is changed // #260 circleVM.LineDistanceType = DistanceTypes.Meters; circleVM.Distance = 1000.0; circleVM.LineDistanceType = DistanceTypes.Kilometers; Assert.AreEqual(circleVM.Distance, 1000.0); circleVM.CircleType = CircleFromTypes.Diameter; Assert.AreEqual(circleVM.DistanceString, "1000"); }
public void CircleViewModel_ThrowsException8() { var circleVM = new CircleViewModel(); circleVM.TimeUnit = TimeUnits.Hours; circleVM.RateTimeUnit = RateTimeTypes.MetersHour; circleVM.TravelTime = 2; circleVM.TravelRate = 10000001; }
public void CircleViewModel_ThrowsException6() { var circleVM = new CircleViewModel(); circleVM.TimeUnit = TimeUnits.Seconds; circleVM.RateTimeUnit = RateTimeTypes.MetersSec; circleVM.TravelTime = 1; circleVM.TravelRate = 20000000; circleVM.TimeUnit = TimeUnits.Hours; }
public void CircleViewModel_ThrowsException5() { var circleVM = new CircleViewModel(); circleVM.TimeUnit = TimeUnits.Hours; circleVM.RateTimeUnit = RateTimeTypes.MetersHour; circleVM.TravelTime = 1; circleVM.TravelRate = 20000000; circleVM.RateUnit = DistanceTypes.Miles; }
public IActionResult ShowCircle(string circleId) { var viewModel = new CircleViewModel { Circle = _circleService.Get(circleId) }; viewModel.Wall = _wallService.Get(viewModel.Circle.WallId, "Circle"); if (viewModel.Wall != null) { viewModel.Posts = _postService.Get().Where(p => p.WallId == viewModel.Wall.ID).ToList(); } return(View(viewModel)); }
public void CircleViewModel() { var circleVM = new CircleViewModel(); // can we create an element Assert.IsFalse(circleVM.CanCreateElement); circleVM.Distance = 1000.0; // test points circleVM.Point1 = new Point() { X = -119.8, Y = 34.4 }; Assert.AreEqual(circleVM.Point1Formatted, "34.4 -119.8"); }
public void ShouldUpdateViewModelOnCircleChanged() { // Arrange const string expectedName = "NewName"; const double expectedRadius = 4; var circle = new Circle { Name = expectedName, Radius = expectedRadius }; // Act var viewModel = new CircleViewModel { Circle = circle }; // Assert viewModel.Name.Should().Be(expectedName); viewModel.Radius.Should().Be(expectedRadius); }
public async Task <IActionResult> Circles(long?id) { if (id == null) { return(NotFound()); } var member = await _context.Members .Include(m => m.Identity) .FirstOrDefaultAsync(m => m.Id == id); if (member == null) { return(NotFound()); } var circles = await _context.Channels .Where(p => p.OwnerId == member.Id) .OrderBy(p => p.Created) .ToListAsync(); var joinedCircles = _context.Channels .Where(c => c.Subscribers.Any(u => u.SubscriberId == member.Id)) .Include(e => e.Owner) .ThenInclude(a => a.Identity) .OrderBy(p => p.Created) .ToList(); var mergedList = circles.Union(joinedCircles).OrderBy(p => p.Created).ToList(); var model = new CircleViewModel { Member = member, Channels = mergedList }; ViewData["CurrentMemberId"] = member.Id; return(View(model)); }
public void ShouldUpdateViewModelRadiusWhenCircleRadiusChanges() { // Arrange const string expectedName = "NewName"; const double oldRadius = 4; const double expectedRadius = 6; var circle = new Circle { Name = expectedName, Radius = oldRadius }; var viewModel = new CircleViewModel { Circle = circle }; // Act circle.Radius = expectedRadius; // Assert viewModel.Name.Should().Be(expectedName); viewModel.Radius.Should().Be(expectedRadius); circle.Name.Should().Be(expectedName); circle.Radius.Should().Be(expectedRadius); }
public void CircleViewModel_ThrowsException4() { var circleVM = new CircleViewModel(); circleVM.TravelRate = -1; }
public void SetCircle() { Content = new CircleViewModel(); NotifyPropertyChanged("Content"); }
public void CircleViewModel_ThrowsException11() { var circleVM = new CircleViewModel(); circleVM.Point1Formatted = "91 180"; }
public void CircleViewModel_ThrowsException() { var circleVM = new CircleViewModel(); circleVM.DistanceString = "esri"; }
public void CircleViewModel_ThrowsException2() { var circleVM = new CircleViewModel(); circleVM.Point1Formatted = "esri"; }
public async Task LoadPage() { var viewModel = new CircleViewModel(Navigation); BindingContext = viewModel; var stack = new StackLayout(); try { viewModel.OrganizationModel = await App.ApiClient.GetOrganizationAsync(_circleId); viewModel.CampaignsModel = await App.ApiClient.GetOrganizationCampaignAsync(_circleId); } catch (Exception ex) { var page = new ContentPage(); page.DisplayAlert("Error", ex.Message, "OK", "Cancel"); } this.Title = viewModel.OrganizationModel.Name; var headerLabel = new Label { Text = viewModel.OrganizationModel.Name, TextColor = Color.White, Font = Font.BoldSystemFontOfSize(20), HorizontalOptions = LayoutOptions.Center }; var descLabel = new Label { Text = viewModel.OrganizationModel.Description, TextColor = Color.White }; var cirleDetailView = new StackLayout { BackgroundColor = Helpers.Color.DarkGray.ToFormsColor(), Padding = new Thickness(10, 10, 10, 20), Children = { headerLabel, descLabel } }; stack.Children.Add(cirleDetailView); var cell = new DataTemplate(typeof(ListTextCell)); cell.SetBinding(TextCell.TextProperty, "Title"); cell.SetBinding(TextCell.DetailProperty, "Description"); var list = new ListView { ItemsSource = viewModel.CampaignsModel, ItemTemplate = cell }; list.ItemSelected += async(sender, e) => { var selectedCampaign = (Campaign)e.SelectedItem; var campaignPage = new CampaignPage(selectedCampaign.Id, _circleId); await Navigation.PushAsync(campaignPage); }; stack.Children.Add(list); var button = new DefaultButton { Text = "ADD CAMPAIGN" }; button.Clicked += async(sender, e) => { var createCampaignPage = new CreateCampaignPage(_circleId); await Navigation.PushAsync(createCampaignPage); }; stack.Children.Add(button); Content = stack; }
protected void CircleClick(CircleViewModel circle) { UriHelper.NavigateTo($"/circle/{circle.Id}"); }