コード例 #1
0
ファイル: Events.cs プロジェクト: yanhuike/arcgis-pro-sdk
        protected void OnRowCreated(RowChangedEventArgs args)
        {
            // RowEvent callbacks are always called on the QueuedTask so there is no need
            // to wrap your code within a QueuedTask.Run lambda.

            // update a separate table when a row is created
            // You MUST use the ArcGIS.Core.Data API to edit the table. Do NOT
            // use a new edit operation in the RowEvent callbacks
            try
            {
                // update Notes table with information about the new feature
                var geoDatabase     = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(Project.Current.DefaultGeodatabasePath)));
                var table           = geoDatabase.OpenDataset <Table>("Notes");
                var tableDefinition = table.GetDefinition();
                using (var rowbuff = table.CreateRowBuffer())
                {
                    // add a description
                    rowbuff["Description"] = "OID: " + args.Row.GetObjectID().ToString() + " " + DateTime.Now.ToShortTimeString();
                    table.CreateRow(rowbuff);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show($@"Error in OnRowCreated for OID: {args.Row.GetObjectID()} : {e.ToString()}");
            }
        }
コード例 #2
0
        private void RowSelectionChanged(object sender, RowChangedEventArgs rowChangedEventArgs)
        {
            if (rowChangedEventArgs == null || rowChangedEventArgs.NewRow == null || rowChangedEventArgs.ReportInstance == null)
            {
                return;
            }

            if (!this.IsSubscribingToReportType(rowChangedEventArgs.ReportInstance.ReportType))
            {
                return;
            }

            if (rowChangedEventArgs.ReportInstance.ReportType == ReportType.TicketSummary)
            {
                return;
            }

            long?accountId = this.GetAccountId(rowChangedEventArgs.NewRow, AccountIdColumnName);

            get_account_name(Convert.ToString(accountId));
            this.PublishedAccount = Convert.ToInt32(accountId);

            SetSelectedAccount(accountId.Value);


            // this.TopSecuritiesViewerWindow.Securitieschart();
        }
コード例 #3
0
 protected void onCreatedRowEvent(RowChangedEventArgs args)
 {
     Utils.RunOnUIThread(() => {
         Dockpane1ViewModel.Show();
         var pane = FrameworkApplication.DockPaneManager.Find("esri_editing_AttributesDockPane");
         pane.Activate();
     });
 }
コード例 #4
0
 private void RowChanged(object sender, RowChangedEventArgs rowChangedEventArgs)
 {
     // only gray group should listen to LV reports
     if (this.Group == WidgetGroups.Gray)
     {
         this.RowSelectionChanged(sender, rowChangedEventArgs);
     }
 }
        private void RecordEvent(RowChangedEventArgs rc, Table table)
        {
            var eventName = $"Row{rc.EditType.ToString()}dEvent";

            var entry = $"{table.GetName()}, oid:{rc.Row.GetObjectID()}";

            RecordEvent(eventName, entry);
        }
コード例 #6
0
        void ApplicationNotification_RowChanged(object sender, RowChangedEventArgs e)
        {
            if (e.NewRow.RowType.ToString() == "Header")
            {
                return;
            }
            if (TransactinosViewerWindow.Follower == "LongView")
            {
                if (e.NewRow.RowType.ToString() == "Header")
                {
                    return;
                }


                if (e.ReportInstance.ReportType.DisplayName == "Appraisal")
                {
                    TransactinosViewerWindow.AccountId   = Convert.ToDecimal(e.NewRow.GetCellValue("account_id"));
                    TransactinosViewerWindow.AccountName = Convert.ToString(e.NewRow.GetCellValue("account_short_name"));
                    TransactinosViewerWindow.UpdateAccoutText();
                    TransactinosViewerWindow.se_get_ipo_data();
                }

                if (e.ReportInstance.ReportType.DisplayName == "CashBalance")
                {
                    TransactinosViewerWindow.AccountId   = Convert.ToDecimal(e.NewRow.GetCellValue("account_id"));
                    TransactinosViewerWindow.AccountName = Convert.ToString(e.NewRow.GetCellValue("account_sh_name"));
                    TransactinosViewerWindow.UpdateAccoutText();
                    TransactinosViewerWindow.se_get_ipo_data();
                }

                if (e.ReportInstance.ReportType.DisplayName == "ManagerBlotter")
                {
                    TransactinosViewerWindow.AccountId   = Convert.ToDecimal(e.NewRow.GetCellValue("account_id"));
                    TransactinosViewerWindow.AccountName = Convert.ToString(e.NewRow.GetCellValue("account_sh_name"));
                    TransactinosViewerWindow.UpdateAccoutText();
                    TransactinosViewerWindow.se_get_ipo_data();
                    ;
                }

                if (e.ReportInstance.ReportType.DisplayName == "Security X-Reference")
                {
                    TransactinosViewerWindow.AccountId   = Convert.ToDecimal(e.NewRow.GetCellValue("account_id"));
                    TransactinosViewerWindow.AccountName = Convert.ToString(e.NewRow.GetCellValue("account_sh_name"));
                    TransactinosViewerWindow.UpdateAccoutText();
                    TransactinosViewerWindow.se_get_ipo_data();
                }


                if (e.ReportInstance.ReportType.DisplayName == "OrderPreview")
                {
                    TransactinosViewerWindow.AccountId   = Convert.ToDecimal(e.NewRow.GetCellValue("account_id"));
                    TransactinosViewerWindow.AccountName = Convert.ToString(e.NewRow.GetCellValue("account_sh_name"));
                    TransactinosViewerWindow.UpdateAccoutText();
                    TransactinosViewerWindow.se_get_ipo_data();
                }
            }
        }
コード例 #7
0
 private static void OnRowDeletedEvent(RowChangedEventArgs obj)
 {
     if (_lastEdit != obj.Guid)
     {
         //cancel with dialog
         // Note - feature edits on Hosted and Standard Feature Services cannot be cancelled.
         obj.CancelEdit("Delete Event\nAre you sure", true);
         _lastEdit = obj.Guid;
     }
 }
コード例 #8
0
        private void MyRowChangedEvent(RowChangedEventArgs obj)
        {
            //example of modifying a field on a row that has been created
            var parentEditOp = obj.Operation;

            // avoid recursion
            if (_lastEdit != obj.Guid)
            {
                //update field on change
                parentEditOp.Modify(obj.Row, "ZONING", "New");

                _lastEdit = obj.Guid;
            }
        }
        /// <summary>
        /// Using RowChangedEventArgs returns inspector for changes (created) row
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        private async Task <Inspector> GetInspectorForRow(RowChangedEventArgs args)
        {
            Inspector inspr = new Inspector();

            try
            {
                //Load the inspector
                await inspr.LoadAsync(_workedOnPolygonLayer, args.Row.GetObjectID());
            }
            catch (Exception e)
            {
                MessageBox.Show($@"Unable to get Inspector for OID: {args.Row.GetObjectID()} in {_workedOnPolygonLayer.Name}: {e.ToString()}");
            }
            return(inspr);
        }
コード例 #10
0
 private static void OnRowChangedEvent(RowChangedEventArgs obj)
 {
     //Get the layer's definition
     var lyrDefn = featureLayer.GetFeatureClass().GetDefinition();
     //Get the shape field of the feature class
     string shapeField = lyrDefn.GetShapeField();
     //Index of the shape field
     var shapeIndex = lyrDefn.FindField(shapeField);
     //Original geometry of the modified row
     var geomOrig = obj.Row.GetOriginalValue(shapeIndex) as Geometry;
     //New geometry of the modified row
     var geomNew = obj.Row[shapeIndex] as Geometry;
     //Compare the two
     bool shapeChanged = geomOrig.IsEqual(geomNew);
 }
コード例 #11
0
ファイル: Events.cs プロジェクト: yanhuike/arcgis-pro-sdk
        protected void OnRowDeleted(RowChangedEventArgs args)
        {
            var row = args.Row;

            // cancel the delete if the feature is in Police District 5

            var fldIdx = row.FindField("POLICE_DISTRICT");

            if (fldIdx != -1)
            {
                var value = row[fldIdx].ToString();
                if (value == "5")
                {
                    args.CancelEdit();
                }
            }
        }
コード例 #12
0
        private void OnRowEvent(RowChangedEventArgs obj)
        {
            //get the parent operation
            var parentEditOp = obj.Operation;

            //create values for the editlog
            var atts = new Dictionary <string, object>();

            atts.Add("Layer", obj.Row.GetTable().GetName());
            atts.Add("OID", obj.Row.GetObjectID());
            atts.Add("Date", DateTime.Now.ToShortTimeString());
            atts.Add("EditType", obj.EditType.ToString());

            //add a row to the editlog table
            //as part of the current running edit operation
            parentEditOp.Create(_ehTable, atts);
        }
コード例 #13
0
        private void MyRowCreatedEvent(RowChangedEventArgs obj)
        {
            // get the edit operation
            var parentEditOp = obj.Operation;

            // set up some attributes
            var attribues = new Dictionary <string, object> {
            };

            attribues.Add("Layer", "Parcels");
            attribues.Add("Description", "OID: " + obj.Row.GetObjectID().ToString() + " " + DateTime.Now.ToShortTimeString());

            //create a record in an audit table
            var sTable = MapView.Active.Map.FindStandaloneTables("EditHistory").First();
            var table  = sTable.GetTable();

            parentEditOp.Create(table, attribues);
        }
コード例 #14
0
        public void RowChanged(object sender, RowChangedEventArgs e)
        {
            if (e.state == ObjectState.Added || e.state == ObjectState.Deleted || e.state == ObjectState.Modified)
            {
                if (!log_transaction)
                {
                    throw new MessageException("TransactionID is not assgined yet.");
                }

                if (this.rowID == 0)
                {
                    if (e.saved)      //log after save with identity value created
                    {
                        if (dpoType != null)
                        {
                            DPObject dpo = (DPObject)Activator.CreateInstance(dpoType, new object[] { e.adapter.Row });
                            this.rowID = dpo.RowId;
                        }
                        else if (this.rowIdColumnName != null)
                        {
                            this.rowID = (int)e.adapter.Row[this.rowIdColumnName];
                        }
                        else
                        {
                            throw new MessageException("DPO Type is not defined");
                        }
                    }
                    else
                    {
                        return;
                    }
                }

                modified = e.state == ObjectState.Modified;

                if (e.state == ObjectState.Modified || e.state == ObjectState.Added || e.state == ObjectState.Deleted)
                {
                    log_row_id = this.logee.LogRow(log_transaction, this.tableName, this.tableId, this.rowID, e.state, e.adapter.Row1, e.adapter.Row);

                    logged = log_row_id > 0;
                }
            }
        }
コード例 #15
0
        private async void OnRowDeleted(RowChangedEventArgs args)
        {
            await QueuedTask.Run(() =>
            {
                Row row         = args.Row;
                Feature feature = row as Feature;
                long objectId   = feature?.GetObjectID() ?? -1;

                if (_selection?.Contains(objectId) ?? false)
                {
                    _selection.Remove(objectId);
                }

                if (IsVisibleInGlobespotter && GlobeSpotterConfiguration.MeasurePermissions)
                {
                    Measurement measurement = _measurementList.Get(objectId);
                    measurement?.RemoveMeasurement();
                }
            });
        }
        private void RowEventHandler(RowChangedEventArgs rc)
        {
            using (var table = rc.Row.GetTable())
            {
                RecordEvent(rc, table);
                //validate flag is set
                //Note, we are validating deletes as well...if that makes sense ;-)
                //if not, change the sample to check the rc.EditType for
                //EditType.Delete and skip...
                if (_validate)
                {
                    //You can use 'rc.Row.HasValueChanged(fieldIndex)` to determine if
                    //a value you need to validate has changed
                    //
                    //call your validation method as needed...
                    //our validate method is a placeholder
                    if (!ValidateTheRow(rc.Row))
                    {
                        //if your validation fails take the appropriate action..
                        //we cancel the edit in this example
                        AddEntry($"*** {_validateMsg}");
                        rc.CancelEdit(_validateMsg);
                        AddEntry("*** edit cancelled");
                        AddEntry("---------------------------------");
                        return;
                    }
                    AddEntry("*** row validated");
                }

                //Cancel flag is set. If you have _failvalidate checked you won't
                //get here - validation will have failed and canceled the edit
                if (_cancelEdit)
                {
                    //cancel the edit
                    rc.CancelEdit($"{rc.EditType} for {table.GetName()} cancelled");
                    AddEntry("*** edit cancelled");
                    AddEntry("---------------------------------");
                }
            }
        }
コード例 #17
0
        private async void OnRowCreated(RowChangedEventArgs args)
        {
            await QueuedTask.Run(async() =>
            {
                Row row           = args.Row;
                Feature feature   = row as Feature;
                Geometry geometry = feature?.GetShape();
                const double e    = 0.1;

                if (geometry?.GeometryType == GeometryType.Point)
                {
                    MapPoint srcPoint = geometry as MapPoint;

                    if ((srcPoint != null) && (Math.Abs(srcPoint.Z) < e))
                    {
                        MapPoint dstPoint = await _vectorLayerList.AddHeightToMapPointAsync(srcPoint);
                        ElevationCapturing.ElevationConstantValue = dstPoint.Z;
                        feature.SetShape(dstPoint);
                    }
                }
            });
        }
コード例 #18
0
ファイル: Events.cs プロジェクト: yanhuike/arcgis-pro-sdk
        protected void OnRowChanged(RowChangedEventArgs args)
        {
            // RowEvent callbacks are always called on the QueuedTask so there is no need
            // to wrap your code within a QueuedTask.Run lambda.

            var row = args.Row;

            // check for re-entry  (only if row.Store is called)
            if (_currentRowChangedGuid == args.Guid)
            {
                return;
            }

            var fldIdx = row.FindField("POLICE_DISTRICT");

            if (fldIdx != -1)
            {
                //Validate any change to “police district”
                //   cancel the edit if validation on the field fails
                if (row.HasValueChanged(fldIdx))
                {
                    if (FailsValidation(row["POLICE_DISTRICT"].ToString()))
                    {
                        //Cancel edits with invalid “police district” values
                        args.CancelEdit($"Police district {row["POLICE_DISTRICT"]} is invalid");
                    }
                }

                // update the description field
                row["Description"] = "Row Changed";

                //  this update with cause another OnRowChanged event to occur
                //  keep track of the row guid to avoid recursion
                _currentRowChangedGuid = args.Guid;
                row.Store();
                _currentRowChangedGuid = Guid.Empty;
            }
        }
コード例 #19
0
        private async void OnRowChanged(RowChangedEventArgs args)
        {
            if (IsVisibleInGlobespotter)
            {
                await QueuedTask.Run(async() =>
                {
                    Row row                    = args.Row;
                    Feature feature            = row as Feature;
                    Geometry geometry          = feature?.GetShape();
                    long objectId              = feature?.GetObjectID() ?? -1;
                    Measurement measurement    = _measurementList.Get(objectId);
                    _measurementList.DrawPoint = false;
                    measurement                = _measurementList.StartMeasurement(geometry, measurement, false, objectId, this);
                    _measurementList.DrawPoint = true;

                    if (measurement != null)
                    {
                        await measurement.UpdateMeasurementPointsAsync(geometry);
                        measurement.CloseMeasurement();
                    }
                });
            }
        }
 /// <summary>
 /// called for each newly created row
 /// </summary>
 /// <param name="args"></param>
 private void OnRowCreatedEvent(RowChangedEventArgs args)
 {
     UpdateStatusText($@"Row created: {args.EditType}");
     UpdateRowIfNeeded(args);
 }
コード例 #21
0
 private void onRowChangedEvent(RowChangedEventArgs obj)
 {
   //do something on row changed
   MessageBox.Show("Changed row id " + obj.Row.GetObjectID().ToString(), "Row Changed Event");
 }
 private void OnPointRowCreatedEvent(RowChangedEventArgs args)
 {
     UpdateStatusText($@"Point Row created: {args.EditType}");
 }
        private void UpdateRowIfNeeded(RowChangedEventArgs args)
        {
            // From the ProConcept documentation @https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Editing#row-events
            // If you need to edit additional tables within the RowEvent you must use the
            // ArcGIS.Core.Data API to edit the tables directly.
            // Do not use a new edit operation to create or modify features or rows in your
            // RowEvent callbacks.
            // RowEvent callbacks are always called on the QueuedTask so there is no need
            // to wrap your code within a QueuedTask.Run lambda.
            try
            {
                // prevent re-entrance (only if row.Store() is called)
                if (_isStoreInOnRowEventEnabled &&
                    _currentRowChangedGuid == args.Guid)
                {
                    UpdateStatusText($@"Re-entrant call - ignored");
                    return;
                }

                var      row           = args.Row;
                var      rowDefinition = (row.GetTable() as FeatureClass).GetDefinition();
                var      geom          = row[rowDefinition.GetShapeField()] as Geometry;
                MapPoint pntLogging    = null;

                var      rowCursorOverlayPoly = _workedOnPolygonLayer.Search(geom, SpatialRelationship.Intersects);
                Geometry geomOverlap          = null;
                Geometry geomChangedPolygon   = null;
                while (rowCursorOverlayPoly.MoveNext())
                {
                    using (var feature = rowCursorOverlayPoly.Current as Feature)
                    {
                        var geomOverlayPoly = feature.GetShape();
                        if (geomOverlayPoly == null)
                        {
                            continue;
                        }

                        // exclude the search polygon
                        if (row.GetObjectID() == feature.GetObjectID())
                        {
                            geomChangedPolygon = geomOverlayPoly.Clone();
                            continue;
                        }
                        if (geomOverlap == null)
                        {
                            geomOverlap = geomOverlayPoly.Clone();
                            continue;
                        }
                        geomOverlap = GeometryEngine.Instance.Union(geomOverlap, geomOverlayPoly);
                    }
                }
                var description = string.Empty;
                if (!geomOverlap.IsNullOrEmpty())
                {
                    var correctedGeom = GeometryEngine.Instance.Difference(geom, geomOverlap);
                    row["Shape"] = correctedGeom;
                    if (!correctedGeom.IsNullOrEmpty())
                    {
                        // use the centerpoint of the polygon as the point for the logging entry
                        pntLogging = GeometryEngine.Instance.LabelPoint(correctedGeom);
                    }
                    description = correctedGeom.IsEmpty ? "Polygon can't be inside existing polygon" : "Corrected input polygon";
                }
                else
                {
                    description = "No overlapping polygons found";
                    if (!geomChangedPolygon.IsNullOrEmpty())
                    {
                        pntLogging = GeometryEngine.Instance.LabelPoint(geomChangedPolygon);
                    }
                }
                row["Description"] = description;
                UpdateStatusText($@"Row: {description}");
                if (_isStoreInOnRowEventEnabled)
                {
                    // calling store will result in a recursive row changed event as long as any
                    // attribute columns have changed
                    // In this case i would need to look at args.Guid to prevent re-entrance
                    _currentRowChangedGuid = args.Guid;
                    row.Store();
                    _currentRowChangedGuid = Guid.Empty;
                }

                // update logging feature class with centerpoint of polygon
                if (!pntLogging.IsNullOrEmpty())
                {
                    var geoDatabase         = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(Project.Current.DefaultGeodatabasePath)));
                    var loggingFeatureClass = geoDatabase.OpenDataset <FeatureClass>(_pointLayerName);
                    var loggingFCDefinition = loggingFeatureClass.GetDefinition();
                    using (var rowbuff = loggingFeatureClass.CreateRowBuffer())
                    {
                        // needs a 3D point
                        rowbuff[loggingFCDefinition.GetShapeField()] = MapPointBuilderEx.CreateMapPoint(pntLogging.X, pntLogging.Y, 0, pntLogging.SpatialReference);
                        rowbuff["Description"] = "OID: " + row.GetObjectID().ToString() + " " + DateTime.Now.ToShortTimeString();
                        loggingFeatureClass.CreateRow(rowbuff);
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show($@"Error in UpdateRowIfNeeded for OID: {args.Row.GetObjectID()} in {_workedOnPolygonLayer.Name}: {e.ToString()}");
            }
        }
コード例 #24
0
 protected void onRowEvent(RowChangedEventArgs args)
 {
     Console.WriteLine("RowChangedEvent " + args.EditType.ToString());
 }
コード例 #25
0
        protected void onRowChangedEvent(RowChangedEventArgs args)
        {
            var row = args.Row;

            UpdateModel(Convert.ToString(row["FacilityID"]));
        }
コード例 #26
0
 void ApplicationNotification_RowChanged(object sender, RowChangedEventArgs e)
 {
 }
コード例 #27
0
 private void onRowChangedEvent(RowChangedEventArgs obj)
 {
     //do something on row changed
     MessageBox.Show("Changed row id " + obj.Row.GetObjectID().ToString(), "Row Changed Event");
 }