Skip to content

Commit

Permalink
Initial commit from alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhathcock committed Jul 4, 2024
0 parents commit 60499e3
Show file tree
Hide file tree
Showing 524 changed files with 36,133 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.28.2",
"commands": [
"dotnet-csharpier"
]
}
}
}
7 changes: 7 additions & 0 deletions .csharpierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
printWidth: 120
useTabs: false
tabWidth: 2
preprocessorSymbolSets:
- ""
- "DEBUG"
- "DEBUG,CODE_STYLE"
309 changes: 309 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# need original files to be windows
*.txt text eol=crlf
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
**/bin/*
**/obj/*
_ReSharper.SharpCompress/
bin/
*.suo
*.user
TestArchives/Scratch/
TestArchives/Scratch2/
TestResults/
*.nupkg
packages/*/
project.lock.json
tests/TestArchives/Scratch
.vs
tools
.vscode
.idea/

.DS_Store
*.snupkg
coverage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using Speckle.Autofac.DependencyInjection;
using Speckle.Connectors.DUI.Bindings;
using Speckle.Connectors.DUI.Bridge;
using Speckle.Connectors.DUI.Models;
using Speckle.Connectors.DUI.Models.Card;
using Speckle.Connectors.Utils;
using Speckle.Connectors.Utils.Cancellation;
using Speckle.Connectors.Utils.Operations;

namespace Speckle.Connectors.ArcGIS.Bindings;

public sealed class ArcGISReceiveBinding : IReceiveBinding
{
public string Name { get; } = "receiveBinding";
private readonly CancellationManager _cancellationManager;
private readonly DocumentModelStore _store;
private readonly IUnitOfWorkFactory _unitOfWorkFactory;

public ReceiveBindingUICommands Commands { get; }
public IBridge Parent { get; }

public ArcGISReceiveBinding(
DocumentModelStore store,
IBridge parent,
CancellationManager cancellationManager,
IUnitOfWorkFactory unitOfWorkFactory
)
{
_store = store;
_cancellationManager = cancellationManager;
Parent = parent;
Commands = new ReceiveBindingUICommands(parent);
_unitOfWorkFactory = unitOfWorkFactory;
}

public async Task Receive(string modelCardId)
{
try
{
// Get receiver card
if (_store.GetModelById(modelCardId) is not ReceiverModelCard modelCard)
{
// Handle as GLOBAL ERROR at BrowserBridge
throw new InvalidOperationException("No download model card was found.");
}

// Init cancellation token source -> Manager also cancel it if exist before
CancellationTokenSource cts = _cancellationManager.InitCancellationTokenSource(modelCardId);

using IUnitOfWork<ReceiveOperation> unitOfWork = _unitOfWorkFactory.Resolve<ReceiveOperation>();

// Receive host objects
var receiveOperationResults = await unitOfWork.Service
.Execute(
modelCard.AccountId.NotNull(), // POC: I hear -you are saying why we're passing them separately. Not sure pass the DUI3-> Connectors.DUI project dependency to the SDK-> Connector.Utils
modelCard.ProjectId.NotNull(),
modelCard.ProjectName.NotNull(),
modelCard.ModelName.NotNull(),
modelCard.SelectedVersionId.NotNull(),
cts.Token,
(status, progress) =>
Commands.SetModelProgress(modelCardId, new ModelCardProgress(modelCardId, status, progress), cts)
)
.ConfigureAwait(false);

modelCard.BakedObjectIds = receiveOperationResults.BakedObjectIds.ToList();
Commands.SetModelReceiveResult(
modelCardId,
receiveOperationResults.BakedObjectIds,
receiveOperationResults.ConversionResults
);
}
// Catch here specific exceptions if they related to model card.
catch (OperationCanceledException)
{
// SWALLOW -> UI handles it immediately, so we do not need to handle anything
return;
}
}

public void CancelReceive(string modelCardId) => _cancellationManager.CancelOperation(modelCardId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Speckle.Connectors.DUI.Bindings;
using Speckle.Connectors.DUI.Bridge;
using ArcGIS.Desktop.Mapping.Events;
using ArcGIS.Desktop.Mapping;

namespace Speckle.Connectors.ArcGIS.Bindings;

public class ArcGISSelectionBinding : ISelectionBinding
{
public string Name => "selectionBinding";
public IBridge Parent { get; }

public ArcGISSelectionBinding(IBridge parent, ITopLevelExceptionHandler topLevelHandler)
{
Parent = parent;

// example: https://github.com/Esri/arcgis-pro-sdk-community-samples/blob/master/Map-Authoring/QueryBuilderControl/DefinitionQueryDockPaneViewModel.cs
// MapViewEventArgs args = new(MapView.Active);
TOCSelectionChangedEvent.Subscribe(_ => topLevelHandler.CatchUnhandled(OnSelectionChanged), true);
}

private void OnSelectionChanged()
{
SelectionInfo selInfo = GetSelection();
Parent.Send(SelectionBindingEvents.SET_SELECTION, selInfo);
}

public SelectionInfo GetSelection()
{
MapView mapView = MapView.Active;
List<MapMember> selectedMembers = new();
selectedMembers.AddRange(mapView.GetSelectedLayers());
selectedMembers.AddRange(mapView.GetSelectedStandaloneTables());

List<string> objectTypes = selectedMembers
.Select(o => o.GetType().ToString().Split(".").Last())
.Distinct()
.ToList();
return new SelectionInfo(
selectedMembers.Select(x => x.URI).ToList(),
$"{selectedMembers.Count} layers ({string.Join(", ", objectTypes)})"
);
}
}
Loading

0 comments on commit 60499e3

Please sign in to comment.