/// <summary> /// Adds the item do the navigation sidebar /// </summary> /// <param name="path">The path which to save</param> /// <returns>Task</returns> public async Task AddItemToSidebarAsync(string path) { var item = await FilesystemTasks.Wrap(() => DrivesManager.GetRootFromPathAsync(path)); var res = await FilesystemTasks.Wrap(() => StorageFileExtensions.DangerousGetFolderFromPathAsync(path, item)); if (res || (FilesystemResult)ItemViewModel.CheckFolderAccessWithWin32(path)) { int insertIndex = MainPage.SideBarItems.IndexOf(MainPage.SideBarItems.Last(x => x.ItemType == NavigationControlItemType.Location && !x.Path.Equals(App.AppSettings.RecycleBinPath))) + 1; var locationItem = new LocationItem { Font = App.Current.Resources["FluentUIGlyphs"] as FontFamily, Path = path, Glyph = GetItemIcon(path), IsDefaultLocation = false, Text = res.Result?.DisplayName ?? Path.GetFileName(path.TrimEnd('\\')) }; if (!MainPage.SideBarItems.Contains(locationItem)) { MainPage.SideBarItems.Insert(insertIndex, locationItem); } } else { Debug.WriteLine($"Pinned item was invalid and will be removed from the file lines list soon: {res.ErrorCode}"); RemoveItem(path); } }
//GET: /api/Location/OsmLocation public ActionResult <string> GetOsmLocation(double lat, double lon, int?order) { LocationItem result = new LocationItem(); try { var pointParam = new NpgsqlParameter("point", Invariant($"POINT({lon} {lat})")); IQueryable <LocationItem> request; if (order == null) { request = _locContext.LocationItem.FromSql("Select Id,Name,z_order as Order,ST_Y(ST_Transform(geometry,4123)) as Lat,ST_X(ST_Transform(geometry,4123)) as Lon, ST_Distance(ST_Transform(ST_GeomFromText(@Point,4123),3857),geometry) as Distance from \"Map\".osm_new_places Where z_order>2 AND z_order<6 order by Distance asc Limit 1", pointParam); } else { var orderParam = new NpgsqlParameter("order", order); request = _locContext.LocationItem.FromSql("Select Id,Name,z_order as Order,ST_Y(ST_Transform(geometry,4123)) as Lat,ST_X(ST_Transform(geometry,4123)) as Lon, ST_Distance(ST_Transform(ST_GeomFromText(@Point,4123),3857),geometry) as Distance from \"Map\".osm_new_places Where z_order=@order order by Distance asc Limit 1", pointParam, orderParam); } result = request.AsEnumerable() .Select(i => new LocationItem() { Id = i.Id, Name = i.Name, Order = i.Order, Lat = Math.Round(i.Lat, 6), Lon = Math.Round(i.Lon, 6) }) .First(); } catch (System.Exception ex) { throw ex; } return(Content(JsonConvert.SerializeObject(result), "application/json")); }
public async Task AddItemToSidebar(string path) { try { var item = await DrivesManager.GetRootFromPath(path); StorageFolder folder = await StorageFileExtensions.GetFolderFromPathAsync(path, item); int insertIndex = MainPage.sideBarItems.IndexOf(MainPage.sideBarItems.Last(x => x.ItemType == NavigationControlItemType.Location && !x.Path.Equals(App.AppSettings.RecycleBinPath))) + 1; var locationItem = new LocationItem { Font = App.Current.Resources["FluentUIGlyphs"] as FontFamily, Path = path, Glyph = GetItemIcon(path), IsDefaultLocation = false, Text = folder.DisplayName }; MainPage.sideBarItems.Insert(insertIndex, locationItem); } catch (UnauthorizedAccessException ex) { Debug.WriteLine(ex.Message); } catch (Exception ex) when( ex is ArgumentException || // Pinned item was invalid ex is FileNotFoundException || // Pinned item was deleted ex is System.Runtime.InteropServices.COMException || // Pinned item's drive was ejected (uint)ex.HResult == 0x8007000F || // The system cannot find the drive specified (uint)ex.HResult == 0x800700A1) // The specified path is invalid (usually an mtp device was disconnected) { Debug.WriteLine("Pinned item was invalid and will be removed from the file lines list soon: " + ex.Message); RemoveItem(path); } }
/// <summary> /// Adds the item do the navigation sidebar /// </summary> /// <param name="path">The path which to save</param> /// <returns>Task</returns> public async Task AddItemToSidebarAsync(string path) { var item = await FilesystemTasks.Wrap(() => DrivesManager.GetRootFromPathAsync(path)); var res = await FilesystemTasks.Wrap(() => StorageFileExtensions.DangerousGetFolderFromPathAsync(path, item)); if (res || (FilesystemResult)FolderHelpers.CheckFolderAccessWithWin32(path)) { var lastItem = favoriteSection.ChildItems.LastOrDefault(x => x.ItemType == NavigationControlItemType.Location && !x.Path.Equals(App.AppSettings.RecycleBinPath)); int insertIndex = lastItem != null?favoriteSection.ChildItems.IndexOf(lastItem) + 1 : 0; var locationItem = new LocationItem { Font = InteractionViewModel.FontName, Path = path, Section = SectionType.Favorites, Icon = GlyphHelper.GetIconUri(path), IsDefaultLocation = false, Text = res.Result?.DisplayName ?? Path.GetFileName(path.TrimEnd('\\')) }; if (!favoriteSection.ChildItems.Contains(locationItem)) { favoriteSection.ChildItems.Insert(insertIndex, locationItem); } } else { Debug.WriteLine($"Pinned item was invalid and will be removed from the file lines list soon: {res.ErrorCode}"); RemoveItem(path); } }
//*********************** Location ********************* //SQL PUTS Location public int putLocationItem(LocationItem item) { conn = new SqlConnection(); conn.ConnectionString = this.sqlConnectionString; string query = "INSERT INTO inventory (id, locationid, streetnumber, streetname, city, zipcode) VALUES (@Id, @LocationId, @StreetNumber, @StreetName, @City, @ZipCode)"; SqlCommand command = new SqlCommand(query, conn); command.Parameters.Add("@Id", System.Data.SqlDbType.Int); command.Parameters.Add("@LocationId", System.Data.SqlDbType.Int); command.Parameters.Add("@StreetNumber", System.Data.SqlDbType.Int); command.Parameters.Add("@StreetName", System.Data.SqlDbType.VarChar); command.Parameters.Add("@City", System.Data.SqlDbType.VarChar); command.Parameters.Add("@ZipCode", System.Data.SqlDbType.Int); command.Parameters["@Id"].Value = item.Id; command.Parameters["@LocationId"].Value = item.LocationId; command.Parameters["@StreetName"].Value = item.StreetName; command.Parameters["@StreetNumber"].Value = item.StreetNumber; command.Parameters["@City"].Value = item.City; command.Parameters["@ZipCode"].Value = item.ZipCode; conn.Open(); int result = command.ExecuteNonQuery(); conn.Close(); // Check Error if (result < 0) { Console.WriteLine("Error inserting data into Database!"); return(1); } return(0); }
public static DataTable getLocationList(string searchString, ComboBox cb) { if (!Login.OnLineMode) { using (CEConn localDB = new CEConn()) { string strSql; strSql = " select serverKey as ID_Location,Name from Locations where ServerKey<>0 and tagid<>'0000000000000000000000D' AND [Name] Like '" + searchString + "%' order by Name"; DataTable dtList = new DataTable(); localDB.FillDataTable(ref dtList, strSql); //return dtList; cb.Items.Clear(); LocationItem item; if (dtList != null && dtList.Rows.Count > 0) { foreach (DataRow dr in dtList.Rows) { //dtt.ImportRow(dr); item = new LocationItem(dr["Name"].ToString(), dr["ID_Location"].ToString()); cb.Items.Add(item); } } //dtt.Columns["ServerKey"].ColumnName = "ID_Location"; return(null); } } else { RConnection.RConnection OnConn = new RConnection.RConnection(); OnConn.Url = Login.webConURL; string strSql; strSql = " select ID_Location,Name from Locations where Is_Active=1 and Is_Deleted=0 and tagid<>'0000000000000000000000D' AND [Name] Like '" + searchString + "%' order by Name"; DataTable dtList = (DataTable)OnConn.getDataTable(strSql); cb.Items.Clear(); LocationItem item; if (dtList != null && dtList.Rows.Count > 0) { foreach (DataRow dr in dtList.Rows) { //dtt.ImportRow(dr); item = new LocationItem(dr["Name"].ToString(), dr["ID_Location"].ToString()); cb.Items.Add(item); } } //return (DataTable)OnConn.getDataTable(strSql); return(null); //return (DataTable)OnConn.getDataTable(strSql); //throw new ApplicationException("Online functionality not implemented yet."); } }
public async void AddItemToSidebar(string path) { try { StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(path); int insertIndex = App.sideBarItems.IndexOf(App.sideBarItems.Last(x => x.ItemType == NavigationControlItemType.Location)) + 1; var locationItem = new LocationItem { Path = path, Glyph = GetItemIcon(path), IsDefaultLocation = false, Text = folder.DisplayName }; App.sideBarItems.Insert(insertIndex, locationItem); } catch (UnauthorizedAccessException ex) { Debug.WriteLine(ex.Message); } catch (FileNotFoundException ex) { Debug.WriteLine("Pinned item was deleted and will be removed from the file lines list soon: " + ex.Message); RemoveItem(path); } catch (System.Runtime.InteropServices.COMException ex) { Debug.WriteLine("Pinned item's drive was ejected and will be removed from the file lines list soon: " + ex.Message); RemoveItem(path); } }
public async Task <ActionResult <LocationItem> > PostLocationItem(LocationItem locationItem) { _context.LocationItems.Add(locationItem); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetLocationItem), new { id = locationItem.Id }, locationItem)); }
//public string NorthEastPoint; //public string SouthWestPoint; protected void Page_Load(object sender, EventArgs e) { var currentItem = Sitecore.Context.Item; LocationItem location = new LocationItem(currentItem); var containerItem = currentItem.Parent.Parent; ClubMicrositeLandingItem landing = new ClubMicrositeLandingItem(containerItem); Sitecore.Data.Items.Item activeClubItem = landing.Club.Item; ActiveClub = new ClubItem(activeClubItem); double lat = 0; double lng = 0; double distance = 10; int zoom = 10; double.TryParse(ActiveClub.Lat.Rendered, out lat); double.TryParse(ActiveClub.Long.Rendered, out lng); double.TryParse(location.Findclubsrange.Rendered, out distance); int.TryParse(location.Zoomlevel.Rendered, out ZoomLevel); //NorthEastPoint = location.NorthEastpoint.Rendered; //SouthWestPoint = location.SoutWestpoint.Rendered; List<Club> clubs = ClubUtil.GetNearestClubsInRange(lat, lng, distance).Where(x => x.ClubItm.InnerItem.ID != ActiveClub.InnerItem.ID).ToList(); ClubRepeater.DataSource = clubs; ClubRepeater.DataBind(); }
public async Task ShowHideRecycleBinItemAsync(bool show) { if (show) { var recycleBinItem = new LocationItem { Text = ApplicationData.Current.LocalSettings.Values.Get("RecycleBin_Title", "Recycle Bin"), IsDefaultLocation = true, Icon = await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => UIHelpers.GetIconResource(Constants.ImageRes.RecycleBin)), Path = CommonPaths.RecycleBinPath }; // Add recycle bin to sidebar, title is read from LocalSettings (provided by the fulltrust process) // TODO: the very first time the app is launched localized name not available if (!favoriteSection.ChildItems.Any(x => x.Path == CommonPaths.RecycleBinPath)) { await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => favoriteSection.ChildItems.Add(recycleBinItem)); } } else { foreach (INavigationControlItem item in favoriteSection.ChildItems.ToList()) { if (item is LocationItem && item.Path == CommonPaths.RecycleBinPath) { await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => favoriteSection.ChildItems.Remove(item)); } } } }
public Swipe(LocationItem location, Swipe previous) { _location = location; _seconds = _cummulative = 0; _previous = previous; _points = 0; }
public async Task Then_If_There_Is_Lat_Lon_Data_The_Location_Is_Used( string locationName, string authorityName, GetTrainingCourseProviderQuery query, GetOverallAchievementRateResponse apiResponse, GetProviderStandardItem apiProviderStandardResponse, GetStandardsListItem apiCourseResponse, GetStandardsListResponse allCoursesApiResponse, LocationItem locationLookupResponse, GetOverallAchievementRateResponse apiAchievementRateResponse, GetUkprnsForStandardAndLocationResponse ukprnsCountResponse, [Frozen] Mock <ICoursesApiClient <CoursesApiConfiguration> > mockCoursesApiClient, [Frozen] Mock <ICourseDeliveryApiClient <CourseDeliveryApiConfiguration> > mockApiClient, [Frozen] Mock <ILocationLookupService> mockLocationLookupService, GetTrainingCourseProviderQueryHandler handler) { mockLocationLookupService .Setup(service => service.GetLocationInformation(query.Location, query.Lat, query.Lon)) .ReturnsAsync(locationLookupResponse); mockApiClient .Setup(client => client.Get <GetProviderStandardItem>(It.Is <GetProviderByCourseAndUkPrnRequest>(c => c.GetUrl.Contains(query.CourseId.ToString()) && c.GetUrl.Contains(query.ProviderId.ToString()) && c.GetUrl.Contains(locationLookupResponse.GeoPoint.First().ToString()) && c.GetUrl.Contains(locationLookupResponse.GeoPoint.Last().ToString()) ))) .ReturnsAsync(apiProviderStandardResponse); mockApiClient .Setup(client => client.Get <GetProviderAdditionalStandardsItem>(It.Is <GetProviderAdditionalStandardsRequest>( c => c.GetUrl.Contains(query.ProviderId.ToString() )))) .ReturnsAsync(new GetProviderAdditionalStandardsItem { StandardIds = allCoursesApiResponse.Standards.Select(c => c.LarsCode).ToList() }); mockCoursesApiClient .Setup(client => client.Get <GetStandardsListItem>( It.Is <GetStandardRequest>(c => c.GetUrl.Contains(query.CourseId.ToString())))) .ReturnsAsync(apiCourseResponse); mockApiClient .Setup(x => x.Get <GetUkprnsForStandardAndLocationResponse>( It.Is <GetUkprnsForStandardAndLocationRequest>(c => c.GetUrl.Contains(query.CourseId.ToString())))) .ReturnsAsync(ukprnsCountResponse); mockCoursesApiClient .Setup(client => client.Get <GetStandardsListResponse>(It.IsAny <GetAvailableToStartStandardsListRequest>())) .ReturnsAsync(allCoursesApiResponse); mockApiClient.Setup(client => client.Get <GetOverallAchievementRateResponse>(It.Is <GetOverallAchievementRateRequest>( c => c.GetUrl.Contains(apiCourseResponse.SectorSubjectAreaTier2Description) ))) .ReturnsAsync(apiAchievementRateResponse); var result = await handler.Handle(query, CancellationToken.None); result.ProviderStandard.Should().BeEquivalentTo(apiProviderStandardResponse); result.Location.Should().BeEquivalentTo(locationLookupResponse); }
public async Task Then_If_There_Is_A_Location_Supplied_It_Is_Searched_And_Passed_To_The_Provider_Search( string locationName, string authorityName, GetTrainingCourseProvidersQuery query, GetProvidersListResponse apiResponse, IEnumerable <GetApprenticeFeedbackResponse> apprenticeFeedbackResponse, GetStandardsListItem apiCourseResponse, LocationItem locationServiceResponse, [Frozen] Mock <ILocationLookupService> mockLocationLookupService, [Frozen] Mock <ICoursesApiClient <CoursesApiConfiguration> > mockCoursesApiClient, [Frozen] Mock <ICourseDeliveryApiClient <CourseDeliveryApiConfiguration> > mockApiClient, [Frozen] Mock <IApprenticeFeedbackApiClient <ApprenticeFeedbackApiConfiguration> > mockApprenticeFeedbackApiClient, GetTrainingCourseProvidersQueryHandler handler) { query.Location = $"{locationName}, {authorityName} "; query.Lat = 0; query.Lon = 0; var providerUkprns = apiResponse.Providers.Select(s => s.Ukprn); for (var i = 0; i < apprenticeFeedbackResponse.Count(); i++) { apprenticeFeedbackResponse.ToArray()[i].Ukprn = providerUkprns.ToArray()[i]; } mockLocationLookupService .Setup(service => service.GetLocationInformation(query.Location, query.Lat, query.Lon, false)) .ReturnsAsync(locationServiceResponse); mockApiClient .Setup(client => client.Get <GetProvidersListResponse>(It.Is <GetProvidersByCourseRequest>(c => c.GetUrl.Contains(query.Id.ToString()) && c.GetUrl.Contains(locationServiceResponse.GeoPoint.First().ToString()) && c.GetUrl.Contains(locationServiceResponse.GeoPoint.Last().ToString()) && c.GetUrl.Contains($"&sortOrder={query.SortOrder}") ))) .ReturnsAsync(apiResponse); mockCoursesApiClient .Setup(client => client.Get <GetStandardsListItem>(It.Is <GetStandardRequest>(c => c.GetUrl.Contains(query.Id.ToString())))) .ReturnsAsync(apiCourseResponse); mockApprenticeFeedbackApiClient .Setup(s => s.PostWithResponseCode <IEnumerable <GetApprenticeFeedbackResponse> >(It.Is <PostApprenticeFeedbackRequest> (t => ((PostApprenticeFeedbackRequestData)t.Data).Ukprns.Except(apiResponse.Providers.Select(s => s.Ukprn)).Count() == 0 && apiResponse.Providers.Select(s => s.Ukprn).Except(((PostApprenticeFeedbackRequestData)t.Data).Ukprns).Count() == 0 ))).ReturnsAsync(new ApiResponse <IEnumerable <GetApprenticeFeedbackResponse> >(apprenticeFeedbackResponse, HttpStatusCode.OK, string.Empty)); var result = await handler.Handle(query, CancellationToken.None); result.Providers.Should().BeEquivalentTo(apiResponse.Providers, options => options.Excluding(s => s.ApprenticeFeedback)); result.Total.Should().Be(apiResponse.TotalResults); result.Course.Should().BeEquivalentTo(apiCourseResponse); result.Location.Name.Should().Be(locationServiceResponse.Name); result.Location.GeoPoint.Should().BeEquivalentTo(locationServiceResponse.GeoPoint); foreach (var provider in result.Providers) { provider.ApprenticeFeedback.Should().BeEquivalentTo(apprenticeFeedbackResponse.First(s => s.Ukprn == provider.Ukprn)); } }
/// <summary> /// Initializes a new instance of the <see cref="LocationItemViewModel"/> class. /// </summary> /// <param name="location">The location item.</param> /// <param name="provider">The provider.</param> public LocationItemViewModel(LocationItem location, ContentDataProviderBase provider) : base(location, provider) { this.Address = location.Address; this.City = location.City; this.Region = location.Region; this.PostalCode = location.PostalCode; }
private bool UseGPSLocation(LocationItem location) { if (location == null) { return(true); } return(string.IsNullOrEmpty(location.Id)); }
private static void QuerySubmitted(AutoSuggestBoxQuerySubmittedEventArgs args) { if (args.ChosenSuggestion != null) { LocationItem selectedItem = (LocationItem)args.ChosenSuggestion; NavigationService.Navigate <ForecastPage>(selectedItem); } }
private async void FetchNewData() { var location = await Settings.GetFavoriteLocation(); if (location == null || string.IsNullOrEmpty(location.Id)) { var granted = await GetLocationPermission(); if (!granted) { ShowNoAccessView(); return; } ShowLoadingView(); var position = await GetPosition(); SetCurrentCity(); location = new LocationItem() { Latitude = position.Latitude, Longitude = position.Longitude }; } else { ShowLoadingView(); SetCurrentCity(); } await FetchCurrentForecast(location); ShowLocalizationSuccess(); TileDesigner.UpdatePrimary(_lastPosition); Settings.CacheForecastData(_pageDataSource.Forecast); Settings.CacheLocationAndTime( _currentTown, DateTime.Now.ToLocalTime().ToString("dddd HH:mm")); Timer deffered = null; deffered = new Timer(async(object state) => { await _UIDispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { if (LoadingView.Visibility == Visibility.Collapsed) { deffered?.Dispose(); return; } HideLoadingView(); PopulateView(); PopulateCurrentLocationAndTime(); }); }, new AutoResetEvent(true), 3000, 2000); }
public NewReservation(HomeUserControl homeUserControl, DataBase context, Mode mode = Mode.Add, int resCode = -1) { InitializeComponent(); _homeUserControl = homeUserControl; if (context == null) { _db = new DataBase(); } else { _db = context; } foreach (Client person in _db.Client) { reservationHolderComboBox.Items.Add(person.Personne.Nom_Personne + " " + person.Personne.Prenom_Personne); reservationHolderComboBox.AutoCompleteCustomSource.Add(person.Personne.Nom_Personne + " " + person.Personne.Prenom_Personne); } locationsListBox.DisplayMember = "LocationName"; lodgersListBox.DisplayMember = "ClientFullName"; _mode = mode; Text = Resources.add_a_reservation; _resToEditCode = resCode; if (_mode == Mode.Edit) { reservationHolderComboBox.Enabled = false; addReservationButton.Text = Resources.edit; Text = Resources.edit_a_reservation; Reservation reservation = _db.Reservation.FirstOrDefault(a => a.Code_Reservation == resCode); if (reservation != null) { beginDateTimePicker.Value = reservation.Date_Debut; endDateTimePicker.Value = reservation.Date_Fin; PayedCheckBox.Checked = reservation.Est_Paye; } foreach (Emplacement location in _db.Loge.Where(a => a.Code_Reservation == resCode).Select(a => a.Emplacement).Distinct()) { LocationItem locationItem = new LocationItem { Lodgers = new HashSet <Lodger>(), Location = location }; locationsListBox.Items.Add(locationItem); foreach (Personne lodger in _db.Loge.Where(a => a.Code_Emplacement == location.Code_Emplacement).Select(a => a.Personne).Distinct()) { if (lodger.Client != null) { locationItem.Lodgers.Add(new Lodger { Client = lodger.Client }); } } } } }
public void Then_The_Fields_Are_Correctly_Mapped(LocationItem source) { //Act var actual = (GetLocationSearchResponseItem)source; //Act actual.Name.Should().Be(source.Name); actual.Location.GeoPoint.Should().BeEquivalentTo(source.GeoPoint); }
/// <summary> /// Adds the item (from a path) to the navigation sidebar /// </summary> /// <param name="path">The path which to save</param> /// <returns>Task</returns> public async Task AddItemToSidebarAsync(string path) { var item = await FilesystemTasks.Wrap(() => DrivesManager.GetRootFromPathAsync(path)); var res = await FilesystemTasks.Wrap(() => StorageFileExtensions.DangerousGetFolderFromPathAsync(path, item)); var locationItem = new LocationItem { Font = MainViewModel.FontName, Path = path, Section = SectionType.Favorites, MenuOptions = new ContextMenuOptions { IsLocationItem = true, ShowProperties = true, ShowUnpinItem = true, ShowShellItems = true, ShowEmptyRecycleBin = path == CommonPaths.RecycleBinPath, }, IsDefaultLocation = false, Text = res.Result?.DisplayName ?? Path.GetFileName(path.TrimEnd('\\')) }; if (res || (FilesystemResult)FolderHelpers.CheckFolderAccessWithWin32(path)) { locationItem.IsInvalid = false; if (res) { var iconData = await FileThumbnailHelper.LoadIconFromStorageItemAsync(res.Result, 24u, Windows.Storage.FileProperties.ThumbnailMode.ListView); if (iconData == null) { iconData = await FileThumbnailHelper.LoadIconFromStorageItemAsync(res.Result, 24u, Windows.Storage.FileProperties.ThumbnailMode.SingleItem); } locationItem.IconData = iconData; locationItem.Icon = await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => locationItem.IconData.ToBitmapAsync()); } if (locationItem.IconData == null) { locationItem.IconData = await FileThumbnailHelper.LoadIconWithoutOverlayAsync(path, 24u); if (locationItem.IconData != null) { locationItem.Icon = await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => locationItem.IconData.ToBitmapAsync()); } } } else { locationItem.Icon = await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => UIHelpers.GetIconResource(Constants.ImageRes.Folder)); locationItem.IsInvalid = true; Debug.WriteLine($"Pinned item was invalid {res.ErrorCode}, item: {path}"); } AddLocationItemToSidebar(locationItem); }
public void Then_The_Fields_Are_Mapped(LocationItem source) { //Act var actual = (Location)source; //Assert actual.Name.Should().Be(source.Name); actual.LocationPoint.Should().BeEquivalentTo(source.LocationPoint.GeoPoint); }
/// <summary> /// Adds all items to the navigation sidebar /// </summary> public async Task AddAllItemsToSidebar() { await SidebarControl.SideBarItemsSemaphore.WaitAsync(); if (IconResources is null) { IconResources = (await SidebarViewModel.LoadSidebarIconResources())?.ToList(); } homeSection = new LocationItem() { Text = "SidebarHome".GetLocalized(), Section = SectionType.Home, Font = MainViewModel.FontName, IsDefaultLocation = true, Icon = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri("ms-appx:///Assets/FluentIcons/Home.png")), Path = "Home", ChildItems = new ObservableCollection <INavigationControlItem>() }; favoriteSection = new LocationItem() { Text = "SidebarFavorites".GetLocalized(), Section = SectionType.Favorites, SelectsOnInvoked = false, Icon = UIHelpers.GetImageForIconOrNull(IconResources?.FirstOrDefault(x => x.Index == Constants.Shell32.QuickAccess).Image), Font = MainViewModel.FontName, ChildItems = new ObservableCollection <INavigationControlItem>() }; try { SidebarControl.SideBarItems.BeginBulkOperation(); if (homeSection != null) { AddItemToSidebarAsync(homeSection); } for (int i = 0; i < FavoriteItems.Count(); i++) { string path = FavoriteItems[i]; await AddItemToSidebarAsync(path); } if (!SidebarControl.SideBarItems.Contains(favoriteSection)) { SidebarControl.SideBarItems.Add(favoriteSection); } SidebarControl.SideBarItems.EndBulkOperation(); } finally { SidebarControl.SideBarItemsSemaphore.Release(); } await ShowHideRecycleBinItemAsync(App.AppSettings.PinRecycleBinToSideBar); }
/// <summary> /// Adds all items to the navigation sidebar /// </summary> public async Task AddAllItemsToSidebar() { if (!UserSettingsService.AppearanceSettingsService.ShowFavoritesSection) { return; } await SidebarControl.SideBarItemsSemaphore.WaitAsync(); try { homeSection = new LocationItem() { Text = "SidebarHome".GetLocalized(), Section = SectionType.Home, Font = MainViewModel.FontName, IsDefaultLocation = true, Icon = await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => new BitmapImage(new Uri("ms-appx:///Assets/FluentIcons/Home.png"))), Path = "Home".GetLocalized(), ChildItems = new ObservableCollection <INavigationControlItem>() }; favoriteSection = new LocationItem() { Text = "SidebarFavorites".GetLocalized(), Section = SectionType.Favorites, SelectsOnInvoked = false, Icon = await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => UIHelpers.GetIconResource(Constants.Shell32.QuickAccess)), Font = MainViewModel.FontName, ChildItems = new ObservableCollection <INavigationControlItem>() }; if (homeSection != null) { AddItemToSidebarAsync(homeSection); } if (!SidebarControl.SideBarItems.Contains(favoriteSection)) { SidebarControl.SideBarItems.BeginBulkOperation(); var index = 0; // First section SidebarControl.SideBarItems.Insert(index, favoriteSection); await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => SidebarControl.SideBarItems.EndBulkOperation()); } } finally { SidebarControl.SideBarItemsSemaphore.Release(); } for (int i = 0; i < FavoriteItems.Count(); i++) { string path = FavoriteItems[i]; await AddItemToSidebarAsync(path); } await ShowHideRecycleBinItemAsync(UserSettingsService.AppearanceSettingsService.PinRecycleBinToSidebar); }
private void removeLodgerButton_Click(object sender, EventArgs e) { LocationItem locationItem = locationsListBox.SelectedItem as LocationItem; if (lodgersListBox.SelectedItem != null) { locationItem?.Lodgers.Remove((Lodger)lodgersListBox.SelectedItem); } RefreshLodgers(); }
/// <summary> /// Adds the item to sidebar asynchronous. /// </summary> /// <param name="section">The section.</param> private void AddItemToSidebarAsync(LocationItem section) { var lastItem = favoriteSection.ChildItems.LastOrDefault(x => x.ItemType == NavigationControlItemType.Location && !x.Path.Equals(CommonPaths.RecycleBinPath)); int insertIndex = lastItem != null?favoriteSection.ChildItems.IndexOf(lastItem) + 1 : 0; if (!favoriteSection.ChildItems.Contains(section)) { favoriteSection.ChildItems.Insert(insertIndex, section); } }
public void DeleteLocation(LocationItem location) { var scope = this.GetContext(); //this.ClearLifecycle(location, this.GetLocations()); if (scope != null) { scope.Remove(location); } }
public LocationResponse SaveLocation(string SearchText, bool IsID) { LocationResponse Response = new LocationResponse(); member = (Member)Session["Member"]; if (member == null) { Utility.RememberMeLogin(); } if (member != null) { if (IsID) { int IPLocationID = Int32.Parse(SearchText); IPLocation loc = new IPLocation(IPLocationID); member.IPLocationID = loc.IPLocationID; Response.LocationText = loc.city; member.Save(); Response.ResponseType = 1; } else { List <IPLocation> IPLocationList = IPLocation.SearchLocation(SearchText); Response.LocationList = new List <LocationItem>(); for (int i = 0; i < IPLocationList.Count; i++) { LocationItem locationItem = new LocationItem(); locationItem.Lcid = IPLocationList[i].IPLocationID.ToString(); locationItem.Text = Server.HtmlEncode(LocationResponse.GetFullLocationName(IPLocationList[i])); Response.LocationList.Add(locationItem); } if (Response.LocationList.Count == 0) { Response.ResponseType = 0; } else if (Response.LocationList.Count == 1) { Response.ResponseType = 1; Response.LocationText = Server.HtmlEncode(IPLocationList[0].city); } else if (Response.LocationList.Count > 1) { Response.ResponseType = 2; } } } return(Response); }
/// <summary> /// Adds the item do the navigation sidebar /// </summary> /// <param name="path">The path which to save</param> /// <returns>Task</returns> public async Task AddItemToSidebarAsync(string path) { var item = await FilesystemTasks.Wrap(() => DrivesManager.GetRootFromPathAsync(path)); var res = await FilesystemTasks.Wrap(() => StorageFileExtensions.DangerousGetFolderFromPathAsync(path, item)); var lastItem = favoriteSection.ChildItems.LastOrDefault(x => x.ItemType == NavigationControlItemType.Location && !x.Path.Equals(CommonPaths.RecycleBinPath)); int insertIndex = lastItem != null?favoriteSection.ChildItems.IndexOf(lastItem) + 1 : 0; var locationItem = new LocationItem { Font = MainViewModel.FontName, Path = path, Section = SectionType.Favorites, IsDefaultLocation = false, Text = res.Result?.DisplayName ?? Path.GetFileName(path.TrimEnd('\\')) }; if (res || (FilesystemResult)FolderHelpers.CheckFolderAccessWithWin32(path)) { locationItem.IsInvalid = false; if (res) { var iconData = await FileThumbnailHelper.LoadIconFromStorageItemAsync(res.Result, 24u, Windows.Storage.FileProperties.ThumbnailMode.ListView); if (iconData == null) { iconData = await FileThumbnailHelper.LoadIconFromStorageItemAsync(res.Result, 24u, Windows.Storage.FileProperties.ThumbnailMode.SingleItem); } locationItem.IconData = iconData; locationItem.Icon = await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => locationItem.IconData.ToBitmapAsync()); } if (locationItem.IconData == null) { locationItem.IconData = await FileThumbnailHelper.LoadIconWithoutOverlayAsync(path, 24u); if (locationItem.IconData != null) { locationItem.Icon = await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => locationItem.IconData.ToBitmapAsync()); } } } else { locationItem.Icon = await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => UIHelpers.GetIconResource(Constants.ImageRes.Folder)); locationItem.IsInvalid = true; Debug.WriteLine($"Pinned item was invalid {res.ErrorCode}, item: {path}"); } if (!favoriteSection.ChildItems.Any(x => x.Path == locationItem.Path)) { await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() => favoriteSection.ChildItems.Insert(insertIndex, locationItem)); } }
public static async Task <List <LocationItem> > GetSuggestions(string text) { string uri = UrlBuilder(text); List <LocationItem> result = new List <LocationItem>(); await Task.Run(() => { ExecuteQueryGetSuggestions(uri, (response) => { IAsyncAction a = CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (response != null) { foreach (Item item in response.items) { if (item.localityType != null) { if (item.localityType == "city" || item.localityType == "county") { string[] locationNames = item.title.Split(','); string title = locationNames[0]; string subtitle = ""; if (locationNames.Length > 2) { subtitle = locationNames[1]; for (int i = 2; i <= locationNames.Length - 1; i++) { subtitle = subtitle + "," + locationNames[i]; } } string id = item.id; LocationItem simpleItem = new LocationItem(title, subtitle, id, item.position); result.Add(simpleItem); } } } } }); return(true); }, (error) => { IAsyncAction a = CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { System.Diagnostics.Debug.WriteLine(error); }); return(false); }); }); return(result); }
public static async Task SaveSecondaryTaskLocation(string locationId, LocationItem location) { string serializedLocation = JsonConvert.SerializeObject(location); StorageFile file = await ApplicationData .Current .LocalFolder .CreateFileAsync(locationId, CreationCollisionOption.ReplaceExisting); await FileIO.WriteTextAsync(file, serializedLocation); }
public void RetrieveAdditionalInformationTest_withInvalidID(string value) { // Arrange LocationItem item = new LocationItem("_aa1", "FilmingLocation"); item.BaseTableName = value; // Act int count = item.RetrieveAdditionalInformation(); // Assert Assert.AreEqual(0, count); }
private double GetDistance(Location source, LocationItem target) { var result = Math.Pow(target.Latitude - source.Latitude, 2) + Math.Pow(target.Longitude - source.Longitude, 2); return result; }
public LocationResponse SaveLocation(string SearchText, bool IsID) { LocationResponse Response = new LocationResponse(); member = (Member)Session["Member"]; if (member == null) { Utility.RememberMeLogin(); } if (member != null) { if (IsID) { int IPLocationID = Int32.Parse(SearchText); IPLocation loc = new IPLocation(IPLocationID); member.IPLocationID = loc.IPLocationID; Response.LocationText = loc.city; member.Save(); Response.ResponseType = 1; } else { List<IPLocation> IPLocationList = IPLocation.SearchLocation(SearchText); Response.LocationList = new List<LocationItem>(); for (int i = 0; i < IPLocationList.Count; i++) { LocationItem locationItem = new LocationItem(); locationItem.Lcid = IPLocationList[i].IPLocationID.ToString(); locationItem.Text = Server.HtmlEncode(LocationResponse.GetFullLocationName(IPLocationList[i])); Response.LocationList.Add(locationItem); } if (Response.LocationList.Count == 0) { Response.ResponseType = 0; } else if (Response.LocationList.Count == 1) { Response.ResponseType = 1; Response.LocationText = Server.HtmlEncode(IPLocationList[0].city); } else if (Response.LocationList.Count > 1) { Response.ResponseType = 2; } } } return Response; }
/// <summary> /// Fetches all the locations in the table. /// </summary> /// <returns>Returns a list of locations.</returns> public static List<LocationItem> FetchDataLocation() { try { List<LocationItem> list = new List<LocationItem>(); string sql = "SELECT DISTINCT Location FROM Bid"; SetConnectionString(); using (var connection = new SqlConnection(_connectionString)) { connection.Open(); using (var command = new SqlCommand(sql, connection)) { using (var reader = command.ExecuteReader()) { if (reader.Read()) { do { //sets the value from the reader LocationItem item = new LocationItem(); item.Value = (string)reader["Location"]; list.Add(item); item = null; } while (reader.Read()); } } } } return list; } catch (Exception) { throw; } }