Friday, May 11, 2012

In the Esri's ArcGIS for SharePoint SDK, you can create buttons in the SharePoint ribbon.  In this example, I will talk about the OnHidden event.  This event fires when the Hide() is called on the floating window after it is displayed.  This can be used to signal a process that the event is finished, and now you can do some other process or show another form etc...

Here I just implemented ICommand, and kept everything default.  I created a custom event EventHandler called OnHidden that will get call when the floating window is hidden or closed by a user.

    [DisplayNameAttribute("This is a Demo")]
    public class cmdGenerateExcelTemplate : ICommand
        public bool CanExecute(object parameter)
            return true;

        public event EventHandler CanExecuteChanged;
        public event EventHandler OnHidden;
        public void Execute(object parameter)
            MapApplication.Current.ShowWindow("This is my control",
            this.OnHidden += new EventHandler(cmdGenerateExcelTemplate_OnHidden);


        void cmdGenerateExcelTemplate_OnHidden(object sender, EventArgs e)
            MessageBox.Show("I'm hidden now!");
That's It.  It's very easy to do, and helpful in some instances.