void RaiseMapSelectedForOpening(object sender, ContentItemEventArgs e) { Cursor = Cursors.Wait; if (e != null && e.Item != null && !string.IsNullOrEmpty(e.Item.Id)) { if (MapSelectedForOpening != null) { string serverBaseUrl = System.IO.Path.Combine(ArcGISOnlineEnvironment.ConfigurationUrls.Sharing, "content"); MapSelectedForOpening(this, new MapDocumentEventArgs() { DocumentID = e.Item.Id, Document = new ESRI.ArcGIS.Client.WebMap.Document() { ServerBaseUrl = serverBaseUrl, BingToken = ArcGISOnlineEnvironment.BingToken, Token = ArcGISOnlineEnvironment.ArcGISOnline.User.Token, ProxyUrl = (string.IsNullOrWhiteSpace(ArcGISOnlineEnvironment.ConfigurationUrls.ProxyServerEncoded) ? null : ArcGISOnlineEnvironment.ConfigurationUrls.ProxyServerEncoded), GeometryServiceUrl = ArcGISOnlineEnvironment.ConfigurationUrls.GeometryServer } }); } //cache map as most recently used map MRUMaps.Add(e.Item); } Cursor = Cursors.Arrow; }
/// <summary> /// Gets called when the async download of a ContentItem has completed. /// </summary> static void GetItemCompleted(object sender, ContentItemEventArgs e) { if (e.Error != null) { //an error occured - remove item from list //e.Id is populated when an error occurs ContentItem item = Find(e.Id); if (item != null) { _contentItems.Remove(item); } return; } //find the place holder item that corresponds to the downloaded item ContentItem placeHolderItem = Find(e.Item.Id); if (placeHolderItem == null) { return; } int indexToReplace = _contentItems.IndexOf(placeHolderItem); _contentItems.RemoveAt(indexToReplace); _contentItems.Insert(indexToReplace, e.Item); }
void RaiseMapSelectedForOpening(object sender, ContentItemEventArgs e) { if (MapSelectedForOpening != null) { MapSelectedForOpening(this, e); } }
/// <summary> /// Raised when a map has been deleted. /// </summary> static void ArcGISOnline_ItemDeleted(object sender, ContentItemEventArgs e) { //remove maps that have been deleted ContentItem item = Find(e.Id); if (item != null) _contentItems.Remove(item); Save(); }
/// <summary> /// Raised when a map has been deleted. /// </summary> static void ArcGISOnline_ItemDeleted(object sender, ContentItemEventArgs e) { //remove maps that have been deleted ContentItem item = Find(e.Id); if (item != null) { _contentItems.Remove(item); } Save(); }
void RaiseMapSelectedForOpening(object sender, ContentItemEventArgs e) { if (MapSelectedForOpening != null) MapSelectedForOpening(this, e); }
/// <summary> /// Gets called when the async download of a ContentItem has completed. /// </summary> static void GetItemCompleted(object sender, ContentItemEventArgs e) { if (e.Error != null) { //an error occured - remove item from list //e.Id is populated when an error occurs ContentItem item = Find(e.Id); if (item != null) _contentItems.Remove(item); return; } //find the place holder item that corresponds to the downloaded item ContentItem placeHolderItem = Find(e.Item.Id); if (placeHolderItem == null) return; int indexToReplace = _contentItems.IndexOf(placeHolderItem); _contentItems.RemoveAt(indexToReplace); _contentItems.Insert(indexToReplace, e.Item); }
/// <summary> /// Deletes the content item specified by its Id. /// </summary> public void Delete(ContentItem item, EventHandler<ContentItemEventArgs> callback) { if (_agol.User.Current == null) { if (callback != null) callback(null, new ContentItemEventArgs() { Error = new Exception(ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.Resources.Strings.ExceptionDeleteFailedUserSignIn), Id = item.Id }); return; } //find out if the item is located in a folder // GetFolder(item, (object sender, RequestEventArgs e) => { if (e.Error != null) { if (callback != null) callback(null, new ContentItemEventArgs() { Error = e.Error }); return; } string folderUrl = ContentFolder.IsSubfolder(item.Folder) ? "/" + item.Folder.Id : ""; string url = _agol.Url + "/content/users/" + _agol.User.Current.Username + folderUrl + "/items/" + item.Id + "/delete?f=json&token=" + _agol.User.Token; WebUtil.UploadStringAsync(url, null, "", (object sender2, UploadStringCompletedEventArgs e2) => { if (e2.Error != null) { if (callback != null) callback(null, new ContentItemEventArgs() { Error = e2.Error, Id = item.Id }); return; } Success result = WebUtil.ReadObject<Success>(new MemoryStream(Encoding.UTF8.GetBytes(e2.Result))); ContentItemEventArgs eventArgs = new ContentItemEventArgs() { Error = (result == null || !result.Succeeded) ? new Exception(ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.Resources.Strings.ExceptionDeleteFailed) : null, Id = item.Id }; if (callback != null) callback(null, eventArgs); //raise event if (ItemDeleted != null) ItemDeleted(null, eventArgs); }); }); }
/// <summary> /// Deletes the content item specified by its Id. /// </summary> public void Delete(ContentItem item, EventHandler <ContentItemEventArgs> callback) { if (_agol.User.Current == null) { if (callback != null) { callback(null, new ContentItemEventArgs() { Error = new Exception(ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.Resources.Strings.ExceptionDeleteFailedUserSignIn), Id = item.Id }); } return; } //find out if the item is located in a folder // GetFolder(item, (object sender, RequestEventArgs e) => { if (e.Error != null) { if (callback != null) { callback(null, new ContentItemEventArgs() { Error = e.Error }); } return; } string folderUrl = ContentFolder.IsSubfolder(item.Folder) ? "/" + item.Folder.Id : ""; string url = _agol.Url + "/content/users/" + _agol.User.Current.Username + folderUrl + "/items/" + item.Id + "/delete?f=json&token=" + _agol.User.Token; WebUtil.UploadStringAsync(url, null, "", (object sender2, UploadStringCompletedEventArgs e2) => { if (e2.Error != null) { if (callback != null) { callback(null, new ContentItemEventArgs() { Error = e2.Error, Id = item.Id }); } return; } Success result = WebUtil.ReadObject <Success>(new MemoryStream(Encoding.UTF8.GetBytes(e2.Result))); ContentItemEventArgs eventArgs = new ContentItemEventArgs() { Error = (result == null || !result.Succeeded) ? new Exception(ESRI.ArcGIS.Mapping.Controls.ArcGISOnline.Resources.Strings.ExceptionDeleteFailed) : null, Id = item.Id }; if (callback != null) { callback(null, eventArgs); } //raise event if (ItemDeleted != null) { ItemDeleted(null, eventArgs); } }); }); }