Schneider Electric GIS Tech Support

Forum discussion for Schneider Electric GIS products, including ArcFM, ArcFM Viewer, Designer, Responder, and others.
It is currently Thu May 23, 2013 9:15 pm

All times are UTC - 7 hours [ DST ]




Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Launch a stored display from a custom button click
PostPosted: Tue Oct 05, 2010 2:37 pm 
Offline

Joined: Thu Sep 30, 2010 1:36 pm
Posts: 14
I created a custom button in ArcFM Viewer for ArcGIS Engine. I am trying to open a stored display from this button click event.

Could it be possible to send me a code sample that will open a stored display on a button click.

Thanks.
PavKal


Top
 Profile  
 
 Post subject: Re: Launch a stored display from a custom button click
PostPosted: Tue Oct 05, 2010 3:22 pm 
Offline
Telvent North America Rep
User avatar

Joined: Wed Aug 18, 2010 4:09 pm
Posts: 108
Location: Fort Collins, Colorado
Something along these lines. This is a little different than what you asked, but you can change it to just get a single IStoredDisplayName if you want...

Hope this helps...

Code:
using System;
using System.Windows.Forms
using Miner.Interop; //Miner.Interop.Framework.dll
using Miner.Windows; //Miner.Windows.dll
using Miner.Windows.ArcGIS; //Miner.Windows.ArcGIS.dll


IExtensionManager extensionMan = Activator.CreateInstance(Type.GetTypeFromProgID("esriSystem.ExtensionManager")) as
IMMStoredDisplayManager storedDisplayMan;
storedDisplayMan = (IMMStoredDisplayManager) extensionMan.FindExtension("MMStoredDisplayMgr");
IMMEnumStoredDisplayName enumDisplays= storedDisplayMan.GetStoredDisplayNames(mmStoredDisplayType.mmSDTSystem);
         
storedDisplayName = enumDisplays.Next()
IMapControlHost host = MainApp.MainWin.ActiveMdiChild as IMapControlHost;
host.LoadStoredDisplay(storedDisplayName);



Top
 Profile  
 
 Post subject: Re: Launch a stored display from a custom button click
PostPosted: Tue Oct 05, 2010 3:34 pm 
Offline

Joined: Thu Sep 30, 2010 1:36 pm
Posts: 14
Thanks for the response.

I am very new to this ArcFM development, so would it be possible to provide me with a sample code that will enable a user to open a storeddisplay?


Top
 Profile  
 
 Post subject: Re: Launch a stored display from a custom button click
PostPosted: Tue Oct 05, 2010 4:05 pm 
Offline
Telvent North America Rep
User avatar

Joined: Wed Aug 18, 2010 4:09 pm
Posts: 108
Location: Fort Collins, Colorado
pavkal wrote:
Thanks for the response.

I am very new to this ArcFM development, so would it be possible to provide me with a sample code that will enable a user to open a storeddisplay?


The code above should work. Just put it in your OnClick implementation of ICommand.


Top
 Profile  
 
 Post subject: Re: Launch a stored display from a custom button click
PostPosted: Tue Oct 05, 2010 5:43 pm 
Offline

Joined: Thu Sep 30, 2010 1:36 pm
Posts: 14
I created a button and I put the code below on the onclick event

protected override void OnClick(EventArgs args)

{
MessageBox.Show("Test Button");

IExtensionManager extensionManager = Activator.CreateInstance(Type.GetTypeFromProgID("esriSystem.ExtensionManager")) as IMMStoredDisplayManager storedDisplayManager;

storedDisplayManager = (IMMStoredDisplayManager) extensionManager.FindExtension("MMStoredDisplayMgr");

IMMEnumStoredDisplayName enumDisplays= storedDisplayManager.GetStoredDisplayNames(mmStoredDisplayType.mmSDTSystem);

storedDisplayName = enumDisplays.Next();
IMapControlHost host = MainApp.MainWin.ActiveMdiChild as IMapControlHost;
host.LoadStoredDisplay(storedDisplayName);

IMap currentMap = MainArcEngineApp.FocusMap();
if (null == currentMap) return;


IActiveView activeView = currentMap as IActiveView;
activeView.Refresh();
}

When I run the code, I could see the messagebox "Test Button", but nothing shows up.

I also see an error message "; expected" on the storedDisplayManager line of code.
I put the ; next to storedDisplayManager, but still see the same error.

Could you please help me with this task of opening a stored display by a name from the button click?


Top
 Profile  
 
 Post subject: Re: Launch a stored display from a custom button click
PostPosted: Tue Oct 05, 2010 5:52 pm 
Offline
Telvent North America Rep
User avatar

Joined: Wed Aug 18, 2010 4:09 pm
Posts: 108
Location: Fort Collins, Colorado
Oops, there was a typo in the code. It should be this...

Code:
IExtensionManager extensionMan = Activator.CreateInstance(Type.GetTypeFromProgID("esriSystem.ExtensionManager"));

IMMStoredDisplayManager storedDisplayMan;
storedDisplayMan = (IMMStoredDisplayManager) extensionMan.FindExtension("MMStoredDisplayMgr");


Top
 Profile  
 
 Post subject: Re: Launch a stored display from a custom button click
PostPosted: Tue Oct 05, 2010 6:03 pm 
Offline

Joined: Thu Sep 30, 2010 1:36 pm
Posts: 14
Still no luck,

it errors on this line,
IExtensionManager extensionMan = Activator.CreateInstance(Type.GetTypeFromProgID("esriSystem.ExtensionManager"));

error message:

Cannot implicitly convert type 'object' to 'ESRI.ArcGIS.esriSystem.IExtensionManager'. An explicit conversion exists (are you missing a cast?)

Am I missing here something?

Could you please provide me with a straight sample that helps me open a storeddisplay?

Thanks for your help.


Top
 Profile  
 
 Post subject: Re: Launch a stored display from a custom button click
PostPosted: Tue Oct 05, 2010 9:18 pm 
Offline
Telvent North America Rep
User avatar

Joined: Wed Aug 18, 2010 4:09 pm
Posts: 108
Location: Fort Collins, Colorado
When I get a chance I'll try to drum something up. You'd probably have better luck contacting customization and/or support, they can get you the coding help you need. Good luck!


Top
 Profile  
 
 Post subject: Re: Launch a stored display from a custom button click
PostPosted: Wed Oct 06, 2010 12:32 pm 
Offline

Joined: Thu Sep 30, 2010 1:36 pm
Posts: 14
The problem got solved. Thanks for the help.

Code to show a stored display from a button click in ArcFM Viewer for ArcGIS Engine:
---------------------------------------------------------------------------------

IExtensionManager extensionMan = Activator.CreateInstance(Type.GetTypeFromProgID("esriSystem.ExtensionManager")) as IExtensionManager;

IMMStoredDisplayManager storedDisplayMan;
storedDisplayMan = (IMMStoredDisplayManager)extensionMan.FindExtension("MMStoredDisplayMgr");

IMMEnumStoredDisplayName enumDisplays = storedDisplayMan.GetStoredDisplayNames(mmStoredDisplayType.mmSDTSystem);

IMMStoredDisplayName storedDisplayName;
storedDisplayName = enumDisplays.Next();
IMapControlHost host = MainApp.MainWin.ActiveMdiChild as IMapControlHost;
host.LoadStoredDisplay(storedDisplayName);

Thanks.
PavKal


Top
 Profile  
 
 Post subject: Re: Launch a stored display from a custom button click
PostPosted: Wed Oct 06, 2010 12:39 pm 
Offline

Joined: Thu Sep 30, 2010 1:36 pm
Posts: 14
I am approaching with a new scenario: "Save stored display settings automatically"

Once I got this sored display shown from a button click, I would like to save the settings of this stored display for example:
- Save the scale to the extent the display is zoomed in/out
- Save the layers that were checked on/off in the TOC

If the user closes the ArcFM viewer for ArcGIS ENgine, these should get saved automatically.

Once the user reopens the application, he should see the last loaded stored display with the saved settings.

Any ideas or sample code!


Top
 Profile  
 
 Post subject: Re: Launch a stored display from a custom button click
PostPosted: Wed Oct 06, 2010 2:17 pm 
Offline
Telvent North America Rep
User avatar

Joined: Wed Aug 18, 2010 4:09 pm
Posts: 108
Location: Fort Collins, Colorado
I don't have any quick sample code on saving a stored display as I did with the opening one, but I would suggest exploring the StoredDisplayManager class and the methods on there. I think there are some that handle the saving of the stored display. Also, when the stored display is saved it saves the layers to the database and along with the layers are whether or not it's visible ("checked on") or not visible ("checked off") so that should just work.

The map extent...I'm not sure there, I'm guessing that might take special customization code, specifically dealing with the serialization of the map blob. If that's true, then that's a much larger effort.


Top
 Profile  
 
 Post subject: Re: Launch a stored display from a custom button click
PostPosted: Thu Oct 07, 2010 3:17 pm 
Offline

Joined: Thu Sep 30, 2010 1:36 pm
Posts: 14
I have an xml file as below:

<?xml version="1.0"?>
<configuration>
<Display>
<StoredDisplayName>cathodic Protection</StoredDisplayName>
</Display>
</configuration>

I need the code to read the ' Cathodic Protection' from this xml file and display the stored display in ArcFM Viewer for Engine based on this name.

I am having trouble assigning the storeddisplayname from xml. Any help or ideas?

I am working on this code so far, to achieve the task:
------------------------------------------------------------
IExtensionManager extensionMan = Activator.CreateInstance(Type.GetTypeFromProgID("esriSystem.ExtensionManager")) as IExtensionManager;

IMMStoredDisplayManager storedDisplayMan;
storedDisplayMan = (IMMStoredDisplayManager)extensionMan.FindExtension("MMStoredDisplayMgr");

IMMEnumStoredDisplayName enumDisplays = storedDisplayMan.GetStoredDisplayNames(mmStoredDisplayType.mmSDTSystem);
IMMStoredDisplayName storedDisplayName;

//--------------------------------------------------------- need help here *****
if (m_xmld.InnerText != "")
MessageBox.Show(m_xmld.InnerText); // This reads the Stored display name as "cathodic Protection" from xml

storedDisplayName = (m_xmld.InnerText); //trying to assign this name to the stored display

//------------------------------------------------------
//storedDisplayName = enumDisplays.Next();
IMapControlHost host = MainApp.MainWin.ActiveMdiChild as IMapControlHost;
host.LoadStoredDisplay(storedDisplayName);

Please advise on how to assign the name.
Thanks.


Top
 Profile  
 
 Post subject: Re: Launch a stored display from a custom button click
PostPosted: Thu Oct 07, 2010 4:13 pm 
Offline
Telvent North America Rep
User avatar

Joined: Wed Aug 18, 2010 4:09 pm
Posts: 108
Location: Fort Collins, Colorado
MMStoredDisplayNameClass storedName = new MMStoredDisplayNameClass();
storedName.Name = "cathodic protection"
storedName.Type = <your type here, e.g user or system>

that should work I think.


Top
 Profile  
 
 Post subject: Re: Launch a stored display from a custom button click
PostPosted: Thu Oct 07, 2010 4:29 pm 
Offline

Joined: Thu Sep 30, 2010 1:36 pm
Posts: 14
It worked.

if (m_xmld.InnerText != "")
MessageBox.Show(m_xmld.InnerText);

MMStoredDisplayNameClass storedName = new MMStoredDisplayNameClass();
storedName.Name = m_xmld.InnerText;
storedName.Type = mmStoredDisplayType.mmSDTSystem;
IMapControlHost host = MainApp.MainWin.ActiveMdiChild as IMapControlHost;
host.LoadStoredDisplay(storedName);


Top
 Profile  
 
 Post subject: Re: Launch a stored display from a custom button click
PostPosted: Thu Oct 07, 2010 4:42 pm 
Offline
Telvent North America Rep
User avatar

Joined: Wed Aug 18, 2010 4:09 pm
Posts: 108
Location: Fort Collins, Colorado
Alright!!! :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group