コード例 #1
0
 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;
 }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
 void RaiseMapSelectedForOpening(object sender, ContentItemEventArgs e)
 {
     if (MapSelectedForOpening != null)
     {
         MapSelectedForOpening(this, e);
     }
 }
コード例 #4
0
 /// <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();
 }
コード例 #5
0
        /// <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();
        }
コード例 #6
0
 void RaiseMapSelectedForOpening(object sender, ContentItemEventArgs e)
 {
   if (MapSelectedForOpening != null)
     MapSelectedForOpening(this, e);
 }
コード例 #7
0
    /// <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);
    }
コード例 #8
0
    /// <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);
            });
        });
    }
コード例 #9
0
        /// <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);
                    }
                });
            });
        }