Skip to content

Commit

Permalink
Merge pull request #88 from isogeo/feature/net6
Browse files Browse the repository at this point in the history
Migrate plugin to .NET 6 + performance optimizations + architecture improvements
  • Loading branch information
VianneyDoleans authored Jan 15, 2024
2 parents a6ed33a + 41c3fbc commit 26f40e5
Show file tree
Hide file tree
Showing 156 changed files with 4,195 additions and 5,359 deletions.
9 changes: 3 additions & 6 deletions AddIn/App.config
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<language>fr</language>
<actionType>view</actionType>
<owner></owner>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<geographicalOperator></geographicalOperator>
<sortMethode>_created</sortMethode>
<sortDirection>desc</sortDirection>
<defaultSearch></defaultSearch>
<fileSde></fileSde>
<userAuthentication>
<id></id>
<secret></secret>
Expand All @@ -30,5 +28,4 @@
<emailSubject>Plugin ArcGis Pro - Demande d'aide</emailSubject>
<emailBody>Bonjour,/nJ'ai une question concernant l'utilisation du plugin Isogeo pour ArcGis Pro.../n/nPour reproduire :/n/n1. Ouvrir ArcGis Pro/n2. Ouvrir le plugin/n3./n/n=&gt; description comportement/n/nVoici le comportement souhaité :/n/n/n=&gt; description comportement/n/nLes informations de mon environnement de travail :/n/n- Mon groupe client utilisé / client id : /n- Windows : /n- Version ArcGis Pro : /n- Version du plugin Isogeo ArcGis Pro : /n- Architecture du processeur : /n- Proxy : pare-feu :/n- utilisateur administrateur ?/n-Autres informations potentiellement utiles/n/nLes captures d'écrans sont en pièces-jointes</emailBody>
<urlHelp>http://help.isogeo.com/arcgispro/fr/</urlHelp>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/></startup>
</configuration>
107 changes: 76 additions & 31 deletions AddIn/Config.daml
Original file line number Diff line number Diff line change
@@ -1,52 +1,97 @@
<ArcGIS defaultAssembly="Isogeo.AddIn.dll" defaultNamespace="Isogeo.AddIn" xmlns="http://schemas.esri.com/DADF/Registry" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.esri.com/DADF/Registry file:///C:/Program%20Files/ArcGIS/Pro/bin/ArcGIS.Desktop.Framework.xsd">
<AddInInfo id="{d3cd9cd7-2008-4a27-be55-da1aeb26239f}" version="1.0.3" desktopVersion="2.5">
<Name>Isogeo Add-In</Name>
<?xml version="1.0" encoding="utf-8" ?>
<ArcGIS defaultAssembly="Isogeo.AddIn.dll"
defaultNamespace="Isogeo.AddIn"
xmlns="http://schemas.esri.com/DADF/Registry"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schemas.esri.com/DADF/Registry file:///C:/Program%20Files/ArcGIS/Pro/bin/ArcGIS.Desktop.Framework.xsd">

<AddInInfo id="{d3cd9cd7-2008-4a27-be55-da1aeb26239f}" version="2.0.0-beta3" desktopVersion="3.0">
<Name>Isogeo Add-In</Name>
<Description>ArcGis Pro Isogeo Add-In</Description>
<Image>Icon\icon_isogeo.png</Image>
<Author>Isogeo</Author>
<Company>Isogeo</Company>
<Date>08/02/2020 09:00:00, 2021</Date>
<Date>23/11/2023 02:00:00 PM</Date>
<Subject>Framework</Subject>
<!-- Note subject can be one or more of these topics:
Content, Framework, Editing, Geodatabase, Geometry, Geoprocessing, Layouts, Map Authoring, Map Exploration -->
</AddInInfo>
<modules>
<insertModule id="Arcgis_Pro_Isogeo_Module" className="Module1" autoLoad="true" caption="Module1">
<!-- uncomment to have the control hosted on a separate tab-->
<tabs>
<!--<tab id="Arcgis_Pro_Isogeo_Tab1" caption="New Tab">

<modules>
<insertModule id="Arcgis_Pro_Isogeo_Module" className="IsogeoModule" autoLoad="true" caption="IsogeoModule">
<!-- uncomment to have the control hosted on a separate tab-->
<tabs>
<!--<tab id="Arcgis_Pro_Isogeo_Tab1" caption="New Tab">
<group refID="Arcgis_Pro_Isogeo_Group1"/>
</tab>-->
</tabs>
<groups>
<!-- comment this out if you have no controls on the Addin tab to avoid
an empty group-->
<group id="Arcgis_Pro_Isogeo_Group1" caption="Isogeo" appearsOnAddInTab="true">
<!-- host controls within groups -->
<button refID="Arcgis_Pro_Isogeo_Dockpane_ShowButton" size="large" />
</group>
</groups>
<controls>
<!-- add your controls here -->
<button id="Arcgis_Pro_Isogeo_Dockpane_ShowButton" caption="Isogeo" className="DockPaneShowButton" loadOnClick="true" smallImage="pack://application:,,,/Isogeo.AddIn;component/Icon/icon_isogeo16.png" largeImage="pack://application:,,,/Isogeo.AddIn;component/Icon/icon_isogeo32.png">
<tooltip heading="ArcGis Pro Isogeo Add-In">
Isogeo<disabledText />
</tooltip>
</button>
<!--<button id="CustomCatalog_PanelIndicatorStatic_MenuButton" caption="Burger Menu Button" className="PanelIndicatorStatic_MenuButton" loadOnClick="true" smallImage="Images\GenericButtonPurple16.png" largeImage="Images\GenericButtonPurple32.png">
<tooltip heading="Burger Menu Button">
ToolTip<disabledText />
</tooltip>
</button>-->
</controls>
<dockPanes>
<dockPane id="Arcgis_Pro_Isogeo_Dockpane" caption="Isogeo" className="DockpaneViewModel" dock="group" dockWith="esri_core_contentsDockPane">
<content className="DockpaneView" />
</dockPane>
</dockPanes>
<menus>
<menu id="CustomCatalog_PanelIndicatorStatic_Menu" caption="Options" contextMenu="true">
<button refID="CustomCatalog_PanelIndicatorStatic_MenuButton" />
</menu>
</menus>
</insertModule>
</modules>

<!--<modules>
<insertModule id="Isogeo.Addin_Module" className="Module1" autoLoad="false" caption="Module1">
--><!-- uncomment to have the control hosted on a separate tab--><!--
<tabs>
--><!--<tab id="Isogeo.Addin_Tab1" caption="New Tab">
<group refID="Isogeo.Addin_Group1"/>
</tab>--><!--
</tabs>
<groups>
<!-- comment this out if you have no controls on the Addin tab to avoid
an empty group-->
<group id="Arcgis_Pro_Isogeo_Group1" caption="Isogeo" appearsOnAddInTab="true">
<!-- host controls within groups -->
--><!-- comment this out if you have no controls on the Addin tab to avoid
an empty group--><!--
<group id="Isogeo.Addin_Group1" caption="Group 1" appearsOnAddInTab="true">
--><!-- host controls within groups --><!--
<button refID="Arcgis_Pro_Isogeo_Dockpane_ShowButton" size="large" />
</group>
</groups>
<controls>
<!-- add your controls here -->
--><!-- add your controls here --><!--
--><!-- add your controls here --><!--
<button id="Arcgis_Pro_Isogeo_Dockpane_ShowButton" caption="Isogeo" className="DockPaneShowButton" loadOnClick="true" smallImage="pack://application:,,,/Isogeo.AddIn;component/Icon/icon_isogeo16.png" largeImage="pack://application:,,,/Isogeo.AddIn;component/Icon/icon_isogeo32.png">
<tooltip heading="ArcGis Pro Isogeo Add-In">Isogeo<disabledText /></tooltip>
<tooltip heading="ArcGis Pro Isogeo Add-In">
Isogeo<disabledText />
</tooltip>
</button>
<!--<button id="CustomCatalog_PanelIndicatorStatic_MenuButton" caption="Burger Menu Button" className="PanelIndicatorStatic_MenuButton" loadOnClick="true" smallImage="Images\GenericButtonPurple16.png" largeImage="Images\GenericButtonPurple32.png">
<tooltip heading="Burger Menu Button">
ToolTip<disabledText />
</tooltip>
</button>-->
</controls>
<dockPanes>
<dockPane id="Arcgis_Pro_Isogeo_Dockpane" caption="Isogeo" className="DockpaneViewModel" dock="group" dockWith="esri_core_contentsDockPane">
<content className="DockpaneView" />
</dockPane>
</dockPanes>
<menus>
<menu id="CustomCatalog_PanelIndicatorStatic_Menu" caption="Options" contextMenu="true">
<button refID="CustomCatalog_PanelIndicatorStatic_MenuButton" />
</menu>
</menus>
<dockPanes>
<dockPane id="Arcgis_Pro_Isogeo_Dockpane" caption="Isogeo" className="DockpaneViewModel" dock="group" dockWith="esri_core_contentsDockPane">
<content className="DockpaneView" />
</dockPane>
</dockPanes>
</insertModule>
</modules>
</modules>-->
</ArcGIS>
6 changes: 3 additions & 3 deletions AddIn/Dockpane.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:extensions="clr-namespace:ArcGIS.Desktop.Extensions;assembly=ArcGIS.Desktop.Extensions"
xmlns:controls="clr-namespace:ArcGIS.Desktop.Framework.Controls;assembly=ArcGIS.Desktop.Framework"
xmlns:viewTabControls="clr-namespace:Isogeo.AddIn.Views.TabControls"
xmlns:viewModelTabControls="clr-namespace:Isogeo.AddIn.ViewsModels.TabControls"
xmlns:tabControls="clr-namespace:Isogeo.AddIn.Views.TabControls"
x:Class="Isogeo.AddIn.DockpaneView"
mc:Ignorable="d"
d:DesignHeight="600" d:DesignWidth="594"
Expand All @@ -17,10 +17,10 @@
<extensions:DesignOnlyResourceDictionary Source="pack://application:,,,/ArcGIS.Desktop.Framework;component\Themes\Default.xaml"/>
</ResourceDictionary.MergedDictionaries>
<DataTemplate DataType="{x:Type viewModelTabControls:SearchViewModel}">
<viewTabControls:Search />
<tabControls:Search />
</DataTemplate>
<DataTemplate DataType="{x:Type viewModelTabControls:SettingsViewModel}">
<viewTabControls:Settings />
<tabControls:Settings />
</DataTemplate>
</ResourceDictionary>
</UserControl.Resources>
Expand Down
116 changes: 59 additions & 57 deletions AddIn/DockpaneViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,33 @@
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.ExceptionServices;
using System.Windows.Controls;
using System.Threading.Tasks;
using System.Windows;
using ArcGIS.Desktop.Framework;
using ArcGIS.Desktop.Framework.Contracts;
using ArcGIS.Desktop.Framework.Dialogs;
using Isogeo.AddIn.Models.FilterManager;
using Isogeo.AddIn.ViewsModels.TabControls;
using Isogeo.Map;
using Isogeo.Models;
using Isogeo.Models.Network;
using Isogeo.Network;
using Isogeo.Utils.LogManager;
using MVVMPattern.MediatorPattern;
using Button = ArcGIS.Desktop.Framework.Contracts.Button;
using ConfigurationManager = Isogeo.Models.Configuration.ConfigurationManager;
using ConfigurationManager = Isogeo.Utils.ConfigurationManager.ConfigurationManager;
using MessageBox = ArcGIS.Desktop.Framework.Dialogs.MessageBox;
using TabControl = ArcGIS.Desktop.Framework.Controls.TabControl;

namespace Isogeo.AddIn
{
public class DockpaneViewModel : DockPane
{
private const string MenuId = "Isogeo_plugin_Menu";
private readonly ViewModelBase _paneH1Vm;
private readonly ViewModelBase _paneH2Vm;
private const string DockPaneId = "Arcgis_Pro_Isogeo_Dockpane";

private readonly INetworkManager _networkManager;
private readonly IFilterManager _filterManager;

private bool _isEnabled = true;
public bool IsEnabled
{
Expand All @@ -35,22 +40,16 @@ public bool IsEnabled
}
}

public void EnableDockableWindowIsogeo(object obj)
{
IsEnabled = (bool) obj;
}

private static void InitRestFunctions()
public async void ResetResearch(object obj)
{
Log.Logger.Info("Initializing Rest Functions");
Variables.restFunctions = new RestFunctions();
if (Variables.configurationManager.config.query == "-") Variables.configurationManager.config.query = " ";
var ob = _filterManager.GetOb();
var od = _filterManager.GetOd();
await _networkManager.ResetData(od, ob);
}

private static void InitConfigurationManager()
public void EnableDockableWindowIsogeo(object obj)
{
Log.Logger.Info("Initializing Configuration Manager");
Variables.configurationManager = new ConfigurationManager();
IsEnabled = (bool) obj;
}

public void Exception(object sender, FirstChanceExceptionEventArgs e)
Expand All @@ -67,7 +66,7 @@ private void InitLog()
{
var dllPAth = GetType().Assembly.Location;

var configPath = dllPAth.Substring(0, dllPAth.LastIndexOf("\\", StringComparison.Ordinal)) + "\\";
var configPath = dllPAth[..dllPAth.LastIndexOf("\\", StringComparison.Ordinal)] + "\\";
Log.InitializeLogManager(configPath + "log4net.config");
Log.InitializeLogPath(configPath);
}
Expand All @@ -84,17 +83,45 @@ protected DockpaneViewModel()
InitLog();
Log.Logger.Info("Isogeo ArcGisPro Add-In is opening...");
Log.Logger.Info("Initializing DockPaneViewModel ...");
Mediator.Register("EnableDockableWindowIsogeo", EnableDockableWindowIsogeo);
InitConfigurationManager();
InitRestFunctions();
Mediator.Register(MediatorEvent.EnableDockableWindowIsogeo, EnableDockableWindowIsogeo);

Log.Logger.Info("Initializing Configuration Manager");

ConfigurationManager configurationManager = null;

try
{
configurationManager = new ConfigurationManager();
}
catch (Exception)
{
MessageBox.Show("Error configuration : missing or wrong App.config file", "Isogeo");
throw;
}

PrimaryMenuList.Add(new TabControl { Text = Language.Resources.Search_word });
PrimaryMenuList.Add(new TabControl { Text = Language.Resources.Settings });
_paneH1Vm = new SearchViewModel();
_paneH2Vm = new SettingsViewModel();


IMapManager mapManager = new MapManager();
_networkManager = new NetworkManager(configurationManager);
_filterManager = new FilterManager(mapManager);

_paneH1Vm = new SearchViewModel(_networkManager, _filterManager, mapManager, configurationManager);
_paneH2Vm = new SettingsViewModel(_networkManager, _filterManager, mapManager, configurationManager);
_selectedPanelHeaderIndex = 0;
CurrentPage = _paneH1Vm;
Variables.restFunctions.ResetData();

Mediator.Register(MediatorEvent.UserAuthentication, ResetResearch);

var query = configurationManager.Config.DefaultSearch;
var box = configurationManager.Config.GeographicalOperator;
var od = configurationManager.Config.SortDirection;
var ob = configurationManager.Config.SortMethode;

Task.Run(() => Application.Current.Dispatcher.Invoke(async () => {
await _networkManager.LoadData(query, 0, box, od, ob);
}));
Log.Logger.Info("END Initializing DockPaneViewModel");
}

Expand All @@ -104,36 +131,29 @@ protected DockpaneViewModel()
internal static void Show()
{
var pane = FrameworkApplication.DockPaneManager.Find(DockPaneId);
if (pane == null)
return;

pane.Activate();
pane?.Activate();
}

#region properties

/// <summary>
/// Text shown near the top of the DockPane.
/// </summary>
private string _heading = "Isogeo";
public string Heading
{
get { return _heading; }
get => _heading;
set
{
SetProperty(ref _heading, value, () => Heading);
}
}

private readonly List<TabControl> _primaryMenuList = new List<TabControl>();
public List<TabControl> PrimaryMenuList
{
get { return _primaryMenuList; }
}
public List<TabControl> PrimaryMenuList { get; } = new();

private int _selectedPanelHeaderIndex;
public int SelectedPanelHeaderIndex
{
get { return _selectedPanelHeaderIndex; }
get => _selectedPanelHeaderIndex;
set
{
SetProperty(ref _selectedPanelHeaderIndex, value, () => SelectedPanelHeaderIndex);
Expand All @@ -143,35 +163,16 @@ public int SelectedPanelHeaderIndex
CurrentPage = _paneH2Vm;
}
}

private PropertyChangedBase _currentPage;
public PropertyChangedBase CurrentPage
{
get { return _currentPage; }
get => _currentPage;
set
{
SetProperty(ref _currentPage, value, () => CurrentPage);
}
}

#endregion
#region Burger Button

/// <summary>
/// Tooltip shown when hovering over the burger button.
/// </summary>
public string BurgerButtonTooltip
{
get { return "Options"; }
}

/// <summary>
/// Menu shown when burger button is clicked.
/// </summary>
public ContextMenu BurgerButtonMenu
{
get { return FrameworkApplication.CreateContextMenu(MenuId); }
}
#endregion
}

/// <summary>
Expand All @@ -184,6 +185,7 @@ protected override void OnClick()
DockpaneViewModel.Show();
}
}

internal class PanelIndicatorStaticMenuButton : Button
{
protected override void OnClick()
Expand Down
Loading

0 comments on commit 26f40e5

Please sign in to comment.