private bool EnablePublisherExtension() { bool checkedOutOK = false; try { IExtensionManager extMgr = new ExtensionManagerClass(); IExtensionManagerAdmin extAdmin = (IExtensionManagerAdmin)extMgr; UID uid = new UID(); uid.Value = "esriPublisherUI.Publisher"; object obj = 0; extAdmin.AddExtension(uid, ref obj); IExtensionConfig extConfig = (IExtensionConfig)extMgr.FindExtension(uid); if ((!(extConfig.State == esriExtensionState.esriESUnavailable))) { //This checks on the extension extConfig.State = esriExtensionState.esriESEnabled; checkedOutOK = true; } } catch (Exception) { MessageBox.Show("Publisher extension has failed to check out.", "Error"); } return(checkedOutOK); }
private void Toggle3DExtension(string strState) { try { IExtensionManagerAdmin pExtAdmin2 = new ExtensionManagerClass(); IExtensionManager pExtManager2 = pExtAdmin2 as IExtensionManager; UID pUID = new UID(); pUID.Value = "{94305472-592E-11D4-80EE-00C04FA0ADF8}"; IExtensionConfig pExtConfig2 = pExtManager2.FindExtension(pUID) as IExtensionConfig; switch (strState) { case "ON": pExtConfig2.State = esriExtensionState.esriESEnabled; break; case "OFF": pExtConfig2.State = esriExtensionState.esriESDisabled; break; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private static void ClearEIDArrayParameterValues(INetworkAnalystExtension nax, List <string> sourceNames, string baseName) { if (nax == null) { return; } bool naxEnabled = false; IExtensionConfig naxConfig = nax as IExtensionConfig; naxEnabled = naxConfig.State == esriExtensionState.esriESEnabled; if (!naxEnabled) { return; } Dictionary <string, List <int> > eidsBySourceName = new Dictionary <string, List <int> >(); foreach (string sourceName in sourceNames) { List <int> eids = null; if (!eidsBySourceName.TryGetValue(sourceName, out eids)) { eidsBySourceName.Add(sourceName, null); } } UpdateEIDArrayParameterValuesFromEIDLists(nax, eidsBySourceName, baseName); }
public void OnCreate(object hook) { // TODO: Add CAddLayer.OnCreate implementation m_pApplication = hook as IApplication; m_pMxDoc = (IMxDocument)m_pApplication.Document; m_pMap = (IMap)m_pMxDoc.FocusMap; UID pUID = new UIDClass(); pUID.Value = "CoM_GISTools.CExtension"; m_pExtension = (IExtensionConfig)m_pApplication.FindExtensionByCLSID(pUID); //// testing //if (m_pExtension.State == esriExtensionState.esriESEnabled) // MessageBox.Show("CAddLayer::Enabled"); //else if (m_pExtension.State == esriExtensionState.esriESDisabled) // MessageBox.Show("CAddLayer::Disabled"); //else // MessageBox.Show("CAddLayer::Unavailable"); m_bitmap = new System.Drawing.Bitmap(GetType().Assembly.GetManifestResourceStream("CoM_GISTools.Images.addLayer.bmp")); //("CoM_GISTools.AddLayer.CAddLayer.bmp")); if (m_bitmap != null) { m_bitmap.MakeTransparent(m_bitmap.GetPixel(1, 1)); m_hBitmap = m_bitmap.GetHbitmap(); } }
private static void EnableEsriLiscences() { ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop); ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.Desktop); UID pUid = new UIDClass(); pUid.Value = "esriSpatialAnalystUI.SAExtension"; // Add Spatial Analyst extension to the license manager. object v = null; IExtensionManagerAdmin extensionManagerAdmin = new ExtensionManagerClass(); extensionManagerAdmin.AddExtension(pUid, ref v); // Enable the license. IExtensionManager extensionManager = (IExtensionManager)extensionManagerAdmin; IExtension extension = extensionManager.FindExtension(pUid); IExtensionConfig extensionConfig = (IExtensionConfig)extension; if (extensionConfig.State != esriExtensionState.esriESUnavailable) { extensionConfig.State = esriExtensionState.esriESEnabled; } else { Console.WriteLine("No Spatial Analyst License available"); } }
public static void Enable3DAnalysis() { ESRI.ArcGIS.esriSystem.IExtensionManagerAdmin iExtensionManagerAdmin = new ESRI.ArcGIS.esriSystem.ExtensionManagerClass(); UID iUid3D = new UIDClass(); iUid3D.Value = "{94305472-592E-11D4-80EE-00C04FA0ADF8}"; object o = new object(); iExtensionManagerAdmin.AddExtension(iUid3D, ref o); IExtensionConfig iExtensionConfig = (IExtensionConfig)(iExtensionManagerAdmin as IExtensionManager).FindExtension(iUid3D); iExtensionConfig.State = esriExtensionState.esriESEnabled; }
private void chkExtension_CheckedChanged(object sender, System.EventArgs e) { //Get the extension manager IExtensionManager extensionManager = (IExtensionManager)m_ExtensionManagerAdmin; //Get the extension from the extension manager IExtensionConfig extensionConfig = (IExtensionConfig)extensionManager.FindExtension("Zoom Factor Extension"); //Set the enabled state if (chkExtension.CheckState == CheckState.Checked) { extensionConfig.State = esriExtensionState.esriESEnabled; } else { extensionConfig.State = esriExtensionState.esriESDisabled; } }
public void OnCreate(object hook) { m_pApplication = hook as IApplication; m_pMxDoc = (IMxDocument)m_pApplication.Document; m_pMap = (IMap)m_pMxDoc.FocusMap; UID pUID = new UIDClass(); pUID.Value = "CoM_GISTools.CExtension"; m_pExtension = (IExtensionConfig)m_pApplication.FindExtensionByCLSID(pUID); m_bitmap = new System.Drawing.Bitmap(GetType().Assembly.GetManifestResourceStream("CoM_GISTools.Images.print_orange.bmp")); // CoM_GISTools.DataFrame.CDataFrame.bmp")); if (m_bitmap != null) { m_bitmap.MakeTransparent(m_bitmap.GetPixel(1, 1)); m_hBitmap = m_bitmap.GetHbitmap(); } }
public static IExtensionConfig GetNAXConfiguration(IApplication app) { IExtensionConfig extConfig = null; try { if (app != null) { UID extCLSID = new UIDClass(); extCLSID.Value = "{C967BD39-1118-42EE-AAAB-B31642C89C3E}"; // Network Analyst extConfig = app.FindExtensionByCLSID(extCLSID) as IExtensionConfig; } } catch { extConfig = null; } return(extConfig); }
private void ToggleSA(bool toggle) { UID puid = new UID(); puid.Value = "esriGeoAnalyst.SAExtension.1"; object v = 0; IExtensionManagerAdmin pLicAdmin = new ExtensionManagerClass(); pLicAdmin.AddExtension(puid, ref v); IExtensionManager pLicManager = pLicAdmin as IExtensionManager; IExtensionConfig pExtensionConfig = pLicManager.FindExtension(puid) as IExtensionConfig; if (toggle) { pExtensionConfig.State = esriExtensionState.esriESEnabled; } else { pExtensionConfig.State = esriExtensionState.esriESDisabled; } }
private bool method_2() { bool result; try { IExtensionManagerAdmin extensionManagerAdmin = new ExtensionManager() as IExtensionManagerAdmin; UID uID = new UID(); uID.Value = "esriGeoDatabase.DddServerEnvironment"; object obj = null; extensionManagerAdmin.AddExtension(uID, ref obj); IExtensionManager extensionManager = extensionManagerAdmin as IExtensionManager; IExtensionConfig extensionConfig = extensionManager.FindExtension(uID) as IExtensionConfig; extensionConfig.State = esriExtensionState.esriESEnabled; result = true; return(result); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } result = false; return(result); }
public void Initialize(IExtensionConfig config) { this.Hub = new VideoHub(); }
public void Initialize(IExtensionConfig config) { myFirstHub = new MyFirstHub(); }
public static void UpdateEIDArrayParameterValuesFromEIDLists(INetworkAnalystExtension nax, Dictionary <string, List <int> > eidsBySourceName, string baseName) { if (nax == null) { return; } bool naxEnabled = false; IExtensionConfig naxConfig = nax as IExtensionConfig; naxEnabled = naxConfig.State == esriExtensionState.esriESEnabled; if (!naxEnabled) { return; } INAWindow naWindow = nax.NAWindow; INALayer naLayer = null; INAContext naContext = null; INetworkDataset nds = null; naLayer = naWindow.ActiveAnalysis; if (naLayer != null) { naContext = naLayer.Context; } if (naContext != null) { nds = naContext.NetworkDataset; } if (nds == null) { return; } IDatasetComponent dsComponent = nds as IDatasetComponent; IDENetworkDataset deNet = dsComponent.DataElement as IDENetworkDataset; INASolver naSolver = naContext.Solver; INASolverSettings2 naSolverSettings2 = naSolver as INASolverSettings2; if (naSolverSettings2 == null) { return; } string prefix = GetEIDArrayPrefixFromBaseName(baseName); VarType vt = GetEIDArrayParameterType(); int cAttributes = nds.AttributeCount; for (int a = 0; a < cAttributes; ++a) { INetworkAttribute2 netAttribute = nds.get_Attribute(a) as INetworkAttribute2; IArray netParams = netAttribute.Parameters; int cParams = netParams.Count; object paramValue; for (int p = 0; p < cParams; ++p) { INetworkAttributeParameter param = netParams.get_Element(p) as INetworkAttributeParameter; if (param.VarType != (int)vt) { continue; } string paramName = param.Name; string sourceName = GetSourceNameFromParameterName(prefix, paramName); if (sourceName.Length == 0) { continue; } List <int> eids = null; if (eidsBySourceName.TryGetValue(sourceName, out eids)) { if (eids != null) { if (eids.Count == 0) { eids = null; } } } paramValue = (eids != null) ? eids.ToArray() : null; naSolverSettings2.set_AttributeParameterValue(netAttribute.Name, param.Name, paramValue); } } }
private static Dictionary <string, List <int> > GetEIDListsBySourceName(INetworkAnalystExtension nax, object searchObject, string baseName) { if (nax == null) { return(null); } bool naxEnabled = false; IExtensionConfig naxConfig = nax as IExtensionConfig; naxEnabled = naxConfig.State == esriExtensionState.esriESEnabled; if (!naxEnabled) { return(null); } INAWindow naWindow = nax.NAWindow; INALayer naLayer = null; INAContext naContext = null; INetworkDataset nds = null; naLayer = naWindow.ActiveAnalysis; if (naLayer != null) { naContext = naLayer.Context; } if (naContext != null) { nds = naContext.NetworkDataset; } INetworkQuery netQuery = nds as INetworkQuery; if (netQuery == null) { return(null); } bool oidSearch = false; bool geometrySearch = false; if (searchObject == null) { return(null); } else if (searchObject is Dictionary <string, ILongArray> ) { oidSearch = true; } else if (searchObject is IGeometry) { geometrySearch = true; } else { return(null); } VarType vt = GetEIDArrayParameterType(); List <string> sourceNames = FindParameterizedSourceNames(nds, baseName, vt); Dictionary <string, List <int> > eidsBySourceName = new Dictionary <string, List <int> >(); foreach (string sourceName in sourceNames) { INetworkSource netSource = nds.get_SourceByName(sourceName); int sourceID = netSource.ID; List <int> eids = new List <int>(); if (oidSearch) { Dictionary <string, ILongArray> oidArraysBySourceName = (Dictionary <string, ILongArray>)searchObject; ILongArray oids = null; IEnumNetworkElement enumNetElement; INetworkElement netElement; if (oidArraysBySourceName.TryGetValue(sourceName, out oids)) { enumNetElement = netQuery.get_ElementsByOIDs(sourceID, oids); enumNetElement.Reset(); netElement = enumNetElement.Next(); while (netElement != null) { eids.Add(netElement.EID); netElement = enumNetElement.Next(); } } } else if (geometrySearch) { IGeometry searchGeometry = (IGeometry)searchObject; if (searchGeometry != null && !searchGeometry.IsEmpty) { IGeometry elementGeometry = null; esriNetworkElementType elementType = esriNetworkElementType.esriNETEdge; int eid = -1; // Search for the network dataset layer associated with the active analysis layer or create one using the // network dataset if matching one not found. // If, for example, multiple network dataset layers are added to the map, the active analysis layer // might not reference the current network dataset layer (nax.CurrentNetworkLayer). INetworkLayer ndsLayer = new NetworkLayerClass(); ndsLayer.NetworkDataset = nds; int count = nax.NetworkLayerCount; for (int i = 0; i < count; ++i) { ndsLayer = nax.get_NetworkLayer(i); if (ndsLayer.NetworkDataset == nds) { break; } else { ndsLayer = null; } } if (ndsLayer == null) { ndsLayer = new NetworkLayerClass(); ndsLayer.NetworkDataset = nds; } IEnumLocatedNetworkElement enumLocatedNetElement = null; if (ndsLayer != null) { enumLocatedNetElement = ndsLayer.SearchLocatedNetworkElements(sourceName, searchGeometry); enumLocatedNetElement.Reset(); eid = enumLocatedNetElement.Next(ref elementGeometry, ref elementType); while (eid != -1) { eids.Add(eid); eid = enumLocatedNetElement.Next(ref elementGeometry, ref elementType); } } } } eidsBySourceName.Add(sourceName, eids); } return(eidsBySourceName); }
public void Initialize(IExtensionConfig config) { this.foxitReaderHub = new FoxitReaderHub(); }
public static void PushParameterValuesToNetwork(INetworkAnalystExtension nax) { try { if (nax == null) { return; } bool naxEnabled = false; IExtensionConfig naxConfig = nax as IExtensionConfig; naxEnabled = naxConfig.State == esriExtensionState.esriESEnabled; if (!naxEnabled) { return; } INAWindow naWindow = nax.NAWindow; INALayer naLayer = null; INAContext naContext = null; INetworkDataset nds = null; naLayer = naWindow.ActiveAnalysis; if (naLayer != null) { naContext = naLayer.Context; } if (naContext != null) { nds = naContext.NetworkDataset; } if (nds == null) { return; } IDatasetComponent dsComponent = nds as IDatasetComponent; IDENetworkDataset deNet = dsComponent.DataElement as IDENetworkDataset; INASolver naSolver = naContext.Solver; INASolverSettings2 naSolverSettings2 = naSolver as INASolverSettings2; if (naSolverSettings2 == null) { return; } INetworkAttribute2 netAttribute; string attributeName; IArray netParameters; INetworkAttributeParameter netParameter; string paramName; int cParameters; object paramValue; int cAttributes = nds.AttributeCount; for (int a = 0; a < cAttributes; ++a) { netAttribute = nds.get_Attribute(a) as INetworkAttribute2; attributeName = netAttribute.Name; netParameters = netAttribute.Parameters; cParameters = netParameters.Count; for (int p = 0; p < cParameters; ++p) { netParameter = netParameters.get_Element(p) as INetworkAttributeParameter; paramName = netParameter.Name; paramValue = naSolverSettings2.get_AttributeParameterValue(attributeName, paramName); netParameter.Value = paramValue; } netAttribute.Refresh(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Push Parameter Values To Network"); } }
public void Initialize(IExtensionConfig config) { screenshotHub = new ScreenshotHub(); }