예제 #1
0
        private static void OnSelectedGraphicCountPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            FeatureDataGrid grid     = d as FeatureDataGrid;
            int             oldValue = (int)e.OldValue;
            int             newValue = (int)e.NewValue;

            // if they are different update the status bar text to reflect changes
            if (oldValue != newValue)
            {
                grid.UpdateRecordsText();
            }

            if (grid.GraphicsLayer == null)
            {
                return;
            }
            IEnumerable <Graphic> gridSelected = grid.SelectedItems.Cast <Graphic>();;
            var addedSelections = grid.GraphicsLayer.SelectedGraphics.Except(gridSelected).ToList();
            IEnumerable <Graphic> layerSelected = grid.GraphicsLayer.SelectedGraphics;
            var removedSelections = gridSelected.Except(grid.GraphicsLayer.SelectedGraphics).ToList();

            foreach (var add in addedSelections)
            {
                grid.SelectedItems.Add(add);
            }
            foreach (var remove in removedSelections)
            {
                grid.SelectedItems.Remove(remove);
            }
        }
        private static void OnFilterSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            FeatureDataGrid       grid     = d as FeatureDataGrid;
            IEnumerable <Graphic> oldValue = e.OldValue as IEnumerable <Graphic>;
            IEnumerable <Graphic> newValue = e.NewValue as IEnumerable <Graphic>;

            if (oldValue != null && oldValue is ObservableCollection <Graphic> )
            {
                (oldValue as ObservableCollection <Graphic>).CollectionChanged -= grid.FilterSource_CollectionChanged;
            }
            if (newValue != null && newValue is ObservableCollection <Graphic> )
            {
                (newValue as ObservableCollection <Graphic>).CollectionChanged += grid.FilterSource_CollectionChanged;
            }

            if (grid.GraphicsLayer != null)
            {
                grid.SetItemsSource((grid.GraphicsLayer != null && grid.GraphicsLayer.Graphics != null) ? (IList <Graphic>)grid.GraphicsLayer.Graphics : new List <Graphic>());
            }
            else
            {
                grid.ItemsSource = null;
            }
            grid.ResetLayout();
            // Restoring previously selected graphics (if any):
            if (grid.GraphicsLayer != null)
            {
                grid.RestorePreviousSelection(grid.GraphicsLayer.SelectedGraphics);
            }
        }
예제 #3
0
        /// <summary>
        /// When filter source changes the view and record text needs to be updated.
        /// </summary>
        private static void OnFilterSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            FeatureDataGrid grid = d as FeatureDataGrid;

            grid.ApplyFilter();
            grid.UpdateRecordsText();
        }
예제 #4
0
        private static void OnTotalGraphicCountPropetyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            FeatureDataGrid grid     = d as FeatureDataGrid;
            int             oldValue = (int)e.OldValue;
            int             newValue = (int)e.NewValue;

            // if they are different update the status bar text to reflect changes
            if (oldValue != newValue)
            {
                grid.UpdateRecordsText();
            }
        }
예제 #5
0
        private static void OnGraphicsLayerPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            FeatureDataGrid grid     = d as FeatureDataGrid;
            GraphicsLayer   oldValue = e.OldValue as GraphicsLayer;
            GraphicsLayer   newValue = e.NewValue as GraphicsLayer;

            if (oldValue != null)
            {
                if (grid.featureLayer != null)
                {
                    grid.featureLayer.UpdateCompleted -= grid.FeatureLayer_UpdateCompleted;
                    grid.featureLayer = null;                     // clear out reference to old feature layer if it exists
                }
                oldValue.PropertyChanged -= grid.GraphicsLayer_PropertyChanged;
                BindingOperations.ClearBinding(grid, FeatureDataGrid.TotalGraphicCountProperty);
                BindingOperations.ClearBinding(grid, FeatureDataGrid.SelectedGraphicCountProperty);
                if (!oldValue.IsInitialized)
                {
                    oldValue.Initialized -= grid.GraphicsLayer_Initialized;
                }
            }
            if (newValue != null)
            {
                // if new layer is feature layer set private member
                if (newValue is FeatureLayer)
                {
                    grid.featureLayer = newValue as FeatureLayer;
                    grid.OutFields    = grid.featureLayer.OutFields.ToString();
                    grid.featureLayer.UpdateCompleted += grid.FeatureLayer_UpdateCompleted;
                }
                else
                {
                    grid.GraphicCollection = newValue.Graphics;
                }

                if (newValue.IsInitialized)
                {
                    newValue.PropertyChanged += grid.GraphicsLayer_PropertyChanged;
                    grid.SetItemsSource(newValue.Graphics);                             // Set the ItemsSource
                    grid.BindToTotalGraphicsCount();                                    // Add total graphic count binding.
                    grid.BindToSelectedGraphicsCount();                                 // Add selected graphic count binding.
                }
                else
                {
                    // Wait for initialize event to fire before configuring feature data grid
                    newValue.Initialized += grid.GraphicsLayer_Initialized;
                }
            }
            grid.UpdateRecordsText();                                           // Update the status bar text.
            grid.SetSubmitButtonVisibility();                                   // Enable/Disable submit button option.
            grid.SetDeleteSelectedRowsMenuButtonEnableState();                  // Enable/Disable delete option.
        }
        private static void OnGraphicsLayerPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            FeatureDataGrid grid     = d as FeatureDataGrid;
            GraphicsLayer   oldValue = e.OldValue as GraphicsLayer;
            GraphicsLayer   newValue = e.NewValue as GraphicsLayer;

            if (oldValue != null)
            {
                oldValue.PropertyChanged -= grid.GraphicsLayer_PropertyChanged;
                #region Mouse Hovering Support
                oldValue.MouseEnter -= grid.GraphicsLayer_MouseEnter;
                oldValue.MouseLeave -= grid.GraphicsLayer_MouseLeave;
                #endregion
                grid.UnregisterGraphicCollectionEventHandlers();
                grid.currentGraphicCollection = null;

                // Setting the FeatureDataGrid's ItemsSource property to null:
                grid.ItemsSource = null;
                grid.ResetLayout();
            }
            if (newValue != null)
            {
                #region Mouse Hovering Support
                newValue.MouseEnter += grid.GraphicsLayer_MouseEnter;
                newValue.MouseLeave += grid.GraphicsLayer_MouseLeave;
                #endregion
                if (!newValue.IsInitialized)
                {
                    EventHandler <EventArgs> handler = null;
                    handler = new EventHandler <EventArgs>(
                        delegate(object s, EventArgs args) { grid.PopulateItemsSource(s as GraphicsLayer, handler); });
                    newValue.Initialized += handler;
                }
                else
                {
                    grid.PopulateItemsSource(newValue, null);
                }
            }
            // Restoring previously selected graphics (if any):
            if (grid.GraphicsLayer != null)
            {
                grid.RestorePreviousSelection(grid.GraphicsLayer.SelectedGraphics);
            }
        }
예제 #7
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.MyDataGrid = ((ESRI.ArcGIS.Client.Toolkit.FeatureDataGrid)(target));
                return;

            case 2:
                this.MyMap = ((ESRI.ArcGIS.Client.Map)(target));

            #line 26 "..\..\MainWindow.xaml"
                this.MyMap.Loaded += new System.Windows.RoutedEventHandler(this.MyMap_Loaded);

            #line default
            #line hidden
                return;

            case 3:
                this.TrajectoriesLayer = ((ESRI.ArcGIS.Client.FeatureLayer)(target));

            #line 36 "..\..\MainWindow.xaml"
                this.TrajectoriesLayer.MouseLeftButtonUp += new ESRI.ArcGIS.Client.GraphicsLayer.MouseButtonEventHandler(this.FeatureLayer_MouseLeftButtonUp);

            #line default
            #line hidden
                return;

            case 4:
                this.ResponseTextBlock = ((System.Windows.Controls.TextBox)(target));
                return;

            case 5:
                this.DeleteScenarioButton = ((System.Windows.Controls.Button)(target));

            #line 43 "..\..\MainWindow.xaml"
                this.DeleteScenarioButton.Click += new System.Windows.RoutedEventHandler(this.DeleteScenarioButton_Click);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
예제 #8
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.MyDataGrid = ((ESRI.ArcGIS.Client.Toolkit.FeatureDataGrid)(target));
                return;

            case 2:
                this.MyMap = ((ESRI.ArcGIS.Client.Map)(target));
                return;

            case 3:
                this.ResponseTextBlock = ((System.Windows.Controls.TextBox)(target));
                return;

            case 4:
                this.urlText = ((System.Windows.Controls.TextBox)(target));
                return;

            case 5:
                this.RefreshScenarioButton = ((System.Windows.Controls.Button)(target));

            #line 45 "..\..\MainWindow.xaml"
                this.RefreshScenarioButton.Click += new System.Windows.RoutedEventHandler(this.RefreshScenarioButton_Click);

            #line default
            #line hidden
                return;

            case 6:
                this.DeleteScenarioButton = ((System.Windows.Controls.Button)(target));

            #line 46 "..\..\MainWindow.xaml"
                this.DeleteScenarioButton.Click += new System.Windows.RoutedEventHandler(this.DeleteScenarioButton_Click);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
 private void AddColumnsToFeatureDataGrid(FeatureDataGrid fdg)
 {
     fdg.Columns.Add(new DataGridTextColumn() { Header = "Attribute1", 
         Binding = new Binding("Attribute1") });
     fdg.Columns.Add(new DataGridTextColumn() { Header = "Attribute2", 
         Binding = new Binding("Attribute2") });
     fdg.Columns.Add(new DataGridTextColumn() { Header = "Attribute3", 
         Binding = new Binding("Attribute3") });
     fdg.Columns.Add(new DataGridTextColumn() { Header = "Attribute4", 
         Binding = new Binding("Attribute4") });
     fdg.Columns.Add(new DataGridTextColumn() { Header = "Attribute5", 
         Binding = new Binding("Attribute5") });
     fdg.Columns.Add(new DataGridTextColumn() { Header = "Attribute6", 
         Binding = new Binding("Attribute6") });
     fdg.Columns.Add(new DataGridTextColumn() { Header = "Attribute7", 
         Binding = new Binding("Attribute7") });
     fdg.Columns.Add(new DataGridTextColumn() { Header = "Attribute8", 
         Binding = new Binding("Attribute8") });
     fdg.Columns.Add(new DataGridTextColumn() { Header = "Attribute9", 
         Binding = new Binding("Attribute9") });
     fdg.Columns.Add(new DataGridTextColumn() { Header = "Attribute10", 
         Binding = new Binding("Attribute10") });
 }