/// <summary> /// This method is used to get the tool tip of the selected temporary geometry. /// </summary> /// <param name="gTDisplayService"></param> /// <param name="strTempGeoDisplayPath"></param> /// <param name="strTempGeoDisplayName"></param> /// <param name="strTempGeoToolTip"></param> /// <returns></returns> private string GetToolTipOfTemporaryGeometry(IGTDisplayService gTDisplayService, out string strTempGeoDisplayPath, out string strTempGeoDisplayName, string strTempGeoToolTip) { strTempGeoDisplayPath = gTDisplayService.SelectedDisplayControlNode.DisplayPathName; strTempGeoDisplayName = gTDisplayService.SelectedDisplayControlNode.DisplayName; if (!string.IsNullOrEmpty(strTempGeoDisplayPath) && !string.IsNullOrEmpty(strTempGeoDisplayName)) { IGTPoint ptTempGeo = gTDisplayService.GetRange(strTempGeoDisplayPath, strTempGeoDisplayName).BottomLeft; IGTDDCKeyObjects gTDDCTempGeoKeyObjects = assetHistoryModel.m_Application.ActiveMapWindow.LocateService.Locate(ptTempGeo, 5, -1, GTSelectionTypeConstants.gtmwstSelectAll); if (gTDDCTempGeoKeyObjects.Count > 0) { foreach (IGTDDCKeyObject ddcKey in gTDDCTempGeoKeyObjects) { if (ddcKey.FNO == 400) { strTempGeoToolTip = Convert.ToString(gTDDCTempGeoKeyObjects[0].Recordset.Fields["G3E_TOOLTIP"].Value); break; } } } } if (string.IsNullOrEmpty(strTempGeoToolTip)) { strTempGeoToolTip = gTDisplayService.SelectedDisplayControlNode.DisplayName; } return(strTempGeoToolTip); }
/// <summary> /// The entry point for the custom command. /// </summary> /// <param name="CustomCommandHelper">Provides notification to the system that the command has finished</param> public void Activate(IGTCustomCommandHelper CustomCommandHelper) { try { m_CustomCommandHelper = CustomCommandHelper; // Get the job information. Used for validating command enabling. if (!CommonDT.GetJobInformation()) { m_CustomCommandHelper.Complete(); return; } IGTDDCKeyObjects oGTDCKeys = GTClassFactory.Create <IGTDDCKeyObjects>(); // Check if selected feature is a Transformer. oGTDCKeys = m_Application.SelectedObjects.GetObjects(); if (!(oGTDCKeys[0].FNO == ConstantsDT.FNO_OH_XFMR || oGTDCKeys[0].FNO == ConstantsDT.FNO_UG_XFMR)) { MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_SC_INVALID_FEATURE_SELECTED, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); m_CustomCommandHelper.Complete(); return; } frmStreetLightVoltageDrop.m_CustomCommandHelper = CustomCommandHelper; frmStreetLightVoltageDrop.m_TransactionManager = m_TransactionManager; frmStreetLightVoltageDrop.StartPosition = FormStartPosition.CenterScreen; frmStreetLightVoltageDrop.Show(m_Application.ApplicationWindow); } catch (Exception ex) { MessageBox.Show(m_Application.ApplicationWindow, ex.Message, ConstantsDT.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); CustomCommandHelper.Complete(); } }
public CheckValidation(IGTDataContext gTDC, IGTDDCKeyObjects gTDDCKey, IGTApplication gTApp, IGTCustomCommandHelper gTCCHeler) { gTDataContext = gTDC; gTDDCKeyObjects = gTDDCKey; gTApplication = gTApp; gTCustomCommandHelper = gTCCHeler; }
/// <summary> /// Intialize variables and check selected feature is valid. /// </summary> /// <param name="CustomCommandHelper"></param> public void Activate(Intergraph.GTechnology.API.IGTCustomCommandHelper CustomCommandHelper) { IGTDDCKeyObjects ddcKeyObjects = GTClassFactory.Create <IGTDDCKeyObjects>(); gtApp = GTClassFactory.Create <IGTApplication>(); try { gtCustomCommandHelper = CustomCommandHelper; gtApp.SelectedObjectsChanged += GtApp_SelectedObjectsChanged; gtCustomCommandHelper.MouseMove += new EventHandler <GTMouseEventArgs>(gtCustomCommandHelper_MouseMove); if (gtApp.DataContext.IsRoleGranted("PRIV_MGMT_LAND")) { if (gtApp.SelectedObjects.FeatureCount == 1) { g3eFno_trg = gtApp.SelectedObjects.GetObjects()[0].FNO; g3eFid_trg = gtApp.SelectedObjects.GetObjects()[0].FID; if (!ValidateSelectedFeature(g3eFno_trg)) { MessageBox.Show(ValidationMsg, msgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); CleanUp(); } } } else { MessageBox.Show("Command Access Denied. Please contact System Administrator", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning); CleanUp(); } } catch (Exception ex) { MessageBox.Show("Error " + ex.Message, msgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); CleanUp(); } }
public SupplementalAgreementPlotModel(IGTDataContext gTDC, IGTDDCKeyObjects gTDDCKey, IGTApplication gTApp, IGTCustomCommandHelper gTCCHeler) { gTDataContext = gTDC; gTDDCKeyObjects = gTDDCKey; gTApplication = gTApp; gTCustomCommandHelper = gTCCHeler; }
public void Activate() { string featureState = string.Empty; List <int> fidList = new List <int>(); IGTDDCKeyObjects selectedObjects = GTClassFactory.Create <IGTDDCKeyObjects>(); try { IGTDDCKeyObjects ddcKeyObjects = m_iGtApp.SelectedObjects.GetObjects(); foreach (IGTDDCKeyObject ddcKeyObject in ddcKeyObjects) { if (!fidList.Contains(ddcKeyObject.FID)) { fidList.Add(ddcKeyObject.FID); selectedObjects.Add(ddcKeyObject); } } foreach (IGTDDCKeyObject selectedObject in selectedObjects) { featureState = GetFeatureState(selectedObject); if (string.IsNullOrEmpty(featureState) || !m_featureStatesList.Contains(featureState)) { MessageBox.Show("One or more features are in an invalid feature state for this operation.", "G/Techonology", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } if (!m_TransactionManager.TransactionInProgress) { m_TransactionManager.Begin("updating feature state..."); } int current = 1; int totalCount = selectedObjects.Count; foreach (IGTDDCKeyObject selectedObject in selectedObjects) { m_iGtApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Transitioning " + current + " out of " + totalCount + " features."); SetFeatureState(selectedObject); current++; } m_TransactionManager.Commit(); m_TransactionManager.RefreshDatabaseChanges(); m_iGtApp.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Selected features were transitioned successfully."); } catch (Exception ex) { m_TransactionManager.Rollback(); MessageBox.Show("Error during execution of Complete Feature custom command." + ex.Message, "G/Techonology", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { m_TransactionManager = null; } }
private void ProcessActiveStructureDDC(IGTDDCKeyObjects ddcStructureList) { try { foreach (IGTDDCKeyObject ddcobj in ddcStructureList) { if ((ddcobj.Geometry.Type == GTGeometryTypeConstants.gtgtOrientedPointGeometry) || (ddcobj.Geometry.Type == GTGeometryTypeConstants.gtgtPointGeometry)) { IGTKeyObject koStructure = oDC.OpenFeature(ddcobj.FNO, ddcobj.FID); oRelationService.ActiveFeature = koStructure; IGTKeyObjects koOwnsList = oRelationService.GetRelatedFeatures(2); if (koOwnsList == null) { continue; } if (koOwnsList.Count == 0) { continue; } GTActiveStructure oStructure = new GTActiveStructure(); oStructure.G3E_FID = ddcobj.FID; oStructure.G3E_FNO = ddcobj.FNO; IGTOrientedPointGeometry ogeom = ddcobj.Geometry as IGTOrientedPointGeometry; oStructure.OGG_X1 = ogeom.Origin.X; oStructure.OGG_Y1 = ogeom.Origin.Y; oStructure.OGG_Z1 = ogeom.Origin.Z; string sid = CommandUtilities.GetCommonNStructureID(koStructure, oDiag); if (koOwnsList != null) { if (koOwnsList.Count > 0) { foreach (IGTKeyObject koObj in koOwnsList) { if (koObj.FNO == 56) { oStructure.StreetlightKOList.Add(koObj); } } } } this.oActiveStructureList.Add(oStructure); } } } catch (Exception ex) { CommandUtilities.LogException(oDiag, "ProcessActiveStreetLightDDC", ex); throw ex; } }
public void Activate(IGTCustomCommandHelper CustomCommandHelper) { IGTDDCKeyObjects ddcKeyObjects = GTClassFactory.Create <IGTDDCKeyObjects>(); List <int> fidList = new List <int>(); try { m_oGTApp = GTClassFactory.Create <IGTApplication>(); m_oGTCustomCommandHelper = CustomCommandHelper; m_ooddcKeyObjects = GTClassFactory.Create <IGTDDCKeyObjects>(); ddcKeyObjects = m_oGTApp.Application.SelectedObjects.GetObjects(); foreach (IGTDDCKeyObject ddcKeyObject in ddcKeyObjects) { if (!fidList.Contains(ddcKeyObject.FID)) { fidList.Add(ddcKeyObject.FID); m_ooddcKeyObjects.Add(ddcKeyObject); } } m_oGTApp.Application.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Initializing RemoveFeature..."); m_oGTApp.Application.BeginWaitCursor(); SetJobAttributes(); if (Validate()) { RemoveFeature(); if (!m_ostatusExit) { SynchronizeWP(); } if (m_oCorrectionsModeIndex != -1) { m_oGTApp.Application.Properties.Remove("CorrectionsMode"); string mapCaption = m_oGTApp.Application.ActiveMapWindow.Caption.Replace("CORRECTIONS MODE - ", ""); m_oGTApp.Application.ActiveMapWindow.Caption = mapCaption; } } if (!m_ostatusExit) { ExitCommand(); } } catch (Exception ex) { m_oGTTransactionManager.Rollback(); MessageBox.Show("Error in Remove Feature command: " + ex.Message, "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Error); ExitCommand(); } }
public void Activate(IGTCustomCommandHelper CustomCommandHelper) { try { customCommandHelper = CustomCommandHelper; if (transactionManager != null) { transactionManager.Begin("Blanket Unitization"); selectedFeatures = gtApp.SelectedObjects.GetObjects(); bool oneFeatureType = true; short fnoChecker; string errorMessage = ""; if (selectedFeatures.Count > 1) { fnoChecker = selectedFeatures[0].FNO; foreach (IGTDDCKeyObject feature in selectedFeatures) { if (fnoChecker != feature.FNO) { oneFeatureType = false; errorMessage = "Multiple feature types selected, please retry command after selecting features of the same type."; } } } if (oneFeatureType) { switch (selectedFeatures[0].FNO) { case g_Service_Line_FNO: case g_Secondary_Box_FNO: featureHandler(); break; case g_Gaurd_Light_FNO: guardLightHandler(); break; default: MessageBox.Show("Invalid feature selected, please select a service line, secondary box, or guard light."); break; } customCommandHelper.Complete(); } else { MessageBox.Show(errorMessage, "GTechnology"); customCommandHelper.Complete(); } } }catch (Exception e) { MessageBox.Show("Error in ccFieldActivity.Activate " + e.Message + "."); transactionManager.Rollback(); customCommandHelper.Complete(); } }
/// <summary> /// This method created the keyobject if the select set contains exactly one feature and if it is a structure, the form defaults to querying by Structure ID. /// </summary> /// <param name="selectedDDDCKeyObjects"></param> /// <returns></returns> private void CreateKeyObjectOfSelectedDDC(IGTDDCKeyObjects selectedDDDCKeyObjects) { try { ConfirmSelectedFeatureIsStructure(selectedDDDCKeyObjects[0].FID, selectedDDDCKeyObjects[0].FNO); } catch { throw; } }
/// <summary> /// Highlight feature in the active map window /// </summary> /// <param name="FNO"></param> /// <param name="FID"></param> public static void HighlightFeature(short FNO, int FID) { IGTApplication app = GTClassFactory.Create <IGTApplication>(); IGTDDCKeyObjects keyObjs = app.DataContext.GetDDCKeyObjects(FNO, FID, GTComponentGeometryConstants.gtddcgAllPrimary); if (keyObjs != null && keyObjs.Count > 0) { app.ActiveMapWindow.HighlightedObjects.Clear(); app.ActiveMapWindow.HighlightedObjects.AddMultiple(keyObjs); app.RefreshWindows(); } }
/// <summary> /// Mouse click event handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void m_oGTCustomCommandHelper_Click(object sender, GTMouseEventArgs e) { IGTLocateService selectedFeaturesService; IGTDDCKeyObjects selectedFeatures; try { if (e.Button == 1) { selectedFeaturesService = m_iGtApplication.ActiveMapWindow.LocateService; selectedFeatures = selectedFeaturesService.Locate(e.WorldPoint, -1, 0, GTSelectionTypeConstants.gtmwstSelectAll); IGTDDCKeyObjects selectedObjects = GTClassFactory.Create <IGTDDCKeyObjects>(); List <int> fidList = new List <int>(); foreach (IGTDDCKeyObject ddcKeyObject in selectedFeatures) { if (!fidList.Contains(ddcKeyObject.FID)) { fidList.Add(ddcKeyObject.FID); selectedObjects.Add(ddcKeyObject); } } if (selectedObjects == null || selectedObjects.Count == 0) { return; } if ((selectedObjects[0].FNO == m_originalObject.FNO) && (selectedObjects[0].FID != m_originalObject.FID)) // Restrict selection to features of the same class as the original feature and make sure same feature instance is not selected { m_invalidFeatureMessage = false; if (!m_selectedObjects.Any(o => o.FID == selectedObjects[0].FID)) { m_selectedObjects.Add(selectedObjects[0]); m_iGtApplication.ActiveMapWindow.HighlightedObjects.AddSingle(selectedObjects[0]); } } else { m_invalidFeatureMessage = true; m_iGtApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, "Invalid feature selected.Selected features are not of same class as source feature or selected feature itself is source feature."); } } } catch (Exception ex) { if (m_oGTTransactionManager.TransactionInProgress) { m_oGTTransactionManager.Rollback(); } ExitCommand(); MessageBox.Show("Error during execution of Copy Ancillaries custom command." + Environment.NewLine + ex.Message, "G/Techonology", MessageBoxButtons.OK, MessageBoxIcon.Error); throw; } }
public SelectedTransformerProperties(IGTDDCKeyObjects p_SelectedObjects) { try { m_keyobjects = p_SelectedObjects; m_App = GTClassFactory.Create <IGTApplication>(); GetDistinctSelectedTransformerFNO(); } catch (Exception) { throw; } }
private void ProcessActiveStreetLightDDC(IGTDDCKeyObjects ddcStreetLightList) { try { foreach (IGTDDCKeyObject ddcobj in ddcStreetLightList) { if ((ddcobj.Geometry.Type == GTGeometryTypeConstants.gtgtOrientedPointGeometry) || (ddcobj.Geometry.Type == GTGeometryTypeConstants.gtgtPointGeometry)) { IGTKeyObject koStreetLight = oDC.OpenFeature(ddcobj.FNO, ddcobj.FID); oRelationService.ActiveFeature = koStreetLight; IGTKeyObjects koOwnedByList = oRelationService.GetRelatedFeatures(3); // Owned By if (koOwnedByList == null) { continue; } if (koOwnedByList.Count == 0) { continue; } //Should only be one IGTKeyObject that owns a streetlight //Need Common_N data on both the structure and the streetlight IGTKeyObject koStructure = koOwnedByList[0]; GTActiveStreetLight objStreetLight = CommandUtilities.GetCommonNActiveFeature(koStreetLight, koStructure, oDiag); if (objStreetLight == null) { continue; } objStreetLight.G3E_FID = ddcobj.FID; objStreetLight.G3E_FNO = ddcobj.FNO; objStreetLight.Structure_FID = koStructure.FID; objStreetLight.StructureFNO = koStructure.FNO; this.oActiveList.Add(objStreetLight); } } } catch (Exception ex) { CommandUtilities.LogException(oDiag, "ProcessActiveStreetLightDDC", ex); throw ex; } }
private void DoActiveMapWindowByStructure() { try { short[] fnoToLocate = new short[3]; fnoToLocate[0] = 107; //Streetlight Standard fnoToLocate[1] = 110; //pole fnoToLocate[2] = 114; //Misc Structure if (this.oLocate == null) { throw new Exception("IGTLocateService object is null."); } if (this.oLocationCriteria == null) { throw new Exception("The map extents for the active map window is null."); } if (this.oRelationService == null) { throw new Exception("IGTRelationshipService is null."); } this.oLocate.FenceMode = GTFenceMode.gtfmInside; IGTDDCKeyObjects activeStructureDDCList = this.oLocate.Locate(this.oLocationCriteria, 0, -1, GTSelectionTypeConstants.gtmwstSelectAll, fnoToLocate); if (activeStructureDDCList == null) { CommandUtilities.LogMessage(this.oDiag, "DoActiveMapWindowByStructure", "IGTLocateService", "There are no structures or street lights in the active map window."); return; } if (activeStructureDDCList.Count == 0) { CommandUtilities.LogMessage(this.oDiag, "LoadActiveDDCObjects", "IGTLocateService", "There are no street lights in the active map window."); //throw new Exception("No features were located in the active map window"); return; } ProcessActiveStructureDDC(activeStructureDDCList); } catch (Exception ex) { CommandUtilities.LogException(oDiag, "DoActiveMapWindow", ex); throw ex; } }
public void Activate(IGTCustomCommandHelper CustomCommandHelper) { try { #region Perform validations m_oGTCustomCommandHelper = CustomCommandHelper; m_oGTTransactionManager.Begin(" begin Repeat reconductoring..."); if (CheckIfNonWrJob()) { ExitCommand(); MessageBox.Show("This command applies only to WR jobs.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } IGTDDCKeyObjects selectedObjects = GTClassFactory.Create <IGTDDCKeyObjects>(); List <int> fidList = new List <int>(); m_ooddcKeyObjects = m_iGtApplication.SelectedObjects.GetObjects(); foreach (IGTDDCKeyObject ddcKeyObject in m_ooddcKeyObjects) { if (!fidList.Contains(ddcKeyObject.FID)) { fidList.Add(ddcKeyObject.FID); selectedObjects.Add(ddcKeyObject); } } m_originalObject = selectedObjects[0]; if (!CheckIfConductorFeature()) { ExitCommand(); MessageBox.Show("This command only applies to conductors.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!ValidateFeatureState()) { ExitCommand(); MessageBox.Show("Select a PPX conductor span from which to copy reconductoring information.", "G/Technology", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } #endregion SubscribeEvents(); CheckFeatureAndGetCno(); ReadCUsWithActivity(); } catch (Exception ex) { ExitCommand(); MessageBox.Show("Error during execution of Repeat Reconductoring custom command." + Environment.NewLine + ex.Message, "G/Techonology", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Activate() { IGTSelectedObjects tmpSelectedObj = null; IGTDDCKeyObjects tmpDDCKeyObjs = null; try { //Set global variables. csGlobals.gApp = GTClassFactory.Create <IGTApplication>(); csGlobals.gDatacont = csGlobals.gApp.DataContext; if (!csGlobals.gGetSysGenPrams()) { return; } // check feature for hyperlink component. tmpSelectedObj = csGlobals.gApp.SelectedObjects; tmpDDCKeyObjs = tmpSelectedObj.GetObjects(); csGlobals.gCCFno = tmpDDCKeyObjs[0].FNO; csGlobals.gCCFid = tmpDDCKeyObjs[0].FID; csGlobals.gCCHyperLnkCno = FeatureHasHyperLnkComp(csGlobals.gCCFno); // if the selected feature has a hyperlink component continue. if (csGlobals.gCCHyperLnkCno != "") { // Create the form. csGlobals.gfrmAddFeatureHyperlink = new frmAddFeatHypLnk(); csGlobals.gfrmAddFeatureHyperlink.ShowDialog(); } else { tmpDDCKeyObjs = null; tmpSelectedObj = null; return; } } catch (Exception ex) { MessageBox.Show("Error in Activate: " + ex.Message, "Attach Feature Hyperlink Document", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void DoActiveMapWindowByStreetlight() { try { if (this.oLocate == null) { throw new Exception("IGTLocateService object is null."); } if (this.oLocationCriteria == null) { throw new Exception("The map extents for the active map window is null."); } if (this.oRelationService == null) { throw new Exception("IGTRelationshipService is null."); } this.oLocate.FenceMode = GTFenceMode.gtfmInside; IGTDDCKeyObjects activeSLightDDCList = this.oLocate.Locate(this.oLocationCriteria, 0, -1, GTSelectionTypeConstants.gtmwstSelectAll, new short[] { 56 }); // 56=Street Light if (activeSLightDDCList == null) { CommandUtilities.LogMessage(this.oDiag, "LoadActiveDDCObjects", "IGTLocateService", "There are no street lights in the active map window."); //throw new Exception("No features were located in the active map window"); return; } if (activeSLightDDCList.Count == 0) { CommandUtilities.LogMessage(this.oDiag, "LoadActiveDDCObjects", "IGTLocateService", "There are no street lights in the active map window."); //throw new Exception("No features were located in the active map window"); return; } ProcessActiveStreetLightDDC(activeSLightDDCList); } catch (Exception ex) { CommandUtilities.LogException(oDiag, "DoActiveMapWindow", ex); throw ex; } }
/// <summary> /// The entry point for the custom command. /// </summary> /// <param name="CustomCommandHelper">Provides notification to the system that the command has finished</param> public void Activate(IGTCustomCommandHelper CustomCommandHelper) { try { m_CustomCommandHelper = CustomCommandHelper; // Get the job information. Used for validating command enabling. if (!CommonDT.GetJobInformation()) { m_CustomCommandHelper.Complete(); return; } if (m_Application.SelectedObjects.FeatureCount > 1) { MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_MULTIPLE_FEATURES_SELECTED, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); m_CustomCommandHelper.Complete(); return; } else if (m_Application.SelectedObjects.FeatureCount == 1) { // Only one feature in select set. Check if selected feature is a Duct Bank. IGTDDCKeyObjects oGTDCKeys = m_Application.SelectedObjects.GetObjects(); IGTDDCKeyObject objKeyObject = GTClassFactory.Create <IGTDDCKeyObject>(); if (oGTDCKeys[0].FNO != ConstantsDT.FNO_UG_SECCOND && oGTDCKeys[0].FNO != ConstantsDT.FNO_UG_COND) { MessageBox.Show(m_Application.ApplicationWindow, ConstantsDT.ERROR_CPT_INVALID_FEATURE_SELECTED, ConstantsDT.COMMAND_NAME_CABLE_PULL_TENSION, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); m_CustomCommandHelper.Complete(); return; } } frmCablePullTension.m_CustomCommandHelper = CustomCommandHelper; frmCablePullTension.StartPosition = FormStartPosition.CenterScreen; frmCablePullTension.Show(m_Application.ApplicationWindow); return; } catch (Exception ex) { MessageBox.Show(m_Application.ApplicationWindow, "IGTCustomCommandModeless_Activate:" + Environment.NewLine + "Error (" + ex.Source + ") - " + ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); CustomCommandHelper.Complete(); } }
public void Terminate() { try { UnsubscribeEvents(); if (m_oEditService != null) { if (m_oEditService.GeometryCount > 0) { m_oEditService.RemoveAllGeometries(); } } m_oGTApplication.Application.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, ""); if (m_oGTTransactionManager != null && m_oGTTransactionManager.TransactionInProgress) { m_oGTTransactionManager.Rollback(); m_oGTTransactionManager.RefreshDatabaseChanges(); } m_oGTApplication.EndWaitCursor(); m_oGTApplication.SelectedObjects.Clear(); m_oGTApplication.RefreshWindows(); } catch (Exception ex) { MessageBox.Show("Error " + ex.Message, m_sMsgBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { m_oGTApplication = null; m_oGTCustomCommandHelper = null; m_osrcGeometry = null; m_otrgFeature = null; m_trgComponent = null; m_oEditService = null; m_oGTTransactionManager = null; m_EditObjects = null; m_locatedObjects = null; m_snapPoint = null; } }
private void ExploreFeatures() { // Similar to the product's dialog, if multiple rows are selected, // the system does not explore or select the features. if(1 == this.dgvErrors.SelectedRows.Count) { IGTFeatureExplorerService fes = GTClassFactory.Create<IGTFeatureExplorerService>(); IGTApplication app = GTClassFactory.Create<IGTApplication>(); DataGridViewRow row = this.dgvErrors.SelectedRows[0]; short FNO = Convert.ToInt16(row.Cells[colFNO.Index].Value); int FID = Convert.ToInt32(row.Cells[colFID.Index].Value); IGTKeyObject keyObject = app.DataContext.OpenFeature(FNO, FID); fes.ExploreFeature(keyObject, "Review"); app.SelectedObjects.Clear(); IGTDDCKeyObjects ddcKeyobjects = app.DataContext.GetDDCKeyObjects(FNO, FID, GTComponentGeometryConstants.gtddcgAllGeographic); app.SelectedObjects.Add(GTSelectModeConstants.gtsosmAllComponentsInActiveLegend, ddcKeyobjects[0]); fes.Visible = true; } }
public static void LogStreetLightPoints(GTDiagnostics oDiag, IGTDDCKeyObjects ddc56List) { try { LogMessage(oDiag, "StreetLightLogTestPoints", "TestPoints", "All located streetlights."); foreach (IGTDDCKeyObject ddc in ddc56List) { if ((ddc.Geometry.Type == GTGeometryTypeConstants.gtgtOrientedPointGeometry) || (ddc.Geometry.Type == GTGeometryTypeConstants.gtgtPointGeometry)) { LogMessage(oDiag, "StreetLightLogTestPoints", "TestPoints", "FID =" + ddc.FID.ToString() + " FNO = " + ddc.FNO.ToString() + " Geometry = " + ddc.Geometry.Type.ToString()); LogMessage(oDiag, "StreetLightLogTestPoints", "TestPoints", "Location = " + ddc.Geometry.FirstPoint.ToString()); } } } catch (Exception ex) { throw ex; } }
private void ExitCommand() { try { if (m_oGTTransactionManager.TransactionInProgress) { m_oGTTransactionManager.Commit(); m_oGTTransactionManager.RefreshDatabaseChanges(); } m_ooddcKeyObjects.Clear(); m_oGTApp.Application.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, ""); UnsubscribeEvents(); if (m_oGTCustomCommandHelper != null) { m_oGTCustomCommandHelper.Complete(); m_oGTCustomCommandHelper = null; } m_oGTApp.Application.EndWaitCursor(); m_oGTApp.Application.RefreshWindows(); } catch (Exception) { throw; } finally { m_oGTApp = null; m_oGTCustomCommandHelper = null; m_ooddcKeyObjects = null; m_oGTTransactionManager = null; m_ofeature = null; m_oOwnedFeatures = null; m_ocommonComponent = null; m_oCUComponent = null; } }
public void FilterLocatedCandidates(bool CanBreak, IGTDDCKeyObjects Candidates, IGTPoint WorldPoint, IGTMapWindow MapWindow) { try { //Added an additional check to see if there are ANY candidate connections to check if (ActiveFeature.FNO == Bypass_FNO) { if (Candidates.Count > 0) { for (int currentCandidateIdx = 1; currentCandidateIdx >= 0; currentCandidateIdx--) { Candidates.RemoveAt(currentCandidateIdx); } } } } catch (Exception ex) { throw ex; } }
/// <summary> /// Custom command mouse move event /// </summary> /// <param name="sender">object sender</param> /// <param name="e">GTMouseEventArgs</param> /// <returns></returns> void m_oGTCustomCommandHelper_MouseMove(object sender, GTMouseEventArgs e) { m_oGTApplication.ActiveMapWindow.MousePointer = GTMousePointerConstants.gtmwmpCrossHair; if ((m_blFirstPointSelected)) { m_oGTApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, m_sStatusBarMsg2); //move the selected feature m_oEditService.Move(e.WorldPoint); m_blSecondPointSelected = true; m_blPointSelected = false; m_locatedObjects = m_oGTApplication.ActiveMapWindow.LocateService.Locate(e.WorldPoint, 3, 1, GTSelectionTypeConstants.gtmwstSelectSingle); } else { m_oGTApplication.SetStatusBarText(GTStatusPanelConstants.gtaspcMessage, m_sStatusBarMsg1); if (!m_blPointSelected) { m_blFirstPointSelected = false; m_blPointSelected = true; } } }
/// <summary> /// The entry point for the custom command. /// </summary> /// <param name="CustomCommandHelper">Provides notification to the system that the command has finished</param> public void Activate(IGTCustomCommandHelper CustomCommandHelper) { try { m_Application.BeginWaitCursor(); // Get feature number and feature identifier for feature in select set IGTDDCKeyObjects oGTDCKeys = GTClassFactory.Create <IGTDDCKeyObjects>(); oGTDCKeys = m_Application.SelectedObjects.GetObjects(); short fno = oGTDCKeys[0].FNO; int fid = oGTDCKeys[0].FID; // Call execute method on UpdateTrace object to run trace and process results UpdateTrace updateTrace = new UpdateTrace(CUSTOM_COMMAND_NUMBER, CUSTOM_COMMAND_NAME); m_TransactionManager.Begin("Update Trace"); if (updateTrace.Execute(fno, fid)) { m_TransactionManager.Commit(); } else { m_TransactionManager.Rollback(); } updateTrace = null; } catch (Exception ex) { MessageBox.Show(m_Application.ApplicationWindow, "ccUpdateTrace.Activate: Error calling UpdateTrace - " + ex.Message, "G /Technology", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } m_Application.EndWaitCursor(); CustomCommandHelper.Complete(); }
/// <summary> /// Add the FID corresponding to the selected row to the select set. /// </summary> private void AddSelectedFidToSelectedSet() { if (m_GridLoaded) { if (dgvSourceResults.SelectedRows.Count > 0) { short fno; int fid; IGTDDCKeyObjects ddcKO = null; m_Application.SelectedObjects.Clear(); foreach (DataGridViewRow r in dgvSourceResults.SelectedRows) { fno = Convert.ToInt16(r.Cells["Fno"].Value); fid = Convert.ToInt32(r.Cells["FeatureID"].Value); ddcKO = m_Application.DataContext.GetDDCKeyObjects(fno, fid, GTComponentGeometryConstants.gtddcgAllGeographic); if (ddcKO.Count > 0) { m_Application.SelectedObjects.Add(GTSelectModeConstants.gtsosmAllComponentsOfFeature, ddcKO[0]); } } } } }
public void Execute() { double dXoord = 0.0; double dYoord = 0.0; double dZoord = 0.0; IGTGeometry geometry = null; IGTDDCKeyObjects oDDCKeyObjects = default(IGTDDCKeyObjects); IGTApplication igtApp = GTClassFactory.Create <IGTApplication>(); oDDCKeyObjects = igtApp.SelectedObjects.GetObjects(); foreach (IGTDDCKeyObject item in oDDCKeyObjects) { geometry = item.Geometry; } if (geometry != null) { dXoord = ((IGTPointGeometry)geometry).FirstPoint.X; dYoord = ((IGTPointGeometry)geometry).FirstPoint.Y; IGTPoint point = GTClassFactory.Create <IGTPoint>(); point.X = dXoord; point.Y = dYoord; point.Z = 0.0; IGTComponent commonComponent = Components.GetComponent(1); if (commonComponent != null) { if (commonComponent.Recordset.RecordCount > 0) { commonComponent.Recordset.MoveFirst(); commonComponent.Recordset.Fields["OGGX_H"].Value = point.X; commonComponent.Recordset.Fields["OGGY_H"].Value = point.Y; } } //ICoordSystemsMgr oCoordSystemsMgr; //oCoordSystemsMgr = (ICoordSystemsMgr)m_oDataContext.CoordSystemsMgr; //ICoordSystem oCoordSystem; //oCoordSystem = oCoordSystemsMgr.BaseCoordSystem; //double dMeters2Database = 1.0 / oCoordSystem.StorageToProjectionScale; //string strCurrDir = System.IO.Directory.GetCurrentDirectory(); //ICoordSystemsMgr iCSM = new Intergraph.CoordSystems.CoordSystemsMgr(); //ICoordSystem iCS = iCSM.BaseCoordSystem; //iCS.LoadFromFile(strCurrDir + "\\StatePlane.csf"); //ICoordSystem iTargCS = new Intergraph.CoordSystems.CoordSystem(); // //iTargCS.LoadFromFile(strCurrDir + "\\EPSG4326.csf"); //iTargCS.LoadFromFile(strCurrDir + "\\0061_WGS84.csf"); //IAltCoordSystemPath iACSP = iCSM.CreateNamedPath("CSFFileConvert"); //ILinkableTransformation iLink = iACSP.CreateLinkableTransformation("CSFFileConvert", Intergraph.CoordSystems.CSTransformLinkConstants.cstlCoordinateSystem); //ICoordSystem altCS = (ICoordSystem)iLink; //((ICopyable<ICoordSystem>)iTargCS).CopyInto(altCS); //iACSP.AddChainLink(iLink, true, Intergraph.CoordSystems.CSTransDirectionConstants.cstdForward); //ILinkableTransformation iTrans = (ILinkableTransformation)iACSP; //iTrans.TransformPoint(Intergraph.CoordSystems.CSPointConstants.cspENU, 1, Intergraph.CoordSystems.CSPointConstants.cspLLG, 2, ref dXoord, ref dYoord, ref dZoord); //MessageBox.Show(dXoord + " " + dYoord); //--------------------------------------------------------------------------------------------------------------------------- Intergraph.CoordSystems.Interop.CoordSystemClass coords = new CoordSystemClass(); int outrec = 0; ADODB.Recordset rs = DataContext.Execute("select c.* from g3e_dataconnection_optable d , gcoordsystemtable c where " + " d.g3e_username ='******' and d.g3e_csname=c.name", out outrec, (int)ADODB.CommandTypeEnum.adCmdText, new object[0]); rs.MoveFirst(); object[] rowformat = new object[rs.Fields.Count]; for (int ifld = 0; ifld < rs.Fields.Count; ifld++) { rowformat[ifld] = rs.Fields[ifld].Value; } coords.LoadFromGCoordSystemTableRowFormat(rowformat); coords.TransformPoint(Intergraph.CoordSystems.Interop.CSPointConstants.cspUOR, (int)Intergraph.CoordSystems.CSTransformLinkConstants.cstlDatumTransformation, Intergraph.CoordSystems.Interop.CSPointConstants.cspLLO, (int)Intergraph.CoordSystems.CSTransformLinkConstants.cstlDatumTransformation, ref dXoord, ref dYoord, ref dZoord); dXoord = dXoord * 180 / (4 * Math.Atan(1)); dYoord = dYoord * 180 / (4 * Math.Atan(1)); } }
public SupplementalAgreementModel(IGTDataContext gTDataContext, IGTDDCKeyObjects gTDDCKeyObjects) { m_gTDataContext = gTDataContext; m_gTDDCKeyObjects = gTDDCKeyObjects; dataLayer = new DataLayer(gTDataContext, gTDDCKeyObjects); }
/// <summary> /// This method is used to validate the initial conditions of the relocate custom command. /// </summary> /// <param name="relatedFeaturesOWB"></param> /// <returns></returns> private bool ValidateCC(out IGTKeyObjects relatedFeaturesOWB) { bool execute = true; string sql = ""; Recordset rsValidate = null; int reCount = 0; IGTRelationshipService relationShipService = GTClassFactory.Create <IGTRelationshipService>(); relatedFeaturesOWB = GTClassFactory.Create <IGTKeyObjects>(); try { //Validate conditions to run the custom command. // 1. This command applies only to WR jobs. #region First Condition sql = "select G3E_JOBTYPE,G3E_JOBSTATUS from G3E_JOB where G3E_IDENTIFIER=?"; //sql = "select JOB_TYPE,G3E_STATUS from G3E_JOB where G3E_IDENTIFIER=?"; rsValidate = m_gtApplication.DataContext.OpenRecordset(sql, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, m_gtApplication.DataContext.ActiveJob); if (rsValidate.RecordCount > 0) { rsValidate.MoveFirst(); if (!rsValidate.EOF && !rsValidate.BOF) { m_strJobtype = Convert.ToString(rsValidate.Fields[0].Value); m_strStatus = Convert.ToString(rsValidate.Fields[1].Value); } } #endregion if (m_strJobtype == "NON-WR") { MessageBox.Show("This command applies only to WR jobs.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); execute = false; } else { //2. This command applies only to features with CUs. #region Second Condition m_gtDDCKeyObjects = m_gtApplication.Application.SelectedObjects.GetObjects(); m_activeFeatureDDCKey = m_gtDDCKeyObjects[0]; m_selectedFno = m_activeFeatureDDCKey.FNO; m_selectedFid = m_activeFeatureDDCKey.FID; sql = "SELECT count(*) FROM G3E_FEATURECOMPS_OPTABLE WHERE G3E_FNO=? AND G3E_CNO=21"; rsValidate = m_gtApplication.DataContext.OpenRecordset(sql, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, m_selectedFno); if (rsValidate.RecordCount > 0) { rsValidate.MoveFirst(); if (!rsValidate.EOF && !rsValidate.BOF) { reCount = Convert.ToInt32(rsValidate.Fields[0].Value); } } #endregion if (reCount < 1) { MessageBox.Show("This command applies only to features with CUs.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); execute = false; } else { // 3. Cannot Relocate a feature that is not currently owned. #region Third Condition m_oActiveKeyObject = m_gtApplication.DataContext.OpenFeature(m_selectedFno, m_selectedFid); relationShipService.ActiveFeature = m_oActiveKeyObject; relationShipService.DataContext = m_gtApplication.DataContext; int ownFcount = 0; try { relatedFeaturesOWB = relationShipService.GetRelatedFeatures(3); ownFcount = relatedFeaturesOWB.Count; } catch { } #endregion if (ownFcount <= 0) { MessageBox.Show("Cannot relocate a feature that is not currently owned.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); execute = false; } else { // 4. This command applies only to point features. #region Fourth Condition sql = "SELECT * FROM G3E_COMPONENTINFO_OPTABLE WHERE G3E_CNO IN(SELECT G3E_PRIMARYGEOGRAPHICCNO FROM G3E_FEATURES_OPTABLE WHERE G3E_FNO=?) AND UPPER(G3E_GEOMETRYTYPE) LIKE '%POINT%'"; rsValidate = m_gtApplication.DataContext.OpenRecordset(sql, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockReadOnly, (int)ADODB.CommandTypeEnum.adCmdText, m_selectedFno); #endregion if (rsValidate.RecordCount <= 0) { MessageBox.Show("This command applies only to point features.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); execute = false; } else { //execute = true; if (!CheckIfInstallAndActiveWrAreDifferent()) { MessageBox.Show("The same feature may not be installed and relocated in the same WR.", "Relocate Feature", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); execute = false; } else { execute = true; } } } } } } catch (Exception ex) { throw ex; } finally { if (rsValidate != null) { if (rsValidate.State == 1) { rsValidate.Close(); rsValidate.ActiveConnection = null; } rsValidate = null; } if (relationShipService != null) { relationShipService.Dispose(); relationShipService = null; } } return(execute); }