Select to view content in your preferred language

Gallery OnUpdate crashes AGX

2236
2
Jump to solution
11-02-2012 05:41 PM
BrianLocke
Frequent Contributor
well not the greatest programmer but basically here is my code all works fine and dandy yet if there is an update to the table while the Gallery Menu is open then she give me a 'Improper Argument Error'

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;  using ESRI.ArcGISExplorer; using ESRI.ArcGISExplorer.Application; using ESRI.ArcGISExplorer.Mapping; using ESRI.ArcGISExplorer.Geometry; using ESRI.ArcGISExplorer.Data; using ESRI.ArcGISExplorer.Threading; using WRMS.AVLDataSetTableAdapters;  namespace WRMS {     public class AvlGallery : ESRI.ArcGISExplorer.Application.Gallery     {          #region Fetch Data          private AVLCurrentResourcesTableAdapter AvlTableAdapter = new AVLCurrentResourcesTableAdapter();         private AVLDataSet AvlDataSet = new AVLDataSet();         private int fetchCount;          #endregion          #region Icons         Image t6resource = WRMS.Properties.Resources.T6Resource;         #endregion          public AvlGallery()         {             this.AvlTableAdapter.Fill(AvlDataSet.AVLCurrentResources);             fetchCount = AvlDataSet.AVLCurrentResources.Count;             avlGalleryFill();         }          public override void OnClick(GalleryItem item)         {             AvlInfoWindow avlInfo = new AvlInfoWindow(item.Caption.ToString());             avlInfo.Location = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.ConvertToScreenPoint(ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.Center);             avlInfo.StartPosition = FormStartPosition.Manual;             avlInfo.Show();         }          public override void OnUpdate()         {             base.OnUpdate();             if (AVL.isChecked)             {                 this.Enabled = true;                                  this.AvlTableAdapter.Fill(AvlDataSet.AVLCurrentResources);                 if (fetchCount != AvlDataSet.AVLCurrentResources.Count)                 {                     this.Items.Clear();                     avlGalleryFill();                 }             }             else             {                 this.Enabled = false;             }          }                  public void avlGalleryFill()         {                          foreach (DataRow resource in AvlDataSet.AVLCurrentResources)             {                 this.Items.Add(new GalleryItem(resource["Callsign"].ToString(), t6resource));             }         }      } }


I am guessing that it would not be wise to alter the GalleryCollection while the Gallery is open????

any suggestions??
0 Kudos
1 Solution

Accepted Solutions
BrianLocke
Frequent Contributor
...... Wooowww really Need to look at my code before putting it up here......
fixed ...
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;  using ESRI.ArcGISExplorer; using ESRI.ArcGISExplorer.Application; using ESRI.ArcGISExplorer.Mapping; using ESRI.ArcGISExplorer.Geometry; using ESRI.ArcGISExplorer.Data; using ESRI.ArcGISExplorer.Threading; using WRMS.AVLDataSetTableAdapters;  namespace WRMS {     public class AvlGallery : ESRI.ArcGISExplorer.Application.Gallery     {          #region Fetch Data          private AVLCurrentResourcesTableAdapter AvlTableAdapter = new AVLCurrentResourcesTableAdapter();         private AVLDataSet AvlDataSet = new AVLDataSet();         private int fetchCount;          #endregion          #region Icons         Image t6resource = WRMS.Properties.Resources.T6Resource;         #endregion          public AvlGallery()         {             AvlTableAdapter.Fill(AvlDataSet.AVLCurrentResources);             fetchCount = AvlDataSet.AVLCurrentResources.Count;             avlGalleryFill();         }          public override void OnClick(GalleryItem item)         {             AvlInfoWindow avlInfo = new AvlInfoWindow(item.Caption.ToString());             avlInfo.Location = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.ConvertToScreenPoint(ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.Center);             avlInfo.StartPosition = FormStartPosition.Manual;             avlInfo.Show();         }          public override void OnUpdate()         {             base.OnUpdate();             if (AVL.isChecked)             {                 Enabled = true;                                  AvlTableAdapter.Fill(AvlDataSet.AVLCurrentResources);                 if (fetchCount != AvlDataSet.AVLCurrentResources.Count)                 {                     Items.Clear();                     avlGalleryFill();                     fetchCount = AvlDataSet.AVLCurrentResources.Count;                 }             }             else             {                 Enabled = false;             }          }                  public void avlGalleryFill()         {                          foreach (DataRow resource in AvlDataSet.AVLCurrentResources)             {                 Items.Add(new GalleryItem(resource["Callsign"].ToString(), t6resource));             }         }      } }

View solution in original post

0 Kudos
2 Replies
BrianLocke
Frequent Contributor
ok Think that I am getting warmer, I am seeing that while the gallery is open it would be protected and you can't write to protected mem. any way to manaually close the gallery drop down maybe even switch the focus???
0 Kudos
BrianLocke
Frequent Contributor
...... Wooowww really Need to look at my code before putting it up here......
fixed ...
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;  using ESRI.ArcGISExplorer; using ESRI.ArcGISExplorer.Application; using ESRI.ArcGISExplorer.Mapping; using ESRI.ArcGISExplorer.Geometry; using ESRI.ArcGISExplorer.Data; using ESRI.ArcGISExplorer.Threading; using WRMS.AVLDataSetTableAdapters;  namespace WRMS {     public class AvlGallery : ESRI.ArcGISExplorer.Application.Gallery     {          #region Fetch Data          private AVLCurrentResourcesTableAdapter AvlTableAdapter = new AVLCurrentResourcesTableAdapter();         private AVLDataSet AvlDataSet = new AVLDataSet();         private int fetchCount;          #endregion          #region Icons         Image t6resource = WRMS.Properties.Resources.T6Resource;         #endregion          public AvlGallery()         {             AvlTableAdapter.Fill(AvlDataSet.AVLCurrentResources);             fetchCount = AvlDataSet.AVLCurrentResources.Count;             avlGalleryFill();         }          public override void OnClick(GalleryItem item)         {             AvlInfoWindow avlInfo = new AvlInfoWindow(item.Caption.ToString());             avlInfo.Location = ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.ConvertToScreenPoint(ESRI.ArcGISExplorer.Application.Application.ActiveMapDisplay.Center);             avlInfo.StartPosition = FormStartPosition.Manual;             avlInfo.Show();         }          public override void OnUpdate()         {             base.OnUpdate();             if (AVL.isChecked)             {                 Enabled = true;                                  AvlTableAdapter.Fill(AvlDataSet.AVLCurrentResources);                 if (fetchCount != AvlDataSet.AVLCurrentResources.Count)                 {                     Items.Clear();                     avlGalleryFill();                     fetchCount = AvlDataSet.AVLCurrentResources.Count;                 }             }             else             {                 Enabled = false;             }          }                  public void avlGalleryFill()         {                          foreach (DataRow resource in AvlDataSet.AVLCurrentResources)             {                 Items.Add(new GalleryItem(resource["Callsign"].ToString(), t6resource));             }         }      } }
0 Kudos