ESRI.ArcGIS.Desktop.AddIns.DockableWindow Set UserData?

3227
5
02-10-2011 07:55 AM
JerryGarcia
Occasional Contributor II
How do you set the UserData property of a dockable window when implementing it as an Add-In?

Is there a developer sample which shows this?

Thanks!
0 Kudos
5 Replies
JerryGarcia
Occasional Contributor II
How do I implement IDockableWindowDef and set UserData with Add-In method?

   public partial class DocWin : UserControl
    {

        public DocWin(object hook)
        {
            InitializeComponent();
            this.Hook = hook;

        }

        /// <summary>
        /// Host object of the dockable window
        /// </summary>
        private object Hook
        {
            get;
            set;
        }

        /// <summary>
        /// Implementation class of the dockable window add-in. It is responsible for
        /// creating and disposing the user interface class of the dockable window.
        /// </summary>
        public class AddinImpl : ESRI.ArcGIS.Desktop.AddIns.DockableWindow
        {

            private DocWin m_windowUI;

            public AddinImpl()
            {
            }

            protected override IntPtr OnCreateChild()
            {
                m_windowUI = new DocWin(this.Hook);
                return m_windowUI.Handle;
            }

            protected override void Dispose(bool disposing)
            {
                if (m_windowUI != null)
                    m_windowUI.Dispose(disposing);

                base.Dispose(disposing);
            }


        }


    }
0 Kudos
JerryGarcia
Occasional Contributor II
How do you set the UserData property of a dockable window when implementing it as an Add-In?

Is there a developer sample which shows this?

Thanks!


I'm still having a problem.  Any help would be very much appreciated, i.e. sample code?
0 Kudos
JerryGarcia
Occasional Contributor II
From a ESRI.ArcGIS.Desktop.AddIns.Button, I would like to get the list box from the dockable window; see below.  Where in the dockable window code can I set the User Data property?  Is this the correct approach?

        protected override void OnClick()
        {
            IDockableWindowManager dockWindowManager = ArcMap.DockableWindowManager as IDockableWindowManager;
            if (dockWindowManager != null)
            {
                UID windowID = new UIDClass();
                windowID.Value = "DocWin";
                IDockableWindow docWin = dockWindowManager.GetDockableWindow(windowID);
                if (docWin.IsVisible())
                {
                    docWin.Show(false);
                }
                else
                {
                    docWin.Show(true);
                }

                System.Windows.Forms.ListBox containedBox = docWin.UserData as System.Windows.Forms.ListBox;
                if (containedBox != null) containedBox.Items.Add("Test 1");
            }

        }


---------------
Docable window class code

/// <summary>
    /// Designer class of the dockable window add-in. It contains user interfaces that
    /// make up the dockable window.
    /// </summary>
    public partial class DocWin : UserControl
    {

        public DocWin(object hook)
        {
            InitializeComponent();
            this.Hook = hook;

        }

        /// <summary>
        /// Host object of the dockable window
        /// </summary>
        private object Hook
        {
            get;
            set;
        }

        /// <summary>
        /// Implementation class of the dockable window add-in. It is responsible for
        /// creating and disposing the user interface class of the dockable window.
        /// </summary>
        public class AddinImpl : ESRI.ArcGIS.Desktop.AddIns.DockableWindow
        {

            private DocWin m_windowUI;

            public AddinImpl()
            {
            }

            protected override IntPtr OnCreateChild()
            {
                m_windowUI = new DocWin(this.Hook);
                return m_windowUI.Handle;
            }

            protected override void Dispose(bool disposing)
            {
                if (m_windowUI != null)
                    m_windowUI.Dispose(disposing);

                base.Dispose(disposing);
            }


        }


    }
0 Kudos
JeffreyHamblin
New Contributor III
It is not clear to me what you are trying to achieve, but this sample might give you some clues:

Sample: Custom selection extension

Specifically, creating static references to controls on the dockable window (like your listbox), and methods to act on them, in the dockable window class. The sample uses a listview.

Is there a particular reason why you are using the UserData property?

-Jeff
0 Kudos
JerryGarcia
Occasional Contributor II
It is not clear to me what you are trying to achieve, but this sample might give you some clues:

Sample: Custom selection extension

Specifically, creating static references to controls on the dockable window (like your listbox), and methods to act on them, in the dockable window class. The sample uses a listview.

Is there a particular reason why you are using the UserData property?

-Jeff


Thanks!  This sample helps.
0 Kudos