|
POST
|
Yes. I was initializing it wrong. I am able to set my camera to focus on my items centroid (lat/long) with this code. I had to convert the lat long to x/y. But it works quite well //Get the Camera Position of the Item to Print
Camera CurrentApplicationCameraPosition = MapView.Active.Camera;
if (exportItemCentroid.SpatialReference.Wkid != CurrentApplicationCameraPosition.SpatialReference.Wkid)
{
var transformation =
ProjectionTransformation.Create(exportItemCentroid.SpatialReference,
CurrentApplicationCameraPosition.SpatialReference);
exportItemCentroid= GeometryEngine.Instance.ProjectEx(exportItemCentroid, transformation) as MapPoint;
}
CurrentApplicationCameraPosition.X = exportItemCentroid.X;
CurrentApplicationCameraPosition.Y = exportItemCentroid.Y;
MapFrame mapFrame = layout.FindElement("MapLayer") as MapFrame;
mapFrame.SetMap(MapView.Active.Map);
mapFrame.SetCamera(CurrentApplicationCameraPosition);
... View more
08-22-2018
09:24 AM
|
0
|
0
|
2641
|
|
POST
|
No that i have that reference to the correct LayoutProjectItem, I am having trouble moving the mapFrame from the mapview. I seem to continue to get the same map location in my map frame. I want to move the from pragmatically according to some lat/long or x/y that i send the function. But when i change the camera X or Y when debugging in the below code, the camera stays in the same spot in my resulting layout print out. //Get a Layout Element Text and update its values
if (layoutItem != null)
{
await QueuedTask.Run(() =>
{
// Reference and load the layout associated with the layout item
Layout layout = layoutItem.GetLayout();
if (layout != null)
{
IEnumerable<Element> LayoutElements = layout.Elements;
//Find a single specific element
TextElement rect = layout.FindElement("Text ID") as TextElement;
rect.SetTextProperties(new TextProperties("Test1Mat", rect.TextProperties.Font, rect.TextProperties.FontSize, rect.TextProperties.FontStyle));
//Change Position of the Map Frame elements focus
Camera newPosition = new Camera();
newPosition.X = MapView.Active.Camera.X;
newPosition.Y = MapView.Active.Camera.Y;
MapFrame mapFrame = layout.FindElement("MapLayer") as MapFrame;
mapFrame.SetMap(MapView.Active.Map);
//I CHANGE the newPosition X and Y below for different printouts, but they all seem to be focused on the same spot of my Active Map
mapFrame.SetCamera(newPosition);
}
});
}
... View more
08-20-2018
02:11 PM
|
0
|
1
|
2641
|
|
POST
|
My work around it to add the LayoutProjectItem to the Project if it doesn't already exist, and then close that pane immediatly afterwards. I don't want the users to see my Layout template. I then proceed to edit the Elements on that layout page and export the layout to a pdf. This way a user will never see the layout. I do need to add the pagx file to the configx file and reference it, but that shouldn't be too difficult. ProApp.Panes.CloseLayoutPanes(LayoutURI); //1. See if the layouts have been imported to this Project
//Reference all the layout project items
IEnumerable<LayoutProjectItem> layouts = Project.Current.GetItems<LayoutProjectItem>();
//Or reference a specific layout project item by name
LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("xMap"));
string LayoutURI = "";
//If the layout is null, then import them
if (layoutItem == null)
{
await QueuedTask.Run(() =>
{
//Get the layout item from the config file
IProjectItem pagx = ItemFactory.Instance.Create(@"C:\Users\xxx\Documents\xMap.pagx") as IProjectItem;
Project.Current.AddItem(pagx);
layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("XMap"));
//Get the layout URI so we can auto close it
Layout li = layoutItem.GetLayout();
LayoutURI = li.URI;
});
}
//Close the layout pane, we don't want to see it
if (!string.IsNullOrEmpty(LayoutURI))
{
ProApp.Panes.CloseLayoutPanes(LayoutURI);
}
//Get a Layout Element Text and update it
if (layoutItem != null)
{
await QueuedTask.Run(() =>
{
// Reference and load the layout associated with the layout item
Layout layout = layoutItem.GetLayout();
if (layout != null)
{
//Find a single specific element
TextElement rect = layout.FindElement("XElementID") as TextElement;
rect.SetTextProperties(new TextProperties("TestRename",
rect.TextProperties.Font, rect.TextProperties.FontSize,
rect.TextProperties.FontStyle));
}
});
}
//Export the Layout Element
if (layoutItem != null)
{
// Create the log file and write the current Folder-Connection's to it
SaveItemDialog saveDialog = new SaveItemDialog();
saveDialog.Title = "Export the current selected map series item";
saveDialog.OverwritePrompt = true;
saveDialog.DefaultExt = "pdf";
// If the save dialog was not dismissed, create the file
if (saveDialog.ShowDialog() == true)
{
await QueuedTask.Run(() =>
{
Layout testlayout = layoutItem.GetLayout();
PDFFormat PDF = new PDFFormat()
{
Resolution = 300,
OutputFileName = saveDialog.FilePath
};
if (PDF.ValidateOutputFilePath())
{
testlayout.Export(PDF);
}
});
}
}
... View more
08-20-2018
01:10 PM
|
1
|
0
|
2641
|
|
POST
|
Can you think of any type of work around for this? I don't want the templates or layouts to open at all. But if they do, i want to have that layout tab close automatically, or when i add the LayoutProjectItem, I quickly close it. I think after the first time, when it is already in the project I can reference it, but I want to add them all for a project and then close them all. Then they can all be referenced without opening them.
... View more
08-20-2018
12:34 PM
|
0
|
3
|
2641
|
|
POST
|
I want to add some layouts to my project from the code. I have about 4 different export templates that I plan to use in a project, so if a user wants to export a selected Item, they select export, the code finds the layout from the Project-->Layouts, updates the text/map elements and saves or shows a pdf to the user. The problem, is that i want to add these 4 Layouts to a users project if they don't exist. I plan on putting the pagx files in the config.x file, then on loading a project I will add them to the layouts for a project if they don't exist. But when I do this, it "Auto" opens the layout when I use additem or import item from the Project tools. I just want them to be added in the background? This code below adds the items to layout, but it also opens up the layout tabs for each, which i don't want. //1. See if the layouts have been imported to this Project
//Reference all the layout project items
IEnumerable<LayoutProjectItem> layouts = Project.Current.GetItems<LayoutProjectItem>();
//Or reference a specific layout project item by name
LayoutProjectItem layoutItem = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault(item => item.Name.Equals("CurrentFieldMapHybrid"));
//*************************
//*************************
//THIS BELOW ADDS THE LAYOUT TO THE CATALOG, BUT OPENS UP THE LAYOUT TABS. I JUST WANT THEM ADDED TO THE LAYOUT CATALOG. BOTH AddItem AND ImportItem do this
//*************************
//*************************
//If the layout is null, then import them
if (layoutItem == null)
{
#region Add new Layout if it doesn't exist
await QueuedTask.Run(() =>
{
//IProjectItem pagx = ItemFactory.Instance.Create(@"xxxxx\CurrentFieldMapHybrid.pagx") as IProjectItem;
//Project.Current.AddItem(pagx);
IProjectMultiItem pagx = ItemFactory.Instance.Create(@"xxxxx\CurrentFieldMapHybrid.pagx") as IProjectMultiItem;
Project.Current.ImportItem(pagx);
});
#endregion
}
... View more
08-20-2018
06:34 AM
|
0
|
11
|
3567
|
|
POST
|
I still haven't gotten back to this, but what you mention above about using the args.Guid to determine reentrance is exactly what I do. When we get to upgrading our version to 2.2 I will be able to work on this more. But I am still suspecting that it has something to do with assigning the Geometry to an inspector on the Row when I load it from change event arg. I think the Shape is not getting loaded correctly to my inspector and is somehow using the old shape on for the Row, and not the updated shape? long _updateOID = args.Row.GetObjectID(); //Get the layer of the selected item FeatureClass newFC = (FeatureClass)args.Row.GetTable(); string updateItemName = newFC.GetDefinition().GetAliasName(); FeatureLayer firstFeatureLayer = FeatureServiceManagement.GetFeatureLayer(updateItemName); //Load the inspector await inspr.LoadAsync(firstFeatureLayer, _updateOID); .
... View more
08-15-2018
08:18 AM
|
0
|
0
|
1687
|
|
POST
|
I want to put a button on my dockpane that "Sets Ideal Size/Position". I have a grid in the dock that is used, and it doesn't look good unless it is at a certain width and height. How can i set the Width/Height from code? I can't seem to get this to work. I want my users to be able to just click the button to get the window to the ideal width. I understand that initially it will be docked, and then when you move it, it will retain that position. But I want to be able make this easy for a user. Having problems accomplishing this. I know for a Window it is quite easy, but not having much luck doing it for a user control.
... View more
08-15-2018
06:44 AM
|
0
|
0
|
2974
|
|
POST
|
So this is a drastic change then? I cannot call apply changes from within a row create/row change event any longer? Will the change you suggest work in 2.1? Or do we have to make all these changes in 2.2 sdk and deploy to 2.2 installation. My production code is out there in 2.1 and we are still developing against 2.1, so my question is will the code changes made to work in 2.2, still work in 2.1. This will require some effort to get this upgraded. My polygon features rely and other polygon features of a different class. Some must be confined within a polygon of a different type, some cannot intersect a polygon of a different type. Their attributes and shapes are changed accordingly using applyasync. So imagine if I shrunk a "Parent" polygon, the child polygon of a different feature lies within that polygon. When that parent polygon shrinks, the child polygon must shrink itself to stay confined, and in most cases update a number of area and location attributes. You are saying that I will need to update these values in a different way, whereas before I just told the underlying OID to basically apply changes and the row change event would take care of the work for that Object. You are saying I can't call row change from withing a row change?
... View more
08-03-2018
07:30 AM
|
0
|
2
|
1687
|
|
POST
|
I have since had to roll back to the 2.1 version as we are in Production now and don't want to upgrade the users version yet. I plan on upgrading and testing again soon. The one thing that i do see that is different is that you are using the row whereas I am loading the inspector with the OID from the Arg. I am thinking it must be something with the Geometry on a non new arg when I load the inspector? protected static async void OnRowCreateEvent(RowChangedEventArgs args)
{
try
{
Inspector inspr = await GetInspectorForRow(args);
ProMapItem pmi = ProMapFactory.GetProMapItem(inspr);
if (pmi != null && Settings.CurrentMapSettings != null)
{
//pmi.CreatedBy = Settings.CurrentUserName;
pmi.PlantCode = Settings.CurrentMapSettings.PlantCode;
pmi.HarvestYear = Settings.CurrentMapSettings.HarvestYear;
pmi.HarvestTrimester = Settings.CurrentMapSettings.HarvestTrimester;
pmi.MaterialGroup = Settings.CurrentMapSettings.MaterialGroup;
//Override of Created/Modified
pmi.PMCreatedBy = Settings.CurrentUserName;
pmi.PMModifiedBy = Settings.CurrentUserName;
//Make the initial commit to get the field to be visible with the definition query
await pmi.CommitChangesAsync();
pmi.ShowEditForm = true;
pmi.HasShapeChanged = true;
pmi.IsNew = true;
await pmi.Edit();
}
}
catch (Exception e)
{
ProMapBlackLogWriter.LogError("ProMapBlackModule - onRowCreateEvent", e);
}
}
private static async Task<Inspector> GetInspectorForRow(RowChangedEventArgs args)
{
Inspector inspr = new Inspector();
try
{
long _updateOID = args.Row.GetObjectID();
//Get the layer of the selected item
FeatureClass newFC = (FeatureClass)args.Row.GetTable();
string updateItemName = newFC.GetDefinition().GetAliasName();
FeatureLayer firstFeatureLayer = FeatureServiceManagement.GetFeatureLayer(updateItemName);
//Load the inspector
await inspr.LoadAsync(firstFeatureLayer, _updateOID);
}
catch (Exception e)
{
ProMapBlackLogWriter.LogError("ProMapBlackModule - GetInspectorForRow", e);
}
return inspr;
}
... View more
07-26-2018
12:02 PM
|
0
|
4
|
2290
|
|
POST
|
Thank you. That worked great. The only change I made to activate the Rectangle Selection tool instead of the explore tool. Also, why cant I post code in these replies? We don't have the option to show syntax? private async void OnMapSelectionChanged(MapSelectionChangedEventArgs args) { //Any Selection change will need you to deactivate the tool and activate the Rectangle select tool await FrameworkApplication.SetCurrentToolAsync("esri_mapping_selectByRectangleTool"); }
... View more
07-25-2018
06:51 AM
|
0
|
5
|
2320
|
|
POST
|
I have a MapTool that will only be activated (OnToolActivateAsync) when one, and only one feature is selected. Then when the user finishes their sketch, the one and only selected item will have some work done to it (OnSketchCompleteAsync). The problem that I find, is that after you activate the tool, if you click on the Clear Selection button, my map tool doesn't deactivate, so the validation of a selected item is no longer valid. i would either like my tool to deactivate when the Clear button is pressed, or have a way to catch the button being clicked from my maptool, and have the validation rerun. I have tried OnSelectionChangedAsync but that doesn't seem to catch the clear selection, as my tool is a sketch tool. Here is my Activate Function that has the line to CheckForValidSelection. But after the tool is activated, I have no way of catching the selection clear button. protected async override Task OnToolActivateAsync(bool hasMapViewChanged)
{
try
{
//this checks the map for only one feature selected and warns user if failed
bool validCheck = await CheckForValidSelection();
//Exist if one thing and one thing only is not selected
if (!validCheck) return;
//Setup the line symbol/snapping/tracing
if (_lineSymbol == null)
{
_lineSymbol = await CreateLineSymbolAsync();
}
SketchSymbol = _lineSymbol.MakeSymbolReference();
//General Snapping
Snapping.IsEnabled = true;
Snapping.SetSnapMode(SnapMode.Edge, true);
Snapping.SetSnapMode(SnapMode.End, true);
Snapping.SetSnapMode(SnapMode.Intersection, true);
//Set the command to Trace, possible bug as we have to set it then set it again
ICommand _trace = FrameworkApplication.GetPlugInWrapper("esri_editing_TraceConstructor") as ICommand;
_trace.Execute(null);
_trace = FrameworkApplication.GetPlugInWrapper("esri_editing_LineConstructor") as ICommand;
_trace.Execute(null);
_trace = FrameworkApplication.GetPlugInWrapper("esri_editing_TraceConstructor") as ICommand;
_trace.Execute(null);
}
catch (Exception e)
{
LogError("OnToolActivateAsync", e);
}
}
... View more
07-24-2018
07:59 AM
|
0
|
7
|
2508
|
|
POST
|
I had to rollback to 2.1 as we are moving to a Production Release and are users will have to start on 2.1 until I have time to move to 2.2 and fix the issue. I am able to Move/Resize/Rotate/Add Vertices, but the changes I make to that feature from a feature service as a result of this action, don't seem to save. After i perform one of these Move/Resize/Rotate/Add Vertices actions, my code must sometimes alter that feature to not overlap (Clip) another feature of the same type or to be fully within a different feature (confine). But with 2.2 this functionality doesn't save. I am able to do the intersection/difference edits, but the saves simply don't save when I execute or commit them. I work with the Create/Change functions in my module too, so on create or change event I populate the Feature Service item being created into an inspector like below. The below code is for create, but the change code works in much the same way. Both create and change are not saving my edit actions when i commit them. (And Sorry, but for some reason the code block option is not available in the reply here?) protected static async void OnRowCreateEvent(RowChangedEventArgs args) { try { Inspector inspr = await GetInspectorForRow(args, true); ProMapItem pmi = ProMapFactory.GetProMapItem(inspr); if (pmi != null && Settings.CurrentMapSettings != null) { //Make the initial commit to get the field to be visible with the definition query await pmi.CommitChangesAsync(); pmi.ShowEditForm = true; pmi.HasShapeChanged = true; pmi.IsNew = true; //Run the difference and intersection rules so the polygon is confined or cliped await pmi.Edit(); } } catch (Exception e) { } private static async Task<Inspector> GetInspectorForRow(RowChangedEventArgs args, bool isNewRow) { Inspector inspr = new Inspector(); try { long _updateOID = args.Row.GetObjectID(); //Get the layer of the selected item FeatureClass newFC = (FeatureClass)args.Row.GetTable(); string updateItemName = newFC.GetDefinition().GetAliasName(); FeatureLayer firstFeatureLayer = FeatureServiceManagement.GetFeatureLayer(updateItemName); //Load the inspector await inspr.LoadAsync(firstFeatureLayer, _updateOID); } catch (Exception e) { } return inspr; }
... View more
07-20-2018
06:41 AM
|
0
|
1
|
2289
|
|
POST
|
Yes it would be nice to be able to "Set Ideal Position" somehow. I can't seem to get the Height/Width to work initially. I understand that it retains the position you set for it after you close it, but I have a grid in my Dock Pane, and the Grid looks much better at a certain Height/Width.
... View more
07-20-2018
06:21 AM
|
0
|
0
|
2974
|
|
POST
|
By watching the Area of the inspector shape, I can see that this line does set the new shape to the difference value _dataInspector.Shape = differenceShape; But when i run the following line, that shape.area quickly reverts back to the original value bool operationResult = eo.Execute();
... View more
07-18-2018
07:09 AM
|
0
|
1
|
2289
|
|
POST
|
Sorry I couldn't get back to you yesterday. What i am trying to do is simply get the difference between to of the same feature from our feature service. Two of the same type Polygons cannot occupy the same space. So when you draw one polygon over one or more of the same type polygon(s), it gets the total of those intersecting polygons, and gets the difference of the new polygon minus the intersecting polygons, this is a small part of that code. I have an object that gets the difference geometry of features of the same type, it then calls this difference procedure and stores the new geometry, but that new geometry doesn't save since the move to 2.2. New code works and the new polygon is clipped/difference, but when we execute the operation if fails to make the change. I can't upgrade to this version until i get this resolved. i am sure it is something simple. public void Difference(Geometry inDifferenceGeometry)
{
try
{
//Get the difference of this ProMap Item minus the inDifferenceGeometry
if (!inDifferenceGeometry.IsNullOrEmpty())
{
Geometry originalShape = _dataInspector.Shape;
Geometry differenceShape = GeometryEngine.Instance.Difference(originalShape, inDifferenceGeometry);
_dataInspector.Shape = differenceShape;
//create and execute the edit operation
// create an edit operation
EditOperation differenceOperation = new EditOperation()
{
Name = "Difference Operation",
ProgressMessage = "Working...",
CancelMessage = "Operation canceled.",
ErrorMessage = "Error In Difference",
SelectModifiedFeatures = false,
SelectNewFeatures = false
};
differenceOperation.Modify(_dataInspector);
CommitEditOperation(differenceOperation);
}
}
catch (Exception e)
{
LogError("Difference", e);
}
Log.Debug("ProMapItem - Difference - Finished");
}
public void CommitEditOperation(EditOperation eo)
{
long currentObjectID = OID;
try
{
PMModifiedBy = Settings.CurrentUserName;
//This line makes sure the OnRowChangeEvent in Module is not retriggered, the OnRowChangeEvent checks this list before it continues
Module.CurrentlyUpdatingOIDList.Add(currentObjectID);
bool operationResult = eo.Execute();
}
catch (Exception e)
{
LogError("CommitEditOperation - " + eo.Name, e);
throw;
}
finally
{
Module.CurrentlyUpdatingOIDList.Remove(currentObjectID);
}
}
... View more
07-18-2018
06:47 AM
|
0
|
5
|
2289
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-23-2018 06:49 AM | |
| 1 | 08-02-2023 08:28 AM | |
| 1 | 01-03-2020 10:54 AM | |
| 1 | 11-30-2017 06:41 AM | |
| 1 | 08-20-2018 01:10 PM |
| Online Status |
Offline
|
| Date Last Visited |
01-27-2026
08:03 AM
|