private ControlHostClientAdapter GetOrCreateClientAdapter(Sce.Atf.Applications.IControlHostClient client)
        {
            ControlHostClientAdapter adapter;

            if (!m_clientAdapters.TryGetValue(client, out adapter))
            {
                adapter = new ControlHostClientAdapter(client);
                m_clientAdapters.Add(client, adapter);
            }
            return(adapter);
        }
        /// <summary>
        /// Registers the control and adds it to a visible form</summary>
        /// <param name="control">Control</param>
        /// <param name="controlInfo">Control display information</param>
        /// <param name="client">Client that owns the control and receives notifications
        /// about its status, or null if no notifications are needed</param>
        /// <remarks>If IControlHostClient.Close() has been called, the IControlHostService
        /// also calls UnregisterControl. Call RegisterControl again to re-register the Control.</remarks>
        public void RegisterControl(System.Windows.Forms.Control control, Sce.Atf.Applications.ControlInfo controlInfo, Sce.Atf.Applications.IControlHostClient client)
        {
            var clientAdapter = GetOrCreateClientAdapter(client);

            // WPF control host service requires a unique control ID in order to be able to reload window layouts
            // on app startup.
            // This is a problem as we do not have one here.
            // The best we can do is try and generate a unique hash
            int uniqueId = GenerateId(control, controlInfo, client);

            IControlInfo contentInfo = m_adaptee.RegisterControl(control, controlInfo.Name, controlInfo.Description, controlInfo.Group, uniqueId.ToString(), clientAdapter);

            controlInfo.Control = control;

            m_info.Add(controlInfo, contentInfo);
            TransferControlInfoValues(controlInfo);
            controlInfo.Changed += (s, e) => TransferControlInfoValues(s as Sce.Atf.Applications.ControlInfo);
        }
 public ControlHostClientAdapter(Sce.Atf.Applications.IControlHostClient adaptee)
 {
     m_adaptee = adaptee;
 }