/// <summary> /// Gets the unopened stored display with the specified type nad name. /// </summary> /// <param name="source">The source.</param> /// <param name="storedDisplayType">Display type of the stored.</param> /// <param name="storedDisplayName">Display name of the stored.</param> /// <returns>Returns a <see cref="IMMStoredDisplay" /> representing the stored display; otherwise <c>null</c></returns> public static IMMStoredDisplay GetUnopenedStoredDisplay(this IMMStoredDisplayManager source, mmStoredDisplayType storedDisplayType, string storedDisplayName) { var items = source.GetStoredDisplayNames(storedDisplayType); foreach (var i in items.AsEnumerable()) { if (i.Name.Equals(storedDisplayName, StringComparison.InvariantCultureIgnoreCase)) { return source.GetUnopenedStoredDisplay(i); } } return null; }
private bool SetArcFMWorkspace() { IMMLoginUtils pMMLogin; try { SW1.Reset(); SW1.Start(); // IMMStandardWorkspaces pMMWKS // pMMWKS = new MM // pMMLogin = new MMDefaultLoginObject(); // ESRI.ArcGIS.Framework.IAppROT pAppRot = new ESRI.ArcGIS.Framework.AppROT(); // ESRI.ArcGIS.Framework.IApplication pApp; // if (pAppRot.Count > 0) // { // for (int i = 0; i < pAppRot.Count; i++) // { // if (pAppRot.get_Item(i) is ESRI.ArcGIS.ArcMapUI.IMxApplication) // { // pApp = (ESRI.ArcGIS.Framework.IApplication)pAppRot; // pMMProps = (IMMPropertiesExt3)pApp.FindExtensionByName("MMPropertiesExt"); // pMMProps.DefaultWorkspace = Workspace; // } // } // } // this.Logger.WriteLine("SetArcFMWorkspace"); _SDMGR = new MMStoredDisplayManager(); pMMLogin = new MMLoginUtils(); this.Workspace = pMMLogin.LoginWorkspace; ScriptEngine.BroadcastProperty("Workspace", this.Workspace, null); SW1.Stop(); _SDMGR.Workspace = this.Workspace; RecordActionTime("SETARCFMWORKSPACE:", SW1.ElapsedMilliseconds); return true; } catch (Exception EX) { this.Logger.WriteLine("Error in SetArcFMWorkspace:" + EX.Message + ":" + EX.StackTrace); return false; } }
private bool ShutdownArcMap() { IApplication pApp; IDocument pDoc; IMxDocument pMXDoc; IDocumentDirty2 pDocDirty; Type t = Type.GetTypeFromProgID("esriFramework.AppRef"); System.Object obj = Activator.CreateInstance(t); pApp = obj as IApplication; pDoc = pApp.Document; pMXDoc = (IMxDocument)pDoc; pDocDirty = (IDocumentDirty2)pMXDoc; pDocDirty.SetClean(); Workspace = null; ScriptEngine.BroadcastProperty("Workspace", this.Workspace, this); ScriptEngine.BroadcastProperty("FeatureClass", null, this); _SDMGR = null; _PTMGR = null; pSelection = null; m_pGN = null; pSC = null; pEditor = null; pDoc = null; pMXDoc = null; pApp.Shutdown(); //Process iProc = Process.GetCurrentProcess(); //iProc.Kill(); Logger.WriteLine("Closing Arcmap"); return true; }
private bool OpenStoredDisplay(string SDName, string SDType) { try { this.Logger.WriteLine("OpenStoredDisplay:" + SDName); IMMStoredDisplayName pSDName; IMMEnumStoredDisplayName pESD; if (SDName == "") { this.Logger.WriteLine("StoredDisplay Name not provided"); return false; } else { if (_SDMGR == null) { _SDMGR = new MMStoredDisplayManager(); } _SDMGR.Workspace = this.Workspace; pSDName = new MMStoredDisplayName(); pSDName.Name = SDName; if (SDType.ToUpper() == "SYSTEM") { pESD = _SDMGR.GetStoredDisplayNames(mmStoredDisplayType.mmSDTSystem); } else { pESD = _SDMGR.GetStoredDisplayNames(mmStoredDisplayType.mmSDTUser); } // Get list of Stored Displays. We have to do this because we have not logged in to ArcFM. pSDName = pESD.Next(); while (pSDName != null) { if (pSDName.Name.Trim().ToUpper() == SDName.Trim().ToUpper()) { SW1.Reset(); SW1.Start(); try { _SDMGR.OpenStoredDisplay(pSDName); SW1.Stop(); RecordActionTime("Open Stored Display :",SW1.ElapsedMilliseconds); } catch (Exception EX) { this.Logger.WriteLine("Error Opening Stored Display :" + EX.Message + ":" + EX.StackTrace); SW1.Stop(); } break; } pSDName = pESD.Next(); } if (pSDName == null) { this.Logger.WriteLine("StoredDisplay not found:" + SDName); return false; } else { return true; } } } catch (Exception EX) { this.Logger.WriteLine("Error in OpenStoredDisplay:" + EX.Message + ":" + EX.StackTrace); return false; } }